Takuya Ono
takuy****@users*****
2007年 8月 16日 (木) 04:17:02 JST
Index: BetaProject/src/org/jent/checksmtp/ApplicationUI.form diff -u BetaProject/src/org/jent/checksmtp/ApplicationUI.form:1.3 BetaProject/src/org/jent/checksmtp/ApplicationUI.form:1.4 --- BetaProject/src/org/jent/checksmtp/ApplicationUI.form:1.3 Mon Jul 23 07:12:53 2007 +++ BetaProject/src/org/jent/checksmtp/ApplicationUI.form Thu Aug 16 04:17:01 2007 @@ -3,7 +3,9 @@ <Form version="1.3" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="0"/> - <Property name="title" type="java.lang.String" value="Mail Destination Confirm Properties"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.title" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> @@ -14,7 +16,7 @@ </Events> <AuxValues> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> @@ -24,7 +26,7 @@ <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jTabbedPane" alignment="0" max="32767" attributes="0"/> + <Component id="jTabbedPane" alignment="0" pref="400" max="32767" attributes="0"/> <Group type="102" alignment="1" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Component id="jButtonQuit" linkSize="1" min="-2" max="-2" attributes="0"/> @@ -60,7 +62,9 @@ <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> <JTabbedPaneConstraints tabName="Mail"> - <Property name="tabTitle" type="java.lang.String" value="Mail"/> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jPanelMail.TabConstraints.tabTitle" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </JTabbedPaneConstraints> </Constraint> </Constraints> @@ -116,41 +120,69 @@ <SubComponents> <Component class="javax.swing.JLabel" name="jLabel1"> <Properties> - <Property name="text" type="java.lang.String" value="Receiver Port:"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabel1.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JLabel" name="jLabel2"> <Properties> - <Property name="text" type="java.lang.String" value="Mail Server:"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabel2.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JLabel" name="jLabel3"> <Properties> - <Property name="text" type="java.lang.String" value="Port:"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabel3.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JTextField" name="jTextFieldReceiverPort"> <Properties> - <Property name="text" type="java.lang.String" value="8725"/> - <Property name="toolTipText" type="java.lang.String" value="Mail Destination Confirmer SMTP port number."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldReceiverPort.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldReceiverPort.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new PortNumberInputVerifier()" type="code"/> + </Property> </Properties> </Component> <Component class="javax.swing.JTextField" name="jTextFieldServerHost"> <Properties> - <Property name="text" type="java.lang.String" value="mail"/> - <Property name="toolTipText" type="java.lang.String" value="Mail server host name or IP address."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldServerHost.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldServerHost.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JTextField" name="jTextFieldServerPort"> <Properties> - <Property name="text" type="java.lang.String" value="25"/> - <Property name="toolTipText" type="java.lang.String" value="Mail server port number."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldServerPort.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldServerPort.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new PortNumberInputVerifier()" type="code"/> + </Property> </Properties> </Component> <Component class="javax.swing.JCheckBox" name="jCheckBoxEnableRemoteConnect"> <Properties> - <Property name="text" type="java.lang.String" value="Enable remote connect"/> - <Property name="toolTipText" type="java.lang.String" value="Enable remote machine access this service. (Usually: disable)"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jCheckBoxEnableRemoteConnect.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jCheckBoxEnableRemoteConnect.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> <EmptyBorder bottom="0" left="0" right="0" top="0"/> @@ -167,7 +199,9 @@ <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> <JTabbedPaneConstraints tabName="LDAP"> - <Property name="tabTitle" type="java.lang.String" value="LDAP"/> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jPanelLDAP.TabConstraints.tabTitle" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </JTabbedPaneConstraints> </Constraint> </Constraints> @@ -233,8 +267,12 @@ <SubComponents> <Component class="javax.swing.JCheckBox" name="jCheckBoxLdap"> <Properties> - <Property name="text" type="java.lang.String" value="Enable LDAP search"/> - <Property name="toolTipText" type="java.lang.String" value="Enable LDAP configration."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jCheckBoxLdap.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jCheckBoxLdap.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> <EmptyBorder bottom="0" left="0" right="0" top="0"/> @@ -250,44 +288,66 @@ </Component> <Component class="javax.swing.JLabel" name="jLabel4"> <Properties> - <Property name="text" type="java.lang.String" value="URL:"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabel4.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JLabel" name="jLabel5"> <Properties> - <Property name="text" type="java.lang.String" value="Root DN:"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabel5.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JLabel" name="jLabel6"> <Properties> - <Property name="text" type="java.lang.String" value="Attribute:"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jLabel6.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> </Component> <Component class="javax.swing.JTextField" name="jTextFieldProviderUrl"> <Properties> - <Property name="text" type="java.lang.String" value="ldap://localhost:389/"/> - <Property name="toolTipText" type="java.lang.String" value="LDAP server URL."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldProviderUrl.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldProviderUrl.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> <Property name="enabled" type="boolean" value="false"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="jTextFieldBaseDn"> <Properties> - <Property name="text" type="java.lang.String" value="C=JP"/> - <Property name="toolTipText" type="java.lang.String" value="LDAP search start DN."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldBaseDn.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldBaseDn.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> <Property name="enabled" type="boolean" value="false"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="jTextFieldAttribute"> <Properties> - <Property name="text" type="java.lang.String" value="cn"/> - <Property name="toolTipText" type="java.lang.String" value="Display Attribuite. Example: cn title;lang-ja-jp"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldAttribute.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jTextFieldAttribute.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> <Property name="enabled" type="boolean" value="false"/> </Properties> </Component> <Component class="javax.swing.JCheckBox" name="jCheckBoxIsSjis"> <Properties> - <Property name="text" type="java.lang.String" value="Force SJIS"/> - <Property name="toolTipText" type="java.lang.String" value="Check this, when LDAP server use Shift JIS on network."/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jCheckBoxIsSjis.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jCheckBoxIsSjis.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> <EmptyBorder bottom="0" left="0" right="0" top="0"/> @@ -305,7 +365,12 @@ </Container> <Component class="javax.swing.JButton" name="jButtonOK"> <Properties> - <Property name="text" type="java.lang.String" value="OK"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jButtonOK.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jButtonOK.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOKActionPerformed"/> @@ -313,7 +378,12 @@ </Component> <Component class="javax.swing.JButton" name="jButtonCancel"> <Properties> - <Property name="text" type="java.lang.String" value="Cancel"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jButtonCancel.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jButtonCancel.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonCancelActionPerformed"/> @@ -321,7 +391,12 @@ </Component> <Component class="javax.swing.JButton" name="jButtonQuit"> <Properties> - <Property name="text" type="java.lang.String" value="Quit"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jButtonQuit.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ApplicationUI.jButtonQuit.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonQuitActionPerformed"/> Index: BetaProject/src/org/jent/checksmtp/SMTPclient.java diff -u BetaProject/src/org/jent/checksmtp/SMTPclient.java:1.4 BetaProject/src/org/jent/checksmtp/SMTPclient.java:1.5 --- BetaProject/src/org/jent/checksmtp/SMTPclient.java:1.4 Fri Aug 10 01:58:33 2007 +++ BetaProject/src/org/jent/checksmtp/SMTPclient.java Thu Aug 16 04:17:01 2007 @@ -12,11 +12,11 @@ private boolean isConfigChange = false; private boolean fatalError = false; private Thread serviceThread = null; - - public SMTPclient() { + + public SMTPclient() { startServiceThread(); - } - + } + private void startServiceThread() { if ( serviceThread !=null && serviceThread.isAlive() ) { //Still service thread was working. @@ -28,90 +28,92 @@ serviceThread = new Thread(this); serviceThread.start(); } - + public void configChangeNotify() { isConfigChange = true; - if ( serviceThread !=null && !serviceThread.isAlive() ) { + if ( serviceThread !=null && !serviceThread.isAlive() ) { startServiceThread(); } } + + public void run() { + while (!fatalError) { + ServerSocket server = null; - public void run() { - while (!fatalError) { - ServerSocket server = null; - - try { - // Server Port - int serverport = ApplicationProperties.getSmtpPort(); - System.err.println("Open SMTP waiting port. " + serverport); - - try { - if ( ApplicationProperties.getSmtpEnebleRemoteConnect() ) { - System.out.println("Enable remote connection."); - server = new ServerSocket(serverport, 10); //TODO: Backlog Configuable - } else { - server = new ServerSocket(serverport, 10, //TODO: Backlog Configuable - InetAddress.getByAddress( - new byte[] { 127, 0, 0, 1 })); - } - } catch (IOException e) { - fatalError = true; - System.err.println("Fatal Error Occurred. Stop service."); - //TODO: Display error dialog. - e.printStackTrace(); //Unexpected!! - break; - } catch (IllegalArgumentException iaEx) { - //Port value out of range - fatalError = true; - System.err.println("Faital Error Occurted(" + iaEx.getMessage() + "). Stop service." ); - //TODO: Display error dialog. - iaEx.printStackTrace(); - break; - } - - acceptWait: - while (true) { - // Wait connect from mail client - server.setSoTimeout(1000); //TODO: Configuable accept wait time. - Socket client; - try { - client = server.accept(); - } catch (SocketTimeoutException ex) { - //Check interupt - if ( isConfigChange ) { - System.err.println("Configuration change restart service."); - isConfigChange = false; - server.close(); - break; // renew ServerSocket - } - continue; - } - System.err.println("Accept new STMP socket."); - Processer processer = new Processer(client); - Thread clientThread = new Thread(processer); - clientThread.start(); - } - } catch (IOException e) { - e.printStackTrace(); - System.err.println("Continure waiting SMTP client."); - - try { - server.close(); - } catch (IOException ioe) { - //IGNORE close Exception - } - } catch (RuntimeException rEx) { - fatalError = true; - System.err.println("Runtime Exception was occurred."); - rEx.printStackTrace(); - //TODO: Display error dialog. - break; - } + try { + // Server Port + int serverport = ApplicationProperties.getSmtpPort(); + System.err.println("Open SMTP waiting port. " + serverport); + + try { + if ( ApplicationProperties.getSmtpEnebleRemoteConnect() ) { + System.out.println("Enable remote connection."); + server = new ServerSocket(serverport, 10); //TODO: Backlog Configuable + } else { + server = new ServerSocket(serverport, 10, //TODO: Backlog Configuable + InetAddress.getByAddress( + new byte[] { 127, 0, 0, 1 })); + } + } catch (IOException e) { + fatalError = true; + String errorMessage = "Fatal Error Occurred. Stop service."; + System.err.println(errorMessage); + new MessageDialogUI(errorMessage, e, MessageDialogUI.ERROR_MODE); + break; + } catch (IllegalArgumentException iaEx) { + //Port value out of range + fatalError = true; + String errorMessage = "Argument Error Occurted(" + iaEx.getMessage() + + "). Stop service."; + System.err.println(errorMessage); + new MessageDialogUI(errorMessage, iaEx, MessageDialogUI.ERROR_MODE); + break; } - if ( !fatalError ) { - //Servce stop by non fatal error. Unexpected. - //TODO: Display stop service dialog. - System.err.println("Stoped service."); + + acceptWait: + while (true) { + // Wait connect from mail client + server.setSoTimeout(1000); //TODO: Configuable accept wait time. + Socket client; + try { + client = server.accept(); + } catch (SocketTimeoutException ex) { + //Check interupt + if ( isConfigChange ) { + System.err.println("Configuration change restart service."); + isConfigChange = false; + server.close(); + break; // renew ServerSocket + } + continue; + } + System.err.println("Accept new STMP socket."); + Processer processer = new Processer(client); + Thread clientThread = new Thread(processer); + clientThread.start(); + } + } catch (IOException e) { + e.printStackTrace(); + System.err.println("Continure waiting SMTP client."); + + try { + server.close(); + } catch (IOException ioe) { + //IGNORE close Exception } + } catch (RuntimeException rEx) { + fatalError = true; + String errorMessage = "Runtime Exception was occurred. Stop service."; + System.err.println(errorMessage); + new MessageDialogUI(errorMessage, rEx, MessageDialogUI.ERROR_MODE); + break; + } + } + if ( !fatalError ) { + //Servce stop by non fatal error. Unexpected. + String errorMessage = "Unexpected service stoping ocurreed. Stoped service."; + System.err.println(errorMessage); + new MessageDialogUI(errorMessage, null, MessageDialogUI.ERROR_MODE); } + } } Index: BetaProject/src/org/jent/checksmtp/ToListUI.java diff -u BetaProject/src/org/jent/checksmtp/ToListUI.java:1.4 BetaProject/src/org/jent/checksmtp/ToListUI.java:1.5 --- BetaProject/src/org/jent/checksmtp/ToListUI.java:1.4 Sat Jul 28 14:09:45 2007 +++ BetaProject/src/org/jent/checksmtp/ToListUI.java Thu Aug 16 04:17:01 2007 @@ -20,12 +20,13 @@ private ResultNotify resultNotify = null; /** Creates new form ToListUI */ - public ToListUI() { - initComponents(); - } - public ToListUI(ResultNotify processer, List toList) { - this(); //TODO: test dould call... + super(); //paranoia statement. + initComponents(); + + jButtonCancel.requestFocusInWindow(); + //getRootPane().setDefaultButton(jButtonOK); + this.toList = toList; this.resultNotify = processer; @@ -85,7 +86,8 @@ jButtonCancel = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Confirm Distination Address"); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle"); // NOI18N + setTitle(bundle.getString("ToListUI.title")); // NOI18N addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); @@ -99,14 +101,14 @@ }); jScrollPane1.setViewportView(jList1); - jButtonOK.setText("OK"); + jButtonOK.setText(bundle.getString("ToListUI.jButtonOK.text")); // NOI18N jButtonOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonOKActionPerformed(evt); } }); - jButtonCancel.setText("Cancel"); + jButtonCancel.setText(bundle.getString("ToListUI.jButtonCancel.text")); // NOI18N jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonCancelActionPerformed(evt); @@ -192,7 +194,8 @@ ApplicationProperties.setConfirmDialogPosH(h); ApplicationProperties.setConfirmDialogPosW(w); if ( !ApplicationProperties.save() ) { - //TODO: save error dialog. + new MessageDialogUI("Fail the properties file of dialog potition save.", + null, MessageDialogUI.ERROR_MODE); } } return modified; Index: BetaProject/src/org/jent/checksmtp/Bundle_ja_JP.properties diff -u /dev/null BetaProject/src/org/jent/checksmtp/Bundle_ja_JP.properties:1.1 --- /dev/null Thu Aug 16 04:17:02 2007 +++ BetaProject/src/org/jent/checksmtp/Bundle_ja_JP.properties Thu Aug 16 04:17:01 2007 @@ -0,0 +1,84 @@ +# Sample ResourceBundle properties file + +ApplicationUI.jPanelMail.TabConstraints.tabTitle=\u30E1\u30FC\u30EB + +ApplicationUI.jCheckBoxLdap.toolTipText=\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u3068LDAP\u306E\u8A2D\u5B9A\u304C\u6709\u52B9\u306B\u306A\u308B\u3002 + +ApplicationUI.jCheckBoxLdap.text=LDAP\u691C\u7D22 + +ApplicationUI.jTextFieldServerHost.toolTipText=\u30E1\u30FC\u30EB\u30B5\u30FC\u30D0\u306E\u30DB\u30B9\u30C8\u540D\u304BIP\u30A2\u30C9\u30EC\u30B9 + +ApplicationUI.jTextFieldServerHost.text=mail + +ApplicationUI.jCheckBoxIsSjis.toolTipText=\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u3068\u5F37\u5236\u7684\u306BLDAP\u30B5\u30FC\u30D0\u3068\u306E\u901A\u4FE1\u3092Shift JIS\u3067\u884C\u3046\u3002 + +ApplicationUI.jCheckBoxIsSjis.text=SJIS\u3067\u901A\u4FE1 + +ApplicationUI.jLabel1.text=\u53D7\u4FE1\u30DD\u30FC\u30C8\: + +ApplicationUI.jPanelLDAP.TabConstraints.tabTitle=LDAP + +ApplicationUI.jTextFieldServerPort.toolTipText=\u30E1\u30FC\u30EB\u30B5\u30FC\u30D0\u306E\u30DD\u30FC\u30C8\u756A\u53F7 + +ApplicationUI.jTextFieldServerPort.text=25 + +ApplicationUI.jLabel6.text=LDAP\u5C5E\u6027\: + +ApplicationUI.jButtonQuit.text=\u7D42\u4E86 + +ApplicationUI.jLabel4.text=URL\: + +ApplicationUI.jTextFieldProviderUrl.toolTipText=LDAP\u30B5\u30FC\u30D0\u306EURL + +ApplicationUI.jTextFieldProviderUrl.text=ldap\://localhost\:389/ + +ApplicationUI.jLabel2.text=\u30E1\u30FC\u30EB\u30B5\u30FC\u30D0\: + +ApplicationUI.jCheckBoxEnableRemoteConnect.toolTipText=\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u3068\u30EA\u30E2\u30FC\u30C8\u304B\u3089\u306E\u63A5\u7D9A\u3092\u8A31\u53EF\u3059\u308B\u3002(\u901A\u5E38\u306F\u30C1\u30A7\u30C3\u30AF\u3057\u306A\u3044) + +ApplicationUI.jCheckBoxEnableRemoteConnect.text=\u30EA\u30E2\u30FC\u30C8\u63A5\u7D9A\u8A31\u53EF + +ApplicationUI.jButtonCancel.text=\u4E2D\u6B62 + +ApplicationUI.jLabel3.text=\u53D7\u4FE1\u30DD\u30FC\u30C8\: + +ApplicationUI.title=\u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D\u30D7\u30ED\u30B0\u30E9\u30E0\u306E\u30D7\u30ED\u30D1\u30C6\u30A3 + +ApplicationUI.jLabel5.text=Root DN\: + +ApplicationUI.jTextFieldBaseDn.toolTipText=LDAP\u3067\u691C\u7D22\u3092\u958B\u59CB\u3059\u308BDN + +ApplicationUI.jTextFieldBaseDn.text=C\=JP + +ApplicationUI.jButtonOK.text=OK + +ApplicationUI.jTextFieldAttribute.toolTipText=\u8868\u793A\u3059\u308BLDAP\u5C5E\u6027 \u4F8B\: cn title;lang-ja-jp + +ApplicationUI.jTextFieldAttribute.text=cn + +ApplicationUI.jTextFieldReceiverPort.toolTipText=\u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D\u30D7\u30ED\u30B0\u30E9\u30E0\u304C\u5F85\u3061\u3046\u3051\u3059\u308B\u30DD\u30FC\u30C8\u756A\u53F7 + +ApplicationUI.jTextFieldReceiverPort.text=8725 + +MessageDialogUI.jButtonDetail.text=\u8A73\u7D30<< + +ToListUI.title=\u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D + +ToListUI.jButtonCancel.text=\u4E2D\u6B62 + +ToListUI.jButtonOK.text=\u9001\u4FE1 + +MessageDialogUI.jButtonOK.text=\u9589\u3058\u308B + +MessageDialogUI.jButtonDetail.text.open=\u8A73\u7D30>> + +MessageDialogUI.title.Error_mdc=\u30A8\u30E9\u30FC \u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D\u30D7\u30ED\u30B0\u30E9\u30E0 + +MessageDialogUI.title.Information_mdc=\u60C5\u5831 \u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u78BA\u8A8D\u30D7\u30ED\u30B0\u30E9\u30E0 + +MessageDialogUI.title.Warning_mdc=\u8B66\u544A \u30E1\u30FC\u30EB\u9001\u4FE1\u5148\u30D7\u30ED\u30B0\u30E9\u30E0 +ApplicationUI.jButtonQuit.toolTipText=\u30D7\u30ED\u30B0\u30E9\u30E0\u3092\u7D42\u4E86\u3057\u307E\u3059\u3002 + +ApplicationUI.jButtonOK.toolTipText=\u8A2D\u5B9A\u3092\u6709\u52B9\u306B\u3057\u307E\u3059\u3002 + +ApplicationUI.jButtonCancel.toolTipText=\u4ECA\u56DE\u306E\u8A2D\u5B9A\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3059\u3002 Index: BetaProject/src/org/jent/checksmtp/ApplicationUI.java diff -u BetaProject/src/org/jent/checksmtp/ApplicationUI.java:1.4 BetaProject/src/org/jent/checksmtp/ApplicationUI.java:1.5 --- BetaProject/src/org/jent/checksmtp/ApplicationUI.java:1.4 Mon Jul 23 07:48:30 2007 +++ BetaProject/src/org/jent/checksmtp/ApplicationUI.java Thu Aug 16 04:17:01 2007 @@ -6,12 +6,16 @@ package org.jent.checksmtp; +import java.awt.Color; import java.awt.Dimension; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.InputVerifier; +import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JTextField; /** * @@ -23,6 +27,10 @@ public ApplicationUI() { initComponents(); + //set Focus + jButtonOK.requestFocusInWindow(); + //getRootPane().setDefaultButton(jButtonOK); + resetDisplay(); } @@ -40,6 +48,36 @@ } + static private MessageDialogUI portNumberOutOfRangeErrorDialog = null; + class PortNumberInputVerifier extends InputVerifier { + public boolean verify(JComponent jComponent) { + JTextField jTextField = (JTextField) jComponent; + boolean ret = true; + String input = jTextField.getText(); + + try { + int port = Integer.parseInt(input); + checkPortRange(port); + } catch (Exception e) { + ret = false; + } + + if ( !ret ) { + jTextField.setBackground(Color.PINK); + if ( portNumberOutOfRangeErrorDialog == null ) { + portNumberOutOfRangeErrorDialog = + new MessageDialogUI("Port number is integer from 1 to 65535.", + null, MessageDialogUI.WARNING_MODE); + } else { + portNumberOutOfRangeErrorDialog.setVisible(true); + } + } else { + jTextField.setBackground(Color.WHITE); + } + + return ret; + } + } /** This method is called from within the constructor to * initialize the form. @@ -71,7 +109,8 @@ jButtonQuit = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); - setTitle("Mail Destination Confirm Properties"); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle"); // NOI18N + setTitle(bundle.getString("ApplicationUI.title")); // NOI18N addWindowListener(new java.awt.event.WindowAdapter() { public void windowDeiconified(java.awt.event.WindowEvent evt) { formWindowDeiconified(evt); @@ -81,23 +120,25 @@ } }); - jLabel1.setText("Receiver Port:"); + jLabel1.setText(bundle.getString("ApplicationUI.jLabel1.text")); // NOI18N - jLabel2.setText("Mail Server:"); + jLabel2.setText(bundle.getString("ApplicationUI.jLabel2.text")); // NOI18N - jLabel3.setText("Port:"); + jLabel3.setText(bundle.getString("ApplicationUI.jLabel3.text")); // NOI18N - jTextFieldReceiverPort.setText("8725"); - jTextFieldReceiverPort.setToolTipText("Mail Destination Confirmer SMTP port number."); + jTextFieldReceiverPort.setText(bundle.getString("ApplicationUI.jTextFieldReceiverPort.text")); // NOI18N + jTextFieldReceiverPort.setToolTipText(bundle.getString("ApplicationUI.jTextFieldReceiverPort.toolTipText")); // NOI18N + jTextFieldReceiverPort.setInputVerifier(new PortNumberInputVerifier()); - jTextFieldServerHost.setText("mail"); - jTextFieldServerHost.setToolTipText("Mail server host name or IP address."); + jTextFieldServerHost.setText(bundle.getString("ApplicationUI.jTextFieldServerHost.text")); // NOI18N + jTextFieldServerHost.setToolTipText(bundle.getString("ApplicationUI.jTextFieldServerHost.toolTipText")); // NOI18N - jTextFieldServerPort.setText("25"); - jTextFieldServerPort.setToolTipText("Mail server port number."); + jTextFieldServerPort.setText(bundle.getString("ApplicationUI.jTextFieldServerPort.text")); // NOI18N + jTextFieldServerPort.setToolTipText(bundle.getString("ApplicationUI.jTextFieldServerPort.toolTipText")); // NOI18N + jTextFieldServerPort.setInputVerifier(new PortNumberInputVerifier()); - jCheckBoxEnableRemoteConnect.setText("Enable remote connect"); - jCheckBoxEnableRemoteConnect.setToolTipText("Enable remote machine access this service. (Usually: disable)"); + jCheckBoxEnableRemoteConnect.setText(bundle.getString("ApplicationUI.jCheckBoxEnableRemoteConnect.text")); // NOI18N + jCheckBoxEnableRemoteConnect.setToolTipText(bundle.getString("ApplicationUI.jCheckBoxEnableRemoteConnect.toolTipText")); // NOI18N jCheckBoxEnableRemoteConnect.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jCheckBoxEnableRemoteConnect.setMargin(new java.awt.Insets(0, 0, 0, 0)); @@ -143,10 +184,10 @@ .add(jTextFieldServerPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(74, Short.MAX_VALUE)) ); - jTabbedPane.addTab("Mail", jPanelMail); + jTabbedPane.addTab(bundle.getString("ApplicationUI.jPanelMail.TabConstraints.tabTitle"), jPanelMail); // NOI18N - jCheckBoxLdap.setText("Enable LDAP search"); - jCheckBoxLdap.setToolTipText("Enable LDAP configration."); + jCheckBoxLdap.setText(bundle.getString("ApplicationUI.jCheckBoxLdap.text")); // NOI18N + jCheckBoxLdap.setToolTipText(bundle.getString("ApplicationUI.jCheckBoxLdap.toolTipText")); // NOI18N jCheckBoxLdap.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jCheckBoxLdap.setMargin(new java.awt.Insets(0, 0, 0, 0)); jCheckBoxLdap.addChangeListener(new javax.swing.event.ChangeListener() { @@ -155,26 +196,26 @@ } }); - jLabel4.setText("URL:"); + jLabel4.setText(bundle.getString("ApplicationUI.jLabel4.text")); // NOI18N - jLabel5.setText("Root DN:"); + jLabel5.setText(bundle.getString("ApplicationUI.jLabel5.text")); // NOI18N - jLabel6.setText("Attribute:"); + jLabel6.setText(bundle.getString("ApplicationUI.jLabel6.text")); // NOI18N - jTextFieldProviderUrl.setText("ldap://localhost:389/"); - jTextFieldProviderUrl.setToolTipText("LDAP server URL."); + jTextFieldProviderUrl.setText(bundle.getString("ApplicationUI.jTextFieldProviderUrl.text")); // NOI18N + jTextFieldProviderUrl.setToolTipText(bundle.getString("ApplicationUI.jTextFieldProviderUrl.toolTipText")); // NOI18N jTextFieldProviderUrl.setEnabled(false); - jTextFieldBaseDn.setText("C=JP"); - jTextFieldBaseDn.setToolTipText("LDAP search start DN."); + jTextFieldBaseDn.setText(bundle.getString("ApplicationUI.jTextFieldBaseDn.text")); // NOI18N + jTextFieldBaseDn.setToolTipText(bundle.getString("ApplicationUI.jTextFieldBaseDn.toolTipText")); // NOI18N jTextFieldBaseDn.setEnabled(false); - jTextFieldAttribute.setText("cn"); - jTextFieldAttribute.setToolTipText("Display Attribuite. Example: cn title;lang-ja-jp"); + jTextFieldAttribute.setText(bundle.getString("ApplicationUI.jTextFieldAttribute.text")); // NOI18N + jTextFieldAttribute.setToolTipText(bundle.getString("ApplicationUI.jTextFieldAttribute.toolTipText")); // NOI18N jTextFieldAttribute.setEnabled(false); - jCheckBoxIsSjis.setText("Force SJIS"); - jCheckBoxIsSjis.setToolTipText("Check this, when LDAP server use Shift JIS on network."); + jCheckBoxIsSjis.setText(bundle.getString("ApplicationUI.jCheckBoxIsSjis.text")); // NOI18N + jCheckBoxIsSjis.setToolTipText(bundle.getString("ApplicationUI.jCheckBoxIsSjis.toolTipText")); // NOI18N jCheckBoxIsSjis.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jCheckBoxIsSjis.setEnabled(false); jCheckBoxIsSjis.setMargin(new java.awt.Insets(0, 0, 0, 0)); @@ -227,23 +268,26 @@ .add(jTextFieldAttribute, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(28, Short.MAX_VALUE)) ); - jTabbedPane.addTab("LDAP", jPanelLDAP); + jTabbedPane.addTab(bundle.getString("ApplicationUI.jPanelLDAP.TabConstraints.tabTitle"), jPanelLDAP); // NOI18N - jButtonOK.setText("OK"); + jButtonOK.setText(bundle.getString("ApplicationUI.jButtonOK.text")); // NOI18N + jButtonOK.setToolTipText(bundle.getString("ApplicationUI.jButtonOK.toolTipText")); // NOI18N jButtonOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonOKActionPerformed(evt); } }); - jButtonCancel.setText("Cancel"); + jButtonCancel.setText(bundle.getString("ApplicationUI.jButtonCancel.text")); // NOI18N + jButtonCancel.setToolTipText(bundle.getString("ApplicationUI.jButtonCancel.toolTipText")); // NOI18N jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonCancelActionPerformed(evt); } }); - jButtonQuit.setText("Quit"); + jButtonQuit.setText(bundle.getString("ApplicationUI.jButtonQuit.text")); // NOI18N + jButtonQuit.setToolTipText(bundle.getString("ApplicationUI.jButtonQuit.toolTipText")); // NOI18N jButtonQuit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonQuitActionPerformed(evt); @@ -254,7 +298,7 @@ getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jTabbedPane) + .add(jTabbedPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap() .add(jButtonQuit) @@ -280,32 +324,33 @@ ); pack(); }// </editor-fold>//GEN-END:initComponents - + private void formWindowDeiconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeiconified setTitle("Mail Destination Confirm Properties"); + jButtonOK.requestFocusInWindow(); }//GEN-LAST:event_formWindowDeiconified - + private void formWindowIconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowIconified setTitle("mdc"); }//GEN-LAST:event_formWindowIconified - + private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed int port; try { port = Integer.parseInt(jTextFieldReceiverPort.getText()); + checkPortRange(port); } catch (NumberFormatException ex) { - ex.printStackTrace(); - port = ApplicationProperties.getSmtpPort(); //last saved value. - jTextFieldReceiverPort.setText(Integer.toString(port)); + jTextFieldReceiverPort.setBackground(Color.PINK); + throw ex; } String serverHost = jTextFieldServerHost.getText(); int serverPort; try { serverPort = Integer.parseInt(jTextFieldServerPort.getText()); + checkPortRange(serverPort); } catch (NumberFormatException ex) { - ex.printStackTrace(); - serverPort = ApplicationProperties.getSmtpServerPort(); //last saved value. - jTextFieldServerPort.setText(Integer.toString(serverPort)); + jTextFieldServerPort.setBackground(Color.PINK); + throw ex; } boolean enableRemoteConnect = jCheckBoxEnableRemoteConnect.isSelected(); @@ -341,19 +386,31 @@ smtpClient.configChangeNotify(); if ( !ApplicationProperties.save() ) { - //TODO: Display Save error Dialog. + new MessageDialogUI("Fail the properties file save.", null, + MessageDialogUI.ERROR_MODE); + } else { + iconified(); } + } else { + iconified(); } - iconified(); - }//GEN-LAST:event_jButtonOKActionPerformed + + /** + * Check port number range. It is unsigned short number. + * Argument is port number. + **/ + private void checkPortRange(final int port) { + if ( port <= 0 || port > 65535 ) { + throw new NumberFormatException("Out of range."); + } + } private void jButtonQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQuitActionPerformed System.exit(0); }//GEN-LAST:event_jButtonQuitActionPerformed private void jCheckBoxLdapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBoxLdapStateChanged -// TODO add your handling code here: boolean check = jCheckBoxLdap.isSelected(); jTextFieldProviderUrl.setEnabled(check); jTextFieldBaseDn.setEnabled(check); @@ -362,9 +419,11 @@ }//GEN-LAST:event_jCheckBoxLdapStateChanged private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed -// TODO add your handling code here: //this.setVisible(false); resetDisplay(); + if ( portNumberOutOfRangeErrorDialog != null && portNumberOutOfRangeErrorDialog.isVisible() ) { + portNumberOutOfRangeErrorDialog.dispose(); + } iconified(); }//GEN-LAST:event_jButtonCancelActionPerformed @@ -379,7 +438,7 @@ //Unexpect logic. Because this method call from pushed "OK" button. x = getX(); y = getY(); - } + } int h = this.getHeight(); int w = this.getWidth(); boolean modified = false; @@ -433,25 +492,25 @@ tray.add(trayIcon); useSystemTray = true; } - */ - } catch (ClassNotFoundException ex) { - // Do not support SystemTray on this VM. + */ + } catch (ClassNotFoundException ex) { + // Do not support SystemTray on this VM. + } + return useSystemTray; } - return useSystemTray; -} - -private void iconified() { - if ( useSystemTray ) { - this.setVisible(false); - } else { - this.setExtendedState(ICONIFIED); + + private void iconified() { + if ( useSystemTray ) { + this.setVisible(false); + } else { + this.setExtendedState(ICONIFIED); + } } -} - -/** - * @param args the command line arguments - */ -public static void main(String args[]) { + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { /* TKYN OLD try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -459,56 +518,56 @@ e.printStackTrace(); } */ - - //TKYN ORIGNAL BLOCK - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - ApplicationUI applicationUI = new ApplicationUI(); - applicationUI.setVisible(true); - - applicationUI.useSystemTray = applicationUI.initSystemTray(); - - //If exsist configuration file, iconise at start up. - if ( ApplicationProperties.isFileLoaded() ) { - int x = ApplicationProperties.getConfigDialogPosX(); - int y = ApplicationProperties.getConfigDialogPosY(); - int w = ApplicationProperties.getConfigDialogPosW(); - int h = ApplicationProperties.getConfigDialogPosH(); + + //TKYN ORIGNAL BLOCK + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + ApplicationUI applicationUI = new ApplicationUI(); + applicationUI.setVisible(true); - if ( x > screenSize.width ) { - x = screenSize.width - w; - if ( x < 0 ) { x = 0; }; - } - if ( y > screenSize.height ) { - y = screenSize.height - h; - if ( y < 0 ) { y = 0; }; - } - applicationUI.setBounds(x, y, w, h); - applicationUI.iconified(); - } else { - //No Configuration file. - Dimension frameSize = ApplicationProperties.getConfigurationDialogSize(); - if (frameSize.height > screenSize.height) { - frameSize.height = screenSize.height; - } - if (frameSize.width > screenSize.width) { - frameSize.width = screenSize.width; - } + applicationUI.useSystemTray = applicationUI.initSystemTray(); - applicationUI.setBounds( - (screenSize.width - frameSize.width) / 2, - (screenSize.height - frameSize.height) / 2, - frameSize.width, frameSize.height ); + //If exsist configuration file, iconise at start up. + if ( ApplicationProperties.isFileLoaded() ) { + int x = ApplicationProperties.getConfigDialogPosX(); + int y = ApplicationProperties.getConfigDialogPosY(); + int w = ApplicationProperties.getConfigDialogPosW(); + int h = ApplicationProperties.getConfigDialogPosH(); + + if ( x > screenSize.width ) { + x = screenSize.width - w; + if ( x < 0 ) { x = 0; }; + } + if ( y > screenSize.height ) { + y = screenSize.height - h; + if ( y < 0 ) { y = 0; }; + } + applicationUI.setBounds(x, y, w, h); + applicationUI.iconified(); + } else { + //No Configuration file. + Dimension frameSize = ApplicationProperties.getConfigurationDialogSize(); + if (frameSize.height > screenSize.height) { + frameSize.height = screenSize.height; + } + if (frameSize.width > screenSize.width) { + frameSize.width = screenSize.width; + } + + applicationUI.setBounds( + (screenSize.width - frameSize.width) / 2, + (screenSize.height - frameSize.height) / 2, + frameSize.width, frameSize.height ); + } } - } - }); + }); + + smtpClient = new SMTPclient(); + } + private static SMTPclient smtpClient = null; + private boolean useSystemTray = false; - smtpClient = new SMTPclient(); -} -private static SMTPclient smtpClient = null; -private boolean useSystemTray = false; - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButtonCancel; private javax.swing.JButton jButtonOK; Index: BetaProject/src/org/jent/checksmtp/ToListUI.form diff -u BetaProject/src/org/jent/checksmtp/ToListUI.form:1.2 BetaProject/src/org/jent/checksmtp/ToListUI.form:1.3 --- BetaProject/src/org/jent/checksmtp/ToListUI.form:1.2 Mon Jul 23 07:12:53 2007 +++ BetaProject/src/org/jent/checksmtp/ToListUI.form Thu Aug 16 04:17:01 2007 @@ -3,7 +3,9 @@ <Form version="1.3" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="2"/> - <Property name="title" type="java.lang.String" value="Confirm Distination Address"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ToListUI.title" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> @@ -13,7 +15,7 @@ </Events> <AuxValues> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> @@ -94,7 +96,9 @@ </Container> <Component class="javax.swing.JButton" name="jButtonOK"> <Properties> - <Property name="text" type="java.lang.String" value="OK"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ToListUI.jButtonOK.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOKActionPerformed"/> @@ -102,7 +106,9 @@ </Component> <Component class="javax.swing.JButton" name="jButtonCancel"> <Properties> - <Property name="text" type="java.lang.String" value="Cancel"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="ToListUI.jButtonCancel.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonCancelActionPerformed"/> Index: BetaProject/src/org/jent/checksmtp/MessageDialogUI.java diff -u /dev/null BetaProject/src/org/jent/checksmtp/MessageDialogUI.java:1.1 --- /dev/null Thu Aug 16 04:17:02 2007 +++ BetaProject/src/org/jent/checksmtp/MessageDialogUI.java Thu Aug 16 04:17:01 2007 @@ -0,0 +1,235 @@ +/* + * MessageDialogUI.java + * + * Created on 2007/08/14, 14:31 + */ + +package org.jent.checksmtp; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.swing.JFrame; + +/** + * + * @author tkyn + */ +public class MessageDialogUI extends javax.swing.JFrame { + static final int ERROR_MODE = 0; + static final int WARNING_MODE = 1; + static final int INFORMATION_MODE = 2; + + static final String MSG_DETAIL_OPEN = java.util.ResourceBundle + .getBundle("org/jent/checksmtp/Bundle") + .getString("MessageDialogUI.jButtonDetail.text.open"); + static final String MSG_DETAIL_CLOSE = java.util.ResourceBundle + .getBundle("org/jent/checksmtp/Bundle") + .getString("MessageDialogUI.jButtonDetail.text"); + + static private boolean detailOpen = true; + + public boolean setDetailOpen(boolean flg) { + boolean old = detailOpen; + detailOpen = flg; + return old; + } + + /* Not use yet. + public String setMessage(String newMessage) { + String oldMessage = jTextAreaMessage.getText(); + jTextAreaMessage.setText(newMessage); + return oldMessage; + } + */ + + /** Creates new form MessageDialogUI */ + public MessageDialogUI(String message, Throwable ex, int mode) { + super(); //paranoia statement. + + initComponents(); + + //move to Forcus + jButtonOK.requestFocusInWindow(); + //getRootPane().setDefaultButton(jButtonOK); + + jTextAreaMessage.setText(message); //NEEDCARE null string. + if ( ex == null ) { + jButtonDetail.setEnabled(false); + jButtonDetail.setText(MSG_DETAIL_OPEN); + jScrollPaneStack.setVisible(false); + pack(); + } else { + StringWriter stackTraceMessageWriter = new StringWriter(); + ex.printStackTrace(new PrintWriter(stackTraceMessageWriter)); + stackTraceMessageWriter.flush(); + jTextAreaStack.setText(stackTraceMessageWriter.toString()); + + if (!detailOpen) { + jButtonDetail.setText(MSG_DETAIL_OPEN); + jScrollPaneStack.setVisible(false); + pack(); + } + } + switch (mode) { + case ERROR_MODE: + setTitle(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle") + .getString("MessageDialogUI.title.Error_mdc")); + break; + case WARNING_MODE: + setTitle(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle") + .getString("MessageDialogUI.title.Warning_mdc")); + break; + case INFORMATION_MODE: + setTitle(java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle") + .getString("MessageDialogUI.title.Information_mdc")); + break; + //Default is "Message - mdc" + } + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension frameSize = getSize(); + if (frameSize.height > screenSize.height) { + frameSize.height = screenSize.height; + } + if (frameSize.width > screenSize.width) { + frameSize.width = screenSize.width; + } + this.setBounds( + (screenSize.width - frameSize.width) / 2, + (screenSize.height - frameSize.height) / 2, + frameSize.width, frameSize.height ); + + setVisible(true); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextAreaMessage = new javax.swing.JTextArea(); + jButtonOK = new javax.swing.JButton(); + jButtonDetail = new javax.swing.JButton(); + jScrollPaneStack = new javax.swing.JScrollPane(); + jTextAreaStack = new javax.swing.JTextArea(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jent/checksmtp/Bundle"); // NOI18N + setTitle(bundle.getString("MessageDialogUI.title")); // NOI18N + jTextAreaMessage.setColumns(20); + jTextAreaMessage.setEditable(false); + jTextAreaMessage.setLineWrap(true); + jTextAreaMessage.setRows(3); + jTextAreaMessage.setText(bundle.getString("MessageDialogUI.jTextAreaMessage.text")); // NOI18N + jTextAreaMessage.setFocusable(false); + jTextAreaMessage.setRequestFocusEnabled(false); + jScrollPane1.setViewportView(jTextAreaMessage); + + jButtonOK.setText(bundle.getString("MessageDialogUI.jButtonOK.text")); // NOI18N + jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonOKActionPerformed(evt); + } + }); + + jButtonDetail.setText(bundle.getString("MessageDialogUI.jButtonDetail.text")); // NOI18N + jButtonDetail.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonDetailActionPerformed(evt); + } + }); + + jTextAreaStack.setColumns(20); + jTextAreaStack.setEditable(false); + jTextAreaStack.setRows(5); + jTextAreaStack.setText(bundle.getString("MessageDialogUI.jTextAreaStack.text")); // NOI18N + jScrollPaneStack.setViewportView(jTextAreaStack); + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPaneStack, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE) + .add(jPanel1Layout.createSequentialGroup() + .add(jButtonDetail) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 238, Short.MAX_VALUE) + .add(jButtonOK)) + .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jButtonOK) + .add(jButtonDetail)) + .add(18, 18, 18) + .add(jScrollPaneStack, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE) + .addContainerGap()) + ); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void jButtonDetailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDetailActionPerformed + if( detailOpen ) { + jScrollPaneStack.setVisible(false); + jButtonDetail.setText(MSG_DETAIL_OPEN); + detailOpen = false; + } else { + jScrollPaneStack.setVisible(true); + jButtonDetail.setText(MSG_DETAIL_CLOSE); + detailOpen = true; + } + pack(); + }//GEN-LAST:event_jButtonDetailActionPerformed + + private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed + dispose(); + }//GEN-LAST:event_jButtonOKActionPerformed + + /** + * @param args the command line arguments + * + * public static void main(String args[]) { + * java.awt.EventQueue.invokeLater(new Runnable() { + * public void run() { + * new MessageDialogUI().setVisible(true); + * } + * }); + * } + */ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButtonDetail; + private javax.swing.JButton jButtonOK; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPaneStack; + private javax.swing.JTextArea jTextAreaMessage; + private javax.swing.JTextArea jTextAreaStack; + // End of variables declaration//GEN-END:variables + +} Index: BetaProject/src/org/jent/checksmtp/MessageDialogUI.form diff -u /dev/null BetaProject/src/org/jent/checksmtp/MessageDialogUI.form:1.1 --- /dev/null Thu Aug 16 04:17:02 2007 +++ BetaProject/src/org/jent/checksmtp/MessageDialogUI.form Thu Aug 16 04:17:01 2007 @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="MessageDialogUI.title" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel1" alignment="0" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel1" alignment="0" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jScrollPaneStack" alignment="0" pref="398" max="32767" attributes="0"/> + <Group type="102" alignment="1" attributes="0"> + <Component id="jButtonDetail" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="238" max="32767" attributes="0"/> + <Component id="jButtonOK" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jScrollPane1" alignment="0" pref="398" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jButtonOK" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jButtonDetail" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="18" max="-2" attributes="0"/> + <Component id="jScrollPaneStack" pref="176" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="jTextAreaMessage"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="editable" type="boolean" value="false"/> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="3"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="MessageDialogUI.jTextAreaMessage.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jButtonOK"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="MessageDialogUI.jButtonOK.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOKActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButtonDetail"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="MessageDialogUI.jButtonDetail.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonDetailActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPaneStack"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="jTextAreaStack"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="editable" type="boolean" value="false"/> + <Property name="rows" type="int" value="5"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/jent/checksmtp/Bundle.properties" key="MessageDialogUI.jTextAreaStack.text" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> Index: BetaProject/src/org/jent/checksmtp/Bundle.properties diff -u /dev/null BetaProject/src/org/jent/checksmtp/Bundle.properties:1.1 --- /dev/null Thu Aug 16 04:17:02 2007 +++ BetaProject/src/org/jent/checksmtp/Bundle.properties Thu Aug 16 04:17:01 2007 @@ -0,0 +1,90 @@ +# Sample ResourceBundle properties file + +ApplicationUI.jPanelMail.TabConstraints.tabTitle=Mail + +ApplicationUI.jCheckBoxLdap.toolTipText=Enable LDAP configration. + +ApplicationUI.jCheckBoxLdap.text=Enable LDAP search + +ApplicationUI.jTextFieldServerHost.toolTipText=Mail server host name or IP address. + +ApplicationUI.jTextFieldServerHost.text=mail + +ApplicationUI.jCheckBoxIsSjis.toolTipText=Check this, when LDAP server use Shift JIS on network. + +ApplicationUI.jCheckBoxIsSjis.text=Force SJIS + +ApplicationUI.jLabel1.text=Receiver Port\: + +ApplicationUI.jPanelLDAP.TabConstraints.tabTitle=LDAP + +ApplicationUI.jTextFieldServerPort.toolTipText=Mail server port number. + +ApplicationUI.jTextFieldServerPort.text=25 + +ApplicationUI.jLabel6.text=Attribute\: + +ApplicationUI.jButtonQuit.text=Quit + +ApplicationUI.jLabel4.text=URL\: + +ApplicationUI.jTextFieldProviderUrl.toolTipText=LDAP server URL. + +ApplicationUI.jTextFieldProviderUrl.text=ldap\://localhost\:389/ + +ApplicationUI.jLabel2.text=Mail Server\: + +ApplicationUI.jCheckBoxEnableRemoteConnect.toolTipText=Enable remote machine access this service. (Usually\: disable) + +ApplicationUI.jCheckBoxEnableRemoteConnect.text=Enable remote connect + +ApplicationUI.jButtonCancel.text=Cancel + +ApplicationUI.jLabel3.text=Port\: + +ApplicationUI.title=Mail Destination Confirm Properties + +ApplicationUI.jLabel5.text=Root DN\: + +ApplicationUI.jTextFieldBaseDn.toolTipText=LDAP search start DN. + +ApplicationUI.jTextFieldBaseDn.text=C\=JP + +ApplicationUI.jButtonOK.text=OK + +ApplicationUI.jTextFieldAttribute.toolTipText=Display Attribuite. Example\: cn title;lang-ja-jp + +ApplicationUI.jTextFieldAttribute.text=cn + +ApplicationUI.jTextFieldReceiverPort.toolTipText=Mail Destination Confirmer SMTP port number. + +ApplicationUI.jTextFieldReceiverPort.text=8725 + +MessageDialogUI.jButtonDetail.text=Detail<< +MessageDialogUI.jButtonOK.text=Close + +MessageDialogUI.title=Message - mdc + +MessageDialogUI.jTextAreaStack.text=This is Stack Trace aria. + +MessageDialogUI.jTextAreaMessage.text=System Fatal Error was ocurred. + +ToListUI.title=Confirm Distination Address + +ToListUI.jButtonCancel.text=Cancel + +ToListUI.jButtonOK.text=OK + +MessageDialogUI.jButtonDetail.text.open=Detail>> + +MessageDialogUI.title.Error_mdc=Error - mdc + +MessageDialogUI.title.Warning_mdc=Warning - mdc + +MessageDialogUI.title.Information_mdc=Information - mdc + +ApplicationUI.jButtonQuit.toolTipText=Stop mdc program. + +ApplicationUI.jButtonOK.toolTipText= + +ApplicationUI.jButtonCancel.toolTipText= Index: BetaProject/src/org/jent/checksmtp/LDAPSearch.java diff -u BetaProject/src/org/jent/checksmtp/LDAPSearch.java:1.4 BetaProject/src/org/jent/checksmtp/LDAPSearch.java:1.5 --- BetaProject/src/org/jent/checksmtp/LDAPSearch.java:1.4 Sat Oct 29 06:25:25 2005 +++ BetaProject/src/org/jent/checksmtp/LDAPSearch.java Thu Aug 16 04:17:01 2007 @@ -19,7 +19,8 @@ public class LDAPSearch { static private InitialDirContext ctx = null; static private String lastProviderUrl = null; - + static private MessageDialogUI initErrorDialog = null; + private LDAPSearch() { } @@ -40,13 +41,26 @@ ctx = new InitialDirContext(env); } catch (NamingException e) { - System.err.println("LDAPSearch init error."); + String errorMessage = "LDAPSearch init error."; + System.err.println(errorMessage); lastProviderUrl = null; e.printStackTrace(); + displayErrorDialog(errorMessage, e); } } } } + + /** + * Display error dialog and devide too many LDAP error dialogs. + */ + private static void displayErrorDialog(final String errorMessage, final Exception e) { + if ( initErrorDialog == null || !initErrorDialog.isVisible() ) { + //Not displaying on screen. + initErrorDialog = new MessageDialogUI(errorMessage, e, + MessageDialogUI.ERROR_MODE); + } + } /** * LDAP connection close. @@ -66,8 +80,8 @@ } catch (NamingException e) { - System.err.println("LDAPSearch init error."); - e.printStackTrace(); + System.err.println("Ignore LDAPSearch close error."); + //e.printStackTrace(); } } @@ -131,18 +145,22 @@ System.out.println("LDAP Search Name Not Found."); //IGNORE Exception } catch (NamingException e) { - System.err.println("LDAP Search Error."); + String errorMessage = "LDAP Search Error."; + System.err.println(errorMessage); e.printStackTrace(); //ctx reflesh close(); - } catch (UnsupportedEncodingException ueEx) { + displayErrorDialog(errorMessage, e); + } catch (UnsupportedEncodingException ueEx) { //Unexpected. UnsupportedEncodingException e = ueEx; System.err.println("LDAP SJIS Error."); e.printStackTrace(); } catch (NullPointerException npEx) { //for failsafe. + String errorMessage = "LDAP Unexpected Error."; NullPointerException e = npEx; - System.err.println("LDAP Unexpected Error."); + System.err.println(errorMessage); e.printStackTrace(); + displayErrorDialog(errorMessage, e); } return ans; Index: BetaProject/src/org/jent/checksmtp/Processer.java diff -u BetaProject/src/org/jent/checksmtp/Processer.java:1.6 BetaProject/src/org/jent/checksmtp/Processer.java:1.7 --- BetaProject/src/org/jent/checksmtp/Processer.java:1.6 Sun Jul 22 16:56:15 2007 +++ BetaProject/src/org/jent/checksmtp/Processer.java Thu Aug 16 04:17:01 2007 @@ -98,9 +98,12 @@ client.close(); client = null; } catch (IOException e) { - System.err.println("Execption occurred in Processer."); - //TODO: Display error Dialog. - e.printStackTrace(); + String errorMessage = "Execption occurred at starting SMTP thread."; + System.err.println(errorMessage); + new MessageDialogUI(errorMessage, e, MessageDialogUI.ERROR_MODE); + } catch (RuntimeException runEx) { + new MessageDialogUI("Runtime Exception occurred in SMTP parse", + runEx, MessageDialogUI.ERROR_MODE); } finally { //for failsafe Socket close. if (server != null) { @@ -266,7 +269,12 @@ } } } catch (IOException e) { - e.printStackTrace(); + String errorMessage = "Error occurred in SMTP parse."; + System.err.println(errorMessage); + new MessageDialogUI(errorMessage, e, MessageDialogUI.ERROR_MODE); + } catch (RuntimeException runEx) { + new MessageDialogUI("Runtime Exception occurred in SMTP parse", + runEx, MessageDialogUI.ERROR_MODE); } System.out.println("End of Session.");