You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/06/09 22:07:25 UTC

svn commit: r1684512 - in /directory/studio/trunk/plugins: common.ui/src/main/java/org/apache/directory/studio/common/ui/ common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/ openldap.config.editor/src/main/java/org/apache/directory/s...

Author: elecharny
Date: Tue Jun  9 20:07:25 2015
New Revision: 1684512

URL: http://svn.apache.org/r1684512
Log:
Big refactoring in the TableWidget code :
o Made the Edit button optional
o Split the createWidget method in two (with or without the edit)
o Don't re-add an element if it already exists in the table
o Remove the modified element if it alreayd exists
o Simplified the AddEditDialog
o Added the clone() method to the TcpBufferwrapper class
o Added the PasswordHashDialog class

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.java
Modified:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java
    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/TcpBufferDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.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/TcpBufferWrapper.java

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java?rev=1684512&r1=1684511&r2=1684512&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java (original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java Tue Jun  9 20:07:25 2015
@@ -49,6 +49,15 @@ public abstract class AddEditDialog<E> e
     }
 
     /**
+     * Initialize the Dialog with the content of the edited element, if any
+     */
+    protected void initDialog()
+    {
+        // Nothing to do
+    }
+    
+    
+    /**
      * @return The added or edited element 
      */
     public E getNewElement()
@@ -61,7 +70,7 @@ public abstract class AddEditDialog<E> e
      * Store the Element that has been added or edited
      * @param newElement The added or edited Element 
      */
-    public void setNewElement( E newElement )
+    protected void setNewElement( E newElement )
     {
         this.newElement = newElement;
     }
@@ -74,6 +83,15 @@ public abstract class AddEditDialog<E> e
     
 
     /**
+     * Add a new Element that will be edited
+     */
+    protected void addNewElement( E editedElement )
+    {
+        // Nothing to do
+    }
+    
+
+    /**
      * @return The edited element 
      */
     public E getEditedElement()
@@ -86,15 +104,9 @@ public abstract class AddEditDialog<E> e
      * Store the Element that will be edited
      * @param editedElement The edited Element 
      */
-    public void setEditedElement( E editedElement )
+    public final void setEditedElement( E editedElement )
     {
         this.editedElement = editedElement;
+        addNewElement( editedElement );
     }
-
-
-    /**
-     * Store the Element that will be edited
-     * @param editedElement The edited Element 
-     */
-    public abstract void setEditedElement( String editedElement );
 }

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=1684512&r1=1684511&r2=1684512&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 Tue Jun  9 20:07:25 2015
@@ -73,6 +73,8 @@ public class TableWidget<E> extends Abst
     /** The LabelProvider for the elements */
     private LabelProvider labelProvider;
 
+    /** A flag set to tell if we have a Edit button */
+    private boolean hasEdit;
 
     // UI widgets
     private Composite composite;
@@ -89,7 +91,11 @@ public class TableWidget<E> extends Abst
         {
             StructuredSelection selection = ( StructuredSelection ) elementTableViewer.getSelection();
 
-            editButton.setEnabled( !selection.isEmpty() );
+            if ( hasEdit )
+            {
+                editButton.setEnabled( !selection.isEmpty() );
+            }
+            
             deleteButton.setEnabled( !selection.isEmpty() );
         }
     };
@@ -140,7 +146,7 @@ public class TableWidget<E> extends Abst
 
 
     /**
-     * Creates the Table widget. It's a Table and three button :
+     * Creates the Table widget. It's a Table and three buttons :
      * <pre>
      * +--------------------------------------+
      * | Element 1                            | (Add... )
@@ -148,12 +154,61 @@ public class TableWidget<E> extends Abst
      * |                                      | (Delete )
      * +--------------------------------------+
      * </pre>
+     * </pre>
+     * 
+     * @param parent the parent
+     * @param toolkit the toolkit
+     */
+    public void createWidgetWithEdit( Composite parent, FormToolkit toolkit )
+    {
+        createWidget( parent, toolkit, true );
+    }
+    
+    
+    /**
+     * Creates the Table widget. It's a Table and two buttons :
+     * <pre>
+     * +--------------------------------------+
+     * | Element 1                            | (Add... )
+     * | Element 2                            | (Delete )
+     * |                                      |
+     * +--------------------------------------+
+     * </pre>
      * 
      * @param parent the parent
      * @param toolkit the toolkit
      */
