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/04/01 03:01:43 UTC

svn commit: r1670531 [5/14] - in /directory/studio/trunk/plugins/openldap.config.editor: ./ resources/icons/ src/main/java/org/apache/directory/studio/openldap/config/ src/main/java/org/apache/directory/studio/openldap/config/actions/ src/main/java/org...

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java Wed Apr  1 01:01:42 2015
@@ -23,17 +23,29 @@ package org.apache.directory.studio.open
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Image;
 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.Label;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.forms.DetailsPart;
 import org.eclipse.ui.forms.IManagedForm;
@@ -44,26 +56,76 @@ import org.eclipse.ui.forms.widgets.Sect
 
 import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
 import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
-import org.apache.directory.studio.openldap.config.model.OlcBdbConfig;
-import org.apache.directory.studio.openldap.config.model.OlcConfig;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils;
+import org.apache.directory.studio.openldap.config.editor.ServerConfigurationEditor;
 import org.apache.directory.studio.openldap.config.model.OlcDatabaseConfig;
-import org.apache.directory.studio.openldap.config.model.OlcHdbConfig;
-import org.apache.directory.studio.openldap.config.model.OlcLdifConfig;
-import org.apache.directory.studio.openldap.config.model.OpenLdapConfiguration;
 
 
 /**
  * This class represents the Databases Master/Details Block used in the Databases Page.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class DatabasesMasterDetailsBlock extends MasterDetailsBlock
 {
+    private static final String NEW_ID = "database";
+
     /** The associated page */
     private DatabasesPage page;
 
+    /** The details page */
+    private DatabasesDetailsPage detailsPage;
+
+    /** The database wrappers */
+    private List<DatabaseWrapper> databaseWrappers = new ArrayList<DatabaseWrapper>();
+
+    /** The currently selected object */
+    private Object currentSelection;
+
     // UI Fields
     private TableViewer viewer;
     private Button addButton;
     private Button deleteButton;
+    private Button upButton;
+    private Button downButton;
+
+    // Listeners
+    private ISelectionChangedListener viewerSelectionChangedListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            viewer.refresh();
+            refreshButtonStates();
+        }
+    };
+    private SelectionAdapter addButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            addNewDatabase();
+        }
+    };
+    private SelectionAdapter deleteButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            deleteSelectedDatabase();
+        }
+    };
+    private SelectionAdapter upButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            moveSelectedDatabaseUp();
+        }
+    };
+    private SelectionAdapter downButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            moveSelectedDatabaseDown();
+        }
+    };
 
 
     /**
@@ -99,24 +161,22 @@ public class DatabasesMasterDetailsBlock
     {
         FormToolkit toolkit = managedForm.getToolkit();
 
+        // Creating the Composite
+        Composite composite = toolkit.createComposite( parent );
+        composite.setLayout( new GridLayout() );
+
         // Creating the Section
-        Section section = toolkit.createSection( parent, Section.TITLE_BAR );
+        Section section = toolkit.createSection( composite, Section.TITLE_BAR );
         section.setText( "All Databases" );
-        section.marginWidth = 10;
-        section.marginHeight = 5;
-        Composite client = toolkit.createComposite( section, SWT.WRAP );
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 2;
-        layout.makeColumnsEqualWidth = false;
-        layout.marginWidth = 2;
-        layout.marginHeight = 2;
-        client.setLayout( layout );
+        Composite client = toolkit.createComposite( section );
+        client.setLayout( new GridLayout( 2, false ) );
         toolkit.paintBordersFor( client );
         section.setClient( client );
+        section.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
 
         // Creating the Table and Table Viewer
-        Table table = toolkit.createTable( client, SWT.NULL );
-        GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 2 );
+        Table table = toolkit.createTable( client, SWT.NONE );
+        GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 5 );
         gd.heightHint = 20;
         gd.widthHint = 100;
         table.setLayoutData( gd );
@@ -127,86 +187,417 @@ public class DatabasesMasterDetailsBlock
         {
             public void selectionChanged( SelectionChangedEvent event )
             {
-                managedForm.fireSelectionChanged( spart, event.getSelection() );
+                Object newSelection = ( ( StructuredSelection ) event.getSelection() ).getFirstElement();
+
+                if ( newSelection != currentSelection )
+                {
+                    currentSelection = newSelection;
+                    detailsPart.commit( false );
+                    managedForm.fireSelectionChanged( spart, event.getSelection() );
+                }
             }
         } );
         viewer.setContentProvider( new ArrayContentProvider() );
-        viewer.setLabelProvider( new LabelProvider()
+        viewer.setLabelProvider( new DatabaseWrapperLabelProvider() );
+        viewer.setSorter( new DatabaseWrapperViewerSorter() );
+
+        // Creating the button(s)
+        addButton = toolkit.createButton( client, "Add", SWT.PUSH );
+        addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+        deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
+        deleteButton.setEnabled( false );
+        deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+        Label separator = BaseWidgetUtils.createSeparator( client, 1 );
+        separator.setLayoutData( new GridData( SWT.NONE, SWT.BEGINNING, false, false ) );
+
+        upButton = toolkit.createButton( client, "Up", SWT.PUSH );
+        upButton.setEnabled( false );
+        upButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+        downButton = toolkit.createButton( client, "Down", SWT.PUSH );
+        downButton.setEnabled( false );
+        downButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+        initFromInput();
+        addListeners();
+    }
+
+
+    /**
+     * Initializes the page with the Editor input.
+     */
+    private void initFromInput()
+    {
+        databaseWrappers.clear();
+        
+        for ( OlcDatabaseConfig database : page.getConfiguration().getDatabases() )
+        {
+            databaseWrappers.add( new DatabaseWrapper( database ) );
+        }
+
+        viewer.setInput( databaseWrappers );
+    }
+
+
+    /**
+     * Refreshes the UI.
+     */
+    public void refreshUI()
+    {
+        initFromInput();
+        viewer.refresh();
+    }
+
+
+    /**
+     * Add listeners to UI fields.
+     */
+    private void addListeners()
+    {
+        viewer.addSelectionChangedListener( viewerSelectionChangedListener );
+        addButton.addSelectionListener( addButtonSelectionListener );
+        deleteButton.addSelectionListener( deleteButtonSelectionListener );
+        upButton.addSelectionListener( upButtonSelectionListener );
+        downButton.addSelectionListener( downButtonSelectionListener );
+    }
+
+
+    /**
+     * This method is called when the 'Add' button is clicked.
+     */
+    private void addNewDatabase()
+    {
+        String newId = getNewId();
+
+        OlcDatabaseConfig database = new OlcDatabaseConfig();
+        database.setOlcDatabase( "{" + getNewOrderingValue() + "}" + newId );
+        try
         {
-            public String getText( Object element )
+            database.addOlcSuffix( new Dn( "dc=" + newId + ",dc=com" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        catch ( LdapInvalidDnException e1 )
+        {
+            // Will never happen
+        }
+
+        DatabaseWrapper databaseWrapper = new DatabaseWrapper( database );
+        databaseWrappers.add( databaseWrapper );
+        viewer.refresh();
+        viewer.setSelection( new StructuredSelection( databaseWrapper ) );
+        setEditorDirty();
+    }
+
+
+    /**
+     * This method is called when the 'Delete' button is clicked.
+     */
+    private void deleteSelectedDatabase()
+    {
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
+        if ( !selection.isEmpty() )
+        {
+            DatabaseWrapper databaseWrapper = ( DatabaseWrapper ) selection.getFirstElement();
+            OlcDatabaseConfig database = databaseWrapper.getDatabase();
+
+            if ( MessageDialog.openConfirm( page.getManagedForm().getForm().getShell(), "Confirm Delete",
+                NLS.bind( "Are you sure you want to delete database ''{0} ({1})''?",
+                    OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase() ),
+                    getSuffixValue( database ) ) ) )
+            {
+                databaseWrappers.remove( databaseWrapper );
+                setEditorDirty();
+            }
+        }
+    }
+
+
+    /**
+     * Gets the suffix value.
+     *
+     * @param database the database
+     * @return the suffix value
+     */
+    private String getSuffixValue( OlcDatabaseConfig database )
+    {
+        String suffix = OpenLdapConfigurationPluginUtils.getFirstValueDn( database.getOlcSuffix() );
+
+        if ( suffix != null )
+        {
+            return suffix;
+        }
+        else
+        {
+            return "none";
+        }
+    }
+
+
+    /**
+     * Gets a new ID for a new database.
+     *
+     * @return 
+     *      a new ID for a new database
+     */
+    private String getNewId()
+    {
+        int counter = 1;
+        String name = NEW_ID;
+        boolean ok = false;
+
+        while ( !ok )
+        {
+            ok = true;
+            name = NEW_ID + counter;
+
+            for ( DatabaseWrapper databaseWrapper : databaseWrappers )
             {
-                if ( element instanceof OlcDatabaseConfig )
+                if ( name.equalsIgnoreCase( OpenLdapConfigurationPluginUtils.stripOrderingPrefix( databaseWrapper
+                    .getDatabase().getOlcDatabase() ) ) )
                 {
-                    OlcDatabaseConfig database = ( OlcDatabaseConfig ) element;
+                    ok = false;
+                }
+            }
+            counter++;
+        }
 
-                    return database.getOlcDatabase();
+        return name;
+    }
+
+
+    /**
+     * Gets the new ordering value.
+     *
+     * @return the new ordering value
+     */
+    private int getNewOrderingValue()
+    {
+        return getMaxOrderingValue() + 1;
+    }
+
+
+    /**
+     * Gets the minimum ordering value.
+     *
+     * @return the minimum ordering value
+     */
+    private int getMinOrderingValue()
+    {
+        int minOrderingValue = Integer.MAX_VALUE;
+
+        for ( DatabaseWrapper databaseWrapper : databaseWrappers )
+        {
+            if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( databaseWrapper.getDatabase().getOlcDatabase() ) )
+            {
+                int databaseOrderingValue = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper
+                    .getDatabase().getOlcDatabase() );
+
+                if ( databaseOrderingValue < minOrderingValue )
+                {
+                    minOrderingValue = databaseOrderingValue;
                 }
+            }
+        }
+
+        return minOrderingValue;
+    }
 
