001: /*
002: * (C) Copyright SimulacraMedia 2003. All rights reserved.
003: *
004: * Created on 23-Feb-2004
005: *
006: */
007: package org.openharmonise.him.editors.report;
008:
009: import java.awt.Color;
010: import java.awt.Component;
011: import java.awt.Container;
012: import java.awt.Dimension;
013: import java.awt.Font;
014: import java.awt.LayoutManager;
015: import java.awt.event.ActionEvent;
016: import java.awt.event.ActionListener;
017:
018: import javax.swing.BorderFactory;
019: import javax.swing.JComboBox;
020: import javax.swing.JLabel;
021: import javax.swing.JPanel;
022:
023: import org.openharmonise.him.editors.report.rqom.*;
024:
025: /**
026: * Panel for the footer of the report editor. This covers the activities
027: * part of the form.
028: *
029: * @author Matthew Large
030: * @version $Revision: 1.1 $
031: *
032: */
033: public class ReportFooter extends JPanel implements LayoutManager,
034: ActionListener {
035:
036: /**
037: * Report query.
038: */
039: private ReportQuery m_reportQuery = null;
040:
041: /**
042: * Label for activities.
043: */
044: private JLabel m_activityLabel = null;
045:
046: /**
047: * Label for published field.
048: */
049: private JLabel m_publishedLabel = null;
050:
051: /**
052: * Published selector.
053: */
054: private JComboBox m_publishedCombo = null;
055:
056: /**
057: * Label for archived field.
058: */
059: private JLabel m_archivedLabel = null;
060:
061: /**
062: * Archived selector.
063: */
064: private JComboBox m_archivedCombo = null;
065:
066: /**
067: * Label for move field.
068: */
069: private JLabel m_moveLabel = null;
070:
071: /**
072: * Move selector.
073: */
074: private JComboBox m_moveCombo = null;
075:
076: /**
077: * Label for retrieved field.
078: */
079: private JLabel m_retrievedLabel = null;
080:
081: /**
082: * Revrieved selector.
083: */
084: private JComboBox m_retrievedCombo = null;
085:
086: /**
087: * Label for retrieved field.
088: */
089: private JLabel m_workflowLabel = null;
090:
091: /**
092: * Revrieved selector.
093: */
094: private JComboBox m_workflowCombo = null;
095:
096: /**
097: * Panel for border line.
098: */
099: private JPanel m_borderPanel = null;
100:
101: /**
102: * Label for displayed properties.
103: */
104: private JLabel 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 fontName = "Dialog";
132: int fontSize = 11;
133: Font font = new Font(fontName, Font.PLAIN, fontSize);
134:
135: String[] sData = new String[] { "Yes", "No" };
136:
137: this .m_activityLabel = new JLabel("Display Attributes");
138: this .m_activityLabel.setFont(font);
139: this .add(this .m_activityLabel);
140:
141: this .m_borderPanel = new JPanel();
142: this .m_borderPanel.setBorder(BorderFactory
143: .createLineBorder(Color.BLACK));
144: this .add(this .m_borderPanel);
145:
146: this .m_publishedLabel = new JLabel("Published");
147: this .m_publishedLabel.setFont(font);
148: this .add(this .m_publishedLabel);
149:
150: this .m_publishedCombo = new JComboBox(sData);
151: this .m_publishedCombo.setActionCommand("PUBLISHED");
152: this .m_publishedCombo.addActionListener(this );
153: this .m_publishedCombo.setBackground(Color.WHITE);
154: this .m_publishedCombo.setFont(font);
155: if (this .m_reportQuery.getActivities().contains(
156: ReportQuery.ACTIVITY_PUBLISH)) {
157: this .m_publishedCombo.setSelectedItem("Yes");
158: } else {
159: this .m_publishedCombo.setSelectedItem("No");
160: }
161: this .add(this .m_publishedCombo);
162:
163: this .m_archivedLabel = new JLabel("Archived");
164: this .m_archivedLabel.setFont(font);
165: this .add(this .m_archivedLabel);
166:
167: this .m_archivedCombo = new JComboBox(sData);
168: this .m_archivedCombo.setActionCommand("ARCHIVED");
169: this .m_archivedCombo.addActionListener(this );
170: this .m_archivedCombo.setBackground(Color.WHITE);
171: this .m_archivedCombo.setFont(font);
172: if (this .m_reportQuery.getActivities().contains(
173: ReportQuery.ACTIVITY_ARCHIVE)) {
174: this .m_archivedCombo.setSelectedItem("Yes");
175: } else {
176: this .m_archivedCombo.setSelectedItem("No");
177: }
178: this .add(this .m_archivedCombo);
179:
180: this .m_moveLabel = new JLabel("Move/copy");
181: this .m_moveLabel.setFont(font);
182: this .add(this .m_moveLabel);
183:
184: this .m_moveCombo = new JComboBox(sData);
185: this .m_moveCombo.setActionCommand("MOVE");
186: this .m_moveCombo.addActionListener(this );
187: this .m_moveCombo.setBackground(Color.WHITE);
188: this .m_moveCombo.setFont(font);
189: if (this .m_reportQuery.getActivities().contains(
190: ReportQuery.ACTIVITY_MOVE)) {
191: this .m_moveCombo.setSelectedItem("Yes");
192: } else {
193: this .m_moveCombo.setSelectedItem("No");
194: }
195: this .add(this .m_moveCombo);
196:
197: this .m_retrievedLabel = new JLabel("Retrieved");
198: this .m_retrievedLabel.setFont(font);
199: this .add(this .m_retrievedLabel);
200:
201: this .m_retrievedCombo = new JComboBox(sData);
202: this .m_retrievedCombo.setActionCommand("RETRIEVED");
203: this .m_retrievedCombo.addActionListener(this );
204: this .m_retrievedCombo.setBackground(Color.WHITE);
205: this .m_retrievedCombo.setFont(font);
206: if (this .m_reportQuery.getActivities().contains(
207: ReportQuery.ACTIVITY_RETRIEVE)) {
208: this .m_retrievedCombo.setSelectedItem("Yes");
209: } else {
210: this .m_retrievedCombo.setSelectedItem("No");
211: }
212: this .add(this .m_retrievedCombo);
213:
214: this .m_workflowLabel = new JLabel("Workflow");
215: this .m_workflowLabel.setFont(font);
216: this .add(this .m_workflowLabel);
217:
218: this .m_workflowCombo = new JComboBox(sData);
219: this .m_workflowCombo.setActionCommand("WORKFLOW");
220: this .m_workflowCombo.addActionListener(this );
221: this .m_workflowCombo.setBackground(Color.WHITE);
222: this .m_workflowCombo.setFont(font);
223: if (this .m_reportQuery.getActivities().contains(
224: ReportQuery.ACTIVITY_WORKFLOW)) {
225: this .m_workflowCombo.setSelectedItem("Yes");
226: } else {
227: this .m_workflowCombo.setSelectedItem("No");
228: }
229: this .add(this .m_workflowCombo);
230:
231: this .m_propLabel = new JLabel("Properties");
232: this .m_propLabel.setFont(font);
233: this .add(this .m_propLabel);
234:
235: m_attributePanel = new AttributePanel(this .m_reportQuery,
236: m_reportQuery.getDisplayAttributes(), null);
237: add(m_attributePanel);
238:
239: }
240:
241: /* (non-Javadoc)
242: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
243: */
244: public void actionPerformed(ActionEvent ae) {
245: if (ae.getActionCommand().equals("PUBLISHED")) {
246: if (((String) this .m_publishedCombo.getSelectedItem())
247: .equals("Yes")
248: && !this .m_reportQuery.getActivities().contains(
249: ReportQuery.ACTIVITY_PUBLISH)) {
250: this .m_reportQuery
251: .addActivity(ReportQuery.ACTIVITY_PUBLISH);
252: } else if (((String) this .m_publishedCombo
253: .getSelectedItem()).equals("No")) {
254: this .m_reportQuery
255: .removeActivity(ReportQuery.ACTIVITY_PUBLISH);
256: }
257: } else if (ae.getActionCommand().equals("ARCHIVED")) {
258: if (((String) this .m_archivedCombo.getSelectedItem())
259: .equals("Yes")
260: && !this .m_reportQuery.getActivities().contains(
261: ReportQuery.ACTIVITY_ARCHIVE)) {
262: this .m_reportQuery
263: .addActivity(ReportQuery.ACTIVITY_ARCHIVE);
264: } else if (((String) this .m_archivedCombo.getSelectedItem())
265: .equals("No")) {
266: this .m_reportQuery
267: .removeActivity(ReportQuery.ACTIVITY_ARCHIVE);
268: }
269: } else if (ae.getActionCommand().equals("MOVE")) {
270: if (((String) this .m_moveCombo.getSelectedItem())
271: .equals("Yes")
272: && !this .m_reportQuery.getActivities().contains(
273: ReportQuery.ACTIVITY_MOVE)) {
274: this .m_reportQuery
275: .addActivity(ReportQuery.ACTIVITY_MOVE);
276: } else if (((String) this .m_moveCombo.getSelectedItem())
277: .equals("No")) {
278: this .m_reportQuery
279: .removeActivity(ReportQuery.ACTIVITY_MOVE);
280: }
281: } else if (ae.getActionCommand().equals("RETRIEVED")) {
282: if (((String) this .m_retrievedCombo.getSelectedItem())
283: .equals("Yes")
284: && !this .m_reportQuery.getActivities().contains(
285: ReportQuery.ACTIVITY_RETRIEVE)) {
286: this .m_reportQuery
287: .addActivity(ReportQuery.ACTIVITY_RETRIEVE);
288: } else if (((String) this .m_retrievedCombo
289: .getSelectedItem()).equals("No")) {
290: this .m_reportQuery
291: .removeActivity(ReportQuery.ACTIVITY_RETRIEVE);
292: }
293: } else if (ae.getActionCommand().equals("WORKFLOW")) {
294: if (((String) this .m_workflowCombo.getSelectedItem())
295: .equals("Yes")
296: && !this .m_reportQuery.getActivities().contains(
297: ReportQuery.ACTIVITY_WORKFLOW)) {
298: this .m_reportQuery
299: .addActivity(ReportQuery.ACTIVITY_WORKFLOW);
300: } else if (((String) this .m_workflowCombo.getSelectedItem())
301: .equals("No")) {
302: this .m_reportQuery
303: .removeActivity(ReportQuery.ACTIVITY_WORKFLOW);
304: }
305: }
306: }
307:
308: /* (non-Javadoc)
309: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
310: */
311: public void layoutContainer(Container arg0) {
312: int nHeight = 10;
313:
314: this .m_activityLabel.setSize(this .m_activityLabel
315: .getPreferredSize());
316: this .m_activityLabel.setLocation(10, nHeight);
317: nHeight = nHeight + this .m_activityLabel.getSize().height + 5;
318:
319: this .m_borderPanel.setSize(700, 1);
320: this .m_borderPanel.setLocation(10 + this .m_activityLabel
321: .getSize().width + 5, this .m_activityLabel
322: .getLocation().y
323: + this .m_activityLabel.getSize().height / 2);
324:
325: m_propLabel.setSize(m_propLabel.getPreferredSize());
326: m_propLabel.setLocation(20, nHeight);
327:
328: m_attributePanel.setSize(m_attributePanel.getPreferredSize());
329: m_attributePanel.setLocation(100, nHeight);
330:
331: int nComboWidth = 170;
332:
333: nHeight += m_propLabel.getSize().height + 10;
334:
335: this .m_publishedLabel.setSize(this .m_publishedLabel
336: .getPreferredSize());
337: this .m_publishedLabel.setLocation(20, nHeight);
338:
339: this .m_publishedCombo.setSize(nComboWidth, 20);
340: this .m_publishedCombo.setLocation(100, nHeight);
341:
342: nHeight = nHeight + this .m_publishedLabel.getSize().height + 10;
343:
344: this .m_archivedLabel.setSize(this .m_archivedLabel
345: .getPreferredSize());
346: this .m_archivedLabel.setLocation(20, nHeight);
347:
348: this .m_archivedCombo.setSize(nComboWidth, 20);
349: this .m_archivedCombo.setLocation(100, nHeight);
350:
351: nHeight = nHeight + this .m_archivedLabel.getSize().height + 10;
352:
353: int nHeight2 = 30;
354:
355: this .m_moveLabel.setSize(this .m_moveLabel.getPreferredSize());
356: this .m_moveLabel.setLocation(340, nHeight2);
357:
358: this .m_moveCombo.setSize(nComboWidth, 20);
359: this .m_moveCombo.setLocation(420, nHeight2);
360:
361: nHeight2 = nHeight2 + this .m_moveLabel.getSize().height + 10;
362:
363: this .m_retrievedLabel.setSize(this .m_retrievedLabel
364: .getPreferredSize());
365: this .m_retrievedLabel.setLocation(340, nHeight2);
366:
367: this .m_retrievedCombo.setSize(nComboWidth, 20);
368: this .m_retrievedCombo.setLocation(420, nHeight2);
369:
370: nHeight2 = nHeight2 + this .m_retrievedLabel.getSize().height
371: + 10;
372:
373: this .m_workflowLabel.setSize(this .m_workflowLabel
374: .getPreferredSize());
375: this .m_workflowLabel.setLocation(340, nHeight2);
376:
377: this .m_workflowCombo.setSize(nComboWidth, 20);
378: this .m_workflowCombo.setLocation(420, nHeight2);
379:
380: nHeight2 = nHeight2 + this .m_workflowLabel.getSize().height
381: + 10;
382:
383: if (nHeight >= nHeight2) {
384: m_nHeight = nHeight;
385: } else {
386: m_nHeight = nHeight2;
387: }
388: }
389:
390: /* (non-Javadoc)
391: * @see java.awt.Component#getPreferredSize()
392: */
393: public Dimension getPreferredSize() {
394: return new Dimension(700, m_nHeight);
395: }
396:
397: /**
398: *
399: */
400: private ReportFooter() {
401: super ();
402: }
403:
404: /**
405: * @param arg0
406: */
407: private ReportFooter(boolean arg0) {
408: super (arg0);
409: }
410:
411: /**
412: * @param arg0
413: */
414: private ReportFooter(LayoutManager arg0) {
415: super (arg0);
416: }
417:
418: /**
419: * @param arg0
420: * @param arg1
421: */
422: private ReportFooter(LayoutManager arg0, boolean arg1) {
423: super (arg0, arg1);
424: }
425:
426: /* (non-Javadoc)
427: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
428: */
429: public void removeLayoutComponent(Component arg0) {
430: }
431:
432: /* (non-Javadoc)
433: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
434: */
435: public void addLayoutComponent(String arg0, Component arg1) {
436: }
437:
438: /* (non-Javadoc)
439: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
440: */
441: public Dimension minimumLayoutSize(Container arg0) {
442: return this .getPreferredSize();
443: }
444:
445: /* (non-Javadoc)
446: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
447: */
448: public Dimension preferredLayoutSize(Container arg0) {
449: return this.getPreferredSize();
450: }
451:
452: }
|