KickJava   Java API By Example, From Geeks To Geeks.

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


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.swing.datefield.*;
31 import org.openharmonise.vfs.*;
32 import org.openharmonise.vfs.servers.ServerList;
33
34
35 /**
36  * Panel for the header of the report editor. This covers the scope of the
37  * report defined by a collection.
38  *
39  * @author Matthew Large
40  * @version $Revision: 1.1 $
41  *
42  */

43 public class ReportHeader extends JPanel implements LayoutManager, DateFieldListener,/*ChangeListener,*/ ActionListener {
44
45     /**
46      * Report query.
47      */

48     private ReportQuery m_reportQuery = null;
49     
50     /**
51      * Label for path field.
52      */

53     private JLabel m_pathLabel = null;
54     
55     /**
56      * Path selector.
57      */

58     private JComboTree m_pathCombo = null;
59     
60     /**
61      * Label for period.
62      */

63     private JLabel m_periodLabel = null;
64     
65     /**
66      * Label for from field.
67      */

68     private JLabel m_fromLabel = null;
69     
70     /**
71      * From field.
72      */

73     private JDateField m_fromDateField = null;
74     
75     /**
76      * Label for to field.
77      */

78     private JLabel m_toLabel = null;
79     
80     /**
81      * To field.
82      */

83     private JDateField m_toDateField = null;
84     
85     /**
86      * Panel for border.
87      */

88     private JPanel m_borderPanel = null;
89     
90     /**
91      * Height of panel.
92      */

93     private int m_nHeight = 30;
94
95     /**
96      * Constructs a new report header.
97      *
98      * @param query Report query
99      */

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().getHarmoniseServer().getVFS();
114
115         String JavaDoc fontName = "Dialog";
116         int fontSize = 11;
117         Font font = new Font(fontName, Font.PLAIN, fontSize);
118     
119         this.m_pathLabel = new JLabel("Resources from");
120         this.m_pathLabel.setFont(font);
121         this.add(m_pathLabel);
122         
123         this.m_pathCombo = new JComboTree();
124         this.m_pathCombo.setShowLeafNodes(false);
125         this.m_pathCombo.setAllowClear(false);
126         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_DOCUMENTS );
127         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_ASSETS );
128         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_USERS );
129         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_PROPERTIES );
130         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_VALUES );
131         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_COMPOSITION );
132         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_XSLT );
133         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_SITE_ASSETS );
134         this.m_pathCombo.addCollectionPath( HarmonisePaths.PATH_PAGE_DEFINITION );
135         this.m_pathCombo.setPath(vfs, this.m_reportQuery.getPath());
136         this.m_pathCombo.addActionListener(this);
137         this.m_pathCombo.setActionCommand("PATHCOMBO");
138         this.add(this.m_pathCombo);
139     
140         this.m_pathCombo.setScopeEnabled(m_reportQuery.isReportPanelEditable());
141     }
142
143     /* (non-Javadoc)
144      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
145      */

146     public void actionPerformed(ActionEvent ae) {
147         if(ae.getActionCommand().equals("PATHCOMBO")) {
148             this.m_reportQuery.setPath(this.m_pathCombo.getPath());
149         }
150     }
151
152     /* (non-Javadoc)
153      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
154      */

155     public void layoutContainer(Container arg0) {
156         int nHeight = 10;
157         
158         this.m_pathLabel.setSize(this.m_pathLabel.getPreferredSize());
159         this.m_pathLabel.setLocation(10, nHeight);
160         
161         this.m_pathCombo.setSize(this.m_pathCombo.getPreferredSize());
162         this.m_pathCombo.setLocation(100, nHeight-3);
163         
164         nHeight = nHeight + this.m_pathLabel.getSize().height + 5;
165     }
166
167     /* (non-Javadoc)
168      * @see java.awt.Component#getPreferredSize()
169      */

170     public Dimension getPreferredSize() {
171         return new Dimension(700, m_nHeight);
172     }
173
174     /**
175      *
176      */

177     private ReportHeader() {
178         super();
179     }
180
181     /**
182      * @param arg0
183      */

184     private ReportHeader(boolean arg0) {
185         super(arg0);
186     }
187
188     /**
189      * @param arg0
190      */

191     private ReportHeader(LayoutManager arg0) {
192         super(arg0);
193     }
194
195     /**
196      * @param arg0
197      * @param arg1
198      */

199     private ReportHeader(LayoutManager arg0, boolean arg1) {
200         super(arg0, arg1);
201     }
202
203     /* (non-Javadoc)
204      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
205      */

206     public void removeLayoutComponent(Component arg0) {
207     }
208
209     /* (non-Javadoc)
210      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
211      */

212     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
213     }
214
215     /* (non-Javadoc)
216      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
217      */

218     public Dimension minimumLayoutSize(Container arg0) {
219         return this.getPreferredSize();
220     }
221
222     /* (non-Javadoc)
223      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
224      */

225     public Dimension preferredLayoutSize(Container arg0) {
226         return this.getPreferredSize();
227     }
228
229     /* (non-Javadoc)
230      * @see com.simulacramedia.swing.datefield.DateFieldListener#validationFailed(com.simulacramedia.swing.datefield.JDateField, int)
231      */

232     public void validationFailed(JDateField source, int nReason) {
233     }
234
235     /* (non-Javadoc)
236      * @see com.simulacramedia.swing.datefield.DateFieldListener#valueChanged(com.simulacramedia.swing.datefield.JDateField)
237      */

238     public void valueChanged(JDateField source) {
239         if(source==this.m_fromDateField) {
240             this.m_reportQuery.setPeriodFrom(this.m_fromDateField.getDate());
241         } else if(source==this.m_toDateField) {
242             this.m_reportQuery.setPeriodTo(this.m_toDateField.getDate());
243         }
244     }
245     public void setScopeEnabled(boolean isEnabled){
246         this.m_pathCombo.setScopeEnabled(isEnabled);
247     }
248
249 }
Popular Tags