-    public void createWidget( Composite parent, FormToolkit toolkit )
+    public void createWidgetNoEdit( Composite parent, FormToolkit toolkit )
     {
+        createWidget( parent, toolkit, false );
+    }
+
+
+    /**
+     * Creates the Table widget. It's a Table and two or three button :
+     * <pre>
+     * +--------------------------------------+
+     * | Element 1                            | (Add... )
+     * | Element 2                            | (Edit...)
+     * |                                      | (Delete )
+     * +--------------------------------------+
+     * </pre>
+     * or :
+     * <pre>
+     * +--------------------------------------+
+     * | Element 1                            | (Add... )
+     * | Element 2                            | (Delete )
+     * |                                      |
+     * +--------------------------------------+
+     * </pre>
+     * 
+     * @param parent the parent
+     * @param toolkit the toolkit
+     */
+    private void createWidget( Composite parent, FormToolkit toolkit, boolean hasEdit )
+    {
+        this.hasEdit = hasEdit;
+        
         // Composite
         if ( toolkit != null )
         {
@@ -192,9 +247,12 @@ public class TableWidget<E> extends Abst
         // The LabelProvider
         elementTableViewer.setLabelProvider( labelProvider );
         
-        // Listeners : we want to catch changes and double clicks
-        elementTableViewer.addSelectionChangedListener( tableViewerSelectionChangedListener );
-        elementTableViewer.addDoubleClickListener( tableViewerDoubleClickListener );
+        // Listeners : we want to catch changes and double clicks (if we have an edit button)
+        if ( hasEdit )
+        {
+            elementTableViewer.addSelectionChangedListener( tableViewerSelectionChangedListener );
+            elementTableViewer.addDoubleClickListener( tableViewerDoubleClickListener );
+        }
         
         // Inject the existing elements
         elementTableViewer.setInput( elements );
@@ -212,20 +270,23 @@ public class TableWidget<E> extends Abst
         addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
         addButton.addSelectionListener( addButtonListener );
 
-        // Create the Edit Button and its listener
-        if ( toolkit != null )
+        // Create the Edit Button and its listener, if requested
+        if ( hasEdit )
         {
-            editButton = toolkit.createButton( composite, "Edit...", SWT.PUSH );
-        }
-        else
-        {
-            editButton = BaseWidgetUtils.createButton( composite, "Edit...", SWT.PUSH );
+            if ( toolkit != null )
+            {
+                editButton = toolkit.createButton( composite, "Edit...", SWT.PUSH );
+            }
+            else
+            {
+                editButton = BaseWidgetUtils.createButton( composite, "Edit...", SWT.PUSH );
+            }
+            
+            // It's not enabled unless we have selected an element
+            editButton.setEnabled( false );
+            editButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+            editButton.addSelectionListener( editButtonListener );
         }
-        
-        // It's not enabled unless we have selected an element
-        editButton.setEnabled( false );
-        editButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
-        editButton.addSelectionListener( editButtonListener );
 
         // Create the Delete Button and its listener
         if ( toolkit != null )
@@ -300,10 +361,15 @@ public class TableWidget<E> extends Abst
         if ( elementDialog.open() == Dialog.OK )
         {
             E newElement = elementDialog.getNewElement();
-            String elementStr = newElement.toString();
-            elements.add( newElement );
-            elementTableViewer.refresh();
-            elementTableViewer.setSelection( new StructuredSelection( elementStr ) );
+            
+            if ( !elements.contains( newElement ) )
+            {
+                String elementStr = newElement.toString();
+                elements.add( newElement );
+                elementTableViewer.refresh();
+                elementTableViewer.setSelection( new StructuredSelection( elementStr ) );
+            }
+            
             notifyListeners();
         }
     }
@@ -326,13 +392,26 @@ public class TableWidget<E> extends Abst
             if ( elementDialog.open() == Dialog.OK )
             {
                 E newElement = elementDialog.getNewElement();
-                int selectedIndexPosition = elements.indexOf( selectedElement );
                 
-                // We will remove the modified element, and replace it with the new element
-                elements.remove( selectedElement );
-                elements.add( selectedIndexPosition, newElement );
+                if ( elements.contains( newElement ) )
+                {
+                    // Remove the original element
+                    elements.remove( selectedElement );
+                    
+                    // Replace the existing element with the new one
+                    elements.remove( newElement );
+                    elements.add( newElement );
+                }
+                else
+                {
+                    // We will remove the modified element, and replace it with the new element
+                    elements.remove( selectedElement );
+                    elements.add( newElement );
+                }
+
                 elementTableViewer.refresh();
                 elementTableViewer.setSelection( new StructuredSelection( newElement.toString() ) );
+
                 notifyListeners();
             }
         }

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.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/PasswordHashDialog.java?rev=1684512&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.java Tue Jun  9 20:07:25 2015
@@ -0,0 +1,227 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.openldap.config.editor.dialogs;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.common.ui.AddEditDialog;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.apache.directory.studio.openldap.common.ui.model.PasswordHashEnum;
+
+
+/**
+ * The PasswordHashDialog is used to select one hash method. The possible
+ * hash methods are :
+ * <ul>
+ * <li>{CLEARTEXT}</li>
+ * <li>{CRYPT}</li>
+ * <li>{LANMAN}</li>
+ * <li>{MD5}</li>
+ * <li>{SMD5}</li>
+ * <li>{SHA}</li>
+ * <li>{SSHA}</li>
+ * <li>{UNIX}</li>
+ * <li></li>
+ * <li></li>
+ * </ul>
+ * </pre>
+ * 
+ * The dialog overlay is like :
+ * 
+ * <pre>
+ * +-----------------------------------------+
+ * | Password hash                           |
+ * | .-------------------------------------. |
+ * | | CLear Text : [ ]   Crypt :      [ ] | |
+ * | | LANMAN :     [ ]   MD5 :        [ ] | |
+ * | | SMD5 :       [ ]   SHA :        [ ] | |
+ * | | SSHA :       [ ]   Unix :       [ ] | |
+ * | '-------------------------------------' |
+ * |                                         |
+ * |  (Cancel)                         (OK)  |
+ * +-----------------------------------------+
+ * </pre>
+ * 
+ * A few rules :
+ * <ul>
+ * <li>When the global limit is set, the soft and hard limits are not used</li>
+ * <li>When the Unlimited button is checked, the integer value is discarded</li>
+ * <li>When the Soft checkbox for the hard limit is checked, the Global value is used </li>
+ * </ul>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PasswordHashDialog extends AddEditDialog<PasswordHashEnum>
+{
+    /** The array of buttons */
+    private Button[] passwordHashCheckboxes = new Button[9];
+    
+    /** The already selected hashes */
+    List<PasswordHashEnum> hashes = new ArrayList<PasswordHashEnum>();
+    
+    /**
+     * Create a new instance of the PasswordHashDialog
+     * 
+     * @param parentShell The parent Shell
+     */
+    public PasswordHashDialog( Shell parentShell )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+    }
+    
+    
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( "Password Hash" );
+    }
+
+    /**
+     * The listener in charge of exposing the changes when some checkbox is selectionned
+     */
+    private SelectionListener checkboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Object object = e.getSource();
+            
+            if ( object instanceof Button )
+            {
+                Button selectedCheckbox = (Button)object;
+                
+                for ( int i = 1; i < passwordHashCheckboxes.length; i++ )
+                {
+                    if ( selectedCheckbox == passwordHashCheckboxes[i] )
+                    {
+                        setNewElement( PasswordHashEnum.getPasswordHash( i ) );
+                    }
+                    else
+                    {
+                        passwordHashCheckboxes[i].setSelection( false );
+                    }
+                }
+            }
+        }
+    };
+
+
+    /**
+     * Create the Dialog for PasswordHash :
+     * <pre>
+     * +-----------------------------------------+
+     * | Password hash                           |
+     * | .-------------------------------------. |
+     * | | CLear Text : [ ]   Crypt :      [ ] | |
+     * | | LANMAN :     [ ]   MD5 :        [ ] | |
+     * | | SMD5 :       [ ]   SHA :        [ ] | |
+     * | | SSHA :       [ ]   Unix :       [ ] | |
+     * | '-------------------------------------' |
+     * |                                         |
+     * |  (Cancel)                         (OK)  |
+     * +-----------------------------------------+
+     * </pre>
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+        
+        createPasswordHashEditGroup( composite );
+        initDialog();
+        
+        applyDialogFont( composite );
+        
+        return composite;
+    }
+
+
+    /**
+     * Creates the PasswordHash input group. This is the part of the dialog
+     * where one can insert the TimeLimit values
+     * 
+     * <pre>
+     * Password hash
+     * .------------------.
+     * | CLear Text : [ ] |
+     * | Crypt :      [ ] |
+     * | LANMAN :     [ ] |
+     * | MD5 :        [ ] |
+     * | SMD5 :       [ ] |
+     * | SHA :        [ ] |
+     * | SSHA :       [ ] |
+     * | Unix :       [ ] |
+     * '------------------'
+     * </pre>
+     * @param parent the parent composite
+     */
+    private void createPasswordHashEditGroup( Composite parent )
+    {
+        // Password Hash Group
+        Group passwordHashGroup = BaseWidgetUtils.createGroup( parent, "", 2 );
+        GridLayout passwordHashGridLayout = new GridLayout( 2, false );
+        passwordHashGroup.setLayout( passwordHashGridLayout );
+        passwordHashGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // The various buttons
+        for ( int i = 1; i < passwordHashCheckboxes.length; i++ )
+        {
+            PasswordHashEnum passwordHash = PasswordHashEnum.getPasswordHash( i );
+            Button button = BaseWidgetUtils.createCheckbox( passwordHashGroup, passwordHash.getName(), 1 );
+            passwordHashCheckboxes[i] = button;
+            passwordHashCheckboxes[i].addSelectionListener( checkboxSelectionListener );
+            
+            // Disable the hashes already selected
+            if ( hashes.contains( passwordHashCheckboxes[i] ) )
+            {
+                passwordHashCheckboxes[i].setEnabled( false );
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addNewElement()
+    {
+        // Default to none
+        setNewElement( PasswordHashEnum.NO_CHOICE );
+    }
+}

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=1684512&r1=1684511&r2=1684512&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 Tue Jun  9 20:07:25 2015
@@ -202,7 +202,6 @@ public class TcpBufferDialog extends Add
             Display display = tcpBufferText.getDisplay();
             Button okButton = getButton( IDialogConstants.OK_ID );
             
-            
             // This button might be null when the dialog is called.
             if ( okButton == null )
             {
@@ -359,7 +358,7 @@ public class TcpBufferDialog extends Add
         createTcpBufferEditGroup( composite );
         createTcpBufferShowGroup( composite );
 
-        initFromTcpBuffer();
+        initDialog();
         addListeners();
         
         applyDialogFont( composite );
@@ -437,13 +436,15 @@ public class TcpBufferDialog extends Add
     /**
      * Initializes the UI from the TcpBuffer
      */
-    private void initFromTcpBuffer()
+    protected void initDialog()
     {
-        if ( getEditedElement() != null )
+        TcpBufferWrapper editedElement = (TcpBufferWrapper)getEditedElement();
+        
+        if ( editedElement != null )
         {
-            sizeText.setText( Long.toString( getEditedElement().getSize() ) );
+            sizeText.setText( Long.toString( editedElement.getSize() ) );
             
-            URL listener =  getEditedElement().getListener();
+            URL listener =  editedElement.getListener();
             
             if ( listener == null )
             {
@@ -454,7 +455,7 @@ public class TcpBufferDialog extends Add
                 listenerText.setText( listener.toString() );
             }
             
-            tcpBufferText.setText( getEditedElement().toString() );
+            tcpBufferText.setText( editedElement.toString() );
         }
     }
 
@@ -476,22 +477,23 @@ public class TcpBufferDialog extends Add
         this.tcpBufferList = tcpBufferList;
     }
     
-    
+
     /**
-     * {@inheritDoc}
+     * Add a new Element that will be edited
      */
-    public void setEditedElement( String editedElement )
+    public void addNewElement()
     {
-        setEditedElement( new TcpBufferWrapper( editedElement ) );
+        setNewElement( new TcpBufferWrapper( "" ) );
     }
     
 
     /**
      * Add a new Element that will be edited
      */
-    public void addNewElement()
+    protected void addNewElement( TcpBufferWrapper editedElement )
     {
-        setNewElement( new TcpBufferWrapper( "" ) );
+        TcpBufferWrapper newElement = (TcpBufferWrapper)editedElement.clone();
+        setNewElement( newElement );
     }
 
     

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.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/SecurityPage.java?rev=1684512&r1=1684511&r2=1684512&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/SecurityPage.java Tue Jun  9 20:07:25 2015
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.openldap.config.editor.pages;
 
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.swt.SWT;
@@ -39,8 +40,10 @@ 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.openldap.common.ui.model.PasswordHashEnum;
 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.PasswordHashDialog;
 import org.apache.directory.studio.openldap.config.editor.dialogs.SaslSecPropsDialog;
 import org.apache.directory.studio.openldap.config.editor.wrappers.SsfWrapper;
 import org.apache.directory.studio.openldap.config.editor.wrappers.TcpBufferWrapperLabelProvider;
@@ -183,7 +186,7 @@ public class SecurityPage extends OpenLD
     private Text passwordCryptSaltFormatText;
 
     /** The olcPasswordHash */
-    private TableWidget<String> passwordHashTableWidget;
+    private TableWidget<PasswordHashEnum> passwordHashTableWidget;
 
     /** The olcSecurity table widget */
     private TableWidget<SsfWrapper> securityTableWidget;
@@ -221,19 +224,6 @@ public class SecurityPage extends OpenLD
         "true"
         };
     
-    /** The list of Password Hashes choices  */
-    private static final String[] hashes = new String[]
-        {
-        NO_CHOICE,
-        "{CLEARTEXT}",
-        "{CRYPT}",
-        "{MD5}",
-        "{SMD5}",
-        "{SHA}",
-        "{SSHA}"
-        };
-    
-    
     
     /**
      * The listener for the SaslSecProps Text
@@ -535,11 +525,11 @@ public class SecurityPage extends OpenLD
         Label passwordHashLabel = toolkit.createLabel( miscSectionComposite, Messages.getString( "OpenLDAPSecurityPage.PasswordHash" ) ); //$NON-NLS-1$
         passwordHashLabel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false, 4, 1 ) );
         
-        passwordHashTableWidget = new TableWidget<String>();
+        passwordHashTableWidget = new TableWidget<PasswordHashEnum>();
         passwordHashTableWidget.setLabelProvider( new TcpBufferWrapperLabelProvider() );
-        //passwordHashTableWidget.setElementDialog( "" );
+        passwordHashTableWidget.setElementDialog( new PasswordHashDialog( null ) );
 
-        passwordHashTableWidget.createWidget( miscSectionComposite, toolkit );
+        passwordHashTableWidget.createWidgetNoEdit( miscSectionComposite, toolkit );
         passwordHashTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) );
         
         // A blank line
@@ -556,7 +546,7 @@ public class SecurityPage extends OpenLD
         securityTableWidget.setLabelProvider( new TcpBufferWrapperLabelProvider() );
         //securityTableWidget.setElementDialog( "" );
 
-        securityTableWidget.createWidget( miscSectionComposite, toolkit );
+        securityTableWidget.createWidgetWithEdit( miscSectionComposite, toolkit );
         securityTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) );
     }
 
@@ -830,15 +820,22 @@ public class SecurityPage extends OpenLD
             }
 
             // Password Hash Table Widget
-            List<String> passwordHash = global.getOlcPasswordHash();
+            List<String> passwordHashes = global.getOlcPasswordHash();
 
-            if ( passwordHash != null )
+            if ( passwordHashes != null )
             {
-                //TODO
+                List<PasswordHashEnum> hashes = new ArrayList<PasswordHashEnum>();
+                
+                for ( String passwordHashName : passwordHashes )
+                {
+                    hashes.add( PasswordHashEnum.getPasswordHash( passwordHashName ) );
+                }
+                
+                passwordHashTableWidget.setElements( hashes );
             }
             else
             {
-                //TODO
+                passwordHashTableWidget.setElements( new ArrayList<PasswordHashEnum>() );
             }
 
             // Security Table Widget

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=1684512&r1=1684511&r2=1684512&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 Tue Jun  9 20:07:25 2015
@@ -857,7 +857,7 @@ public class TuningPage extends OpenLDAP
         tcpBufferTableWidget.setLabelProvider( new TcpBufferWrapperLabelProvider() );
         tcpBufferTableWidget.setElementDialog( new TcpBufferDialog( null ) );
 
-        tcpBufferTableWidget.createWidget( networkSectionComposite, toolkit );
+        tcpBufferTableWidget.createWidgetWithEdit( networkSectionComposite, toolkit );
         tcpBufferTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 4, 1 ) );
 
         // The olcSockbufMaxIncoming parameter.

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.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/TcpBufferWrapper.java?rev=1684512&r1=1684511&r2=1684512&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java Tue Jun  9 20:07:25 2015
@@ -32,7 +32,7 @@ import org.apache.directory.api.util.Str
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class TcpBufferWrapper
+public class TcpBufferWrapper implements Cloneable
 {
     /** The maximum buffer size (2^32-1) */
     public static final long MAX_TCP_BUFFER_SIZE = 0xFFFFFFFFL;
@@ -141,22 +141,25 @@ public class TcpBufferWrapper
                         pos++;
                     }
                 }
