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.swing.datefield.*;
031: import org.openharmonise.vfs.*;
032: import org.openharmonise.vfs.servers.ServerList;
033:
034: /**
035: * Panel for the header of the report editor. This covers the scope of the
036: * report defined by a collection.
037: *
038: * @author Matthew Large
039: * @version $Revision: 1.1 $
040: *
041: */
042: public class ReportHeader extends JPanel implements LayoutManager,
043: DateFieldListener,/*ChangeListener,*/ActionListener {
044:
045: /**
046: * Report query.
047: */
048: private ReportQuery m_reportQuery = null;
049:
050: /**
051: * Label for path field.
052: */
053: private JLabel m_pathLabel = null;
054:
055: /**
056: * Path selector.
057: */
058: private JComboTree m_pathCombo = null;
059:
060: /**
061: * Label for period.
062: */
063: private JLabel m_periodLabel = null;
064:
065: /**
066: * Label for from field.
067: */
068: private JLabel m_fromLabel = null;
069:
070: /**
071: * From field.
072: */
073: private JDateField m_fromDateField = null;
074:
075: /**
076: * Label for to field.
077: */
078: private JLabel m_toLabel = null;
079:
080: /**
081: * To field.
082: */
083: private JDateField m_toDateField = null;
084:
085: /**
086: * Panel for border.
087: */
088: private JPanel m_borderPanel = null;
089:
090: /**
091: * Height of panel.
092: */
093: private int m_nHeight = 30;
094:
095: /**
096: * Constructs a new report header.
097: *
098: * @param query Report query
099: */
100: public ReportHeader(ReportQuery query) {
101: super ();
102: this .m_reportQuery = query;
103: this .setup();
104: }
105:
106: /**
107: * Configures this component.
108: *
109: */
110: private void setup() {
111: this .setLayout(this );
112:
113: AbstractVirtualFileSystem vfs = ServerList.getInstance()
114: .getHarmoniseServer().getVFS();
115:
116: String fontName = "Dialog";
117: int fontSize = 11;
118: Font font = new Font(fontName, Font.PLAIN, fontSize);
119:
120: this .m_pathLabel = new JLabel("Resources from");
121: this .m_pathLabel.setFont(font);
122: this .add(m_pathLabel);
123:
124: this .m_pathCombo = new JComboTree();
125: this .m_pathCombo.setShowLeafNodes(false);
126: this .m_pathCombo.setAllowClear(false);
127: this .m_pathCombo
128: .addCollectionPath(HarmonisePaths.PATH_DOCUMENTS);
129: this .m_pathCombo.addCollectionPath(HarmonisePaths.PATH_ASSETS);
130: this .m_pathCombo.addCollectionPath(HarmonisePaths.PATH_USERS);
131: this .m_pathCombo
132: .addCollectionPath(HarmonisePaths.PATH_PROPERTIES);
133: this .m_pathCombo.addCollectionPath(HarmonisePaths.PATH_VALUES);
134: this .m_pathCombo
135: .addCollectionPath(HarmonisePaths.PATH_COMPOSITION);
136: this .m_pathCombo.addCollectionPath(HarmonisePaths.PATH_XSLT);
137: this .m_pathCombo
138: .addCollectionPath(HarmonisePaths.PATH_SITE_ASSETS);
139: this .m_pathCombo
140: .addCollectionPath(HarmonisePaths.PATH_PAGE_DEFINITION);
141: this .m_pathCombo.setPath(vfs, this .m_reportQuery.getPath());
142: this .m_pathCombo.addActionListener(this );
143: this .m_pathCombo.setActionCommand("PATHCOMBO");
144: this .add(this .m_pathCombo);
145:
146: this .m_pathCombo.setScopeEnabled(m_reportQuery
147: .isReportPanelEditable());
148: }
149:
150: /* (non-Javadoc)
151: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
152: */
153: public void actionPerformed(ActionEvent ae) {
154: if (ae.getActionCommand().equals("PATHCOMBO")) {
155: this .m_reportQuery.setPath(this .m_pathCombo.getPath());
156: }
157: }
158:
159: /* (non-Javadoc)
160: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
161: */
162: public void layoutContainer(Container arg0) {
163: int nHeight = 10;
164:
165: this .m_pathLabel.setSize(this .m_pathLabel.getPreferredSize());
166: this .m_pathLabel.setLocation(10, nHeight);
167:
168: this .m_pathCombo.setSize(this .m_pathCombo.getPreferredSize());
169: this .m_pathCombo.setLocation(100, nHeight - 3);
170:
171: nHeight = nHeight + this .m_pathLabel.getSize().height + 5;
172: }
173:
174: /* (non-Javadoc)
175: * @see java.awt.Component#getPreferredSize()
176: */
177: public Dimension getPreferredSize() {
178: return new Dimension(700, m_nHeight);
179: }
180:
181: /**
182: *
183: */
184: private ReportHeader() {
185: super ();
186: }
187:
188: /**
189: * @param arg0
190: */
191: private ReportHeader(boolean arg0) {
192: super (arg0);
193: }
194:
195: /**
196: * @param arg0
197: */
198: private ReportHeader(LayoutManager arg0) {
199: super (arg0);
200: }
201:
202: /**
203: * @param arg0
204: * @param arg1
205: */
206: private ReportHeader(LayoutManager arg0, boolean arg1) {
207: super (arg0, arg1);
208: }
209:
210: /* (non-Javadoc)
211: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
212: */
213: public void removeLayoutComponent(Component arg0) {
214: }
215:
216: /* (non-Javadoc)
217: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
218: */
219: public void addLayoutComponent(String arg0, Component arg1) {
220: }
221:
222: /* (non-Javadoc)
223: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
224: */
225: public Dimension minimumLayoutSize(Container arg0) {
226: return this .getPreferredSize();
227: }
228:
229: /* (non-Javadoc)
230: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
231: */
232: public Dimension preferredLayoutSize(Container arg0) {
233: return this .getPreferredSize();
234: }
235:
236: /* (non-Javadoc)
237: * @see com.simulacramedia.swing.datefield.DateFieldListener#validationFailed(com.simulacramedia.swing.datefield.JDateField, int)
238: */
239: public void validationFailed(JDateField source, int nReason) {
240: }
241:
242: /* (non-Javadoc)
243: * @see com.simulacramedia.swing.datefield.DateFieldListener#valueChanged(com.simulacramedia.swing.datefield.JDateField)
244: */
245: public void valueChanged(JDateField source) {
246: if (source == this .m_fromDateField) {
247: this .m_reportQuery.setPeriodFrom(this .m_fromDateField
248: .getDate());
249: } else if (source == this .m_toDateField) {
250: this .m_reportQuery
251: .setPeriodTo(this .m_toDateField.getDate());
252: }
253: }
254:
255: public void setScopeEnabled(boolean isEnabled) {
256: this.m_pathCombo.setScopeEnabled(isEnabled);
257: }
258:
259: }
|