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