KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * (C) Copyright SimulacraMedia 2003. All rights reserved.
3  *
4  * Created on 23-Feb-2004
5  *
6  */

7 package org.openharmonise.him.editors.report;
8
9 import java.awt.Color JavaDoc;
10 import java.awt.Component JavaDoc;
11 import java.awt.Container JavaDoc;
12 import java.awt.Dimension JavaDoc;
13 import java.awt.Font JavaDoc;
14 import java.awt.LayoutManager JavaDoc;
15 import java.awt.event.ActionEvent JavaDoc;
16 import java.awt.event.ActionListener JavaDoc;
17
18 import javax.swing.BorderFactory JavaDoc;
19 import javax.swing.JComboBox JavaDoc;
20 import javax.swing.JLabel JavaDoc;
21 import javax.swing.JPanel JavaDoc;
22
23 import org.openharmonise.him.editors.report.rqom.*;
24
25
26 /**
27  * Panel for the footer of the report editor. This covers the activities
28  * part of the form.
29  *
30  * @author Matthew Large
31  * @version $Revision: 1.1 $
32  *
33  */

34 public class ReportFooter extends JPanel JavaDoc implements LayoutManager JavaDoc, ActionListener JavaDoc {
35
36     /**
37      * Report query.
38      */

39     private ReportQuery m_reportQuery = null;
40     
41     /**
42      * Label for activities.
43      */

44     private JLabel JavaDoc m_activityLabel = null;
45     
46     /**
47      * Label for published field.
48      */

49     private JLabel JavaDoc m_publishedLabel = null;
50     
51     /**
52      * Published selector.
53      */

54     private JComboBox JavaDoc m_publishedCombo = null;
55     
56     /**
57      * Label for archived field.
58      */

59     private JLabel JavaDoc m_archivedLabel = null;
60     
61     /**
62      * Archived selector.
63      */

64     private JComboBox JavaDoc m_archivedCombo = null;
65     
66     /**
67      * Label for move field.
68      */

69     private JLabel JavaDoc m_moveLabel = null;
70     
71     /**
72      * Move selector.
73      */

74     private JComboBox JavaDoc m_moveCombo = null;
75     
76     /**
77      * Label for retrieved field.
78      */

79     private JLabel JavaDoc m_retrievedLabel = null;
80     
81     /**
82      * Revrieved selector.
83      */

84     private JComboBox JavaDoc m_retrievedCombo = null;
85     
86     /**
87      * Label for retrieved field.
88      */

89     private JLabel JavaDoc m_workflowLabel = null;
90     
91     /**
92      * Revrieved selector.
93      */

94     private JComboBox JavaDoc m_workflowCombo = null;
95     
96     /**
97      * Panel for border line.
98      */

99     private JPanel JavaDoc m_borderPanel = null;
100     
101     /**
102      * Label for displayed properties.
103      */

104     private JLabel JavaDoc m_propLabel = null;
105     
106     /**
107      * Panel for displayed properties.
108      */

109     private AttributePanel m_attributePanel;
110     
111     private int m_nHeight = 100;
112
113     /**
114      * Constructs a new report footer.
115      *
116      * @param query Report query.
117      */

118     public ReportFooter(ReportQuery query) {
119         super();
120         this.m_reportQuery = query;
121         this.setup();
122     }
123     
124     /**
125      * Configures this component.
126      *
127      */

128     private void setup() {
129         this.setLayout(this);
130
131         String JavaDoc fontName = "Dialog";
132         int fontSize = 11;
133         Font JavaDoc font = new Font JavaDoc(fontName, Font.PLAIN, fontSize);
134
135         String JavaDoc[] sData = new String JavaDoc[]{"Yes", "No"};
136
137         this.m_activityLabel = new JLabel JavaDoc("Display Attributes");
138         this.m_activityLabel.setFont(font);
139         this.add(this.m_activityLabel);
140         
141         this.m_borderPanel = new JPanel JavaDoc();
142         this.m_borderPanel.setBorder( BorderFactory.createLineBorder(Color.BLACK));
143         this.add(this.m_borderPanel);
144
145         this.m_publishedLabel = new JLabel JavaDoc("Published");
146         this.m_publishedLabel.setFont(font);
147         this.add(this.m_publishedLabel);
148         
149         this.m_publishedCombo = new JComboBox JavaDoc(sData);
150         this.m_publishedCombo.setActionCommand("PUBLISHED");
151         this.m_publishedCombo.addActionListener(this);
152         this.m_publishedCombo.setBackground(Color.WHITE);
153         this.m_publishedCombo.setFont(font);
154         if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_PUBLISH)) {
155             this.m_publishedCombo.setSelectedItem("Yes");
156         } else {
157             this.m_publishedCombo.setSelectedItem("No");
158         }
159         this.add(this.m_publishedCombo);
160         
161         this.m_archivedLabel = new JLabel JavaDoc("Archived");
162         this.m_archivedLabel.setFont(font);
163         this.add(this.m_archivedLabel);
164         
165         this.m_archivedCombo = new JComboBox JavaDoc(sData);
166         this.m_archivedCombo.setActionCommand("ARCHIVED");
167         this.m_archivedCombo.addActionListener(this);
168         this.m_archivedCombo.setBackground(Color.WHITE);
169         this.m_archivedCombo.setFont(font);
170         if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_ARCHIVE)) {
171             this.m_archivedCombo.setSelectedItem("Yes");
172         } else {
173             this.m_archivedCombo.setSelectedItem("No");
174         }
175         this.add(this.m_archivedCombo);
176         
177         this.m_moveLabel = new JLabel JavaDoc("Move/copy");
178         this.m_moveLabel.setFont(font);
179         this.add(this.m_moveLabel);
180         
181         this.m_moveCombo = new JComboBox JavaDoc(sData);
182         this.m_moveCombo.setActionCommand("MOVE");
183         this.m_moveCombo.addActionListener(this);
184         this.m_moveCombo.setBackground(Color.WHITE);
185         this.m_moveCombo.setFont(font);
186         if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_MOVE)) {
187             this.m_moveCombo.setSelectedItem("Yes");
188         } else {
189             this.m_moveCombo.setSelectedItem("No");
190         }
191         this.add(this.m_moveCombo);
192         
193         this.m_retrievedLabel = new JLabel JavaDoc("Retrieved");
194         this.m_retrievedLabel.setFont(font);
195         this.add(this.m_retrievedLabel);
196         
197         this.m_retrievedCombo = new JComboBox JavaDoc(sData);
198         this.m_retrievedCombo.setActionCommand("RETRIEVED");
199         this.m_retrievedCombo.addActionListener(this);
200         this.m_retrievedCombo.setBackground(Color.WHITE);
201         this.m_retrievedCombo.setFont(font);
202         if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_RETRIEVE)) {
203             this.m_retrievedCombo.setSelectedItem("Yes");
204         } else {
205             this.m_retrievedCombo.setSelectedItem("No");
206         }
207         this.add(this.m_retrievedCombo);
208         
209         this.m_workflowLabel = new JLabel JavaDoc("Workflow");
210         this.m_workflowLabel.setFont(font);
211         this.add(this.m_workflowLabel);
212         
213         this.m_workflowCombo = new JComboBox JavaDoc(sData);
214         this.m_workflowCombo.setActionCommand("WORKFLOW");
215         this.m_workflowCombo.addActionListener(this);
216         this.m_workflowCombo.setBackground(Color.WHITE);
217         this.m_workflowCombo.setFont(font);
218         if(this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_WORKFLOW)) {
219             this.m_workflowCombo.setSelectedItem("Yes");
220         } else {
221             this.m_workflowCombo.setSelectedItem("No");
222         }
223         this.add(this.m_workflowCombo);
224         
225         this.m_propLabel = new JLabel JavaDoc("Properties");
226         this.m_propLabel.setFont(font);
227         this.add(this.m_propLabel);
228         
229         m_attributePanel = new AttributePanel(this.m_reportQuery, m_reportQuery.getDisplayAttributes(), null);
230         add(m_attributePanel);
231         
232     }
233
234     /* (non-Javadoc)
235      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
236      */

