directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r605161 - in /directory/studio/trunk: studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/
Date Tue, 18 Dec 2007 09:55:57 GMT
Author: pamarcelot
Date: Tue Dec 18 01:55:57 2007
New Revision: 605161

URL: http://svn.apache.org/viewvc?rev=605161&view=rev
Log:
Fix for DIRSTUDIO-204 (Warning displayed when showing the properties of a connection). I have
delayed the creation of the listeners in a dedicated method after the inputs are filled with
values.

Modified:
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
    directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java?rev=605161&r1=605160&r2=605161&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
Tue Dec 18 01:55:57 2007
@@ -60,7 +60,7 @@
 
     /** The text widget to input bind password */
     private Text bindPasswordText;
-    
+
     /** The text widget to input saslRealm */
     private Combo saslRealmText;
 
@@ -122,7 +122,8 @@
     {
         return isSaveBindPassword() ? bindPasswordText.getText() : null;
     }
-    
+
+
     private String getSaslRealm()
     {
         return saslRealmText.getText();
@@ -167,13 +168,6 @@
         String[] authMethods = new String[]
             { "Anonymous Authentication", "Simple Authentication", "DIGEST-MD5 (SASL)", "CRAM-MD5
(SASL)" };
         authenticationMethodCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite,
authMethods, 1, 2 );
-        authenticationMethodCombo.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         Composite composite2 = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
 
@@ -183,45 +177,17 @@
         BaseWidgetUtils.createLabel( composite, "Bind DN or user:", 1 );
         String[] dnHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_PRINCIPAL_HISTORY
);
         bindPrincipalCombo = BaseWidgetUtils.createCombo( composite, dnHistory, -1, 2 );
-        bindPrincipalCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createLabel( composite, "Bind password:", 1 );
         bindPasswordText = BaseWidgetUtils.createPasswordText( composite, "", 2 );
-        bindPasswordText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createLabel( composite, "SASL Realm:", 1 );
         String[] saslHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_REALM_HISTORY
);
         saslRealmText = BaseWidgetUtils.createCombo( composite, saslHistory, -1, 2 );
-        saslRealmText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent even )
-            {
-                connectionPageModified();
-            }
-        } );
-        
+
         BaseWidgetUtils.createSpacer( composite, 1 );
         saveBindPasswordButton = BaseWidgetUtils.createCheckbox( composite, "Save password",
1 );
         saveBindPasswordButton.setSelection( true );
-        saveBindPasswordButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         checkPrincipalPasswordAuthButton = new Button( composite, SWT.PUSH );
         GridData gd = new GridData( GridData.FILL_HORIZONTAL );
@@ -229,22 +195,6 @@
         checkPrincipalPasswordAuthButton.setLayoutData( gd );
         checkPrincipalPasswordAuthButton.setText( "Check Authentication" );
         checkPrincipalPasswordAuthButton.setEnabled( false );
-        checkPrincipalPasswordAuthButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                Connection connection = getTestConnection();
-                CheckBindJob job = new CheckBindJob( connection );
-                RunnableContextJobAdapter.execute( job, runnableContext );
-                if ( job.getExternalResult().isOK() )
-                {
-                    MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Check Authentication",
-                        "The authentication was successful." );
-                }
-            }
-        } );
-        
-        validate();
     }
 
 
@@ -253,7 +203,6 @@
      */
     private void connectionPageModified()
     {
-    	
         validate();
         fireConnectionPageModified();
     }
@@ -286,7 +235,7 @@
                 message = "Please enter a bind DN or user.";
             }
         }
-        
+
         if ( isSaslRealmTextEnabled() )
         {
             if ( "".equals( saslRealmText.getText() ) )
@@ -309,15 +258,17 @@
             || ( getAuthenticationMethod() == AuthenticationMethod.SASL_DIGEST_MD5 )
             || ( getAuthenticationMethod() == AuthenticationMethod.SASL_CRAM_MD5 );
     }
-    
-    
-    private boolean isSaslRealmTextEnabled(){
-    	return getAuthenticationMethod() == AuthenticationMethod.SASL_DIGEST_MD5;
-    }
-    
-    
-    private boolean isGssapiEnabled(){
-    	return getAuthenticationMethod() == AuthenticationMethod.SASL_GSSAPI;
+
+
+    private boolean isSaslRealmTextEnabled()
+    {
+        return getAuthenticationMethod() == AuthenticationMethod.SASL_DIGEST_MD5;
+    }
+
+
+    private boolean isGssapiEnabled()
+    {
+        return getAuthenticationMethod() == AuthenticationMethod.SASL_GSSAPI;
     }
 
 
@@ -338,11 +289,75 @@
         saveBindPasswordButton.setSelection( parameter.getBindPassword() != null );
         saslRealmText.setText( parameter.getSaslRealm() != null ? parameter.getSaslRealm()
: "" );
 
+        initListeners();
+
         connectionPageModified();
     }
 
 
     /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        authenticationMethodCombo.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        bindPrincipalCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        bindPasswordText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        saslRealmText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent even )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        saveBindPasswordButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        checkPrincipalPasswordAuthButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                Connection connection = getTestConnection();