-                return super.getText( element );
-            };
 
+    /**
+     * Gets the maximum ordering value.
+     *
+     * @return the maximum ordering value
+     */
+    private int getMaxOrderingValue()
+    {
+        int maxOrderingValue = -1;
 
-            public Image getImage( Object element )
+        for ( DatabaseWrapper databaseWrapper : databaseWrappers )
+        {
+            if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( databaseWrapper.getDatabase().getOlcDatabase() ) )
             {
-                if ( element instanceof OlcDatabaseConfig )
+                int databaseOrderingValue = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper
+                    .getDatabase().getOlcDatabase() );
+
+                if ( databaseOrderingValue > maxOrderingValue )
                 {
-                    return OpenLdapConfigurationPlugin.getDefault().getImage(
-                        OpenLdapConfigurationPluginConstants.IMG_DATABASE );
+                    maxOrderingValue = databaseOrderingValue;
                 }
+            }
+        }
 
-                return super.getImage( element );
-            };
-        } );
+        return maxOrderingValue;
+    }
 
-        // Creating the button(s)
-        addButton = toolkit.createButton( client, "Add", SWT.PUSH );
-        addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
 
-        deleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
-        deleteButton.setEnabled( false );
-        deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+    /**
+     * This method is called when the 'Up' button is clicked.
+     */
+    private void moveSelectedDatabaseUp()
+    {
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
 
-        initFromInput();
+        if ( !selection.isEmpty() )
+        {
+            OlcDatabaseConfig selectedDatabase = ( ( DatabaseWrapper ) selection.getFirstElement() ).getDatabase();
+            int selectedDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( selectedDatabase
+                .getOlcDatabase() );
+            String selectedDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( selectedDatabase
+                .getOlcDatabase() );
+
+            OlcDatabaseConfig swapDatabase = findPreviousDatabase( selectedDatabaseOrderingPrefix );
+            if ( swapDatabase != null )
+            {
+                int swapDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( swapDatabase
+                    .getOlcDatabase() );
+                String swapDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( swapDatabase
+                    .getOlcDatabase() );
+
+                selectedDatabase.setOlcDatabase( "{" + swapDatabaseOrderingPrefix + "}" + selectedDatabaseName );
+                swapDatabase.setOlcDatabase( "{" + selectedDatabaseOrderingPrefix + "}" + swapDatabaseName );
+
+                viewer.refresh();
+                refreshButtonStates();
+                setEditorDirty();
+            }
+        }
     }
 
 
     /**
-     * Initializes the page with the Editor input.
+     * Finds the previous database.
+     *
+     * @param orderingPrefix the ordering prefix
+     * @return the previous database
      */
-    private void initFromInput()
+    private OlcDatabaseConfig findPreviousDatabase( int orderingPrefix )
     {
-        OpenLdapConfiguration configuration = page.getConfiguration();
+        OlcDatabaseConfig selectedDatabase = null;
+        int selectedDatabaseOrderingPrefix = Integer.MIN_VALUE;
 
-        List<OlcConfig> configurationElements = configuration.getConfigurationElements();
-        List<OlcDatabaseConfig> databaseConfigurationElements = new ArrayList<OlcDatabaseConfig>();
-        for ( OlcConfig configurationElement : configurationElements )
+        for ( DatabaseWrapper databaseWrapper : databaseWrappers )
         {
-            if ( configurationElement instanceof OlcDatabaseConfig )
+            int databaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper
+                .getDatabase().getOlcDatabase() );
+
+            if ( ( databaseOrderingPrefix < orderingPrefix )
+                && ( databaseOrderingPrefix > selectedDatabaseOrderingPrefix ) )
             {
-                databaseConfigurationElements.add( ( OlcDatabaseConfig ) configurationElement );
+                selectedDatabase = databaseWrapper.getDatabase();
+                selectedDatabaseOrderingPrefix = databaseOrderingPrefix;
             }
         }
 
-        viewer.setInput( databaseConfigurationElements.toArray( new OlcDatabaseConfig[0] ) );
+        return selectedDatabase;
     }
 
 
     /**
-     * {@inheritDoc}
+     * This method is called when the 'Down' button is clicked.
      */