237     public void actionPerformed(ActionEvent JavaDoc ae) {
238         if(ae.getActionCommand().equals("PUBLISHED")) {
239             if(((String JavaDoc)this.m_publishedCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_PUBLISH)) {
240                 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_PUBLISH);
241             } else if(((String JavaDoc)this.m_publishedCombo.getSelectedItem()).equals("No")) {
242                 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_PUBLISH);
243             }
244         } else if(ae.getActionCommand().equals("ARCHIVED")) {
245             if(((String JavaDoc)this.m_archivedCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_ARCHIVE)) {
246                 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_ARCHIVE);
247             } else if(((String JavaDoc)this.m_archivedCombo.getSelectedItem()).equals("No")) {
248                 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_ARCHIVE);
249             }
250         } else if(ae.getActionCommand().equals("MOVE")) {
251             if(((String JavaDoc)this.m_moveCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_MOVE)) {
252                 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_MOVE);
253             } else if(((String JavaDoc)this.m_moveCombo.getSelectedItem()).equals("No")) {
254                 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_MOVE);
255             }
256         } else if(ae.getActionCommand().equals("RETRIEVED")) {
257             if(((String JavaDoc)this.m_retrievedCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_RETRIEVE)) {
258                 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_RETRIEVE);
259             } else if(((String JavaDoc)this.m_retrievedCombo.getSelectedItem()).equals("No")) {
260                 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_RETRIEVE);
261             }
262         } else if(ae.getActionCommand().equals("WORKFLOW")) {
263             if(((String JavaDoc)this.m_workflowCombo.getSelectedItem()).equals("Yes") && !this.m_reportQuery.getActivities().contains(ReportQuery.ACTIVITY_WORKFLOW)) {
264                 this.m_reportQuery.addActivity(ReportQuery.ACTIVITY_WORKFLOW);
265             } else if(((String JavaDoc)this.m_workflowCombo.getSelectedItem()).equals("No")) {
266                 this.m_reportQuery.removeActivity(ReportQuery.ACTIVITY_WORKFLOW);
267             }
268         }
269     }
270
271     /* (non-Javadoc)
272      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
273      */