+                CheckBindJob job = new CheckBindJob( connection );
+                RunnableContextJobAdapter.execute( job, runnableContext );
+                if ( job.getExternalResult().isOK() )
+                {
+                    MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Check Authentication",
+                        "The authentication was successful." );
+                }
+            }
+        } );
+    }
+
+
+    /**
      * @see org.apache.directory.studio.connection.ui.ConnectionParameterPage#saveParameters(org.apache.directory.studio.connection.core.ConnectionParameter)
      */
     public void saveParameters( ConnectionParameter parameter )
@@ -350,7 +365,7 @@
         parameter.setAuthMethod( getAuthenticationMethod() );
         parameter.setBindPrincipal( getBindPrincipal() );
         parameter.setBindPassword( getBindPassword() );
-        parameter.setSaslRealm(getSaslRealm());
+        parameter.setSaslRealm( getSaslRealm() );
     }
 
 

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=605161&r1=605160&r2=605161&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Tue Dec 18 01:55:57 2007
@@ -151,19 +151,11 @@
      */
     public void createComposite( Composite parent )
     {
-
         Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 );
 
         Composite nameComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1
);
         BaseWidgetUtils.createLabel( nameComposite, "Connection name:", 1 );
         nameText = BaseWidgetUtils.createText( nameComposite, "", 1 );
-        nameText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createSpacer( composite, 1 );
 
@@ -173,51 +165,16 @@
         BaseWidgetUtils.createLabel( groupComposite, "Hostname:", 1 );
         String[] hostHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_HOST_HISTORY
);
         hostCombo = BaseWidgetUtils.createCombo( groupComposite, hostHistory, -1, 2 );
-        hostCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         BaseWidgetUtils.createLabel( groupComposite, "Port:", 1 );
         String[] portHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_PORT_HISTORY
);
         portCombo = BaseWidgetUtils.createCombo( groupComposite, portHistory, -1, 2 );
-        portCombo.addVerifyListener( new VerifyListener()
-        {
-            public void verifyText( VerifyEvent event )
-            {
-                if ( !event.text.matches( "[0-9]*" ) )
-                {
-                    event.doit = false;
-                }
-                if ( portCombo.getText().length() > 4 && event.text.length() >
0 )
-                {
-                    event.doit = false;
-                }
-            }
-        } );
-        portCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
 
         String[] encMethods = new String[]
             { "No encryption", "Use SSL encryption (ldaps://)", "Use StartTLS extension"
};
         int index = 0;
         BaseWidgetUtils.createLabel( groupComposite, "Encryption method:", 1 );
         encryptionMethodCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite, encMethods,
index, 2 );
-        encryptionMethodCombo.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
         BaseWidgetUtils.createSpacer( groupComposite, 1 );
         BaseWidgetUtils
             .createLabel(
@@ -232,22 +189,7 @@
         gd.verticalAlignment = SWT.BOTTOM;
         checkConnectionButton.setLayoutData( gd );
         checkConnectionButton.setText( "Check Network Parameter" );
-        checkConnectionButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent event )
-            {
-                Connection connection = getTestConnection();
-                CheckNetworkParameterJob job = new CheckNetworkParameterJob( connection );
-                RunnableContextJobAdapter.execute( job, runnableContext );
-                if ( job.getExternalResult().isOK() )
-                {
-                    MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Check Network Parameter",
-                        "The connection was established successfully." );
-                }
-            }
-        } );
 
-        validate();
         nameText.setFocus();
     }
 
@@ -257,10 +199,7 @@
      */
     private void connectionPageModified()
     {
-        // validate()
         validate();
-
-        // fire
         fireConnectionPageModified();
     }
 
@@ -310,7 +249,77 @@
             : parameter.getEncryptionMethod() == EncryptionMethod.START_TLS ? 2 : 0;
         encryptionMethodCombo.select( index );
 
+        initListeners();
+
         connectionPageModified();
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        nameText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        hostCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        portCombo.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent event )
+            {
+                if ( !event.text.matches( "[0-9]*" ) )
+                {
+                    event.doit = false;
+                }
+                if ( portCombo.getText().length() > 4 && event.text.length() >
0 )
+                {
+                    event.doit = false;
+                }
+            }
+        } );
+        portCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        encryptionMethodCombo.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        checkConnectionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                Connection connection = getTestConnection();
+                CheckNetworkParameterJob job = new CheckNetworkParameterJob( connection );
+                RunnableContextJobAdapter.execute( job, runnableContext );
+                if ( job.getExternalResult().isOK() )
+                {
+                    MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Check Network Parameter",
+                        "The connection was established successfully." );
+                }
+            }
+        } );
     }
 
 

