001: /*
002: /*
003: * The contents of this file are subject to the
004: * Mozilla Public License Version 1.1 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
007: *
008: * Software distributed under the License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
010: * See the License for the specific language governing rights and
011: * limitations under the License.
012: *
013: * The Initial Developer of the Original Code is Simulacra Media Ltd.
014: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
015: *
016: * All Rights Reserved.
017: *
018: * Contributor(s):
019: */
020: package org.openharmonise.him.editors.report;
021:
022: import java.awt.*;
023: import java.awt.event.*;
024:
025: import javax.swing.*;
026:
027: import org.openharmonise.him.*;
028: import org.openharmonise.him.editors.report.rqom.*;
029: import org.openharmonise.him.editors.report.swing.*;
030: import org.openharmonise.him.harmonise.*;
031: import org.openharmonise.vfs.*;
032: import org.openharmonise.vfs.servers.ServerList;
033:
034: /**
035: * @author MATT TREANOR
036: * @version $Revision: 1.1 $
037: *
038: */
039: public class OrderByPanel extends JPanel implements LayoutManager,
040: ActionListener {
041:
042: private Metadata m_metadata;
043: private ReportQuery m_reportQuery;
044: private JComboTree m_propertyCombo;
045: private JLabel m_propLabel;
046: private String m_sLabelText;
047:
048: /**
049: * Contructs new OrderByPanel
050: */
051: public OrderByPanel(ReportQuery query, Metadata metadata,
052: String label) {
053: super ();
054: this .m_metadata = metadata;
055: this .m_reportQuery = query;
056: this .m_sLabelText = label;
057: this .setup();
058: }
059:
060: /**
061: * Configures this component.
062: *
063: */
064: private void setup() {
065: this .setLayout(this );
066:
067: AbstractVirtualFileSystem vfs = ServerList.getInstance()
068: .getHarmoniseServer().getVFS();
069:
070: this .m_propertyCombo = new JComboTree();
071: this .m_propertyCombo
072: .setResourceTreeFilter(new ReportResourceFilter(
073: m_reportQuery));
074: this .m_propertyCombo.setActionCommand("PROPCOMBO");
075: this .m_propertyCombo.addActionListener(this );
076: this .m_propertyCombo.setAllowClear(false);
077: this .m_propertyCombo.setShowLeafNodes(true);
078: this .m_propertyCombo.setSelectedLeafOnly(true);
079: this .m_propertyCombo
080: .addCollectionPath(HarmonisePaths.PATH_SYSTEM_PROPS);
081: this .m_propertyCombo
082: .addCollectionPath(HarmonisePaths.PATH_PROPERTIES);
083: this .add(m_propertyCombo);
084:
085: if (this .m_metadata.getPath() != null) {
086: this .m_propertyCombo
087: .setPath(vfs, this .m_metadata.getPath());
088: }
089:
090: String fontName = "Dialog";
091: int fontSize = 11;
092: Font font = new Font(fontName, Font.PLAIN, fontSize);
093:
094: this .m_propLabel = new JLabel(m_sLabelText);
095: this .m_propLabel.setFont(font);
096: this .add(this .m_propLabel);
097: }
098:
099: /**
100: * Returns the metadata data.
101: *
102: * @return Data
103: */
104: public Metadata getMetadata() {
105: return this .m_metadata;
106: }
107:
108: /* (non-Javadoc)
109: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
110: */
111: public void removeLayoutComponent(Component comp) {
112: }
113:
114: /* (non-Javadoc)
115: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
116: */
117: public void layoutContainer(Container parent) {
118: int x = 0;
119:
120: this .m_propLabel.setSize(this .m_propLabel.getPreferredSize());
121: this .m_propLabel.setLocation(x, 0);
122:
123: this .m_propertyCombo.setSize(this .m_propertyCombo
124: .getPreferredSize());
125: this .m_propertyCombo.setLocation(x, 15);
126: }
127:
128: /* (non-Javadoc)
129: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
130: */
131: public void addLayoutComponent(String name, Component comp) {
132: }
133:
134: public Dimension getPreferredSize() {
135: return new Dimension(420, 35);
136: }
137:
138: /* (non-Javadoc)
139: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
140: */
141: public Dimension minimumLayoutSize(Container parent) {
142: return this .getPreferredSize();
143: }
144:
145: /* (non-Javadoc)
146: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
147: */
148: public Dimension preferredLayoutSize(Container parent) {
149: return this .getPreferredSize();
150: }
151:
152: /* (non-Javadoc)
153: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
154: */
155: public void actionPerformed(ActionEvent e) {
156: if (e.getActionCommand().equals("PROPCOMBO")) {
157: this.m_metadata.setPath(this.m_propertyCombo.getPath());
158: this.layoutContainer(null);
159: this.validateTree();
160: this.repaint();
161: }
162: }
163:
164: }
|