directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1685561 - in /directory/studio/trunk/plugins: common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/ openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ openldap.config.editor/sr...
Date Mon, 15 Jun 2015 12:02:58 GMT
Author: elecharny
Date: Mon Jun 15 12:02:57 2015
New Revision: 1685561

URL: http://svn.apache.org/r1685561
Log:
o Fixed the TableWidget.getElements() which was trying to copy a List using an arraycopy
o The ServerId is now handled by a TableWidget like the other tables
o Removed the ServerIdWidget which is not anymore used
o All the Tuning and Overview pages elements are now associated with a listener so that they
can be saved
o Suppress a double registring of a listener for the ServerId table

Removed:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/widgets/ServerIdTableWidget.java
Modified:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ServerIdDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java?rev=1685561&r1=1685560&r2=1685561&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
(original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
Mon Jun 15 12:02:57 2015
@@ -342,7 +342,8 @@ public class TableWidget<E> extends Abst
         if ( elements != null )
         {
             List<E> copy = new ArrayList<E>( elements.size() );
-            System.arraycopy( elements, 0, copy, 0, elements.size() );
+            
+            copy.addAll( elements );
             
             return copy;
         }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ServerIdDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ServerIdDialog.java?rev=1685561&r1=1685560&r2=1685561&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ServerIdDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/ServerIdDialog.java
Mon Jun 15 12:02:57 2015
@@ -20,13 +20,10 @@
 package org.apache.directory.studio.openldap.config.editor.dialogs;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.directory.api.ldap.model.exception.LdapURLEncodingException;
 import org.apache.directory.api.ldap.model.url.LdapUrl;
+import org.apache.directory.studio.common.ui.AddEditDialog;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
-import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -65,17 +62,8 @@ import org.apache.directory.studio.openl
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ServerIdDialog extends Dialog
+public class ServerIdDialog extends AddEditDialog<ServerIdWrapper>
 {
-    /** The ServerId */
-    private ServerIdWrapper serverId;
-
-    /** The new serverId */
-    private ServerIdWrapper newServerId;
-
-    /** The list of existing ServerID */
-    List<ServerIdWrapper> serverIdList;
-    
     // UI widgets
     /** The ID Text */
     private Text idText;
@@ -91,33 +79,11 @@ public class ServerIdDialog extends Dial
      * Create a new instance of the ServerIdDialog
      * 
      * @param parentShell The parent Shell
-     * @param serverId The instance containing the ServerID data
-     */
-    public ServerIdDialog( Shell parentShell, List<ServerIdWrapper> serverIdList, ServerIdWrapper
serverId )
-    {
-        super( parentShell );
-        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
-        this.serverId = serverId;
-        this.serverIdList = serverIdList;
-        
-        if ( serverIdList == null )
-        {
-            this.serverIdList = new ArrayList<ServerIdWrapper>();
-        }
-    }
-
-
-    /**
-     * Create a new instance of the ServerIdDialog
-     * 
-     * @param parentShell The parent Shell
-     * @param serverIdStr : The string containing the serverID
      */
-    public ServerIdDialog( Shell parentShell, String serverIdStr )
+    public ServerIdDialog( Shell parentShell )
     {
         super( parentShell );
         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
-        this.serverId = new ServerIdWrapper( serverIdStr );
     }
     
     
@@ -140,27 +106,26 @@ public class ServerIdDialog extends Dial
             try
             {
                 int idValue = Integer.parseInt( idText.getText() );
+                serverIdText.setText( getEditedElement().toString() );
 
                 // The value must be between 0 and 4095, and it must not already exists
                 if ( ( idValue < 0 ) || ( idValue > 4096 ) )
                 {
-                    System.out.println( "Wrong ID : it must be a value in [0..4095]" );
-                    serverIdText.setText( "Wrong ID : it must be a value in [0..4095]" );
                     serverIdText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
                     okButton.setEnabled( false );
+                    
                     return;
                 }
                 else
                 {
                     // Be sure the value is not already taken
-                    for ( ServerIdWrapper serverIdWrapper : serverIdList )
+                    for ( ServerIdWrapper serverIdWrapper : getElements() )
                     {
                         if ( serverIdWrapper.getServerId() == idValue )
                         {
-                            System.out.println( "Wrong ServerID : already taken" );
-                            serverIdText.setText( "Wrong ID : it's already taken by another
Server ID" );
                             serverIdText.setForeground( display.getSystemColor( SWT.COLOR_RED
) );
                             okButton.setEnabled( false );
+                            
                             return;
                         }
                     }
@@ -168,13 +133,13 @@ public class ServerIdDialog extends Dial
                 
                 serverIdText.setText( idText.getText() + ' ' + urlText.getText() );
                 serverIdText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
+                getEditedElement().setServerId( idValue );
                 okButton.setEnabled( true );
             }
             catch ( NumberFormatException nfe )
             {
                 // Not even a number
-                System.out.println( "Wrong ServerID : it must be an integer" );
-                serverIdText.setText( "Wrong ID : it must be an integer in [0..4095]" );
+                serverIdText.setText( getEditedElement().toString() );
                 serverIdText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
                 okButton.setEnabled( false );
             }
@@ -201,16 +166,16 @@ public class ServerIdDialog extends Dial
 
             try
             {
-                new LdapUrl( urlText.getText() );
-                
-                serverIdText.setText( idText.getText() + ' ' + urlText.getText() );
+                String urlStr = urlText.getText();
+                new LdapUrl( urlStr );
+
+                getEditedElement().setUrl( urlStr );
+                serverIdText.setText( idText.getText() + ' ' + urlStr );
                 serverIdText.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
                 okButton.setEnabled( true );
             }
             catch ( LdapURLEncodingException luee )
             {
-                System.out.println( "Wrong ServerID : the URL is invalid" );
-                serverIdText.setText( "Wrong ServerID : the URL is invalid" );
                 serverIdText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
                 okButton.setEnabled( false );
             }
@@ -230,22 +195,6 @@ public class ServerIdDialog extends Dial
 
 
     /**
-     * We have to check that the ID does not already exist.
-     * {@inheritDoc}
-     */
-    protected void okPressed()
-    {
-        // Creating the new index
-        String id = idText.getText();
-        String url = urlText.getText();
-        int idValue = Integer.valueOf( id );
-        
-        newServerId = new ServerIdWrapper( idValue , url );
-        super.okPressed();
-    }
-
-
-    /**
      * Create the Dialog for ServerID :
      * <pre>
      * +---------------------------------------+
@@ -271,7 +220,8 @@ public class ServerIdDialog extends Dial
         createServerIdEditGroup( composite );
         createServerIdShowGroup( composite );
 
-        initFromServerId();
+        initDialog();
+        addListeners();
 
         applyDialogFont( composite );
         
@@ -304,13 +254,11 @@ public class ServerIdDialog extends Dial
         BaseWidgetUtils.createLabel( serverIdGroup, "ID:", 1 );
         idText = BaseWidgetUtils.createText( serverIdGroup, "", 1 );
         idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-        idText.addModifyListener( idTextListener );
 
         // URL Text
         BaseWidgetUtils.createLabel( serverIdGroup, "URL:", 1 );
         urlText = BaseWidgetUtils.createText( serverIdGroup, "", 1 );
         urlText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-        urlText.addModifyListener( urlTextListener );
     }
 
 
@@ -343,13 +291,15 @@ public class ServerIdDialog extends Dial
     /**
      * Initializes the UI from the ServerId
      */
-    private void initFromServerId()
+    protected void initDialog()
     {
-        if ( serverId != null )
+        ServerIdWrapper editedElement = (ServerIdWrapper)getEditedElement();
+        
+        if ( editedElement != null )
         {
-            idText.setText( Integer.toString( serverId.getServerId() ) );
+            idText.setText( Integer.toString( editedElement.getServerId() ) );
             
-            String url = serverId.getUrl();
+            String url = editedElement.getUrl();
             
             if ( url == null )
             {
@@ -357,19 +307,36 @@ public class ServerIdDialog extends Dial
             }
             else
             {
-                urlText.setText( serverId.getUrl() );
+                urlText.setText( editedElement.getUrl() );
             }
         }
     }
 
 
     /**
-     * Gets the new ServerId.
-     *
-     * @return the new serverID
+     * Add a new Element that will be edited
+     */
+    public void addNewElement()
+    {
+        setEditedElement( new ServerIdWrapper( "" ) );
+    }
+
+
+    @Override
+    public void addNewElement( ServerIdWrapper editedElement )
+    {
+        ServerIdWrapper newElement = (ServerIdWrapper)editedElement.clone();
+        setEditedElement( newElement );
+        
+    }
+
+    
+    /**
+     * Adds listeners.
      */
-    public ServerIdWrapper getNewServerId()
+    private void addListeners()
     {
-        return newServerId;
+        idText.addModifyListener( idTextListener );
+        urlText.addModifyListener( urlTextListener );
     }
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java?rev=1685561&r1=1685560&r2=1685561&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
Mon Jun 15 12:02:57 2015
@@ -125,6 +125,7 @@ public class TcpBufferDialog extends Add
                 if ( ( sizeValue < 0L ) || ( sizeValue > TcpBufferWrapper.MAX_TCP_BUFFER_SIZE
) )
                 {
                     sizeText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
+                    tcpBufferText.setText( getEditedElement().toString() );
                     tcpBufferText.setForeground( display.getSystemColor( SWT.COLOR_RED )
);
                     okButton.setEnabled( false );
                     return;
@@ -268,16 +269,6 @@ public class TcpBufferDialog extends Add
 
 
     /**
-     * Construct the TcpBufferWrapper from what we have in the dialog
-     * {@inheritDoc}
-     */
-    protected void okPressed()
-    {
-        super.okPressed();
-    }
-
-
-    /**
      * Create the Dialog for TcpBuffer :
      * <pre>
      * +---------------------------------------+
@@ -433,5 +424,4 @@ public class TcpBufferDialog extends Add
         readCheckbox.addSelectionListener( checkboxSelectionListener );
         writeCheckbox.addSelectionListener( checkboxSelectionListener );
     }
-
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java?rev=1685561&r1=1685560&r2=1685561&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OverviewPage.java
Mon Jun 15 12:02:57 2015
@@ -25,10 +25,14 @@ import java.util.List;
 
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.common.ui.widgets.TableWidget;
+import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
 import org.apache.directory.studio.openldap.common.ui.model.LogLevelEnum;
 import org.apache.directory.studio.openldap.common.ui.dialogs.LogLevelDialog;
 import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils;
 import org.apache.directory.studio.openldap.config.editor.OpenLDAPServerConfigurationEditor;
+import org.apache.directory.studio.openldap.config.editor.dialogs.ServerIdDialog;
 import org.apache.directory.studio.openldap.config.editor.overlays.ModuleWrapper;
 import org.apache.directory.studio.openldap.config.editor.overlays.ModuleWrapperLabelProvider;
 import org.apache.directory.studio.openldap.config.editor.overlays.ModuleWrapperViewerSorter;
@@ -37,9 +41,9 @@ import org.apache.directory.studio.openl
 import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperLabelProvider;
 import org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperViewerSorter;
 import org.apache.directory.studio.openldap.config.editor.wrappers.ServerIdWrapper;
+import org.apache.directory.studio.openldap.config.editor.wrappers.ServerIdWrapperLabelProvider;
 import org.apache.directory.studio.openldap.config.model.OlcModuleList;
 import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig;
-import org.apache.directory.studio.openldap.config.model.widgets.ServerIdTableWidget;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
@@ -128,7 +132,7 @@ public class OverviewPage extends OpenLD
     private List<ServerIdWrapper> serverIdWrappers = new ArrayList<ServerIdWrapper>();
     
     /** The Widget used to manage ServerID */
-    private ServerIdTableWidget serverIdWidget;
+    private TableWidget<ServerIdWrapper> serverIdTableWidget;
 
     /** olcConfigDir */
     private Text configDirText;
@@ -321,6 +325,27 @@ public class OverviewPage extends OpenLD
         }
     };
 
+    
+    // The listener for the ServerIdTableWidget
+    private WidgetModifyListener serverIdTableWidgetListener = new WidgetModifyListener()
+    {
+        @Override
+        public void widgetModified( WidgetModifyEvent event )
+        {
+            // Process the parameter modification
+            TableWidget<ServerIdWrapper> serverIdWrapperTable = (TableWidget<ServerIdWrapper>)event.getSource();
+            List<String> serverIds = new ArrayList<String>();
+            
+            for ( Object serverIdWrapper : serverIdWrapperTable.getElements() )
+            {
+                String str = serverIdWrapper.toString();
+                serverIds.add( str );
+            }
+            
+            getConfiguration().getGlobal().setOlcServerID( serverIds );
+        }
+    };
+
 
     /**
      * Creates the global Overview OpenLDAP config Tab. It contains 3 rows, with
@@ -437,10 +462,14 @@ public class OverviewPage extends OpenLD
         serverIdLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 5, 1
) );
 
         // The ServerID widget
-        serverIdWidget = new ServerIdTableWidget();
-        serverIdWidget.createWidget( globalSectionComposite );
-        serverIdWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true,
false, 5, 1 ) );
-        
+        serverIdTableWidget = new TableWidget<ServerIdWrapper>();
+        serverIdTableWidget.setLabelProvider( new ServerIdWrapperLabelProvider() );
+        serverIdTableWidget.setElementDialog( new ServerIdDialog( null ) );
+
+        serverIdTableWidget.createWidgetWithEdit( globalSectionComposite, toolkit );
+        serverIdTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE,
true, false, 5, 1 ) );
+        serverIdTableWidget.addWidgetModifyListener( serverIdTableWidgetListener );
+
         // One blank line
         for ( int i = 0; i < gridLayout.numColumns; i++ )
         {
@@ -765,7 +794,7 @@ public class OverviewPage extends OpenLD
                 serverIdWrappers.add( new ServerIdWrapper( serverIdWrapper ) );
             }
 
-            serverIdWidget.setElements( serverIdWrappers );
+            serverIdTableWidget.setElements( serverIdWrappers );
             
             // Update the ConfigDirText
             configDirText.setText( getConfiguration().getGlobal().getOlcConfigDir() );
@@ -830,7 +859,7 @@ public class OverviewPage extends OpenLD
     private void removeListeners()
     {
         // The serverID Text 
-        //removeDirtyListener( serverIdText );
+        serverIdTableWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
 
         // The configDir Text 
         removeDirtyListener( configDirText );
@@ -852,7 +881,7 @@ public class OverviewPage extends OpenLD
     private void addListeners()
     {
         // The serverID Text 
-        //addDirtyListener( serverIdText );
+        serverIdTableWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
 
         // The configDir Text 
         addDirtyListener( configDirText );

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java?rev=1685561&r1=1685560&r2=1685561&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/TuningPage.java
Mon Jun 15 12:02:57 2015
@@ -43,6 +43,8 @@ import org.eclipse.ui.forms.widgets.Tabl
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.common.ui.widgets.TableWidget;
+import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener;
 import org.apache.directory.studio.openldap.config.editor.OpenLDAPServerConfigurationEditor;
 import org.apache.directory.studio.openldap.config.editor.dialogs.OverlayDialog;
 import org.apache.directory.studio.openldap.config.editor.dialogs.SizeLimitDialog;
@@ -206,8 +208,6 @@ public class TuningPage extends OpenLDAP
     {
         super( editor, ID, TITLE );
     }
-
-    
     
     
     /**
@@ -739,6 +739,27 @@ public class TuningPage extends OpenLDAP
     };
     
     
+    // The listener for the TcpBufferTableWidget
+    private WidgetModifyListener tcpBufferTableWidgetListener = new WidgetModifyListener()
+    {
+        @Override
+        public void widgetModified( WidgetModifyEvent event )
+        {
+            // Process the parameter modification
+            TableWidget<TcpBufferWrapper> tcpBufferWrapperTable = (TableWidget<TcpBufferWrapper>)event.getSource();
+            List<String> tcpBuffers = new ArrayList<String>();
+            
+            for ( Object tcpBufferWrapper : tcpBufferWrapperTable.getElements() )
+            {
+                String str = tcpBufferWrapper.toString();
+                tcpBuffers.add( str );
+            }
+            
+            getConfiguration().getGlobal().setOlcTCPBuffer( tcpBuffers );
+        }
+    };
+    
+    
     /**
      * Creates the OpenLDAP tuning config Tab. It contains 2 rows, with
      * 2 columns :
@@ -849,6 +870,7 @@ public class TuningPage extends OpenLDAP
 
         tcpBufferTableWidget.createWidgetWithEdit( networkSectionComposite, toolkit );
         tcpBufferTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE,
true, false, 4, 1 ) );
+        tcpBufferTableWidget.addWidgetModifyListener( tcpBufferTableWidgetListener );
 
         // The olcSockbufMaxIncoming parameter.
         toolkit.createLabel( networkSectionComposite, 

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java?rev=1685561&r1=1685560&r2=1685561&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
Mon Jun 15 12:02:57 2015
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.studio.openldap.config.editor.wrappers;
 
+import org.apache.directory.api.util.Strings;
+
 /**
  * A wrapper for a ServerID which can be either an integer between 0 and 4095 
  * (or from 0x0 to 0xFFF), and may be followed by an URL. We can't have both format,
@@ -65,7 +67,10 @@ public class ServerIdWrapper implements
      */
     public ServerIdWrapper( String serverIdStr )
     {
-        this.serverId = Integer.parseInt( serverIdStr );
+        if ( !Strings.isEmpty( serverIdStr ) )
+        {
+            this.serverId = Integer.parseInt( serverIdStr );
+        }
     }
 
     



Mime
View raw message