directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1694439 [4/4] - in /directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui: ./ actions/ dialogs/ dnd/ preferences/ properties/ widgets/ wizards/
Date Thu, 06 Aug 2015 10:03:43 GMT
Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java
Thu Aug  6 10:03:42 2015
@@ -71,6 +71,7 @@ public class ConnectionWidget extends Vi
      */
     public ConnectionWidget( ConnectionConfiguration configuration, IActionBars actionBars
)
     {
+        super();
         this.configuration = configuration;
         this.actionBars = actionBars;
     }
@@ -116,7 +117,6 @@ public class ConnectionWidget extends Vi
         if ( actionBars == null )
         {
             return super.getMenuManager();
-
         }
         else
         {
@@ -210,5 +210,4 @@ public class ConnectionWidget extends Vi
     {
         return viewer;
     }
-
 }

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ExtendedContentAssistCommandAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ExtendedContentAssistCommandAdapter.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ExtendedContentAssistCommandAdapter.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ExtendedContentAssistCommandAdapter.java
Thu Aug  6 10:03:42 2015
@@ -36,7 +36,6 @@ import org.eclipse.ui.fieldassist.Conten
  */
 public class ExtendedContentAssistCommandAdapter extends ContentAssistCommandAdapter
 {
-
     /**
      * Creates a new instance of ExtendedContentAssistCommandAdapter 
      * with the following settings:
@@ -66,7 +65,9 @@ public class ExtendedContentAssistComman
         setAutoActivationDelay( 0 );
     }
 
-
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void closeProposalPopup()
     {
@@ -74,10 +75,12 @@ public class ExtendedContentAssistComman
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void openProposalPopup()
     {
         super.openProposalPopup();
     }
-
 }

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/Messages.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/Messages.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/Messages.java
Thu Aug  6 10:03:42 2015
@@ -31,6 +31,10 @@ import java.util.ResourceBundle;
  */
 public final class Messages
 {
+    /** The resource name */
+    private static final ResourceBundle RESOURCE_BUNDLE = 
+        ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
+    
     /**
      * Make the constructor private to make this class an utility class
      */
@@ -39,10 +43,6 @@ public final class Messages
     }
     
     
-    /** The resource name */
-    private static final ResourceBundle RESOURCE_BUNDLE = 
-        ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
-    
     /**
      * Get back a message from the resource file given a key
      * 

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Thu Aug  6 10:03:42 2015
@@ -27,6 +27,8 @@ import java.util.Date;
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.api.ldap.model.url.LdapUrl;
 import org.apache.directory.api.ldap.model.url.LdapUrl.Extension;
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.common.ui.CommonUIUtils;
 import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.core.Connection;
@@ -105,14 +107,22 @@ public class NetworkParameterPage extend
 
     /** The checkbox to make the connection read-only */
     private Button readOnlyConnectionCheckbox;
-
-
+    
     /**
-     * Creates a new instance of NetworkParameterPage.
+     * A listener for the Link data widget. It will open the CertificateValidationPreference
dialog.
      */
-    public NetworkParameterPage()
+    private SelectionAdapter linkDataWidgetListener = new SelectionAdapter()
     {
-    }
+        public void widgetSelected( SelectionEvent event )
+        {
+            String certificateValidationPreferencePageId = "org.apache.directory.studio.connection.preferences.CertificateValidationPreferencePage";
//$NON-NLS-1$
+
+            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getDefault()
+                .getActiveShell(), certificateValidationPreferencePageId, new String[]
+                { certificateValidationPreferencePageId }, null );
+            dialog.open();
+        }
+    };
 
 
     /**
@@ -159,8 +169,10 @@ public class NetworkParameterPage extend
         {
             case 1:
                 return ConnectionParameter.EncryptionMethod.LDAPS;
+                
             case 2:
                 return ConnectionParameter.EncryptionMethod.START_TLS;
+                
             default:
                 return ConnectionParameter.EncryptionMethod.NONE;
         }
@@ -174,13 +186,12 @@ public class NetworkParameterPage extend
      */
     private ConnectionParameter.NetworkProvider getNetworkProvider()
     {
-        switch ( networkProviderCombo.getSelectionIndex() )
+        if ( networkProviderCombo.getSelectionIndex() == 1 )
         {
-            case 1:
-                return ConnectionParameter.NetworkProvider.JNDI;
-            default:
-                return ConnectionParameter.NetworkProvider.APACHE_DIRECTORY_LDAP_API;
+            return ConnectionParameter.NetworkProvider.JNDI;
         }
+
+        return ConnectionParameter.NetworkProvider.APACHE_DIRECTORY_LDAP_API;
     }
 
 
