KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > configuration > reporting > ReportingConfigOptions


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.configuration.reporting;
20
21 import java.awt.Color JavaDoc;
22 import java.awt.Component JavaDoc;
23 import java.awt.Container JavaDoc;
24 import java.awt.Dimension JavaDoc;
25 import java.awt.LayoutManager JavaDoc;
26 import java.awt.event.ActionEvent JavaDoc;
27 import java.awt.event.ActionListener JavaDoc;
28
29 import javax.swing.BorderFactory JavaDoc;
30 import javax.swing.JComboBox JavaDoc;
31 import javax.swing.JLabel JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33
34 import org.openharmonise.him.configuration.*;
35 import org.openharmonise.vfs.gui.*;
36
37
38 /**
39  * Configuration options for the way in which Content Manager reports
40  * back to the user.
41  *
42  * @author Matthew Large
43  * @version $Revision: 1.1 $
44  *
45  */

46 public class ReportingConfigOptions
47     extends AbstractConfigOptions
48     implements ApplyChangesListener, LayoutManager JavaDoc, ActionListener JavaDoc {
49
50     /**
51      * Label for confirmations reporting.
52      */

53     private JLabel JavaDoc m_confirmationsLabel = null;
54     
55     /**
56      * Confirmations reporting field.
57      */

58     private JComboBox JavaDoc m_confirmationsCombo = null;
59     
60     /**
61      * true if the confirmations reporting value has changed.
62      */

63     private boolean m_bConfirmationsChanged = false;
64     
65     /**
66      * Label for informational reporting.
67      */

68     private JLabel JavaDoc m_informationLabel = null;
69     
70     /**
71      * Informational reporting field.
72      */

73     private JComboBox JavaDoc m_informationCombo = null;
74     
75     /**
76      * true if the informational reporting value has changed.
77      */

78     private boolean m_bInformationChanged = false;
79     
80     /**
81      * Label for error reporting.
82      */

83     private JLabel JavaDoc m_errorLabel = null;
84     
85     /**
86      * Error reporting field.
87      */

88     private JComboBox JavaDoc m_errorCombo = null;
89     
90     /**
91      * true if the error reporting value has changed.
92      */

93     private boolean m_bErrorChanged = false;
94
95     /**
96      * Main label for reporting options.
97      */

98     private JLabel JavaDoc m_optionsLabel = null;
99     
100     /**
101      * Panel for border line.
102      */

103     private JPanel JavaDoc m_borderPanel = null;
104
105     /**
106      * Constructs a new reporting config options.
107      *
108      * @param dialog Config dialog that will display these options
109      */

110     public ReportingConfigOptions(ConfigDialog dialog) {
111         super(dialog);
112         dialog.addApplyChangesListener(this);
113         this.setup();
114     }
115     
116     /**
117      * Configures this options class.
118      *
119      */

120     private void setup() {
121         this.setLayout(this);
122         
123         this.m_optionsLabel = new JLabel JavaDoc("Reporting options");
124         this.add(this.m_optionsLabel);
125         
126         String JavaDoc[] aData = new String JavaDoc[]{"Don't Report", "Report"};
127         
128         String JavaDoc sValue = ConfigStore.getInstance().getPropertyValue("MSG_CONFIRM_REPORT");
129         
130         this.m_confirmationsLabel = new JLabel JavaDoc("Confirmations");
131         this.m_confirmationsLabel.setIcon(IconManager.getInstance().getIcon("16-message-confirm.gif"));
132         this.add(m_confirmationsLabel);
133         
134         this.m_confirmationsCombo = new JComboBox JavaDoc(aData);
135         this.m_confirmationsCombo.setActionCommand("CONFIRM");
136         this.m_confirmationsCombo.addActionListener(this);
137         this.add(m_confirmationsCombo);
138         if(sValue!=null) {
139             if(sValue.equals("TRUE")) {
140                 this.m_confirmationsCombo.setSelectedItem("Report");
141             } else {
142                 this.m_confirmationsCombo.setSelectedItem("Don't Report");
143             }
144         } else {
145             this.m_confirmationsCombo.setSelectedItem("Report");
146         }
147         
148         sValue = ConfigStore.getInstance().getPropertyValue("MSG_INFORMATION_REPORT");
149         
150         this.m_informationLabel = new JLabel JavaDoc("Information");
151         this.m_informationLabel.setIcon(IconManager.getInstance().getIcon("16-message-information.gif"));
152         this.add(m_informationLabel);
153
154         this.m_informationCombo = new JComboBox JavaDoc(aData);
155         this.m_informationCombo.setActionCommand("INFORMATION");
156         this.m_informationCombo.addActionListener(this);
157         this.add(m_informationCombo);
158         if(sValue!=null) {
159             if(sValue.equals("TRUE")) {
160                 this.m_informationCombo.setSelectedItem("Report");
161             } else {
162                 this.m_informationCombo.setSelectedItem("Don't Report");
163             }
164         } else {
165             this.m_informationCombo.setSelectedItem("Report");
166         }
167         
168         sValue = ConfigStore.getInstance().getPropertyValue("MSG_ERROR_REPORT");
169         
170         this.m_errorLabel = new JLabel JavaDoc("Errors");
171         this.m_errorLabel.setIcon(IconManager.getInstance().getIcon("16-message-error.gif"));
172         this.add(m_errorLabel);
173
174         this.m_errorCombo = new JComboBox JavaDoc(aData);
175         this.m_errorCombo.setActionCommand("ERROR");
176         this.m_errorCombo.addActionListener(this);
177         this.add(m_errorCombo);
178         if(sValue!=null) {
179             if(sValue.equals("TRUE")) {
180                 this.m_errorCombo.setSelectedItem("Report");
181             } else {
182                 this.m_errorCombo.setSelectedItem("Don't Report");
183             }
184         } else {
185             this.m_errorCombo.setSelectedItem("Report");
186         }
187         
188         this.m_borderPanel = new JPanel JavaDoc();
189         this.m_borderPanel.setBorder( BorderFactory.createLineBorder(Color.BLACK) );
190         this.add(this.m_borderPanel);
191     }
192
193     /* (non-Javadoc)
194      * @see com.simulacramedia.contentmanager.configuration.ApplyChangesListener#applyChanges()
195      */

196     public boolean applyChanges() {
197         if(this.m_bConfirmationsChanged) {
198             if(((String JavaDoc)this.m_confirmationsCombo.getSelectedItem()).equals("Report")) {
199                 ConfigStore.getInstance().setProperty("MSG_CONFIRM_REPORT", "TRUE");
200             } else {
201                 ConfigStore.getInstance().setProperty("MSG_CONFIRM_REPORT", "FALSE");
202             }
203             this.m_bConfirmationsChanged = false;
204         }
205         if(this.m_bInformationChanged) {
206             if(((String JavaDoc)this.m_informationCombo.getSelectedItem()).equals("Report")) {
207                 ConfigStore.getInstance().setProperty("MSG_INFORMATION_REPORT", "TRUE");
208             } else {
209                 ConfigStore.getInstance().setProperty("MSG_INFORMATION_REPORT", "FALSE");
210             }
211             this.m_bInformationChanged = false;
212         }
213         if(this.m_bErrorChanged) {
214             if(((String JavaDoc)this.m_errorCombo.getSelectedItem()).equals("Report")) {
215                 ConfigStore.getInstance().setProperty("MSG_ERROR_REPORT", "TRUE");
216             } else {
217                 ConfigStore.getInstance().setProperty("MSG_ERROR_REPORT", "FALSE");
218             }
219             this.m_bErrorChanged = false;
220         }
221         return true;
222     }
223
224     /* (non-Javadoc)
225      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
226      */

227     public void actionPerformed(ActionEvent JavaDoc ae) {
228         if(ae.getActionCommand().equals("CONFIRM")) {
229             this.fireChangesMade();
230             this.m_bConfirmationsChanged = true;
231         } else if(ae.getActionCommand().equals("INFORMATION")) {
232             this.fireChangesMade();
233             this.m_bInformationChanged = true;
234         } else if(ae.getActionCommand().equals("ERROR")) {
235             this.fireChangesMade();
236             this.m_bErrorChanged = true;
237         }
238     }
239
240     /* (non-Javadoc)
241      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
242      */

243     public void layoutContainer(Container JavaDoc arg0) {
244         
245         this.m_optionsLabel.setSize(this.m_optionsLabel.getPreferredSize());
246         this.m_optionsLabel.setLocation(10, 0);
247         
248         this.m_borderPanel.setSize(this.getSize().width-this.m_optionsLabel.getSize().width-10, 1);
249         this.m_borderPanel.setLocation(this.m_optionsLabel.getSize().width+this.m_optionsLabel.getLocation().x + 5, this.m_optionsLabel.getLocation().y+8);
250         
251         this.m_confirmationsLabel.setSize(150, 20);
252         this.m_confirmationsLabel.setLocation(20, 20);
253         this.m_confirmationsCombo.setSize(150, 20);
254         this.m_confirmationsCombo.setLocation(200, 20);
255         
256         this.m_informationLabel.setSize(150, 20);
257         this.m_informationLabel.setLocation(20, 50);
258         this.m_informationCombo.setSize(150, 20);
259         this.m_informationCombo.setLocation(200, 50);
260         
261         this.m_errorLabel.setSize(150, 20);
262         this.m_errorLabel.setLocation(20, 80);
263         this.m_errorCombo.setSize(150, 20);
264         this.m_errorCombo.setLocation(200, 80);
265     }
266
267     /* (non-Javadoc)
268      * @see java.awt.Component#getPreferredSize()
269      */

270     public Dimension JavaDoc getPreferredSize() {
271         return new Dimension JavaDoc(this.getParent().getSize().width, 120);
272     }
273
274     /* (non-Javadoc)
275      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
276      */

277     public Dimension JavaDoc minimumLayoutSize(Container JavaDoc arg0) {
278         return this.getPreferredSize();
279     }
280
281     /* (non-Javadoc)
282      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
283      */

284     public Dimension JavaDoc preferredLayoutSize(Container JavaDoc arg0) {
285         return this.getPreferredSize();
286     }
287
288     /* (non-Javadoc)
289      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
290      */

291     public void removeLayoutComponent(Component JavaDoc arg0) {
292     }
293
294     /* (non-Javadoc)
295      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
296      */

297     public void addLayoutComponent(String JavaDoc arg0, Component JavaDoc arg1) {
298     }
299
300     /* (non-Javadoc)
301      * @see com.simulacramedia.contentmanager.configuration.ApplyChangesListener#discardChanges()
302      */

303     public void discardChanges() {
304         // TODO Auto-generated method stub
305

306     }
307
308 }
309
Popular Tags