274     public void layoutContainer(Container JavaDoc arg0) {
275         int nHeight = 10;
276         
277         this.m_activityLabel.setSize(this.m_activityLabel.getPreferredSize());
278         this.m_activityLabel.setLocation(10, nHeight);
279         nHeight = nHeight + this.m_activityLabel.getSize().height + 5;
280         
281         this.m_borderPanel.setSize(700, 1);
282         this.m_borderPanel.setLocation(10 + this.m_activityLabel.getSize().width + 5, this.m_activityLabel.getLocation().y + this.m_activityLabel.getSize().height/2);
283         
284         m_propLabel.setSize(m_propLabel.getPreferredSize());
285         m_propLabel.setLocation(20,nHeight);
286         
287         m_attributePanel.setSize(m_attributePanel.getPreferredSize());
288         m_attributePanel.setLocation(100, nHeight);
289         
290         int nComboWidth = 170;
291         
292         nHeight += m_propLabel.getSize().height + 10;
293         
294         this.m_publishedLabel.setSize(this.m_publishedLabel.getPreferredSize());
295         this.m_publishedLabel.setLocation(20, nHeight);
296         
297         this.m_publishedCombo.setSize(nComboWidth, 20);
298         this.m_publishedCombo.setLocation(100, nHeight);
299         
300         nHeight = nHeight + this.m_publishedLabel.getSize().height + 10;
301         
302         this.m_archivedLabel.setSize(this.m_archivedLabel.getPreferredSize());
303         this.m_archivedLabel.setLocation(20, nHeight);
304         
305         this.m_archivedCombo.setSize(nComboWidth, 20);
306         this.m_archivedCombo.setLocation(100, nHeight);
307         
308         nHeight = nHeight + this.m_archivedLabel.getSize().height + 10;
309         
310         int nHeight2 = 30;
311         
312         this.m_moveLabel.setSize(this.m_moveLabel.getPreferredSize());
313         this.m_moveLabel.setLocation(340, nHeight2);
314         
315         this.m_moveCombo.setSize(nComboWidth, 20);
316         this.m_moveCombo.setLocation(420, nHeight2);
317         
318         nHeight2 = nHeight2 + this.m_moveLabel.getSize().height + 10;
319         
320         this.m_retrievedLabel.setSize(this.m_retrievedLabel.getPreferredSize());
321         this.m_retrievedLabel.setLocation(340, nHeight2);
322         
323         this.m_retrievedCombo.setSize(nComboWidth, 20);
324         this.m_retrievedCombo.setLocation(420, nHeight2);
325         
326         nHeight2 = nHeight2 + this.m_retrievedLabel.getSize().height + 10;
327         
328         this.m_workflowLabel.setSize(this.m_workflowLabel.getPreferredSize());
329         this.m_workflowLabel.setLocation(340, nHeight2);
330         
331         this.m_workflowCombo.setSize(nComboWidth, 20);
332         this.m_workflowCombo.setLocation(420, nHeight2);
333         
334         nHeight2 = nHeight2 + this.m_workflowLabel.getSize().height + 10;
335         
336         if(nHeight>=nHeight2){
337             m_nHeight = nHeight;
338         } else {
339             m_nHeight = nHeight2;
340         }
341     }
342
343     /* (non-Javadoc)
344      * @see java.awt.Component#getPreferredSize()
345      */

346     public Dimension JavaDoc getPreferredSize() {
347         return new Dimension JavaDoc(700, m_nHeight);
348     }
349
350     /**
351      *
352      */

353     private ReportFooter() {
354         super();
355     }
356
357     /**
358      * @param arg0
359      */

360     private ReportFooter(boolean arg0) {
361         super(arg0);
362     }
363
364     /**
365      * @param arg0
366      */

367     private ReportFooter(LayoutManager JavaDoc arg0) {
368         super(arg0);
369     }
370
371     /**
372      * @param arg0
373      * @param arg1
374      */

375     private ReportFooter(LayoutManager JavaDoc arg0, boolean arg1) {
376         super(arg0, arg1);
377     }
378
379     /* (non-Javadoc)
380      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
381      */

382     public void removeLayoutComponent(Component JavaDoc arg0) {
383     }
384
385     /* (non-Javadoc)
386      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
387      */

388     public void addLayoutComponent(String JavaDoc arg0, Component JavaDoc arg1) {
389     }
390
391     /* (non-Javadoc)
392      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
393      */

394     public Dimension JavaDoc minimumLayoutSize(Container JavaDoc arg0) {
395         return this.getPreferredSize();
396     }
397
398     /* (non-Javadoc)
399      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
400      */

401     public Dimension JavaDoc preferredLayoutSize(Container JavaDoc arg0) {
402         return this.getPreferredSize();
403     }
404
405 }
406
Popular Tags