@@ -192,9 +203,10 @@ public class NetworkParameterPage extend
      */
     private Connection getTestConnection()
     {
-        ConnectionParameter cp = new ConnectionParameter( null, getHostName(), getPort(),
getEncyrptionMethod(),
+        ConnectionParameter connectionParameter = new ConnectionParameter( null, getHostName(),
getPort(), getEncyrptionMethod(),
             getNetworkProvider(), ConnectionParameter.AuthenticationMethod.NONE, null, null,
null, true, null );
-        Connection conn = new Connection( cp );
+        Connection conn = new Connection( connectionParameter );
+        
         return conn;
     }
 
@@ -219,7 +231,7 @@ public class NetworkParameterPage extend
 
         Composite nameComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1
);
         BaseWidgetUtils.createLabel( nameComposite, Messages.getString( "NetworkParameterPage.ConnectionName"
), 1 ); //$NON-NLS-1$
-        nameText = BaseWidgetUtils.createText( nameComposite, "", 1 ); //$NON-NLS-1$
+        nameText = BaseWidgetUtils.createText( nameComposite, StringUtils.EMPTY, 1 ); //$NON-NLS-1$
 
         BaseWidgetUtils.createSpacer( composite, 1 );
 
@@ -248,13 +260,8 @@ public class NetworkParameterPage extend
 
         boolean validateCertificates = ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
             ConnectionCoreConstants.PREFERENCE_VALIDATE_CERTIFICATES );
-        if ( !validateCertificates )
-        {
-            BaseWidgetUtils.createSpacer( groupComposite, 1 );
-            BaseWidgetUtils.createLabel( groupComposite, Messages
-                .getString( "NetworkParameterPage.WarningCertificateValidation" ), 2 ); //$NON-NLS-1$
-        }
-        else
+        
+        if ( validateCertificates )
         {
             BaseWidgetUtils.createSpacer( groupComposite, 1 );
 
@@ -264,22 +271,21 @@ public class NetworkParameterPage extend
             linkGridData.horizontalSpan = 2;
             linkGridData.widthHint = 100;
             link.setLayoutData( linkGridData );
-            link.addSelectionListener( new SelectionAdapter()
-            {
-                public void widgetSelected( SelectionEvent e )
-                {
-                    String certificateValidationPreferencePageId = "org.apache.directory.studio.connection.preferences.CertificateValidationPreferencePage";
//$NON-NLS-1$
-
-                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( Display.getDefault()
-                        .getActiveShell(), certificateValidationPreferencePageId, new String[]
-                        { certificateValidationPreferencePageId }, null );
-                    dialog.open();
-                }
-            } );
+            link.addSelectionListener( linkDataWidgetListener );
+        }
+        else
+        {
+            BaseWidgetUtils.createSpacer( groupComposite, 1 );
+            BaseWidgetUtils.createLabel( groupComposite, Messages
+                .getString( "NetworkParameterPage.WarningCertificateValidation" ), 2 ); //$NON-NLS-1$
         }
 
         String[] networkProviders = new String[]
-            { "Apache Directory LDAP Client API", "JNDI (Java Naming and Directory Interface)"
}; //$NON-NLS-1$ //$NON-NLS-2$
+        { 
+            "Apache Directory LDAP Client API", 
+            "JNDI (Java Naming and Directory Interface)" 
+        }; //$NON-NLS-1$ //$NON-NLS-2$
+        
         BaseWidgetUtils.createLabel( groupComposite, Messages.getString( "NetworkParameterPage.Provider"
), 1 ); //$NON-NLS-1$
         networkProviderCombo = BaseWidgetUtils.createReadonlyCombo( groupComposite, networkProviders,
0, 2 );
         networkProviderCombo