-                    
-                // We might have a 'read' or 'write' prefix
-                if ( lowerCaseTcpBuffer.startsWith( "read=", pos ) )
-                {
-                    tcpType = TcpTypeEnum.READ;
-                    pos += 5;
-                }
-                else if ( lowerCaseTcpBuffer.startsWith( "write=", pos ) )
-                {
-                    tcpType = TcpTypeEnum.WRITE;
-                    pos += 6;
-                }
-                
-                // get the integer
-                String sizeStr = lowerCaseTcpBuffer.substring( pos );
+            }
                 
+            // We might have a 'read' or 'write' prefix
+            if ( lowerCaseTcpBuffer.startsWith( "read=", pos ) )
+            {
+                tcpType = TcpTypeEnum.READ;
+                pos += 5;
+            }
+            else if ( lowerCaseTcpBuffer.startsWith( "write=", pos ) )
+            {
+                tcpType = TcpTypeEnum.WRITE;
+                pos += 6;
+            }
+            
+            // get the integer
+            String sizeStr = lowerCaseTcpBuffer.substring( pos );
+            
+            if ( !Strings.isEmpty( sizeStr ) )
+            {
                 size = Long.valueOf( sizeStr );
                 
                 if ( ( size < 0L ) || ( size > MAX_TCP_BUFFER_SIZE ) )
@@ -265,6 +268,22 @@ public class TcpBufferWrapper
     }
     
     
+    /**
+     * Clone the current object
+     */
+    public TcpBufferWrapper clone()
+    {
+        try
+        {
+            return (TcpBufferWrapper)super.clone();
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            return null;
+        }
+    }
+    
+    
     /**
      * @see Object#equals(Object)
      */