01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * 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.util.Iterator;
22:
23: import javax.swing.JPanel;
24:
25: import org.openharmonise.him.editors.report.rqom.*;
26:
27: /**
28: * Panel for the users section of the report query editor.
29: *
30: * @author Matthew Large
31: * @version $Revision: 1.1 $
32: *
33: */
34: public class ReportUsers extends ReportMultiPanel {
35:
36: /**
37: * Constructs a new users panel.
38: *
39: * @param query Report query
40: */
41: public ReportUsers(ReportQuery query) {
42: super (query, "Changes made by");
43: this .setup();
44: }
45:
46: /**
47: * Configures this component.
48: *
49: */
50: private void setup() {
51: Iterator itor = this .m_reportQuery.getUsers().iterator();
52: while (itor.hasNext()) {
53: User user = (User) itor.next();
54: UserPanel userPanel = new UserPanel(this .m_reportQuery,
55: user);
56: super .addValueComponent(userPanel);
57: }
58: }
59:
60: /* (non-Javadoc)
61: * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#getNewValueComponent()
62: */
63: public JPanel getNewValueComponent() {
64: User user = new User(null, this .m_reportQuery);
65: this .m_reportQuery.addUser(user);
66: UserPanel userPanel = new UserPanel(this .m_reportQuery, user);
67: return userPanel;
68: }
69:
70: /* (non-Javadoc)
71: * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#removeValueComponent(javax.swing.JPanel)
72: */
73: public void removeValueComponent(JPanel valueComponent) {
74: UserPanel panel = (UserPanel) valueComponent;
75: this .m_reportQuery.removeUser(panel.getUser());
76: }
77:
78: /* (non-Javadoc)
79: * @see com.simulacramedia.contentmanager.editors.report.ReportMultiPanel#getComponentCount()
80: */
81: public int getValueComponentCount() {
82: return m_reportQuery.getUsers().size();
83: }
84:
85: }
|