Modified: directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java?rev=605161&r1=605160&r2=605161&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/connection/BrowserParameterPage.java
Tue Dec 18 01:55:57 2007
@@ -174,7 +174,6 @@
     {
         addBaseDNInput( parent );
         addLimitInput( parent );
-        validate();
     }
 
 
@@ -193,13 +192,6 @@
 
         autoFetchBaseDnsButton = BaseWidgetUtils.createCheckbox( groupComposite, "Get base
DNs from Root DSE", 2 );
         autoFetchBaseDnsButton.setSelection( true );
-        autoFetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent arg0 )
-            {
-                connectionPageModified();
-            }
-        } );
 
         fetchBaseDnsButton = new Button( groupComposite, SWT.PUSH );
         fetchBaseDnsButton.setText( "Fetch Base DNs" );
@@ -207,49 +199,9 @@
         gd = new GridData();
         gd.horizontalAlignment = SWT.RIGHT;
         fetchBaseDnsButton.setLayoutData( gd );
-        fetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
-        {
-            public void widgetSelected( SelectionEvent e )
-            {
-                Connection connection = getTestConnection();
-                IBrowserConnection browserConnection = new BrowserConnection( connection
);
-
-                FetchBaseDNsJob job = new FetchBaseDNsJob( browserConnection );
-                RunnableContextJobAdapter.execute( job, runnableContext );
-                if ( job.getExternalResult().isOK() )
-                {
-                    if ( job.getBaseDNs().length > 0 )
-                    {
-                        String[] baseDNs = job.getBaseDNs();
-                        baseDNCombo.setItems( baseDNs );
-                        baseDNCombo.select( 0 );
-
-                        String msg = "The server returned the following base DNs:";
-                        for ( int i = 0; i < baseDNs.length; i++ )
-                        {
-                            msg += "\n  - " + baseDNs[i];
-                        }
-                        MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Fetch Base DNs", msg );
-                    }
-                    else
-                    {
-                        MessageDialog.openWarning( Display.getDefault().getActiveShell(),
"Fetch Base DNs",
-                            "No base DN returned from server. Please enter the base DN manually."
);
-                        autoFetchBaseDnsButton.setSelection( false );
-                    }
-                }
-            }
-        } );
 
         BaseWidgetUtils.createLabel( groupComposite, "Base DN:", 1 );
         baseDNCombo = BaseWidgetUtils.createCombo( groupComposite, new String[0], 0, 2 );
-        baseDNCombo.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent event )
-            {
-                connectionPageModified();
-            }
-        } );
     }
 
 
@@ -296,7 +248,7 @@
         errorMessage = null;
         if ( !isAutoFetchBaseDns() )
         {
-            if( !LdapDN.isValid( getBaseDN() ) )
+            if ( !LdapDN.isValid( getBaseDN() ) )
             {
                 message = "Please enter a valid base DN.";
             }
@@ -334,7 +286,66 @@
             .getByOrdinal( aliasesDereferencingMethodOrdinal );
         aliasesDereferencingWidget.setAliasesDereferencingMethod( aliasesDereferencingMethod
);
 
+        initListeners();
+
         connectionPageModified();
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        autoFetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                connectionPageModified();
+            }
+        } );
+
+        fetchBaseDnsButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                Connection connection = getTestConnection();
+                IBrowserConnection browserConnection = new BrowserConnection( connection
);
+
+                FetchBaseDNsJob job = new FetchBaseDNsJob( browserConnection );
+                RunnableContextJobAdapter.execute( job, runnableContext );
+                if ( job.getExternalResult().isOK() )
+                {
+                    if ( job.getBaseDNs().length > 0 )
+                    {
+                        String[] baseDNs = job.getBaseDNs();
+                        baseDNCombo.setItems( baseDNs );
+                        baseDNCombo.select( 0 );
+
+                        String msg = "The server returned the following base DNs:";
+                        for ( int i = 0; i < baseDNs.length; i++ )
+                        {
+                            msg += "\n  - " + baseDNs[i];
+                        }
+                        MessageDialog.openInformation( Display.getDefault().getActiveShell(),
"Fetch Base DNs", msg );
+                    }
+                    else
+                    {
+                        MessageDialog.openWarning( Display.getDefault().getActiveShell(),
"Fetch Base DNs",
+                            "No base DN returned from server. Please enter the base DN manually."
);
+                        autoFetchBaseDnsButton.setSelection( false );
+                    }
+                }
+            }
+        } );
+
+        baseDNCombo.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent event )
+            {
+                connectionPageModified();
+            }
+        } );
     }
 
 



Mime
View raw message