-    protected void registerPages( DetailsPart detailsPart )
+    private void moveSelectedDatabaseDown()
+    {
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
+        if ( !selection.isEmpty() )
+        {
+            OlcDatabaseConfig selectedDatabase = ( ( DatabaseWrapper ) selection.getFirstElement() ).getDatabase();
+            int selectedDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( selectedDatabase
+                .getOlcDatabase() );
+            String selectedDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( selectedDatabase
+                .getOlcDatabase() );
+
+            OlcDatabaseConfig swapDatabase = findNextDatabase( selectedDatabaseOrderingPrefix );
+            if ( swapDatabase != null )
+            {
+                int swapDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( swapDatabase
+                    .getOlcDatabase() );
+                String swapDatabaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( swapDatabase
+                    .getOlcDatabase() );
+
+                selectedDatabase.setOlcDatabase( "{" + swapDatabaseOrderingPrefix + "}" + selectedDatabaseName );
+                swapDatabase.setOlcDatabase( "{" + selectedDatabaseOrderingPrefix + "}" + swapDatabaseName );
+
+                viewer.refresh();
+                refreshButtonStates();
+                setEditorDirty();
+            }
+        }
+    }
+
+
+    /**
+     * Finds the next database.
+     *
+     * @param orderingPrefix the ordering prefix
+     * @return the next database
+     */
+    private OlcDatabaseConfig findNextDatabase( int orderingPrefix )
     {
-        DatabasesDetailsPage olcDatabaseConfigDetailsPage = new DatabasesDetailsPage( this );
-        detailsPart.registerPage( OlcDatabaseConfig.class, olcDatabaseConfigDetailsPage );
+        OlcDatabaseConfig selectedDatabase = null;
+        int selectedDatabaseOrderingPrefix = Integer.MAX_VALUE;
 
-        DatabasesDetailsPage olcBdbConfigDetailsPage = new DatabasesDetailsPage( this );
-        detailsPart.registerPage( OlcBdbConfig.class, olcBdbConfigDetailsPage );
+        for ( DatabaseWrapper databaseWrapper : databaseWrappers )
+        {
+            int databaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( databaseWrapper
+                .getDatabase().getOlcDatabase() );
 
-        DatabasesDetailsPage olcHdbConfigDetailsPage = new DatabasesDetailsPage( this );
-        detailsPart.registerPage( OlcHdbConfig.class, olcHdbConfigDetailsPage );
+            if ( ( databaseOrderingPrefix > orderingPrefix )
+                && ( databaseOrderingPrefix < selectedDatabaseOrderingPrefix ) )
+            {
+                selectedDatabase = databaseWrapper.getDatabase();
+                selectedDatabaseOrderingPrefix = databaseOrderingPrefix;
+            }
+        }
 
-        DatabasesDetailsPage olcLdifConfigDetailsPage = new DatabasesDetailsPage( this );
-        detailsPart.registerPage( OlcLdifConfig.class, olcLdifConfigDetailsPage );
+        return selectedDatabase;
+    }
+
+
+    private void refreshButtonStates()
+    {
+        // Getting the selection of the table viewer
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
+        if ( !selection.isEmpty() )
+        {
+            OlcDatabaseConfig database = ( ( DatabaseWrapper ) selection.getFirstElement() ).getDatabase();
+
+            deleteButton.setEnabled( true );
+            upButton.setEnabled( getMinOrderingValue() != OpenLdapConfigurationPluginUtils
+                .getOrderingPrefix( database.getOlcDatabase() ) );
+            downButton.setEnabled( getMaxOrderingValue() != OpenLdapConfigurationPluginUtils
+                .getOrderingPrefix( database.getOlcDatabase() ) );
+        }
+        else
+        {
+            deleteButton.setEnabled( false );
+            upButton.setEnabled( false );
+            downButton.setEnabled( false );
+        }
+    }
+
+
+    /**
+     * Sets the Editor as dirty.
+     */
+    public void setEditorDirty()
+    {
+        ( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
+        detailsPage.commit( false );
+        viewer.refresh();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void registerPages( DetailsPart detailsPart )
+    {
+        detailsPage = new DatabasesDetailsPage( this );
+        detailsPart.registerPage( DatabaseWrapper.class, detailsPage );
     }
 
 
@@ -228,4 +619,173 @@ public class DatabasesMasterDetailsBlock
     {
         return page;
     }
+
+
+    /**
+     * Saves the necessary elements to the input model.
+     */
+    public void doSave( IProgressMonitor monitor )
+    {
+        // Committing information on the details page
+        detailsPage.commit( true );
+
+        // Saving the databases
+        getPage().getConfiguration().clearDatabases();
+        for ( DatabaseWrapper databaseWrapper : databaseWrappers )
+        {
+            getPage().getConfiguration().addDatabase( databaseWrapper.getDatabase() );
+        }
+    }
+
+    /**
+     * This class defines a label provider for a database wrapper viewer.
+     */
+    private class DatabaseWrapperLabelProvider extends LabelProvider
+    {
+        public String getText( Object element )
+        {
+            if ( element instanceof DatabaseWrapper )
+            {
+                OlcDatabaseConfig database = ( ( DatabaseWrapper ) element ).getDatabase();
+
+                return getDatabaseType( database ) + " (" + getSuffix( database ) + ")";
+            }
+
+            return super.getText( element );
+        };
+
+
+        public Image getImage( Object element )
+        {
+            if ( element instanceof DatabaseWrapper )
+            {
+                return OpenLdapConfigurationPlugin.getDefault().getImage(
+                    OpenLdapConfigurationPluginConstants.IMG_DATABASE );
+            }
+
+            return super.getImage( element );
+        };
+
+
+        private String getDatabaseType( OlcDatabaseConfig database )
+        {
+            if ( database != null )
+            {
+                String databaseType = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase() );
+
+                if ( "bdb".equalsIgnoreCase( databaseType ) )
+                {
+                    return "BDB";
+                }
+                else if ( "hdb".equalsIgnoreCase( databaseType ) )
+                {
+                    return "HDB";
+                }
+                else if ( "mdb".equalsIgnoreCase( databaseType ) )
+                {
+                    return "MDB";
+                }
+                else if ( "ldap".equalsIgnoreCase( databaseType ) )
+                {
+                    return "LDAP";
+                }
+                else if ( "ldif".equalsIgnoreCase( databaseType ) )
+                {
+                    return "LDIF";
+                }
+                else if ( "null".equalsIgnoreCase( databaseType ) )
+                {
+                    return "Null";
+                }
+                else if ( "relay".equalsIgnoreCase( databaseType ) )
+                {
+                    return "Relay";
+                }
+                else if ( "frontend".equalsIgnoreCase( databaseType ) )
+                {
+                    return "FrontEnd";
+                }
+                else if ( "config".equalsIgnoreCase( databaseType ) )
+                {
+                    return "Config";
+                }
+                else
+                {
+                    return "None";
+                }
+            }
+
+            return null;
+        }
+
+
+        private String getSuffix( OlcDatabaseConfig database )
+        {
+            if ( database != null )
+            {
+                List<Dn> suffixes = database.getOlcSuffix();
+
+                if ( ( suffixes != null ) && ( suffixes.size() > 0 ) )
+                {
+                    return suffixes.get( 0 ).toString();
+                }
+            }
+
+            return "none";
+        }
+    }
+
+    /**
+     * This class defines a sorter for a database wrapper viewer.
+     */
+    private class DatabaseWrapperViewerSorter extends ViewerSorter
+    {
+        public int compare( Viewer viewer, Object e1, Object e2 )
+        {
+            if ( ( e1 != null ) && ( e2 != null ) && ( e1 instanceof DatabaseWrapper )
+                && ( e2 instanceof DatabaseWrapper ) )
+            {
+                OlcDatabaseConfig database1 = ( ( DatabaseWrapper ) e1 ).getDatabase();
+                OlcDatabaseConfig database2 = ( ( DatabaseWrapper ) e2 ).getDatabase();
+
+                if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1.getOlcDatabase() )
+                    && ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2.getOlcDatabase() ) ) )
+                {
+                    int orderingPrefix1 = OpenLdapConfigurationPluginUtils.getOrderingPrefix( database1
+                        .getOlcDatabase() );
+                    int orderingPrefix2 = OpenLdapConfigurationPluginUtils.getOrderingPrefix( database2
+                        .getOlcDatabase() );
+
+                    if ( orderingPrefix1 > orderingPrefix2 )
+                    {
+                        return Integer.MAX_VALUE;
+                    }
+                    else if ( orderingPrefix1 < orderingPrefix2 )
+                    {
+                        return Integer.MIN_VALUE;
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+                else if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1.getOlcDatabase() )
+                    && ( !OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2.getOlcDatabase() ) ) )
+                {
+                    return Integer.MIN_VALUE;
+                }
+                else if ( !OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1.getOlcDatabase() )
+                    && ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2.getOlcDatabase() ) ) )
+                {
+                    return Integer.MAX_VALUE;
+                }
+                else
+                {
+                    return 1;
+                }
+            }
+
+            return super.compare( viewer, e1, e2 );
+        }
+    }
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesPage.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesPage.java Wed Apr  1 01:01:42 2015
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.openldap.config.editor.databases;
 
 
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
@@ -29,6 +30,8 @@ import org.apache.directory.studio.openl
 
 /**
  * This class represents the General Page of the Server Configuration Editor.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class DatabasesPage extends ServerConfigurationEditorPage
 {
@@ -38,6 +41,9 @@ public class DatabasesPage extends Serve
     /** The Page Title */
     private static final String TITLE = "Databases";
 
