KickJava   Java API By Example, From Geeks To Geeks.

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


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

19 package org.openharmonise.him.editors.report;
20
21 import java.awt.*;
22 import java.awt.event.*;
23
24 import javax.swing.*;
25
26 import org.openharmonise.him.*;
27 import org.openharmonise.him.editors.report.rqom.*;
28 import org.openharmonise.him.editors.report.swing.*;
29 import org.openharmonise.him.harmonise.*;
30 import org.openharmonise.vfs.*;
31 import org.openharmonise.vfs.servers.ServerList;
32
33
34 /**
35  * Panel for the user field in the report query editor.
36  *
37  * @author Matthew Large
38  * @version $Revision: 1.1 $
39  *
40  */

41 public class UserPanel extends JPanel implements LayoutManager, ActionListener {
42
43     /**
44      * Report query.
45      */

46     private ReportQuery m_reportQuery = null;
47     
48     /**
49      * User.
50      */

51     private User m_user = null;
52     
53     /**
54      * User selector.
55      */

56     private JComboTree m_propertyCombo = null;
57     
58     private JLabel m_propLabel = null;
59
60     /**
61      * Constructs a new user panel.
62      *
63      * @param query Report query
64      * @param user User
65      */

66     public UserPanel(ReportQuery query, User user) {
67         super();
68         this.m_user = user;
69         this.m_reportQuery = query;
70         this.setup();
71     }
72     
73     /**
74      * Returns the user.
75      *
76      * @return User
77      */

78     public User getUser() {
79         return this.m_user;
80     }
81     
82     /**
83      * Configures this component.
84      *
85      */

86     private void setup() {
87         this.setLayout(this);
88         
89         AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS();
90         
91         this.m_propertyCombo = new JComboTree();
92         this.m_propertyCombo.setActionCommand("USERCOMBO");
93         this.m_propertyCombo.addActionListener(this);
94         this.m_propertyCombo.setAllowClear(false);
95         this.m_propertyCombo.setShowLeafNodes(true);
96         this.m_propertyCombo.setSelectedLeafOnly(true);
97         this.m_propertyCombo.addCollectionPath(HarmonisePaths.PATH_USERS);
98         this.add(m_propertyCombo);
99         
100         if(this.m_user.getPath()!=null) {
101             this.m_propertyCombo.setPath(vfs, this.m_user.getPath());
102         }
103
104         String JavaDoc fontName = "Dialog";
105         int fontSize = 11;
106         Font font = new Font(fontName, Font.PLAIN, fontSize);
107         
108         this.m_propLabel = new JLabel("Select a user");
109         this.m_propLabel.setFont(font);
110         this.add(this.m_propLabel);
111     }
112
113     /* (non-Javadoc)
114      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
115      */

116     public void actionPerformed(ActionEvent ae) {
117         if(ae.getActionCommand().equals("USERCOMBO")) {
118             this.m_user.setPath(this.m_propertyCombo.getPath());
119         }
120     }
121
122     /* (non-Javadoc)
123      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
124      */

125     public void layoutContainer(Container arg0) {
126         this.m_propLabel.setSize(this.m_propLabel.getPreferredSize());
127         this.m_propLabel.setLocation(0, 0);
128         
129         this.m_propertyCombo.setSize(this.m_propertyCombo.getPreferredSize());
130         this.m_propertyCombo.setLocation(0, 15);
131     }
132
133     /* (non-Javadoc)
134      * @see java.awt.Component#getPreferredSize()
135      */

136     public Dimension getPreferredSize() {
137         return new Dimension(420, 35);
138     }
139
140     /**
141      *
142      */

143     private UserPanel() {
144         super();
145     }
146
147     /**
148      * @param arg0
149      */

150     private UserPanel(boolean arg0) {
151         super(arg0);
152     }
153
154     /**
155      * @param arg0
156      */

157     private UserPanel(LayoutManager arg0) {
158         super(arg0);
159     }
160
161     /**
162      * @param arg0
163      * @param arg1
164      */

165     private UserPanel(LayoutManager arg0, boolean arg1) {
166         super(arg0, arg1);
167     }
168
169     /* (non-Javadoc)
170      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
171      */

172     public void removeLayoutComponent(Component arg0) {
173     }
174
175     /* (non-Javadoc)
176      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
177      */

178     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
179     }
180
181     /* (non-Javadoc)
182      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
183      */

184     public Dimension minimumLayoutSize(Container arg0) {
185         return this.getPreferredSize();
186     }
187
188     /* (non-Javadoc)
189      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
190      */

191     public Dimension preferredLayoutSize(Container arg0) {
192         return this.getPreferredSize();
193     }
194
195 }
196
Popular Tags