@@ -288,10 +294,10 @@ public class NetworkParameterPage extend
 
         BaseWidgetUtils.createSpacer( groupComposite, 2 );
         checkConnectionButton = new Button( groupComposite, SWT.PUSH );
-        GridData gd = new GridData();
-        gd.horizontalAlignment = SWT.RIGHT;
-        gd.verticalAlignment = SWT.BOTTOM;
-        checkConnectionButton.setLayoutData( gd );
+        GridData gridData = new GridData();
+        gridData.horizontalAlignment = SWT.RIGHT;
+        gridData.verticalAlignment = SWT.BOTTOM;
+        checkConnectionButton.setLayoutData( gridData );
         checkConnectionButton.setText( Messages.getString( "NetworkParameterPage.CheckNetworkParameter"
) ); //$NON-NLS-1$
 
         readOnlyConnectionCheckbox = BaseWidgetUtils.createCheckbox( composite,
@@ -307,26 +313,31 @@ public class NetworkParameterPage extend
     protected void validate()
     {
         // set enabled/disabled state of check connection button
-        checkConnectionButton.setEnabled( !hostCombo.getText().equals( "" ) && !portCombo.getText().equals(
"" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+        checkConnectionButton.setEnabled( !hostCombo.getText().equals( StringUtils.EMPTY
) && 
+                                          !portCombo.getText().equals( StringUtils.EMPTY
) ); //$NON-NLS-1$ //$NON-NLS-2$
 
         // validate input fields
         message = null;
         infoMessage = null;
         errorMessage = null;
-        if ( "".equals( portCombo.getText() ) ) //$NON-NLS-1$
+        
+        if ( Strings.isEmpty( portCombo.getText() ) ) //$NON-NLS-1$
         {
             message = Messages.getString( "NetworkParameterPage.PleaseEnterPort" ); //$NON-NLS-1$
         }
-        if ( "".equals( hostCombo.getText() ) ) //$NON-NLS-1$
+        
+        if ( Strings.isEmpty( hostCombo.getText() ) ) //$NON-NLS-1$
         {
             message = Messages.getString( "NetworkParameterPage.PleaseEnterHostname" ); //$NON-NLS-1$
         }
-        if ( "".equals( nameText.getText() ) ) //$NON-NLS-1$
+        
+        if ( Strings.isEmpty( nameText.getText() ) ) //$NON-NLS-1$
         {
             message = Messages.getString( "NetworkParameterPage.PleaseEnterConnectionName"
); //$NON-NLS-1$
         }
+        
         if ( ConnectionCorePlugin.getDefault().getConnectionManager().getConnectionByName(
nameText.getText() ) != null
-            && ( connectionParameter == null || !nameText.getText().equals( connectionParameter.getName()
) ) )
+            && ( ( connectionParameter == null ) || !nameText.getText().equals( connectionParameter.getName()
) ) )
         {
             errorMessage = NLS.bind(
                 Messages.getString( "NetworkParameterPage.ConnectionExists" ), new String[]
{ nameText.getText() } ); //$NON-NLS-1$
@@ -341,11 +352,20 @@ public class NetworkParameterPage extend
     {
         connectionParameter = parameter;
 
-        nameText.setText( parameter.getName() );
-        hostCombo.setText( parameter.getHost() );
+        nameText.setText( CommonUIUtils.getTextValue( parameter.getName() ) );
+        hostCombo.setText( CommonUIUtils.getTextValue( parameter.getHost() ) );
         portCombo.setText( Integer.toString( parameter.getPort() ) );
-        int encryptionMethodIndex = parameter.getEncryptionMethod() == EncryptionMethod.LDAPS
? 1
-            : parameter.getEncryptionMethod() == EncryptionMethod.START_TLS ? 2 : 0;
+        int encryptionMethodIndex = 0;
+        
+        if ( parameter.getEncryptionMethod() == EncryptionMethod.LDAPS )
+        {
+            encryptionMethodIndex = 1;
+        }
+        else if ( parameter.getEncryptionMethod() == EncryptionMethod.START_TLS )
+        {
+            encryptionMethodIndex = 2;
+        }
+        
         encryptionMethodCombo.select( encryptionMethodIndex );
         networkProviderCombo.select( parameter.getNetworkProvider() == NetworkProvider.APACHE_DIRECTORY_LDAP_API
? 0
             : 1 );
@@ -360,6 +380,9 @@ public class NetworkParameterPage extend
     {
         nameText.addModifyListener( new ModifyListener()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void modifyText( ModifyEvent event )
             {
                 connectionPageModified();
@@ -368,6 +391,9 @@ public class NetworkParameterPage extend
 
         hostCombo.addModifyListener( new ModifyListener()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void modifyText( ModifyEvent event )
             {
                 connectionPageModified();
@@ -376,6 +402,9 @@ public class NetworkParameterPage extend
 
         portCombo.addVerifyListener( new VerifyListener()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void verifyText( VerifyEvent event )
             {
                 if ( !event.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
@@ -384,8 +413,12 @@ public class NetworkParameterPage extend
                 }
             }
         } );
+        
         portCombo.addModifyListener( new ModifyListener()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void modifyText( ModifyEvent event )
             {
                 connectionPageModified();
@@ -394,6 +427,9 @@ public class NetworkParameterPage extend
 
         encryptionMethodCombo.addSelectionListener( new SelectionAdapter()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void widgetSelected( SelectionEvent event )
             {
                 connectionPageModified();
@@ -402,6 +438,9 @@ public class NetworkParameterPage extend
 
         networkProviderCombo.addSelectionListener( new SelectionAdapter()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void widgetSelected( SelectionEvent event )
             {
                 connectionPageModified();
@@ -410,11 +449,15 @@ public class NetworkParameterPage extend
 
         checkConnectionButton.addSelectionListener( new SelectionAdapter()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void widgetSelected( SelectionEvent event )
             {
                 Connection connection = getTestConnection();
                 CheckNetworkParameterRunnable runnable = new CheckNetworkParameterRunnable(
connection );
                 IStatus status = RunnableContextRunner.execute( runnable, runnableContext,
true );
+                
                 if ( status.isOK() )
                 {
                     MessageDialog.openInformation( Display.getDefault().getActiveShell(),
Messages
@@ -426,6 +469,9 @@ public class NetworkParameterPage extend
 
         readOnlyConnectionCheckbox.addSelectionListener( new SelectionAdapter()
         {
+            /**
+             * {@inheritDoc}
+             */
             public void widgetSelected( SelectionEvent event )
             {
                 connectionPageModified();
@@ -497,9 +543,7 @@ public class NetworkParameterPage extend
     public void mergeParametersToLdapURL( ConnectionParameter parameter, LdapUrl ldapUrl
)
     {
         ldapUrl.getExtensions().add( new Extension( false, X_CONNECTION_NAME, parameter.getName()
) );
-
         ldapUrl.setHost( parameter.getHost() );
-
         ldapUrl.setPort( parameter.getPort() );
 
         switch ( parameter.getEncryptionMethod() )
@@ -507,9 +551,11 @@ public class NetworkParameterPage extend
             case NONE:
                 // default
                 break;
+                
             case LDAPS:
                 ldapUrl.getExtensions().add( new Extension( false, X_ENCRYPTION, X_ENCRYPTION_LDAPS
) );
                 break;
+                
             case START_TLS:
                 ldapUrl.getExtensions().add( new Extension( false, X_ENCRYPTION, X_ENCRYPTION_START_TLS
) );
                 break;
@@ -520,6 +566,7 @@ public class NetworkParameterPage extend
             case JNDI:
                 ldapUrl.getExtensions().add( new Extension( false, X_NETWORK_PROVIDER, X_NETWORK_PROVIDER_JNDI
) );
                 break;
+            
             case APACHE_DIRECTORY_LDAP_API:
                 ldapUrl.getExtensions().add(
                     new Extension( false, X_NETWORK_PROVIDER, X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API
) );
@@ -535,10 +582,12 @@ public class NetworkParameterPage extend
     {
         // connection name, current date if absent
         String name = ldapUrl.getExtensionValue( X_CONNECTION_NAME );
+        
         if ( StringUtils.isEmpty( name ) )
         {
             name = new SimpleDateFormat( "yyyy-MM-dd HH-mm-ss" ).format( new Date() ); //$NON-NLS-1$
         }
+        
         parameter.setName( name );
 
         // host
@@ -549,6 +598,7 @@ public class NetworkParameterPage extend
 
         // encryption method, none if unknown or absent 
         String encryption = ldapUrl.getExtensionValue( X_ENCRYPTION );
+        
         if ( StringUtils.isNotEmpty( encryption ) && X_ENCRYPTION_LDAPS.equalsIgnoreCase(
encryption ) )
         {
             parameter.setEncryptionMethod( ConnectionParameter.EncryptionMethod.LDAPS );
@@ -564,6 +614,7 @@ public class NetworkParameterPage extend
 
         // encryption method, none if unknown or absent 
         String networkProvider = ldapUrl.getExtensionValue( X_NETWORK_PROVIDER );
+        
         if ( StringUtils.isNotEmpty( networkProvider )
             && X_NETWORK_PROVIDER_APACHE_DIRECTORY_LDAP_API.equalsIgnoreCase( networkProvider
) )
         {

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizard.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizard.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizard.java
Thu Aug  6 10:03:42 2015
@@ -60,6 +60,7 @@ public class ExportCertificateWizard ext
      */
     public ExportCertificateWizard( X509Certificate certificate )
     {
+        super();
         this.certificate = certificate;
         setWindowTitle( Messages.getString( "ExportCertificateWizard.ExportCertificate" )
); //$NON-NLS-1$
         setNeedsProgressMonitor( false );
@@ -95,12 +96,13 @@ public class ExportCertificateWizard ext
 
         try
         {
-            switch ( format )
+            if ( format == CertificateExportFormat.DER )
             {
-                case DER:
-                    return exportAsDerFormat();
-                case PEM:
-                    return exportAsPemFormat();
+                return exportAsDerFormat();
+            }
+            else
+            {
+                return exportAsPemFormat();
             }
         }
         catch ( Exception e )
@@ -111,8 +113,6 @@ public class ExportCertificateWizard ext
                     e.getMessage() ) );
             return false;
         }
-
-        return false;
     }
 
 

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizardPage.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizardPage.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/ExportCertificateWizardPage.java
Thu Aug  6 10:03:42 2015
@@ -23,6 +23,9 @@ package org.apache.directory.studio.conn
 
 import java.io.File;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.common.ui.CommonUIUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
@@ -54,9 +57,13 @@ import org.eclipse.ui.PlatformUI;
 public class ExportCertificateWizardPage extends WizardPage
 {
     // UI widgets
+    /** The certificate file name */
     private Text fileText;
-    private Button browseButton;
+    
+    /** The button for overwriting teh file */
     private Button overwriteFileButton;
+    
+    /** The combo for the certificate format (DER or PEM)  */
     private ComboViewer formatComboViewer;
 
 
@@ -93,25 +100,28 @@ public class ExportCertificateWizardPage
         fileComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
 
         // Creating the file's text widget
-        fileText = BaseWidgetUtils.createText( fileComposite, "", 1 ); //$NON-NLS-1$
+        fileText = BaseWidgetUtils.createText( fileComposite, StringUtils.EMPTY, 1 ); //$NON-NLS-1$
         fileText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
         fileText.addModifyListener( new ModifyListener()
         {
-            public void modifyText( ModifyEvent e )
+            /**
+             * {@InheritDoc}
+             */
+            public void modifyText( ModifyEvent event )
             {
                 validate();
             }
         } );
 
         // Creating the file's 'Browse' button widget
-        browseButton = BaseWidgetUtils.createButton( fileComposite,
+        Button browseButton = BaseWidgetUtils.createButton( fileComposite,
             Messages.getString( "ExportCertificateWizardPage.Browse" ), 1 ); //$NON-NLS-1$
         browseButton.addSelectionListener( new SelectionAdapter()
         {
             /**
              * {@inheritDoc}
              */
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected( SelectionEvent event )
             {
                 chooseExportFile();
                 validate();
@@ -123,6 +133,9 @@ public class ExportCertificateWizardPage
             Messages.getString( "ExportCertificateWizardPage.OverwriteExistingFile" ), 2
); //$NON-NLS-1$
         overwriteFileButton.addSelectionListener( new SelectionAdapter()
         {
+            /**
+             * {@InheritDoc}
+             */
             public void widgetSelected( SelectionEvent event )
             {
                 validate();
@@ -139,18 +152,22 @@ public class ExportCertificateWizardPage
         formatComboViewer.setContentProvider( new ArrayContentProvider() );
         formatComboViewer.setLabelProvider( new LabelProvider()
         {
+            /**
+             * {@InheritDoc}
+             */
             public String getText( Object element )
             {
                 if ( element instanceof CertificateExportFormat )
                 {
                     CertificateExportFormat format = ( CertificateExportFormat ) element;
 
-                    switch ( format )
+                    if ( format == CertificateExportFormat.DER )
+                    {
+                        return Messages.getString( "ExportCertificateWizardPage.X509CertificateDER"
); //$NON-NLS-1$
+                    }
+                    else
                     {
-                        case DER:
-                            return Messages.getString( "ExportCertificateWizardPage.X509CertificateDER"
); //$NON-NLS-1$
-                        case PEM:
-                            return Messages.getString( "ExportCertificateWizardPage.X509CertificatePEM"
); //$NON-NLS-1$
+                        return Messages.getString( "ExportCertificateWizardPage.X509CertificatePEM"
); //$NON-NLS-1$
                     }
                 }
 
@@ -175,6 +192,7 @@ public class ExportCertificateWizardPage
     private void validate()
     {
         File file = new File( fileText.getText() );
+        
         if ( file.isDirectory() )
         {
             displayErrorMessage( Messages.getString( "ExportCertificateWizardPage.ErrorFileNotAFile"
) ); //$NON-NLS-1$
@@ -221,16 +239,15 @@ public class ExportCertificateWizardPage
     {
         FileDialog dialog = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.SAVE );
         dialog.setText( Messages.getString( "ExportCertificateWizardPage.ChooseFile" ) );
//$NON-NLS-1$
-        if ( !"".equals( fileText.getText() ) ) //$NON-NLS-1$
+        
+        if ( !Strings.isEmpty( fileText.getText() ) ) //$NON-NLS-1$
         {
             dialog.setFilterPath( fileText.getText() );
         }
 
         String selectedFile = dialog.open();
-        if ( selectedFile != null )
-        {
-            fileText.setText( selectedFile );
-        }
+        
+        fileText.setText( CommonUIUtils.getTextValue( selectedFile ) );
     }
 
 
@@ -253,6 +270,7 @@ public class ExportCertificateWizardPage
     public CertificateExportFormat getCertificateExportFormat()
     {
         StructuredSelection selection = ( StructuredSelection ) formatComboViewer.getSelection();
+        
         if ( !selection.isEmpty() )
         {
             return ( CertificateExportFormat ) selection.getFirstElement();
@@ -261,6 +279,7 @@ public class ExportCertificateWizardPage
         // Default format
         return CertificateExportFormat.DER;
     }
+    
 
     /**
      * This enum represents the various certificate export formats.

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/Messages.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/Messages.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/Messages.java
Thu Aug  6 10:03:42 2015
@@ -29,13 +29,21 @@ import java.util.ResourceBundle;
  *  
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class Messages
+public final class Messages
 {
     /** The resource name */
     private static final ResourceBundle RESOURCE_BUNDLE = 
         ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
     
     /**
+     * A private constructor : this is an utility class
+     */
+    private Messages()
+    {
+    }
+
+    
+    /**
      * Get back a message from the resource file given a key
      * 
      * @param key The key associated with the message

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizard.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizard.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizard.java
Thu Aug  6 10:03:42 2015
@@ -45,7 +45,6 @@ import org.eclipse.ui.PlatformUI;
  */
 public class NewConnectionWizard extends Wizard implements INewWizard
 {
-
     /** The wizard pages. */
     private NewConnectionWizardPage[] wizardPages;
 
@@ -61,6 +60,7 @@ public class NewConnectionWizard extends
      */
     public NewConnectionWizard()
     {
+        super();
         setWindowTitle( Messages.getString( "NewConnectionWizard.NewLdapConnection" ) );
//$NON-NLS-1$
         setNeedsProgressMonitor( true );
     }
@@ -83,6 +83,7 @@ public class NewConnectionWizard extends
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
         Object firstElement = selection.getFirstElement();
+        
         if ( firstElement instanceof ConnectionFolder )
         {
             selectedConnectionFolder = ( ConnectionFolder ) firstElement;
@@ -108,8 +109,8 @@ public class NewConnectionWizard extends
     public void addPages()
     {
         pages = ConnectionParameterPageManager.getConnectionParameterPages();
-
         wizardPages = new NewConnectionWizardPage[pages.length];
+        
         for ( int i = 0; i < pages.length; i++ )
         {
             wizardPages[i] = new NewConnectionWizardPage( this, pages[i] );
@@ -139,13 +140,14 @@ public class NewConnectionWizard extends
      */
     public boolean canFinish()
     {
-        for ( int i = 0; i < pages.length; i++ )
+        for ( ConnectionParameterPage page: pages )
         {
-            if ( !pages[i].isValid() )
+            if ( !page.isValid() )
             {
                 return false;
             }
         }
+        
         return true;
     }
 
@@ -157,14 +159,15 @@ public class NewConnectionWizard extends
     {
         // get connection parameters from pages and save dialog settings 
         ConnectionParameter connectionParameter = new ConnectionParameter();
-        for ( int i = 0; i < pages.length; i++ )
+
+        for ( ConnectionParameterPage page: pages )
         {
-            pages[i].saveParameters( connectionParameter );
-            pages[i].saveDialogSettings();
+            page.saveParameters( connectionParameter );
+            page.saveDialogSettings();
         }
 
         // create persistent connection
-        final Connection conn = new Connection( connectionParameter );
+        Connection conn = new Connection( connectionParameter );
         ConnectionCorePlugin.getDefault().getConnectionManager().addConnection( conn );
 
         // add connection to folder
@@ -185,11 +188,12 @@ public class NewConnectionWizard extends
     public ConnectionParameter getTestConnectionParameters()
     {
         ConnectionParameter connectionParameter = new ConnectionParameter();
-        for ( int i = 0; i < pages.length; i++ )
+
+        for ( ConnectionParameterPage page: pages )
         {
-            pages[i].saveParameters( connectionParameter );
+            page.saveParameters( connectionParameter );
         }
+        
         return connectionParameter;
     }
-
 }

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizardPage.java?rev=1694439&r1=1694438&r2=1694439&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizardPage.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/wizards/NewConnectionWizardPage.java
Thu Aug  6 10:03:42 2015
@@ -26,6 +26,7 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.ui.ConnectionParameterPageModifyListener;
 import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.eclipse.jface.wizard.IWizardContainer;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridLayout;
@@ -39,7 +40,6 @@ import org.eclipse.swt.widgets.Composite
  */
 public class NewConnectionWizardPage extends WizardPage implements ConnectionParameterPageModifyListener
 {
-
     /** The wizard. */
     private NewConnectionWizard wizard;
 
@@ -87,8 +87,8 @@ public class NewConnectionWizardPage ext
     public void createControl( Composite parent )
     {
         Composite composite = new Composite( parent, SWT.NONE );
-        GridLayout gl = new GridLayout( 1, false );
-        composite.setLayout( gl );
+        GridLayout gridLayout = new GridLayout( 1, false );
+        composite.setLayout( gridLayout );
         page.init( composite, this, null );
         setControl( composite );
     }
@@ -114,12 +114,15 @@ public class NewConnectionWizardPage ext
         {
             setMessage( null );
         }
+        
         setErrorMessage( page.getErrorMessage() );
         setPageComplete( page.isValid() );
+        
+        IWizardContainer container = getContainer();
 
-        if ( getContainer() != null && getContainer().getCurrentPage() != null )
+        if ( ( container != null ) && ( container.getCurrentPage() != null ) )
         {
-            getContainer().updateButtons();
+            container.updateButtons();
         }
     }
 
@@ -131,5 +134,4 @@ public class NewConnectionWizardPage ext
     {
         return wizard.getTestConnectionParameters();
     }
-
 }
\ No newline at end of file



Mime
View raw message