+    /** The master details block */
+    private DatabasesMasterDetailsBlock masterDetailsBlock;
+
 
     /**
      * Creates a new instance of GeneralPage.
@@ -56,7 +62,7 @@ public class DatabasesPage extends Serve
      */
     protected void createFormContent( Composite parent, FormToolkit toolkit )
     {
-        DatabasesMasterDetailsBlock masterDetailsBlock = new DatabasesMasterDetailsBlock( this );
+        masterDetailsBlock = new DatabasesMasterDetailsBlock( this );
         masterDetailsBlock.createContent( getManagedForm() );
     }
 
@@ -66,5 +72,21 @@ public class DatabasesPage extends Serve
      */
     public void refreshUI()
     {
+        if ( isInitialized() )
+        {
+            masterDetailsBlock.refreshUI();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void doSave( IProgressMonitor monitor )
+    {
+        if ( masterDetailsBlock != null )
+        {
+            masterDetailsBlock.doSave( monitor );
+        }
     }
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendDatabaseSpecificDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendDatabaseSpecificDetailsBlock.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendDatabaseSpecificDetailsBlock.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/FrontendDatabaseSpecificDetailsBlock.java Wed Apr  1 01:01:42 2015
@@ -20,61 +20,246 @@
 package org.apache.directory.studio.openldap.config.editor.databases;
 
 
+import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
 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.graphics.Image;
 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.Text;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
+import org.apache.directory.studio.openldap.common.ui.dialogs.AttributeDialog;
+import org.apache.directory.studio.openldap.common.ui.widgets.EntryWidget;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
+import org.apache.directory.studio.openldap.config.model.AuxiliaryObjectClass;
+import org.apache.directory.studio.openldap.config.model.OlcDatabaseConfig;
 import org.apache.directory.studio.openldap.config.model.OlcFrontendConfig;
 
 
 /**
  * This interface represents a block for Frontend Specific Details.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class FrontendDatabaseSpecificDetailsBlock implements DatabaseSpecificDetailsBlock
+public class FrontendDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcDatabaseConfig>
 {
-    /** The database */
-    private OlcFrontendConfig database;
+    private static final String SHA = "{SHA}";
+    private static final String SSHA = "{SSHA}";
+    private static final String CRYPT = "{CRYPT}";
+    private static final String MD5 = "{MD5}";
+    private static final String SMD5 = "{SMD5}";
+    private static final String CLEARTEXT = "{CLEARTEXT}";
+
+    /** The list of sorted attributes values */
+    private List<String> sortedValuesAttributesList = new ArrayList<String>();
 
     // UI Fields
-    private Text defaultSearchBaseText;
-    private Text passwordHashText;
-    private Text sortValsText;
+    private EntryWidget defaultSearchBaseEntryWidget;
+    private Button shaCheckbox;
+    private Button sshaCheckbox;
+    private Button cryptCheckbox;
+    private Button md5Checkbox;
+    private Button smd5Checkbox;
+    private Button cleartextCheckbox;
+    private Table sortedValuesTable;
+    private TableViewer sortedValuesTableViewer;
+    private Button addSortedValueButton;
+    private Button deleteSortedValueButton;
+
+    // Listeners
+    private ISelectionChangedListener sortedValuesTableViewerSelectionChangedListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            deleteSortedValueButton.setEnabled( !sortedValuesTableViewer.getSelection().isEmpty() );
+        }
+    };
+    private SelectionListener addSortedValueButtonSelectionListener = new SelectionAdapter()
+    {
+
+        public void widgetSelected( SelectionEvent e )
+        {
+            AttributeDialog dialog = new AttributeDialog( addSortedValueButton.getShell(), browserConnection );
+            if ( dialog.open() == AttributeDialog.OK )
+            {
+                String attribute = dialog.getAttribute();
+
+                if ( !sortedValuesAttributesList.contains( attribute ) )
+                {
+                    sortedValuesAttributesList.add( attribute );
+                    sortedValuesTableViewer.refresh();
+                    sortedValuesTableViewer.setSelection( new StructuredSelection( attribute ) );
+
+                    detailsPage.setEditorDirty();
+                }
+            }
+        }
+    };
+    private SelectionListener deleteSortedValueButtonSelectionListener = new SelectionAdapter()
+    {
+
+        public void widgetSelected( SelectionEvent e )
+        {
+            StructuredSelection selection = ( StructuredSelection ) sortedValuesTableViewer.getSelection();
+
+            if ( !selection.isEmpty() )
+            {
+                String selectedAttribute = ( String ) selection.getFirstElement();
+
+                sortedValuesAttributesList.remove( selectedAttribute );
+                sortedValuesTableViewer.refresh();
+
+                detailsPage.setEditorDirty();
+            }
+        }
+    };
 
 
     /**
      * Creates a new instance of FrontendDatabaseSpecificDetailsBlock.
      *
+     * @param detailsPage the details page
      * @param database the database
+     * @param browserConnection the connection
      */
-    public FrontendDatabaseSpecificDetailsBlock( OlcFrontendConfig database )
+    public FrontendDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcDatabaseConfig database,
+        IBrowserConnection browserConnection )
     {
-        this.database = database;
+        super( detailsPage, database, browserConnection );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void createFormContent( Composite parent, FormToolkit toolkit )
+    public Composite createBlockContent( Composite parent, FormToolkit toolkit )
     {
+        // Composite
+        Composite composite = toolkit.createComposite( parent );
+        composite.setLayout( new GridLayout( 2, false ) );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
         // Default Search Base Text
-        toolkit.createLabel( parent, "Default Search Base:" );
-        defaultSearchBaseText = toolkit.createText( parent, "" );
-        defaultSearchBaseText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-
-        // Password Hash Text
-        toolkit.createLabel( parent, "Password Hash:" );
-        passwordHashText = toolkit.createText( parent, "" );
-        passwordHashText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-
-        // Sort Vals Text
-        toolkit.createLabel( parent, "Sort Vals:" );
-        sortValsText = toolkit.createText( parent, "" );
-        sortValsText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        toolkit.createLabel( composite, "Default Search Base:" );
+        defaultSearchBaseEntryWidget = new EntryWidget( browserConnection, null, true );
+        defaultSearchBaseEntryWidget.createWidget( composite, toolkit );
+        defaultSearchBaseEntryWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Password Hash
+        createPasswordHashContent( composite, toolkit );
+
+        // Sorted Values Attributes
+        createSortedValuesAttributesContent( composite, toolkit );
+
+        return composite;
+    }
+
+
+    /**
+     * Creates the content for the password hash.
+     *
+     * @param parent the parent composite
+     * @param toolkit the toolkit
+     */
+    private void createPasswordHashContent( Composite parent, FormToolkit toolkit )
+    {
+        // Label
+        Label passwordHashLabel = toolkit.createLabel( parent, "Password Hash:" );
+        passwordHashLabel.setLayoutData( new GridData( SWT.NONE, SWT.TOP, false, false ) );
+
+        // Composite
+        Composite passwordHashComposite = toolkit.createComposite( parent );
+        GridLayout passwordHashCompositeGridLayout = new GridLayout( 3, true );
+        passwordHashCompositeGridLayout.marginHeight = passwordHashCompositeGridLayout.marginWidth = 0;
+        passwordHashComposite.setLayout( passwordHashCompositeGridLayout );
+        passwordHashComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // SHA Checkbox
+        shaCheckbox = toolkit.createButton( passwordHashComposite, "SHA", SWT.CHECK );
+
+        // SSHA Checkbox
+        sshaCheckbox = toolkit.createButton( passwordHashComposite, "SSHA", SWT.CHECK );
+
+        // CRYPT Checkbox
+        cryptCheckbox = toolkit.createButton( passwordHashComposite, "CRYPT", SWT.CHECK );
+
+        // MD5 Checkbox
+        md5Checkbox = toolkit.createButton( passwordHashComposite, "MD5", SWT.CHECK );
+
+        // SMD5 Checkbox
+        smd5Checkbox = toolkit.createButton( passwordHashComposite, "SMD5", SWT.CHECK );
+
+        // CLEARTEXT Checkbox
+        cleartextCheckbox = toolkit.createButton( passwordHashComposite, "CLEARTEXT", SWT.CHECK );
+
+    }
+
+
+    /**
+     * Creates the content for the sorted values attributes.
+     *
+     * @param parent the parent composite
+     * @param toolkit the toolkit
+     */
+    private void createSortedValuesAttributesContent( Composite parent, FormToolkit toolkit )
+    {
+        // Label
+        Label sortedValuesLabel = toolkit.createLabel( parent, "Maintain sorted values for these attributes:" );
+        sortedValuesLabel.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1 ) );
+
+        // Composite
+        Composite sortedValuesComposite = toolkit.createComposite( parent );
+        GridLayout attributesCompositeGridLayout = new GridLayout( 2, false );
+        attributesCompositeGridLayout.marginHeight = attributesCompositeGridLayout.marginWidth = 0;
+        //        attributesCompositeGridLayout.verticalSpacing = attributesCompositeGridLayout.horizontalSpacing = 0;
+        sortedValuesComposite.setLayout( attributesCompositeGridLayout );
+        sortedValuesComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+        // Table and Table Viewer
+        sortedValuesTable = toolkit.createTable( sortedValuesComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+        GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 );
+        gd.heightHint = 20;
+        gd.widthHint = 100;
+        sortedValuesTable.setLayoutData( gd );
+        sortedValuesTableViewer = new TableViewer( sortedValuesTable );
+        sortedValuesTableViewer.setContentProvider( new ArrayContentProvider() );
+        sortedValuesTableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                return OpenLdapConfigurationPlugin.getDefault().getImage(
+                    OpenLdapConfigurationPluginConstants.IMG_ATTRIBUTE );
+            }
+        } );
+        sortedValuesTableViewer.setInput( sortedValuesAttributesList );
+
+        // Add Button
+        addSortedValueButton = toolkit.createButton( sortedValuesComposite, "Add...", SWT.PUSH );
+        addSortedValueButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+        // Delete Button
+        deleteSortedValueButton = toolkit.createButton( sortedValuesComposite, "Delete", SWT.PUSH );
+        deleteSortedValueButton.setEnabled( false );
+        deleteSortedValueButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
     }
 
 
