1 19 package org.openharmonise.him.configuration.reporting; 20 21 import java.awt.Color ; 22 import java.awt.Component ; 23 import java.awt.Container ; 24 import java.awt.Dimension ; 25 import java.awt.LayoutManager ; 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 29 import javax.swing.BorderFactory ; 30 import javax.swing.JComboBox ; 31 import javax.swing.JLabel ; 32 import javax.swing.JPanel ; 33 34 import org.openharmonise.him.configuration.*; 35 import org.openharmonise.vfs.gui.*; 36 37 38 46 public class ReportingConfigOptions 47 extends AbstractConfigOptions 48 implements ApplyChangesListener, LayoutManager , ActionListener { 49 50 53 private JLabel m_confirmationsLabel = null; 54 55 58 private JComboBox m_confirmationsCombo = null; 59 60 63 private boolean m_bConfirmationsChanged = false; 64 65 68 private JLabel m_informationLabel = null; 69 70 73 private JComboBox m_informationCombo = null; 74 75 78 private boolean m_bInformationChanged = false; 79 80 83 private JLabel m_errorLabel = null; 84 85 88 private JComboBox m_errorCombo = null; 89 90 93 private boolean m_bErrorChanged = false; 94 95 98 private JLabel m_optionsLabel = null; 99 100 103 private JPanel m_borderPanel = null; 104 105 110 public ReportingConfigOptions(ConfigDialog dialog) { 111 super(dialog); 112 dialog.addApplyChangesListener(this); 113 this.setup(); 114 } 115 116 120 private void setup() { 121 this.setLayout(this); 122 123 this.m_optionsLabel = new JLabel ("Reporting options"); 124 this.add(this.m_optionsLabel); 125 126 String [] aData = new String []{"Don't Report", "Report"}; 127 128 String sValue = ConfigStore.getInstance().getPropertyValue("MSG_CONFIRM_REPORT"); 129 130 this.m_confirmationsLabel = new JLabel ("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 (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 ("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 (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 ("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 (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 (); 189 this.m_borderPanel.setBorder( BorderFactory.createLineBorder(Color.BLACK) ); 190 this.add(this.m_borderPanel); 191 } 192 193 196 public boolean applyChanges() { 197 if(this.m_bConfirmationsChanged) { 198 if(((String )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 )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 )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 227 public void actionPerformed(ActionEvent 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 243 public void layoutContainer(Container 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 270 public Dimension getPreferredSize() { 271 return new Dimension (this.getParent().getSize().width, 120); 272 } 273 274 277 public Dimension minimumLayoutSize(Container arg0) { 278 return this.getPreferredSize(); 279 } 280 281 284 public Dimension preferredLayoutSize(Container arg0) { 285 return this.getPreferredSize(); 286 } 287 288 291 public void removeLayoutComponent(Component arg0) { 292 } 293 294 297 public void addLayoutComponent(String arg0, Component arg1) { 298 } 299 300 303 public void discardChanges() { 304 306 } 307 308 } 309 | Popular Tags |