KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > editors > report > OrderByPanel


1 /*
2 /*
3  * The contents of this file are subject to the
4  * Mozilla Public License Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
10  * See the License for the specific language governing rights and
11  * limitations under the License.
12  *
13  * The Initial Developer of the Original Code is Simulacra Media Ltd.
14  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
15  *
16  * All Rights Reserved.
17  *
18  * Contributor(s):
19  */

20 package org.openharmonise.him.editors.report;
21
22 import java.awt.*;
23 import java.awt.event.*;
24
25 import javax.swing.*;
26
27 import org.openharmonise.him.*;
28 import org.openharmonise.him.editors.report.rqom.*;
29 import org.openharmonise.him.editors.report.swing.*;
30 import org.openharmonise.him.harmonise.*;
31 import org.openharmonise.vfs.*;
32 import org.openharmonise.vfs.servers.ServerList;
33
34
35 /**
36  * @author MATT TREANOR
37  * @version $Revision: 1.1 $
38  *
39  */

40 public class OrderByPanel extends JPanel implements LayoutManager, ActionListener {
41
42     private Metadata m_metadata;
43     private ReportQuery m_reportQuery;
44     private JComboTree m_propertyCombo;
45     private JLabel m_propLabel;
46     private String JavaDoc m_sLabelText;
47     
48
49     /**
50      * Contructs new OrderByPanel
51      */

52     public OrderByPanel(ReportQuery query, Metadata metadata, String JavaDoc label) {
53         super();
54         this.m_metadata = metadata;
55         this.m_reportQuery = query;
56         this.m_sLabelText = label;
57         this.setup();
58     }
59
60     /**
61      * Configures this component.
62      *
63      */

64     private void setup() {
65         this.setLayout(this);
66         
67         AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS();
68         
69         this.m_propertyCombo = new JComboTree();
70         this.m_propertyCombo.setResourceTreeFilter(new ReportResourceFilter(m_reportQuery));
71         this.m_propertyCombo.setActionCommand("PROPCOMBO");
72         this.m_propertyCombo.addActionListener(this);
73         this.m_propertyCombo.setAllowClear(false);
74         this.m_propertyCombo.setShowLeafNodes(true);
75         this.m_propertyCombo.setSelectedLeafOnly(true);
76         this.m_propertyCombo.addCollectionPath(HarmonisePaths.PATH_SYSTEM_PROPS);
77         this.m_propertyCombo.addCollectionPath(HarmonisePaths.PATH_PROPERTIES);
78         this.add(m_propertyCombo);
79         
80         if(this.m_metadata.getPath()!=null) {
81             this.m_propertyCombo.setPath(vfs, this.m_metadata.getPath());
82         }
83
84         String JavaDoc fontName = "Dialog";
85         int fontSize = 11;
86         Font font = new Font(fontName, Font.PLAIN, fontSize);
87         
88         this.m_propLabel = new JLabel(m_sLabelText);
89         this.m_propLabel.setFont(font);
90         this.add(this.m_propLabel);
91     }
92     /**
93      * Returns the metadata data.
94      *
95      * @return Data
96      */

97     public Metadata getMetadata() {
98         return this.m_metadata;
99     }
100
101     /* (non-Javadoc)
102      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
103      */

104     public void removeLayoutComponent(Component comp) {
105     }
106
107     /* (non-Javadoc)
108      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
109      */

110     public void layoutContainer(Container parent) {
111         int x = 0;
112         
113         this.m_propLabel.setSize(this.m_propLabel.getPreferredSize());
114         this.m_propLabel.setLocation(x, 0);
115         
116         this.m_propertyCombo.setSize(this.m_propertyCombo.getPreferredSize());
117         this.m_propertyCombo.setLocation(x, 15);
118     }
119
120     /* (non-Javadoc)
121      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
122      */

123     public void addLayoutComponent(String JavaDoc name, Component comp) {
124     }
125     
126     public Dimension getPreferredSize() {
127         return new Dimension(420, 35);
128     }
129
130     /* (non-Javadoc)
131      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
132      */

133     public Dimension minimumLayoutSize(Container parent) {
134         return this.getPreferredSize();
135     }
136
137     /* (non-Javadoc)
138      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
139      */

140     public Dimension preferredLayoutSize(Container parent) {
141         return this.getPreferredSize();
142     }
143
144     /* (non-Javadoc)
145      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
146      */

147     public void actionPerformed(ActionEvent e) {
148         if(e.getActionCommand().equals("PROPCOMBO")) {
149             this.m_metadata.setPath(this.m_propertyCombo.getPath());
150             this.layoutContainer(null);
151             this.validateTree();
152             this.repaint();
153         }
154     }
155
156 }
Popular Tags