@@ -83,44 +268,221 @@ public class FrontendDatabaseSpecificDet
      */
     public void refresh()
     {
-        if ( database == null )
+        removeListeners();
+
+        if ( database != null )
         {
-            // Blank out all fields
-            // TODO
+            OlcFrontendConfig frontendConfig = getFrontendConfig();
+
+            if ( frontendConfig == null )
+            {
+                // Default Search Base
+                defaultSearchBaseEntryWidget.setInput( null );
+
+                // Password Hash
+                shaCheckbox.setSelection( false );
+                sshaCheckbox.setSelection( false );
+                cryptCheckbox.setSelection( false );
+                md5Checkbox.setSelection( false );
+                smd5Checkbox.setSelection( false );
+                cleartextCheckbox.setSelection( false );
+
+                // Sorted Values Attributes
+                sortedValuesAttributesList.clear();
+                sortedValuesTableViewer.refresh();
+            }
+            else
+            {
+                // Default Search Base
+                String defaultSearchBase = frontendConfig.getOlcDefaultSearchBase();
+
+                if ( Strings.isEmpty( defaultSearchBase ) )
+                {
+                    defaultSearchBaseEntryWidget.setInput( null );
+                }
+                else
+                {
+                    try
+                    {
+                        defaultSearchBaseEntryWidget.setInput( new Dn( defaultSearchBase ) );
+                    }
+                    catch ( LdapInvalidDnException e )
+                    {
+                        // Nothing to do.
+                    }
+                }
+
+                // Password Hash
+                List<String> passwordHashList = frontendConfig.getOlcPasswordHash();
+
+                if ( ( passwordHashList != null ) && ( passwordHashList.size() > 0 ) )
+                {
+                    shaCheckbox.setSelection( passwordHashList.contains( SHA ) );
+                    sshaCheckbox.setSelection( passwordHashList.contains( SSHA ) );
+                    cryptCheckbox.setSelection( passwordHashList.contains( CRYPT ) );
+                    md5Checkbox.setSelection( passwordHashList.contains( MD5 ) );
+                    smd5Checkbox.setSelection( passwordHashList.contains( SMD5 ) );
+                    cleartextCheckbox.setSelection( passwordHashList.contains( CLEARTEXT ) );
+                }
+
+                // Sorted Values Attributes
+                sortedValuesAttributesList.clear();
+
+                List<String> sortVals = frontendConfig.getOlcSortVals();
+
+                for ( String attribute : sortVals )
+                {
+                    sortedValuesAttributesList.add( attribute );
+                }
+                sortedValuesTableViewer.refresh();
+            }
         }
-        else
-        {
-            // Default Search Base Text
-            String defaultSearchBase = database.getOlcDefaultSearchBase();
-            defaultSearchBaseText.setText( ( defaultSearchBase == null ) ? "" : defaultSearchBase ); //$NON-NLS-1$
 
-            // Password Hash Text
-            List<String> passwordHash = database.getOlcPasswordHash();
-            passwordHashText.setText( ( passwordHash == null ) ? "" : concatenate( passwordHash ) ); //$NON-NLS-1$
+        addListeners();
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        defaultSearchBaseEntryWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+
+        sortedValuesTableViewer.addSelectionChangedListener( sortedValuesTableViewerSelectionChangedListener );
+        addSortedValueButton.addSelectionListener( addSortedValueButtonSelectionListener );
+        deleteSortedValueButton.addSelectionListener( deleteSortedValueButtonSelectionListener );
+
+        shaCheckbox.addSelectionListener( dirtySelectionListener );
+        sshaCheckbox.addSelectionListener( dirtySelectionListener );
+        cryptCheckbox.addSelectionListener( dirtySelectionListener );
+        md5Checkbox.addSelectionListener( dirtySelectionListener );
+        smd5Checkbox.addSelectionListener( dirtySelectionListener );
+        cleartextCheckbox.addSelectionListener( dirtySelectionListener );
+    }
+
+
+    /**
+     * Removes the listeners
+     */
+    private void removeListeners()
+    {
+        defaultSearchBaseEntryWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+
+        sortedValuesTableViewer.removeSelectionChangedListener( sortedValuesTableViewerSelectionChangedListener );
+        addSortedValueButton.removeSelectionListener( addSortedValueButtonSelectionListener );
+        deleteSortedValueButton.removeSelectionListener( deleteSortedValueButtonSelectionListener );
+
+        shaCheckbox.removeSelectionListener( dirtySelectionListener );
+        sshaCheckbox.removeSelectionListener( dirtySelectionListener );
+        cryptCheckbox.removeSelectionListener( dirtySelectionListener );
+        md5Checkbox.removeSelectionListener( dirtySelectionListener );
+        smd5Checkbox.removeSelectionListener( dirtySelectionListener );
+        cleartextCheckbox.removeSelectionListener( dirtySelectionListener );
+    }
+
+
+    /**
+     * Gets the frontend config.
+     *
+     * @return the frontend config
+     */
+    private OlcFrontendConfig getFrontendConfig()
+    {
+        if ( database != null )
+        {
+            List<AuxiliaryObjectClass> auxiliaryObjectClassesList = database.getAuxiliaryObjectClasses();
 
-            // Sort Vals Text
-            List<String> sortVals = database.getOlcSortVals();
-            sortValsText.setText( ( sortVals == null ) ? "" : concatenate( sortVals ) ); //$NON-NLS-1$
+            if ( ( auxiliaryObjectClassesList != null ) && ( auxiliaryObjectClassesList.size() > 0 ) )
+            {
+                for ( AuxiliaryObjectClass auxiliaryObjectClass : auxiliaryObjectClassesList )
+                {
+                    if ( auxiliaryObjectClass instanceof OlcFrontendConfig )
+                    {
+                        return ( OlcFrontendConfig ) auxiliaryObjectClass;
+                    }
+                }
+            }
         }
+
+        return null;
     }
 
 
-    private String concatenate( List<String> list )
+    /**
+     * {@inheritDoc}
+     */
+    public void commit( boolean onSave )
     {
-        StringBuilder sb = new StringBuilder();
+        OlcFrontendConfig frontendConfig = getOrCreateFrontendConfig();
 
-        for ( String string : list )
+        if ( frontendConfig != null )
         {
-            sb.append( string );
-            sb.append( ", " );
+            // Default Search Base
+            Dn defaultSearchBase = defaultSearchBaseEntryWidget.getDn();
+
+            if ( defaultSearchBase == null )
+            {
+                frontendConfig.setOlcDefaultSearchBase( null );
+            }
+            else
+            {
+                frontendConfig.setOlcDefaultSearchBase( defaultSearchBase.toString() );
+            }
+
+            // Password Hash
+            frontendConfig.clearOlcPasswordHash();
+
+            if ( shaCheckbox.getSelection() )
+            {
+                frontendConfig.addOlcPasswordHash( SHA );
+            }
+            if ( sshaCheckbox.getSelection() )
+            {
+                frontendConfig.addOlcPasswordHash( SSHA );
+            }
+            if ( cryptCheckbox.getSelection() )
+            {
+                frontendConfig.addOlcPasswordHash( CRYPT );
+            }
+            if ( md5Checkbox.getSelection() )
+            {
+                frontendConfig.addOlcPasswordHash( MD5 );
+            }
+            if ( smd5Checkbox.getSelection() )
+            {
+                frontendConfig.addOlcPasswordHash( SMD5 );
+            }
+            if ( cleartextCheckbox.getSelection() )
+            {
+                frontendConfig.addOlcPasswordHash( CLEARTEXT );
+            }
+
+            // Sorted Values Attributes
+            frontendConfig.clearOlcSortVals();
+            for ( String attribute : sortedValuesAttributesList )
+            {
+                frontendConfig.addOlcSortVals( attribute );
+            }
         }
+    }
+
+
+    /**
+     * Gets the frontend config or creates one if it's not available.
+     *
+     * @return the frontend config
+     */
+    private OlcFrontendConfig getOrCreateFrontendConfig()
+    {
+        OlcFrontendConfig frontendConfig = getFrontendConfig();
 
-        if ( sb.length() > 1 )
+        if ( ( frontendConfig == null ) && ( database != null ) )
         {
-            sb.deleteCharAt( sb.length() - 1 );
-            sb.deleteCharAt( sb.length() - 1 );
+            frontendConfig = new OlcFrontendConfig();
+            database.addAuxiliaryObjectClasses( frontendConfig );
         }
 
-        return sb.toString();
+        return frontendConfig;
     }
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/LdifDatabaseSpecificDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/LdifDatabaseSpecificDetailsBlock.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/LdifDatabaseSpecificDetailsBlock.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/LdifDatabaseSpecificDetailsBlock.java Wed Apr  1 01:01:42 2015
@@ -22,45 +22,53 @@ package org.apache.directory.studio.open
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
+import org.apache.directory.studio.openldap.common.ui.widgets.DirectoryBrowserWidget;
 import org.apache.directory.studio.openldap.config.model.OlcLdifConfig;
 
 
 /**
  * This interface represents a block for None Specific Details.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdifDatabaseSpecificDetailsBlock implements DatabaseSpecificDetailsBlock
+public class LdifDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcLdifConfig>
 {
-    /** The database */
-    private OlcLdifConfig database;
-
     // UI Widgets
-    private Text directoryText;
+    private DirectoryBrowserWidget directoryBrowserWidget;
 
 
     /**
      * Creates a new instance of LdifDatabaseSpecificDetailsBlock.
      * 
+     * @param detailsPage the details page
      * @param database the database
      */
-    public LdifDatabaseSpecificDetailsBlock( OlcLdifConfig database )
+    public LdifDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcLdifConfig database )
     {
-        this.database = database;
+        super( detailsPage, database );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void createFormContent( Composite parent, FormToolkit toolkit )
+    public Composite createBlockContent( Composite parent, FormToolkit toolkit )
     {
-        // Directory Text
-        toolkit.createLabel( parent, "Directory:" );
-        directoryText = toolkit.createText( parent, "" );
-        directoryText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        // Composite
+        Composite composite = toolkit.createComposite( parent );
+        composite.setLayout( new GridLayout() );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Directory Widget
+        toolkit.createLabel( composite, "Directory:" );
+        directoryBrowserWidget = new DirectoryBrowserWidget( "" );
+        directoryBrowserWidget.createWidget( composite, toolkit );
+
+        return composite;
     }
 
 
@@ -69,17 +77,53 @@ public class LdifDatabaseSpecificDetails
      */
     public void refresh()
     {
+        removeListeners();
 
-        if ( database == null )
+        if ( database != null )
         {
-            // Blank out all fields
-            // TODO
+            // Directory Widget
+            String directory = database.getOlcDbDirectory();
+
+            if ( directory != null )
+            {
+                directoryBrowserWidget.setDirectoryPath( directory );
+            }
+            else
+            {
+                directoryBrowserWidget.setDirectoryPath( "" );
+            }
         }
-        else
+
+        addListeners();
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        directoryBrowserWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+    }
+
+
+    /**
+     * Removes the listeners
+     */
+    private void removeListeners()
+    {
+        directoryBrowserWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void commit( boolean onSave )
+    {
+        if ( database != null )
         {
-            // Directory Text
-            String directory = database.getOlcDbDirectory();
-            directoryText.setText( ( directory == null ) ? "" : directory ); //$NON-NLS-1$
+            database.setOlcDbDirectory( directoryBrowserWidget.getDirectoryPath() );
         }
     }
 }

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,394 @@
+/*
+ *  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.databases;
+
+
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+import org.apache.directory.studio.openldap.common.ui.widgets.BooleanWithDefaultWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.DirectoryBrowserWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.UnixPermissionsWidget;
+import org.apache.directory.studio.openldap.config.model.OlcMdbConfig;
+import org.apache.directory.studio.openldap.config.model.widgets.IndicesWidget;
+
+
+/**
+ * This class implements a block for Memory-Mapped DB Specific Details.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MdbDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcMdbConfig>
+{
+    // UI Widgets
+    private DirectoryBrowserWidget directoryBrowserWidget;
+    private UnixPermissionsWidget modeUnixPermissionsWidget;
+    private IndicesWidget indicesWidget;
+    private Text maxReadersText;
+    private Text maxSizeText;
+    private Text searchStackDepthText;
+    private Text checkpointText;
+    private BooleanWithDefaultWidget disableSynchronousDatabaseWritesBooleanWithDefaultWidget;
+
+
+    /**
+     * Creates a new instance of MdbDatabaseSpecificDetailsBlock.
+     * 
+     * @param databaseDetailsPage the database details page 
+     * @param database the database
+     * @param browserConnection the connection
+     */
+    public MdbDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcMdbConfig database,
+        IBrowserConnection browserConnection )
+    {
+        super( detailsPage, database, browserConnection );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Composite createBlockContent( Composite parent, FormToolkit toolkit )
+    {
+        // Composite
+        Composite composite = toolkit.createComposite( parent );
+        composite.setLayout( new GridLayout() );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        createDatabaseConfigurationSection( composite, toolkit );
+        createDatabaseIndexesSection( composite, toolkit );
+        createDatabaseLimitsSection( composite, toolkit );
+        createDatabaseOptionsSection( composite, toolkit );
+
+        return composite;
+    }
+
+
+    /**
+     * Creates the database configuration section. We manage the following configuration elements :
+     * <ul>
+     * <li>Directory : the directory on disk where the file will be stored</li>
+     * <li>mode : the file mode for this directory</li>
+     * </ul>
+     *
+     * @param parent the parent composite
+     * @param toolkit the toolkit
+     */
+    private void createDatabaseConfigurationSection( Composite parent, FormToolkit toolkit )
+    {
+        // Database Configuration Section
+        Section databaseConfigurationSection = toolkit.createSection( parent, Section.TWISTIE );
+        databaseConfigurationSection.setText( "Database Configuration" );
+        databaseConfigurationSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        Composite databaseConfigurationComposite = toolkit.createComposite( databaseConfigurationSection );
+        toolkit.paintBordersFor( databaseConfigurationComposite );
+        databaseConfigurationComposite.setLayout( new GridLayout( 2, false ) );
+        databaseConfigurationSection.setClient( databaseConfigurationComposite );
+
+        // Directory Text
+        toolkit.createLabel( databaseConfigurationComposite, "Directory:" );
+        Composite directoryComposite = toolkit.createComposite( databaseConfigurationComposite );
+        GridLayout directoryCompositeGridLayout = new GridLayout( 2, false );
+        directoryCompositeGridLayout.marginHeight = directoryCompositeGridLayout.marginWidth = 0;
+        directoryCompositeGridLayout.verticalSpacing = 0;
+        directoryComposite.setLayout( directoryCompositeGridLayout );
+        directoryComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        directoryBrowserWidget = new DirectoryBrowserWidget( "" );
+        directoryBrowserWidget.createWidget( directoryComposite, toolkit );
+
+        // Mode Text
+        toolkit.createLabel( databaseConfigurationComposite, "Mode:" );
+        modeUnixPermissionsWidget = new UnixPermissionsWidget();
+        modeUnixPermissionsWidget.create( databaseConfigurationComposite, toolkit );
+        modeUnixPermissionsWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+    }
+
+
+    /**
+     * Creates the database indexes section.
+     *
+     * @param parent the parent composite
+     * @param toolkit the toolkit
+     */
+    private void createDatabaseIndexesSection( Composite parent, FormToolkit toolkit )
+    {
+        // Database Indices Section
+        Section databaseIndexesSection = toolkit.createSection( parent, Section.TWISTIE );
+        databaseIndexesSection.setText( "Database Indices" );
+        databaseIndexesSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        Composite databaseIndexesComposite = toolkit.createComposite( databaseIndexesSection );
+        toolkit.paintBordersFor( databaseIndexesComposite );
+        databaseIndexesComposite.setLayout( new GridLayout( 2, false ) );
+        databaseIndexesSection.setClient( databaseIndexesComposite );
+
+        // Indices Widget
+        indicesWidget = new IndicesWidget( browserConnection );
+        indicesWidget.createWidget( databaseIndexesComposite, toolkit );
+        indicesWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+    }
+
+
+    /**
+     * Creates the database limits section.
+     *
+     * @param parent the parent composite
+     * @param toolkit the toolkit
+     */
+    private void createDatabaseLimitsSection( Composite parent, FormToolkit toolkit )
+    {
+        // Database Limits Section
+        Section databaseLimitsSection = toolkit.createSection( parent, Section.TWISTIE );
+        databaseLimitsSection.setText( "Database Limits" );
+        databaseLimitsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        Composite databaseLimitsComposite = toolkit.createComposite( databaseLimitsSection );
+        toolkit.paintBordersFor( databaseLimitsComposite );
+        databaseLimitsComposite.setLayout( new GridLayout( 2, false ) );
+        databaseLimitsSection.setClient( databaseLimitsComposite );
+
+        // Max Readers Text
+        toolkit.createLabel( databaseLimitsComposite, "Maximum Readers:" );
+        maxReadersText = createIntegerText( toolkit, databaseLimitsComposite );
+        maxReadersText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Max Size Text
+        toolkit.createLabel( databaseLimitsComposite, "Maximum Size:" );
+        maxSizeText = createIntegerText( toolkit, databaseLimitsComposite );
+        maxSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Search Stack Depth Text
+        toolkit.createLabel( databaseLimitsComposite, "Search Stack Depth:" );
+        searchStackDepthText = createIntegerText( toolkit, databaseLimitsComposite );
+        searchStackDepthText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Checkpoint Text
+        toolkit.createLabel( databaseLimitsComposite, "Checkpoint Interval:" );
+        checkpointText = toolkit.createText( databaseLimitsComposite, "" );
+        checkpointText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+    }
+
+
+    /**
+     * Creates the database options section.
+     *
+     * @param parent the parent composite
+     * @param toolkit the toolkit
+     */
+    private void createDatabaseOptionsSection( Composite parent, FormToolkit toolkit )
+    {
+        // Database Options Section
+        Section databaseOptionsSection = toolkit.createSection( parent, Section.TWISTIE );
+        databaseOptionsSection.setText( "Database Options" );
+        databaseOptionsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        Composite databaseOptionsComposite = toolkit.createComposite( databaseOptionsSection );
+        toolkit.paintBordersFor( databaseOptionsComposite );
+        databaseOptionsComposite.setLayout( new GridLayout( 2, false ) );
+        databaseOptionsSection.setClient( databaseOptionsComposite );
+
+        // Disable Synchronous Database Writes Widget
+        toolkit.createLabel( databaseOptionsComposite, "Disable Synchronous Database Writes:" );
+        disableSynchronousDatabaseWritesBooleanWithDefaultWidget = new BooleanWithDefaultWidget( false );
+        disableSynchronousDatabaseWritesBooleanWithDefaultWidget.create( databaseOptionsComposite, toolkit );
+        disableSynchronousDatabaseWritesBooleanWithDefaultWidget.getControl().setLayoutData(
+            new GridData( SWT.FILL, SWT.NONE, true, false ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void refresh()
+    {
+        removeListeners();
+
+        if ( database != null )
+        {
+            // Directory Text
+            String directory = database.getOlcDbDirectory();
+            directoryBrowserWidget.setDirectoryPath( ( directory == null ) ? "" : directory );
+
+            // Mode Text
+            String mode = database.getOlcDbMode();
+            modeUnixPermissionsWidget.setValue( mode );
+
+            // Indices Text
+            indicesWidget.setIndices( database.getOlcDbIndex() );
+
+            // Max Readers Text
+            Integer maxReaders = database.getOlcDbMaxReaders();
+            maxReadersText.setText( ( maxReaders == null ) ? "" : "" + maxReaders ); //$NON-NLS-1$
+
+            // Max Size Text
+            Long maxSize = database.getOlcDbMaxSize();
+            maxSizeText.setText( ( maxSize == null ) ? "" : "" + maxSize ); //$NON-NLS-1$
+
+            // Search Stack Depth Text
+            Integer searchStackDepth = database.getOlcDbSearchStack();
+            searchStackDepthText.setText( ( searchStackDepth == null ) ? "" : "" + searchStackDepth ); //$NON-NLS-1$
+
+            // Checkpoint Text
+            String checkpoint = database.getOlcDbCheckpoint();
+            checkpointText.setText( ( checkpoint == null ) ? "" : checkpoint ); //$NON-NLS-1$
+
+            // Disable Synchronous Database Writes Widget
+            disableSynchronousDatabaseWritesBooleanWithDefaultWidget.setValue( database.getOlcDbNoSync() );
+        }
+
+        addListeners();
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        directoryBrowserWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+        modeUnixPermissionsWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+
+        indicesWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+
+        maxReadersText.addModifyListener( dirtyModifyListener );
+        maxSizeText.addModifyListener( dirtyModifyListener );
+        searchStackDepthText.addModifyListener( dirtyModifyListener );
+        checkpointText.addModifyListener( dirtyModifyListener );
+
+        disableSynchronousDatabaseWritesBooleanWithDefaultWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+    }
+
+
+    /**
+     * Removes the listeners
+     */
+    private void removeListeners()
+    {
+        directoryBrowserWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+        modeUnixPermissionsWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+
+        indicesWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+
+        maxReadersText.removeModifyListener( dirtyModifyListener );
+        maxSizeText.removeModifyListener( dirtyModifyListener );
+        searchStackDepthText.removeModifyListener( dirtyModifyListener );
+        checkpointText.removeModifyListener( dirtyModifyListener );
+
+        disableSynchronousDatabaseWritesBooleanWithDefaultWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+    }
+
+
+    /**
+     * Creates a Text that can be used to enter an integer.
+     *
+     * @param toolkit the toolkit
+     * @param parent the parent
+     * @return a Text that can be used to enter a port number
+     */
+    protected Text createIntegerText( FormToolkit toolkit, Composite parent )
+    {
+        Text integerText = toolkit.createText( parent, "" ); //$NON-NLS-1$
+        integerText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        return integerText;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void commit( boolean onSave )
+    {
+        // Directory Text
+        String directory = directoryBrowserWidget.getDirectoryPath();
+
+        if ( Strings.isEmpty( directory ) )
+        {
+            database.setOlcDbDirectory( null );
+        }
+        else
+        {
+            database.setOlcDbDirectory( directory );
+        }
+
+        directoryBrowserWidget.saveDialogSettings();
+
+        // Mode Text
+        database.setOlcDbMode( modeUnixPermissionsWidget.getValue() );
+
+        // Indices Widget
+        database.clearOlcDbIndex();
+        for ( String index : indicesWidget.getIndices() )
+        {
+            database.addOlcDbIndex( index );
+        }
+
+        // Cache Size Text
+        try
+        {
+            database.setOlcDbMaxReaders( Integer.parseInt( maxReadersText.getText() ) );
+        }
+        catch ( NumberFormatException e )
+        {
+            database.setOlcDbMaxReaders( null );
+        }
+
+        // Cache Free Text
+        try
+        {
+            database.setOlcDbMaxSize( Long.parseLong( maxSizeText.getText() ) );
+        }
+        catch ( NumberFormatException e )
+        {
+            database.setOlcDbMaxSize( null );
+        }
+
+        // Search Stack Depth Text
+        try
+        {
+            database.setOlcDbSearchStack( Integer.parseInt( searchStackDepthText.getText() ) );
+        }
+        catch ( NumberFormatException e )
+        {
+            database.setOlcDbSearchStack( null );
+        }
+
+        // Checkpoint Interval Text
+        database.setOlcDbCheckpoint( checkpointText.getText() );
+
+        // Disable Synchronous Database Writes Widget
+        database.setOlcDbNoSync( disableSynchronousDatabaseWritesBooleanWithDefaultWidget.getValue() );
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/NullDatabaseSpecificDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/NullDatabaseSpecificDetailsBlock.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/NullDatabaseSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/NullDatabaseSpecificDetailsBlock.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,128 @@
+/*
+ *  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.databases;
+
+
+import org.eclipse.swt.SWT;
+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.ui.forms.widgets.FormToolkit;
+
+import org.apache.directory.studio.openldap.config.model.OlcNullConfig;
+
+
+/**
+ * This interface represents a block for Null Specific Details.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class NullDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcNullConfig>
+{
+    // UI Widgets
+    private Button allowBindCheckbox;
+
+
+    /**
+     * Creates a new instance of NullDatabaseSpecificDetailsBlock.
+     * 
+     * @param detailsPage the details page
+     * @param database the database
+     */
+    public NullDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcNullConfig database )
+    {
+        super( detailsPage, database );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Composite createBlockContent( Composite parent, FormToolkit toolkit )
+    {
+        // Composite
+        Composite composite = toolkit.createComposite( parent );
+        composite.setLayout( new GridLayout() );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Allow Bind
+        allowBindCheckbox = toolkit.createButton( composite, "Allow bind to the database", SWT.CHECK );
+
+        return composite;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void refresh()
+    {
+        removeListeners();
+
+        if ( database != null )
+        {
+            // Allow Bind
+            Boolean allowBind = database.getOlcDbBindAllowed();
+
+            if ( allowBind != null )
+            {
+                allowBindCheckbox.setSelection( allowBind );
+            }
+            else
+            {
+                allowBindCheckbox.setSelection( false );
+            }
+        }
+
+        addListeners();
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        allowBindCheckbox.addSelectionListener( dirtySelectionListener );
+    }
+
+
+    /**
+     * Removes the listeners
+     */
+    private void removeListeners()
+    {
+        allowBindCheckbox.removeSelectionListener( dirtySelectionListener );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void commit( boolean onSave )
+    {
+        if ( database != null )
+        {
+            // Allow Bind
+            database.setOlcDbBindAllowed( allowBindCheckbox.getSelection() );
+        }
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/RelayDatabaseSpecificDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/RelayDatabaseSpecificDetailsBlock.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/RelayDatabaseSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/RelayDatabaseSpecificDetailsBlock.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,135 @@
+/*
+ *  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.databases;
+
+
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import org.apache.directory.studio.openldap.common.ui.widgets.EntryWidget;
+import org.apache.directory.studio.openldap.config.model.OlcRelayConfig;
+
+
+/**
+ * This interface represents a block for Relay Specific Details.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class RelayDatabaseSpecificDetailsBlock extends AbstractDatabaseSpecificDetailsBlock<OlcRelayConfig>
+{
+    // UI Widgets
+    private EntryWidget relayEntryWidget;
+
+
+    /**
+     * Creates a new instance of NullDatabaseSpecificDetailsBlock.
+     * 
+     * @param detailsPage the details page
+     * @param database the database
+     * @param browserConnection the connection
+     */
+    public RelayDatabaseSpecificDetailsBlock( DatabasesDetailsPage detailsPage, OlcRelayConfig database,
+        IBrowserConnection browserConnection )
+    {
+        super( detailsPage, database, browserConnection );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Composite createBlockContent( Composite parent, FormToolkit toolkit )
+    {
+        // Composite
+        Composite composite = toolkit.createComposite( parent );
+        composite.setLayout( new GridLayout( 3, false ) );
+        composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Relay
+        toolkit.createLabel( composite, "Relay:" );
+        relayEntryWidget = new EntryWidget( browserConnection );
+        relayEntryWidget.createWidget( composite, toolkit );
+        relayEntryWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        return composite;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void refresh()
+    {
+        removeListeners();
+
+        if ( database != null )
+        {
+            // Relay
+            relayEntryWidget.setInput( database.getOlcRelay() );
+        }
+
+        addListeners();
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        relayEntryWidget.addWidgetModifyListener( dirtyWidgetModifyListener );
+    }
+
+
+    /**
+     * Removes the listeners
+     */
+    private void removeListeners()
+    {
+        relayEntryWidget.removeWidgetModifyListener( dirtyWidgetModifyListener );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void commit( boolean onSave )
+    {
+        if ( database != null )
+        {
+            // Relay
+            Dn relay = relayEntryWidget.getDn();
+
+            if ( ( relay != null ) & ( !Dn.EMPTY_DN.equals( relay ) ) )
+            {
+                database.setOlcRelay( relay );
+            }
+            else
+            {
+                database.setOlcRelay( null );
+            }
+        }
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractOverlayDialogConfigurationBlock.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/AbstractOverlayDialogConfigurationBlock.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractOverlayDialogConfigurationBlock.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AbstractOverlayDialogConfigurationBlock.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,104 @@
+/*
+ *  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 org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+
+import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig;
+
+
+/**
+ * This interface represents a block for overlay configuration.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractOverlayDialogConfigurationBlock<Overlay extends OlcOverlayConfig> implements
+    OverlayDialogConfigurationBlock<Overlay>
+{
+    /** The dialog */
+    protected OverlayDialog dialog;
+
+    /** The overlay */
+    protected Overlay overlay;
+
+    /** The connection */
+    protected IBrowserConnection browserConnection;
+
+
+    /**
+     * Creates a new instance of AbstractOverlayConfigurationBlock.
+     *
+     * @param dialog the dialog
+     */
+    public AbstractOverlayDialogConfigurationBlock( OverlayDialog dialog )
+    {
+        this.dialog = dialog;
+    }
+
+
+    /**
+     * Creates a new instance of AbstractOverlayConfigurationBlock.
+     *
+     * @param dialog the dialog
+     * @param browserConnection the connection
+     */
+    public AbstractOverlayDialogConfigurationBlock( OverlayDialog dialog, IBrowserConnection browserConnection )
+    {
+        this.dialog = dialog;
+        this.browserConnection = browserConnection;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public OverlayDialog getDialog()
+    {
+        return dialog;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Overlay getOverlay()
+    {
+        return overlay;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDialog( OverlayDialog dialog )
+    {
+        this.dialog = dialog;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setOverlay( Overlay overlay )
+    {
+        this.overlay = overlay;
+    }
+}