4 * Created on 2007/07/21, 22:37
7 package org.jent.checksmtp;
10 import java.awt.Dimension;
11 import java.awt.Point;
12 import java.awt.Toolkit;
13 import java.awt.event.ActionEvent;
14 import java.awt.event.ActionListener;
15 import javax.swing.InputVerifier;
16 import javax.swing.JComponent;
17 import javax.swing.JFrame;
18 import javax.swing.JTextField;
22 * @author Takuya Ono <takuya-o@users.sourceforge.jp>
24 public class ApplicationUI extends javax.swing.JFrame {
26 /** Creates new form ApplicationUI */
27 public ApplicationUI() {
31 jButtonOK.requestFocusInWindow();
32 //getRootPane().setDefaultButton(jButtonOK);
37 private void resetDisplay() {
38 jTextFieldReceiverPort.setText(Integer.toString(ApplicationProperties.getSmtpPort()));
39 jTextFieldServerHost.setText(ApplicationProperties.getSmtpServerHost());
40 jTextFieldServerPort.setText(Integer.toString(ApplicationProperties.getSmtpServerPort()));
41 jCheckBoxEnableRemoteConnect.setSelected(ApplicationProperties.getSmtpEnebleRemoteConnect());
43 jCheckBoxLdap.setSelected(ApplicationProperties.getLdap());
44 jTextFieldProviderUrl.setText(ApplicationProperties.getLdapProviderURL());
45 jTextFieldBaseDn.setText(ApplicationProperties.getLdapRoot());
46 jTextFieldAttribute.setText(ApplicationProperties.getLdapAttributes());
47 jCheckBoxIsSjis.setSelected(ApplicationProperties.getLdapIsSjis());
51 static private MessageDialogUI portNumberOutOfRangeErrorDialog = null;
52 class PortNumberInputVerifier extends InputVerifier {
53 public boolean verify(JComponent jComponent) {
54 JTextField jTextField = (JTextField) jComponent;
56 String input = jTextField.getText();
59 int port = Integer.parseInt(input);
61 } catch (Exception e) {
66 jTextField.setBackground(Color.PINK);
67 if ( portNumberOutOfRangeErrorDialog == null ) {
68 portNumberOutOfRangeErrorDialog =
69 new MessageDialogUI("Port number is integer from 1 to 65535.",
70 null, MessageDialogUI.WARNING_MODE);
72 portNumberOutOfRangeErrorDialog.setVisible(true);
75 jTextField.setBackground(Color.WHITE);
82 /** This method is called from within the constructor to
83 * initialize the form.
84 * WARNING: Do NOT modify this code. The content of this method is
85 * always regenerated by the Form Editor.
87 // <editor-fold defaultstate="collapsed" desc=" Generated Code">//GEN-BEGIN:initComponents
88 private void initComponents() {
89 jTabbedPane = new javax.swing.JTabbedPane();
90 jPanelMail = new javax.swing.JPanel();
91 jLabel1 = new javax.swing.JLabel();
92 jLabel2 = new javax.swing.JLabel();
93 jLabel3 = new javax.swing.JLabel();
94 jTextFieldReceiverPort = new javax.swing.JTextField();
95 jTextFieldServerHost = new javax.swing.JTextField();
96 jTextFieldServerPort = new javax.swing.JTextField();
97 jCheckBoxEnableRemoteConnect = new javax.swing.JCheckBox();
98 jPanelLDAP = new javax.swing.JPanel();
99 jCheckBoxLdap = new javax.swing.JCheckBox();
100 jLabel4 = new javax.swing.JLabel();
101 jLabel5 = new javax.swing.JLabel();
102 jLabel6 = new javax.swing.JLabel();
103 jTextFieldProviderUrl = new javax.swing.JTextField();
104 jTextFieldBaseDn = new javax.swing.JTextField();
105 jTextFieldAttribute = new javax.swing.JTextField();
106 jCheckBoxIsSjis = new javax.swing.JCheckBox();
107 jPanelAbout = new javax.swing.JPanel();
108 jLabelProgramName = new javax.swing.JLabel();
109 jLabelProgramVersion = new javax.swing.JLabel();
110 jLabelSfURL = new javax.swing.JLabel();
111 jButtonOK = new javax.swing.JButton();
112 jButtonCancel = new javax.swing.JButton();
113 jButtonQuit = new javax.swing.JButton();
115 setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
116 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle"); // NOI18N
117 setTitle(bundle.getString("ApplicationUI.title")); // NOI18N
118 addWindowListener(new java.awt.event.WindowAdapter() {
119 public void windowDeiconified(java.awt.event.WindowEvent evt) {
120 formWindowDeiconified(evt);
122 public void windowIconified(java.awt.event.WindowEvent evt) {
123 formWindowIconified(evt);
127 jLabel1.setText(bundle.getString("ApplicationUI.jLabel1.text")); // NOI18N
129 jLabel2.setText(bundle.getString("ApplicationUI.jLabel2.text")); // NOI18N
131 jLabel3.setText(bundle.getString("ApplicationUI.jLabel3.text")); // NOI18N
133 jTextFieldReceiverPort.setText(bundle.getString("ApplicationUI.jTextFieldReceiverPort.text")); // NOI18N
134 jTextFieldReceiverPort.setToolTipText(bundle.getString("ApplicationUI.jTextFieldReceiverPort.toolTipText")); // NOI18N
135 jTextFieldReceiverPort.setInputVerifier(new PortNumberInputVerifier());
137 jTextFieldServerHost.setText(bundle.getString("ApplicationUI.jTextFieldServerHost.text")); // NOI18N
138 jTextFieldServerHost.setToolTipText(bundle.getString("ApplicationUI.jTextFieldServerHost.toolTipText")); // NOI18N
140 jTextFieldServerPort.setText(bundle.getString("ApplicationUI.jTextFieldServerPort.text")); // NOI18N
141 jTextFieldServerPort.setToolTipText(bundle.getString("ApplicationUI.jTextFieldServerPort.toolTipText")); // NOI18N
142 jTextFieldServerPort.setInputVerifier(new PortNumberInputVerifier());
144 jCheckBoxEnableRemoteConnect.setText(bundle.getString("ApplicationUI.jCheckBoxEnableRemoteConnect.text")); // NOI18N
145 jCheckBoxEnableRemoteConnect.setToolTipText(bundle.getString("ApplicationUI.jCheckBoxEnableRemoteConnect.toolTipText")); // NOI18N
146 jCheckBoxEnableRemoteConnect.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
147 jCheckBoxEnableRemoteConnect.setMargin(new java.awt.Insets(0, 0, 0, 0));
149 org.jdesktop.layout.GroupLayout jPanelMailLayout = new org.jdesktop.layout.GroupLayout(jPanelMail);
150 jPanelMail.setLayout(jPanelMailLayout);
151 jPanelMailLayout.setHorizontalGroup(
152 jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
153 .add(jPanelMailLayout.createSequentialGroup()
155 .add(jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
156 .add(jPanelMailLayout.createSequentialGroup()
158 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
159 .add(jTextFieldReceiverPort, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
160 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
161 .add(jCheckBoxEnableRemoteConnect))
162 .add(jPanelMailLayout.createSequentialGroup()
164 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
165 .add(jTextFieldServerHost, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
166 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
168 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
169 .add(jTextFieldServerPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
173 jPanelMailLayout.linkSize(new java.awt.Component[] {jLabel1, jLabel2}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
175 jPanelMailLayout.setVerticalGroup(
176 jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
177 .add(jPanelMailLayout.createSequentialGroup()
179 .add(jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
181 .add(jCheckBoxEnableRemoteConnect)
182 .add(jTextFieldReceiverPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
183 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
184 .add(jPanelMailLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
187 .add(jTextFieldServerHost, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
188 .add(jTextFieldServerPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
189 .addContainerGap(58, Short.MAX_VALUE))
191 jTabbedPane.addTab(bundle.getString("ApplicationUI.jPanelMail.TabConstraints.tabTitle"), jPanelMail); // NOI18N
193 jCheckBoxLdap.setText(bundle.getString("ApplicationUI.jCheckBoxLdap.text")); // NOI18N
194 jCheckBoxLdap.setToolTipText(bundle.getString("ApplicationUI.jCheckBoxLdap.toolTipText")); // NOI18N
195 jCheckBoxLdap.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
196 jCheckBoxLdap.setMargin(new java.awt.Insets(0, 0, 0, 0));
197 jCheckBoxLdap.addChangeListener(new javax.swing.event.ChangeListener() {
198 public void stateChanged(javax.swing.event.ChangeEvent evt) {
199 jCheckBoxLdapStateChanged(evt);
203 jLabel4.setText(bundle.getString("ApplicationUI.jLabel4.text")); // NOI18N
205 jLabel5.setText(bundle.getString("ApplicationUI.jLabel5.text")); // NOI18N
207 jLabel6.setText(bundle.getString("ApplicationUI.jLabel6.text")); // NOI18N
209 jTextFieldProviderUrl.setText(bundle.getString("ApplicationUI.jTextFieldProviderUrl.text")); // NOI18N
210 jTextFieldProviderUrl.setToolTipText(bundle.getString("ApplicationUI.jTextFieldProviderUrl.toolTipText")); // NOI18N
211 jTextFieldProviderUrl.setEnabled(false);
213 jTextFieldBaseDn.setText(bundle.getString("ApplicationUI.jTextFieldBaseDn.text")); // NOI18N
214 jTextFieldBaseDn.setToolTipText(bundle.getString("ApplicationUI.jTextFieldBaseDn.toolTipText")); // NOI18N
215 jTextFieldBaseDn.setEnabled(false);
217 jTextFieldAttribute.setText(bundle.getString("ApplicationUI.jTextFieldAttribute.text")); // NOI18N
218 jTextFieldAttribute.setToolTipText(bundle.getString("ApplicationUI.jTextFieldAttribute.toolTipText")); // NOI18N
219 jTextFieldAttribute.setEnabled(false);
221 jCheckBoxIsSjis.setText(bundle.getString("ApplicationUI.jCheckBoxIsSjis.text")); // NOI18N
222 jCheckBoxIsSjis.setToolTipText(bundle.getString("ApplicationUI.jCheckBoxIsSjis.toolTipText")); // NOI18N
223 jCheckBoxIsSjis.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
224 jCheckBoxIsSjis.setEnabled(false);
225 jCheckBoxIsSjis.setMargin(new java.awt.Insets(0, 0, 0, 0));
227 org.jdesktop.layout.GroupLayout jPanelLDAPLayout = new org.jdesktop.layout.GroupLayout(jPanelLDAP);
228 jPanelLDAP.setLayout(jPanelLDAPLayout);
229 jPanelLDAPLayout.setHorizontalGroup(
230 jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
231 .add(jPanelLDAPLayout.createSequentialGroup()
232 .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
233 .add(jPanelLDAPLayout.createSequentialGroup()
235 .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
236 .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6)
237 .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5)
238 .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4))
239 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
240 .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
241 .add(jTextFieldAttribute, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
242 .add(jTextFieldBaseDn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
243 .add(jPanelLDAPLayout.createSequentialGroup()
244 .add(jTextFieldProviderUrl, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
245 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
246 .add(jCheckBoxIsSjis))))
247 .add(jPanelLDAPLayout.createSequentialGroup()
249 .add(jCheckBoxLdap)))
253 jPanelLDAPLayout.linkSize(new java.awt.Component[] {jLabel4, jLabel5, jLabel6}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
255 jPanelLDAPLayout.setVerticalGroup(
256 jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
257 .add(jPanelLDAPLayout.createSequentialGroup()
260 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
261 .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
263 .add(jTextFieldProviderUrl, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
264 .add(jCheckBoxIsSjis))
265 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
266 .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
268 .add(jTextFieldBaseDn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
269 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
270 .add(jPanelLDAPLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
272 .add(jTextFieldAttribute, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
273 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
275 jTabbedPane.addTab(bundle.getString("ApplicationUI.jPanelLDAP.TabConstraints.tabTitle"), jPanelLDAP); // NOI18N
277 jLabelProgramName.setFont(new java.awt.Font("Dialog", 1, 18));
278 jLabelProgramName.setText(bundle.getString("ApplicationUI.jLabelProgramName.text")); // NOI18N
280 jLabelProgramVersion.setFont(new java.awt.Font("Dialog", 1, 18));
281 jLabelProgramVersion.setText(bundle.getString("ApplicationUI.jLabelProgramVersion.text")); // NOI18N
283 jLabelSfURL.setFont(new java.awt.Font("Dialog", 1, 14));
284 jLabelSfURL.setText(bundle.getString("ApplicationUI.jLabelSfURL.text")); // NOI18N
286 org.jdesktop.layout.GroupLayout jPanelAboutLayout = new org.jdesktop.layout.GroupLayout(jPanelAbout);
287 jPanelAbout.setLayout(jPanelAboutLayout);
288 jPanelAboutLayout.setHorizontalGroup(
289 jPanelAboutLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
290 .add(jPanelAboutLayout.createSequentialGroup()
291 .add(jPanelAboutLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
292 .add(jPanelAboutLayout.createSequentialGroup()
294 .add(jLabelProgramName)
295 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
296 .add(jLabelProgramVersion))
297 .add(jPanelAboutLayout.createSequentialGroup()
300 .addContainerGap(35, Short.MAX_VALUE))
302 jPanelAboutLayout.setVerticalGroup(
303 jPanelAboutLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
304 .add(jPanelAboutLayout.createSequentialGroup()
306 .add(jPanelAboutLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
307 .add(jLabelProgramName)
308 .add(jLabelProgramVersion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
309 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
311 .addContainerGap(57, Short.MAX_VALUE))
313 jTabbedPane.addTab(bundle.getString("ApplicationUI.jPanelAbout.TabConstraints.tabTitle"), jPanelAbout); // NOI18N
315 jButtonOK.setText(bundle.getString("ApplicationUI.jButtonOK.text")); // NOI18N
316 jButtonOK.setToolTipText(bundle.getString("ApplicationUI.jButtonOK.toolTipText")); // NOI18N
317 jButtonOK.addActionListener(new java.awt.event.ActionListener() {
318 public void actionPerformed(java.awt.event.ActionEvent evt) {
319 jButtonOKActionPerformed(evt);
323 jButtonCancel.setText(bundle.getString("ApplicationUI.jButtonCancel.text")); // NOI18N
324 jButtonCancel.setToolTipText(bundle.getString("ApplicationUI.jButtonCancel.toolTipText")); // NOI18N
325 jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
326 public void actionPerformed(java.awt.event.ActionEvent evt) {
327 jButtonCancelActionPerformed(evt);
331 jButtonQuit.setText(bundle.getString("ApplicationUI.jButtonQuit.text")); // NOI18N
332 jButtonQuit.setToolTipText(bundle.getString("ApplicationUI.jButtonQuit.toolTipText")); // NOI18N
333 jButtonQuit.addActionListener(new java.awt.event.ActionListener() {
334 public void actionPerformed(java.awt.event.ActionEvent evt) {
335 jButtonQuitActionPerformed(evt);
339 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
340 getContentPane().setLayout(layout);
341 layout.setHorizontalGroup(
342 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
343 .add(jTabbedPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
344 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
347 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 145, Short.MAX_VALUE)
349 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
354 layout.linkSize(new java.awt.Component[] {jButtonCancel, jButtonOK, jButtonQuit}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
356 layout.setVerticalGroup(
357 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
358 .add(layout.createSequentialGroup()
359 .add(jTabbedPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
360 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
361 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
368 }// </editor-fold>//GEN-END:initComponents
370 private void formWindowDeiconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeiconified
371 setTitle("Mail Destination Confirm Properties");
372 jButtonOK.requestFocusInWindow();
373 }//GEN-LAST:event_formWindowDeiconified
375 private void formWindowIconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowIconified
377 }//GEN-LAST:event_formWindowIconified
379 private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
382 port = Integer.parseInt(jTextFieldReceiverPort.getText());
383 checkPortRange(port);
384 } catch (NumberFormatException ex) {
385 jTextFieldReceiverPort.setBackground(Color.PINK);
388 String serverHost = jTextFieldServerHost.getText();
391 serverPort = Integer.parseInt(jTextFieldServerPort.getText());
392 checkPortRange(serverPort);
393 } catch (NumberFormatException ex) {
394 jTextFieldServerPort.setBackground(Color.PINK);
397 boolean enableRemoteConnect = jCheckBoxEnableRemoteConnect.isSelected();
399 boolean enableLdap = jCheckBoxLdap.isSelected();
400 String ldapUrl = jTextFieldProviderUrl.getText();
401 String rootDn = jTextFieldBaseDn.getText();
402 String attribute = jTextFieldAttribute.getText();
403 boolean isSjis = jCheckBoxIsSjis.isSelected();
405 if ( port != ApplicationProperties.getSmtpPort()
406 || !serverHost.equals(ApplicationProperties.getSmtpServerHost())
407 || serverPort != ApplicationProperties.getSmtpServerPort()
408 || enableRemoteConnect != ApplicationProperties.getSmtpEnebleRemoteConnect()
410 || enableLdap != ApplicationProperties.getLdap()
411 || !ldapUrl.equals(ApplicationProperties.getLdapProviderURL())
412 || !rootDn.equals(ApplicationProperties.getLdapRoot())
413 || !attribute.equals(ApplicationProperties.getLdapAttributes())
414 || isSjis != ApplicationProperties.getLdapIsSjis()
415 || isModifiedPotition()
417 // When modify data, save properries file.
418 ApplicationProperties.setSmtpPort(port);
419 ApplicationProperties.setSmtpServerHost(serverHost);
420 ApplicationProperties.setSmtpServerPort(serverPort);
421 ApplicationProperties.setSmtpEnableRemoteConnect(enableRemoteConnect);
423 ApplicationProperties.setLdap(enableLdap);
424 ApplicationProperties.setLdapProviderURL(ldapUrl);
425 ApplicationProperties.setLdapRoot(rootDn);
426 ApplicationProperties.setLdapAttributes(attribute);
427 ApplicationProperties.setLdapIsSjis(isSjis);
429 smtpClient.configChangeNotify();
430 if ( !ApplicationProperties.save() ) {
431 new MessageDialogUI("Fail the properties file save.", null,
432 MessageDialogUI.ERROR_MODE);
439 }//GEN-LAST:event_jButtonOKActionPerformed
442 * Check port number range. It is unsigned short number.
443 * Argument is port number.
445 private void checkPortRange(final int port) {
446 if ( port <= 0 || port > 65535 ) {
447 throw new NumberFormatException("Out of range.");
451 private void jButtonQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQuitActionPerformed
453 }//GEN-LAST:event_jButtonQuitActionPerformed
455 private void jCheckBoxLdapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBoxLdapStateChanged
456 boolean check = jCheckBoxLdap.isSelected();
457 jTextFieldProviderUrl.setEnabled(check);
458 jTextFieldBaseDn.setEnabled(check);
459 jTextFieldAttribute.setEnabled(check);
460 jCheckBoxIsSjis.setEnabled(check);
461 }//GEN-LAST:event_jCheckBoxLdapStateChanged
463 private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
464 //this.setVisible(false);
466 if ( portNumberOutOfRangeErrorDialog != null && portNumberOutOfRangeErrorDialog.isVisible() ) {
467 portNumberOutOfRangeErrorDialog.dispose();
470 }//GEN-LAST:event_jButtonCancelActionPerformed
472 private boolean isModifiedPotition() {
475 if ( getExtendedState() == JFrame.NORMAL ) {
476 Point locationPoint = getLocationOnScreen(); //TODO: IllegalComponentStateException
480 //Unexpect logic. Because this method call from pushed "OK" button.
484 int h = this.getHeight();
485 int w = this.getWidth();
486 boolean modified = false;
488 if ( x != ApplicationProperties.getConfigDialogPosX()
489 || y != ApplicationProperties.getConfigDialogPosY()
490 || h != ApplicationProperties.getConfigDialogPosH()
491 || w != ApplicationProperties.getConfigDialogPosW()
494 ApplicationProperties.setConfigDialogPosX(x);
495 ApplicationProperties.setConfigDialogPosY(y);
496 ApplicationProperties.setConfigDialogPosH(h);
497 ApplicationProperties.setConfigDialogPosW(w);
503 private boolean initSystemTray() {
504 boolean useSystemTray = false;
506 Class.forName("java.awt.SystemTray");
507 /* TODO: SystemTray suuport
508 java.awt.SystemTray tray = java.awt.SystemTray.getSystemTray();
509 if(tray.isSupported()){
510 java.awt.TrayIcon trayIcon = new java.awt.TrayIcon(
511 new javax.swing.ImageIcon(
512 SystemTrayTest.class.getResource("images/mdc.gif")).getImage());
513 trayIcon.setImageAutoSize(true);
515 // create a action listener to listen for default action executed on the tray icon
516 ActionListener listener = new ActionListener() {
517 public void actionPerformed(ActionEvent e) {
518 // execute default action of the application
519 if ( e.paramString().equal("Quit")) {
523 if ( this.getExtendedState() == ICONIFIED ) {
524 this.setExtendedState(NORMAL);
529 java.awt.PopupMenu popup = new java.awt.PopupMenu();
530 popup.addActionListener(listener);
533 trayIcon.setPopupMenu(popup);
535 useSystemTray = true;
538 } catch (ClassNotFoundException ex) {
539 // Do not support SystemTray on this VM.
541 return useSystemTray;
544 private void iconified() {
545 if ( useSystemTray ) {
546 this.setVisible(false);
548 this.setExtendedState(ICONIFIED);
553 * @param args the command line arguments
555 public static void main(String args[]) {
558 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
559 } catch (Exception e) {
565 java.awt.EventQueue.invokeLater(new Runnable() {
567 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
568 ApplicationUI applicationUI = new ApplicationUI();
569 applicationUI.setVisible(true);
571 applicationUI.useSystemTray = applicationUI.initSystemTray();
573 //If exsist configuration file, iconise at start up.
574 if ( ApplicationProperties.isFileLoaded() ) {
575 int x = ApplicationProperties.getConfigDialogPosX();
576 int y = ApplicationProperties.getConfigDialogPosY();
577 int w = ApplicationProperties.getConfigDialogPosW();
578 int h = ApplicationProperties.getConfigDialogPosH();
580 if ( x > screenSize.width ) {
581 x = screenSize.width - w;
582 if ( x < 0 ) { x = 0; };
584 if ( y > screenSize.height ) {
585 y = screenSize.height - h;
586 if ( y < 0 ) { y = 0; };
588 applicationUI.setBounds(x, y, w, h);
589 applicationUI.iconified();
591 //No Configuration file.
592 Dimension frameSize = ApplicationProperties.getConfigurationDialogSize();
593 if (frameSize.height > screenSize.height) {
594 frameSize.height = screenSize.height;
596 if (frameSize.width > screenSize.width) {
597 frameSize.width = screenSize.width;
600 applicationUI.setBounds(
601 (screenSize.width - frameSize.width) / 2,
602 (screenSize.height - frameSize.height) / 2,
603 frameSize.width, frameSize.height );
608 smtpClient = new SMTPclient();
610 private static SMTPclient smtpClient = null;
611 private boolean useSystemTray = false;
613 // Variables declaration - do not modify//GEN-BEGIN:variables
614 private javax.swing.JButton jButtonCancel;
615 private javax.swing.JButton jButtonOK;
616 private javax.swing.JButton jButtonQuit;
617 private javax.swing.JCheckBox jCheckBoxEnableRemoteConnect;
618 private javax.swing.JCheckBox jCheckBoxIsSjis;
619 private javax.swing.JCheckBox jCheckBoxLdap;
620 private javax.swing.JLabel jLabel1;
621 private javax.swing.JLabel jLabel2;
622 private javax.swing.JLabel jLabel3;
623 private javax.swing.JLabel jLabel4;
624 private javax.swing.JLabel jLabel5;
625 private javax.swing.JLabel jLabel6;
626 private javax.swing.JLabel jLabelProgramName;
627 private javax.swing.JLabel jLabelProgramVersion;
628 private javax.swing.JLabel jLabelSfURL;
629 private javax.swing.JPanel jPanelAbout;
630 private javax.swing.JPanel jPanelLDAP;
631 private javax.swing.JPanel jPanelMail;
632 private javax.swing.JTabbedPane jTabbedPane;
633 private javax.swing.JTextField jTextFieldAttribute;
634 private javax.swing.JTextField jTextFieldBaseDn;
635 private javax.swing.JTextField jTextFieldProviderUrl;
636 private javax.swing.JTextField jTextFieldReceiverPort;
637 private javax.swing.JTextField jTextFieldServerHost;
638 private javax.swing.JTextField jTextFieldServerPort;
639 // End of variables declaration//GEN-END:variables