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 [6/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...

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/DbConfigurationDialog.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/DbConfigurationDialog.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/DbConfigurationDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/DbConfigurationDialog.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,166 @@
+/*
+ *  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.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils;
+
+
+/**
+ * The DbConfigurationDialog is used to edit the (BDB) database configuration.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DbConfigurationDialog extends Dialog
+{
+    /** The OS specific line separator character */
+    private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
+
+    /** The configuration */
+    private String[] configuration;
+
+    // UI widgets
+    private Text text;
+
+
+    /**
+     * Creates a new instance of DbConfigurationDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param initialConfiguration the initial configuration
+     */
+    public DbConfigurationDialog( Shell parentShell, String[] initialConfiguration )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.configuration = initialConfiguration;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( "Database Configuration Editor" );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+     */
+    protected void okPressed()
+    {
+        if ( ( text.getText() != null ) && ( text.getText().length() > 0 ) )
+        {
+            List<String> newConfiguration = new ArrayList<String>();
+
+            String[] splittedConfiguration = text.getText().split( LINE_SEPARATOR );
+            for ( int i = 0; i < splittedConfiguration.length; i++ )
+            {
+                newConfiguration.add( "{" + i + "}" + splittedConfiguration[i] );
+            }
+
+            configuration = newConfiguration.toArray( new String[0] );
+        }
+
+        super.okPressed();
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        // create composite
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+
+        // text widget
+        text = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+        gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        text.setLayoutData( gd );
+
+        text.setText( prepareInitialConfiguration() );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * Prepares the initial configuration string.
+     *
+     * @return the initial configuration string
+     */
+    private String prepareInitialConfiguration()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        if ( ( configuration != null ) && ( configuration.length > 0 ) )
+        {
+            for ( String line : configuration )
+            {
+                sb.append( OpenLdapConfigurationPluginUtils.stripOrderingPrefix( line ) );
+                sb.append( LINE_SEPARATOR );
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Gets the configuration.
+     * 
+     * @return the configuration
+     */
+    public String[] getConfiguration()
+    {
+        return configuration;
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/IndexDialog.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/IndexDialog.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/IndexDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/IndexDialog.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,553 @@
+/*
+ *  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.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+import org.apache.directory.studio.openldap.common.ui.dialogs.AttributeDialog;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
+import org.apache.directory.studio.openldap.config.model.OlcDbIndex;
+import org.apache.directory.studio.openldap.config.model.OlcDbIndexTypeEnum;
+
+
+/**
+ * The IndexDialog is used to edit an index configuration.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class IndexDialog extends Dialog
+{
+    /** The index */
+    private OlcDbIndex index;
+
+    /** The new index */
+    private OlcDbIndex newIndex;
+
+    /** The connection */
+    private IBrowserConnection browserConnection;
+
+    /** The attributes list */
+    private List<String> attributes = new ArrayList<String>();
+
+    // UI widgets
+    private Button okButton;
+    private Button attributesCheckbox;
+    private Table table;
+    private TableViewer tableViewer;
+    private Button addButton;
+    private Button deleteButton;
+    private Button defaultCheckbox;
+    private Button presCheckbox;
+    private Button eqCheckbox;
+    private Button approxCheckbox;
+    private Button subCheckbox;
+    private Button noLangCheckbox;
+    private Button noSubtypesCheckbox;
+    private Button subInitialCheckbox;
+    private Button subAnyCheckbox;
+    private Button subFinalCheckbox;
+
+    // Listeners
+    private SelectionListener attributesCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            table.setEnabled( true );
+            addButton.setEnabled( true );
+            deleteButton.setEnabled( !tableViewer.getSelection().isEmpty() );
+            checkAndUpdateOkButtonEnableState();
+        }
+    };
+    private ISelectionChangedListener tableViewerSelectionChangedListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            deleteButton.setEnabled( !tableViewer.getSelection().isEmpty() );
+        }
+    };
+    private SelectionListener addButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            AttributeDialog dialog = new AttributeDialog( addButton.getShell(), browserConnection );
+            if ( dialog.open() == AttributeDialog.OK )
+            {
+                String attribute = dialog.getAttribute();
+
+                if ( !attributes.contains( attribute ) )
+                {
+                    attributes.add( attribute );
+                    tableViewer.refresh();
+                    tableViewer.setSelection( new StructuredSelection( attribute ) );
+                    checkAndUpdateOkButtonEnableState();
+                }
+            }
+        }
+    };
+    private SelectionListener deleteButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            StructuredSelection selection = ( StructuredSelection ) tableViewer.getSelection();
+
+            if ( !selection.isEmpty() )
+            {
+                String selectedAttribute = ( String ) selection.getFirstElement();
+
+                attributes.remove( selectedAttribute );
+                tableViewer.refresh();
+                checkAndUpdateOkButtonEnableState();
+            }
+        }
+    };
+    private SelectionListener defaultCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            disableAttributesTableAndButtons();
+            checkAndUpdateOkButtonEnableState();
+        }
+    };
+    private SelectionListener subCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            setSelectionForSubCheckboxes( subCheckbox.getSelection() );
+            checkAndUpdateOkButtonEnableState();
+        }
+    };
+    private SelectionListener checkOkButtonSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            checkAndUpdateOkButtonEnableState();
+        };
+    };
+    private SelectionListener checkSubCheckboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            checkAndUpdateSubCheckboxSelectionState();
+            checkAndUpdateOkButtonEnableState();
+        }
+    };
+
+
+    /**
+     * Creates a new instance of OverlayDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param index the index
+     * @param browserConnection the connection
+     */
+    public IndexDialog( Shell parentShell, OlcDbIndex index, IBrowserConnection browserConnection )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.index = index;
+        this.browserConnection = browserConnection;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( "Index" );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+
+        checkAndUpdateOkButtonEnableState();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void okPressed()
+    {
+        // Creating the new index
+        newIndex = new OlcDbIndex();
+
+        // Default
+        if ( defaultCheckbox.getSelection() )
+        {
+            newIndex.setDefault( true );
+        }
+        else
+        {
+            // Attributes
+            if ( attributes.size() > 0 )
+            {
+                for ( String attribute : attributes )
+                {
+                    newIndex.addAttribute( attribute );
+                }
+            }
+        }
+
+        // Index types
+        if ( presCheckbox.getSelection() )
+        {
+            newIndex.addIndexType( OlcDbIndexTypeEnum.PRES );
+        }
+        if ( eqCheckbox.getSelection() )
+        {
+            newIndex.addIndexType( OlcDbIndexTypeEnum.EQ );
+        }
+        if ( approxCheckbox.getSelection() )
+        {
+            newIndex.addIndexType( OlcDbIndexTypeEnum.APPROX );
+        }
+        if ( ( subCheckbox.getSelection() ) && ( !subCheckbox.getGrayed() ) )
+        {
+            newIndex.addIndexType( OlcDbIndexTypeEnum.SUB );
+        }
+        else
+        {
+            if ( subInitialCheckbox.getSelection() )
+            {
+                newIndex.addIndexType( OlcDbIndexTypeEnum.SUBINITIAL );
+            }
+            if ( subAnyCheckbox.getSelection() )
+            {
+                newIndex.addIndexType( OlcDbIndexTypeEnum.SUBANY );
+            }
+            if ( subFinalCheckbox.getSelection() )
+            {
+                newIndex.addIndexType( OlcDbIndexTypeEnum.SUBFINAL );
+            }
+        }
+        if ( noLangCheckbox.getSelection() )
+        {
+            newIndex.addIndexType( OlcDbIndexTypeEnum.NOLANG );
+        }
+        if ( noSubtypesCheckbox.getSelection() )
+        {
+            newIndex.addIndexType( OlcDbIndexTypeEnum.NOSUBTYPES );
+        }
+
+        super.okPressed();
+    }
+
+
+    /**
+     * @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 );
+
+        createAttributesGroup( composite );
+        createIndicesGroup( composite );
+
+        initFromIndex();
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * Creates the attributes group.
+     *
+     * @param parent the parent composite
+     */
+    private void createAttributesGroup( Composite parent )
+    {
+        // Attributes Group
+        Group attributesGroup = BaseWidgetUtils.createGroup( parent, "Attributes", 1 );
+        GridLayout attributesGroupGridLayout = new GridLayout( 2, false );
+        attributesGroup.setLayout( attributesGroupGridLayout );
+        attributesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Attributes Checkbox
+        attributesCheckbox = BaseWidgetUtils.createRadiobutton( attributesGroup, "", 1 );
+        attributesCheckbox.setLayoutData( new GridData( SWT.NONE, SWT.CENTER, false, false ) );
+        attributesCheckbox.setSelection( true );
+        attributesCheckbox.addSelectionListener( attributesCheckboxSelectionListener );
+
+        Composite attributesComposite = new Composite( attributesGroup, SWT.NONE );
+        GridLayout attributesCompositeGridLayout = new GridLayout( 2, false );
+        attributesCompositeGridLayout.marginHeight = attributesCompositeGridLayout.marginWidth = 0;
+        attributesCompositeGridLayout.verticalSpacing = attributesCompositeGridLayout.horizontalSpacing = 0;
+        attributesComposite.setLayout( attributesCompositeGridLayout );
+        attributesComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Table and Table Viewer
+        table = new Table( attributesComposite, 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;
+        table.setLayoutData( gd );
+        tableViewer = new TableViewer( table );
+        tableViewer.setContentProvider( new ArrayContentProvider() );
+        tableViewer.setLabelProvider( new LabelProvider()
+        {
+            public Image getImage( Object element )
+            {
+                return OpenLdapConfigurationPlugin.getDefault().getImage(
+                    OpenLdapConfigurationPluginConstants.IMG_ATTRIBUTE );
+            }
+        } );
+        tableViewer.setInput( attributes );
+        tableViewer.addSelectionChangedListener( tableViewerSelectionChangedListener );
+
+        // Add Button
+        addButton = BaseWidgetUtils.createButton( attributesComposite, "Add...", 1 );
+        addButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        addButton.addSelectionListener( addButtonSelectionListener );
+
+        // Delete Button
+        deleteButton = BaseWidgetUtils.createButton( attributesComposite, "Delete", 1 );
+        deleteButton.setEnabled( false );
+        deleteButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+        deleteButton.addSelectionListener( deleteButtonSelectionListener );
+
+        // Attributes Checkbox
+        defaultCheckbox = BaseWidgetUtils.createRadiobutton( attributesGroup, "  Default", 2 );
+        defaultCheckbox.addSelectionListener( defaultCheckboxSelectionListener );
+    }
+
+
+    /**
+     * Creates the indices group.
+     *
+     * @param parent the parent composite
+     */
+    private void createIndicesGroup( Composite parent )
+    {
+        // Indices Group
+        Group indicesGroup = BaseWidgetUtils.createGroup( parent, "Indices", 1 );
+        GridLayout indicesGroupGridLayout = new GridLayout( 3, true );
+        indicesGroupGridLayout.verticalSpacing = indicesGroupGridLayout.horizontalSpacing = 0;
+        indicesGroup.setLayout( indicesGroupGridLayout );
+        indicesGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        // Pres Checkbox
+        presCheckbox = BaseWidgetUtils.createCheckbox( indicesGroup, "pres", 1 );
+        presCheckbox.addSelectionListener( checkOkButtonSelectionListener );
+
+        // Eq Checkbox
+        eqCheckbox = BaseWidgetUtils.createCheckbox( indicesGroup, "eq", 1 );
+        eqCheckbox.addSelectionListener( checkOkButtonSelectionListener );
+
+        // Approx Checkbox
+        approxCheckbox = BaseWidgetUtils.createCheckbox( indicesGroup, "approx", 1 );
+        approxCheckbox.addSelectionListener( checkOkButtonSelectionListener );
+
+        // Sub Checkbox
+        subCheckbox = BaseWidgetUtils.createCheckbox( indicesGroup, "sub", 1 );
+        subCheckbox.addSelectionListener( subCheckboxSelectionListener );
+
+        // NoLang Checkbox
+        noLangCheckbox = BaseWidgetUtils.createCheckbox( indicesGroup, "nolang", 1 );
+        noLangCheckbox.addSelectionListener( checkOkButtonSelectionListener );
+
+        // NoSybtypes Checkbox
+        noSubtypesCheckbox = BaseWidgetUtils.createCheckbox( indicesGroup, "nosubtypes", 1 );
+        noSubtypesCheckbox.addSelectionListener( checkOkButtonSelectionListener );
+
+        // Sub Composite
+        Composite subComposite = new Composite( indicesGroup, SWT.NONE );
+        GridLayout subCompositeGridLayout = new GridLayout( 2, false );
+        subCompositeGridLayout.marginHeight = subCompositeGridLayout.marginWidth = 0;
+        subCompositeGridLayout.verticalSpacing = subCompositeGridLayout.horizontalSpacing = 0;
+        subComposite.setLayout( subCompositeGridLayout );
+
+        // SubInitial Checkbox
+        BaseWidgetUtils.createRadioIndent( subComposite, 1 );
+        subInitialCheckbox = BaseWidgetUtils.createCheckbox( subComposite, "subinitial", 1 );
+        subInitialCheckbox.addSelectionListener( checkSubCheckboxSelectionListener );
+
+        // SubAny Checkbox
+        BaseWidgetUtils.createRadioIndent( subComposite, 1 );
+        subAnyCheckbox = BaseWidgetUtils.createCheckbox( subComposite, "subany", 1 );
+        subAnyCheckbox.addSelectionListener( checkSubCheckboxSelectionListener );
+
+        // SubFinal Checkbox
+        BaseWidgetUtils.createRadioIndent( subComposite, 1 );
+        subFinalCheckbox = BaseWidgetUtils.createCheckbox( subComposite, "subfinal", 1 );
+        subFinalCheckbox.addSelectionListener( checkSubCheckboxSelectionListener );
+    }
+
+
+    /**
+     * Disables the attributes table and buttons.
+     */
+    private void disableAttributesTableAndButtons()
+    {
+        table.setEnabled( false );
+        addButton.setEnabled( false );
+        deleteButton.setEnabled( false );
+    }
+
+
+    /**
+     * Sets the selection for sub checkboxes.
+     *
+     * @param selection the selection
+     */
+    private void setSelectionForSubCheckboxes( boolean selection )
+    {
+        subCheckbox.setGrayed( false );
+        subInitialCheckbox.setSelection( selection );
+        subAnyCheckbox.setSelection( selection );
+        subFinalCheckbox.setSelection( selection );
+    }
+
+
+    /**
+     * Verifies and updates the selection state for the 'sub' checkbox.
+     */
+    private void checkAndUpdateSubCheckboxSelectionState()
+    {
+        boolean atLeastOneSelected = subInitialCheckbox.getSelection()
+            || subAnyCheckbox.getSelection() || subFinalCheckbox.getSelection();
+        boolean allSelected = subInitialCheckbox.getSelection()
+            && subAnyCheckbox.getSelection() && subFinalCheckbox.getSelection();
+        subCheckbox.setGrayed( atLeastOneSelected && !allSelected );
+        subCheckbox.setSelection( atLeastOneSelected );
+    }
+
+
+    /**
+     * Inits the UI from the index
+     */
+    private void initFromIndex()
+    {
+        if ( index != null )
+        {
+            // Attributes
+            List<String> attributes = index.getAttributes();
+
+            if ( ( attributes != null ) && ( attributes.size() > 0 ) )
+            {
+                this.attributes.addAll( attributes );
+                tableViewer.refresh();
+            }
+
+            // Default
+            if ( index.isDefault() )
+            {
+                attributesCheckbox.setSelection( false );
+                disableAttributesTableAndButtons();
+                defaultCheckbox.setSelection( true );
+            }
+
+            // Index types
+            List<OlcDbIndexTypeEnum> indexTypes = index.getIndexTypes();
+
+            if ( ( indexTypes != null ) && ( indexTypes.size() > 0 ) )
+            {
+                presCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.PRES ) );
+                eqCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.EQ ) );
+                approxCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.APPROX ) );
+                if ( indexTypes.contains( OlcDbIndexTypeEnum.SUB ) )
+                {
+                    subCheckbox.setSelection( true );
+                    setSelectionForSubCheckboxes( indexTypes.contains( OlcDbIndexTypeEnum.SUB ) );
+                }
+                else
+                {
+                    subInitialCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.SUBINITIAL ) );
+                    subAnyCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.SUBANY ) );
+                    subFinalCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.SUBFINAL ) );
+                    checkAndUpdateSubCheckboxSelectionState();
+                }
+                noLangCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.NOLANG ) );
+                noSubtypesCheckbox.setSelection( indexTypes.contains( OlcDbIndexTypeEnum.NOSUBTYPES ) );
+            }
+        }
+    }
+
+
+    /**
+     * Checks and updates the OK button 'enable' state.
+     */
+    private void checkAndUpdateOkButtonEnableState()
+    {
+        boolean enableOkButton = true;
+
+        if ( defaultCheckbox.getSelection() )
+        {
+            enableOkButton = presCheckbox.getSelection() || eqCheckbox.getSelection() || approxCheckbox.getSelection()
+                || subCheckbox.getSelection() || subInitialCheckbox.getSelection() || subAnyCheckbox.getSelection()
+                || subFinalCheckbox.getSelection() || noLangCheckbox.getSelection()
+                || noSubtypesCheckbox.getSelection();
+        }
+        else
+        {
+            enableOkButton = attributes.size() > 0;
+        }
+
+        okButton.setEnabled( enableOkButton );
+    }
+
+
+    /**
+     * Gets the new index.
+     *
+     * @return the new index
+     */
+    public OlcDbIndex getNewIndex()
+    {
+        return newIndex;
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayDialog.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/OverlayDialog.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayDialog.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayDialog.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,530 @@
+/*
+ *  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.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+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.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.AccessLogOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.AuditLogOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.MemberOfOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.PasswordPolicyOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.ReferentialIntegrityOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.RewriteRemapOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.SyncProvOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.editor.dialogs.overlays.ValueSortingOverlayConfigurationBlock;
+import org.apache.directory.studio.openldap.config.model.OlcAccessLogConfig;
+import org.apache.directory.studio.openldap.config.model.OlcAuditlogConfig;
+import org.apache.directory.studio.openldap.config.model.OlcMemberOf;
+import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig;
+import org.apache.directory.studio.openldap.config.model.OlcPPolicyConfig;
+import org.apache.directory.studio.openldap.config.model.OlcRefintConfig;
+import org.apache.directory.studio.openldap.config.model.OlcRwmConfig;
+import org.apache.directory.studio.openldap.config.model.OlcSyncProvConfig;
+import org.apache.directory.studio.openldap.config.model.OlcValSortConfig;
+
+
+/**
+ * The OverlayDialog is used to edit the configuration of an overlay.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OverlayDialog extends Dialog
+{
+    /** The instance */
+    private OverlayDialog instance;
+
+    /** The flag to allow the overlay type selection */
+    private boolean allowOverlayTypeSelection;
+
+    /** The overlay configuration */
+    private OlcOverlayConfig overlay;
+
+    /** The configuration block */
+    private OverlayDialogConfigurationBlock<? extends OlcOverlayConfig> configurationBlock;
+
+    /** The connection */
+    private IBrowserConnection browserConnection;
+
+    // UI widgets
+    private Combo overlayTypeCombo;
+    private ComboViewer overlayTypeComboViewer;
+    private Composite configurationComposite;
+    private Composite configurationInnerComposite;
+
+    // Listeners
+    private ISelectionChangedListener overlayTypeComboViewerSelectionChangedListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            OverlayType type = ( OverlayType ) ( ( StructuredSelection ) overlayTypeComboViewer.getSelection() )
+                .getFirstElement();
+
+            switch ( type )
+            {
+                case AUDIT_LOG:
+                    overlay = new OlcAuditlogConfig();
+                    configurationBlock = new AuditLogOverlayConfigurationBlock( instance, ( OlcAuditlogConfig ) overlay );
+                    break;
+                case MEMBER_OF:
+                    overlay = new OlcMemberOf();
+                    configurationBlock = new MemberOfOverlayConfigurationBlock( instance, browserConnection,
+                        ( OlcMemberOf ) overlay );
+                    break;
+                case PASSWORD_POLICY:
+                    overlay = new OlcPPolicyConfig();
+                    configurationBlock = new PasswordPolicyOverlayConfigurationBlock( instance, browserConnection,
+                        ( OlcPPolicyConfig ) overlay );
+                    break;
+                case REFERENTIAL_INTEGRITY:
+                    overlay = new OlcRefintConfig();
+                    configurationBlock = new ReferentialIntegrityOverlayConfigurationBlock( instance,
+                        browserConnection, ( OlcRefintConfig ) overlay );
+                    break;
+                case REWRITE_REMAP:
+                    overlay = new OlcRwmConfig();
+                    configurationBlock = new RewriteRemapOverlayConfigurationBlock( instance,
+                        browserConnection, ( OlcRwmConfig ) overlay );
+                    break;
+                case SYNC_PROV:
+                    overlay = new OlcSyncProvConfig();
+                    configurationBlock = new SyncProvOverlayConfigurationBlock( instance, ( OlcSyncProvConfig ) overlay );
+                    break;
+                case VALUE_SORTING:
+                    overlay = new OlcValSortConfig();
+                    configurationBlock = new ValueSortingOverlayConfigurationBlock( instance, browserConnection,
+                        ( OlcValSortConfig ) overlay );
+                    break;
+                case ACCESS_LOG:
+                default:
+                    overlay = new OlcAccessLogConfig();
+                    configurationBlock = new AccessLogOverlayConfigurationBlock( instance, browserConnection,
+                        ( OlcAccessLogConfig ) overlay );
+                    break;
+            }
+
+            refreshOverlayContent();
+            autoresizeDialog();
+        }
+    };
+
+
+    /**
+     * Creates a new instance of OverlayDialog.
+     * 
+     * @param parentShell the parent shell
+     */
+    public OverlayDialog( Shell parentShell )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        instance = this;
+    }
+
+
+    /**
+     * Creates a new instance of OverlayDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param allowOverlayTypeSelection the flag to allow the overlay type selection
+     */
+    public OverlayDialog( Shell parentShell, boolean allowOverlayTypeSelection )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        instance = this;
+        this.allowOverlayTypeSelection = allowOverlayTypeSelection;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( getDialogText() );
+    }
+
+
+    /**
+     * Gets the dialog text.
+     *
+     * @return the dialog text
+     */
+    private String getDialogText()
+    {
+        if ( overlay != null )
+        {
+            return NLS.bind( "{0} Overlay Configuration", getOverlayDisplayName( overlay ) );
+        }
+        else
+        {
+            return "Overlay Configuration";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void okPressed()
+    {
+        if ( configurationBlock != null )
+        {
+            configurationBlock.save();
+        }
+
+        super.okPressed();
+    }
+
+
+    /**
+     * @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 );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        composite.setLayoutData( gd );
+
+        // Checking if we need to show the overlay type selection
+        if ( allowOverlayTypeSelection )
+        {
+            createOverlayTypeSelection( composite );
+
+            BaseWidgetUtils.createSeparator( composite, 1 );
+        }
+
+        // Creating the configuration composites
+        configurationComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 1 );
+        createConfigurationInnerComposite();
+
+        // Checking for empty overlay
+        if ( overlay == null )
+        {
+            // Assigning a default one
+            overlay = new OlcAccessLogConfig();
+
+            // Select the correct value on the combo viewer (if required)
+            if ( allowOverlayTypeSelection )
+            {
+                overlayTypeComboViewer.setSelection( new StructuredSelection( OverlayType.ACCESS_LOG ) );
+            }
+        }
+
+        // Initializing the dialog with the overlay
+        initWithOverlay();
+
+        // Adding the listener on the combo viewer  (if required)
+        if ( allowOverlayTypeSelection )
+        {
+            overlayTypeComboViewer.addSelectionChangedListener( overlayTypeComboViewerSelectionChangedListener );
+        }
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * Creates the UI widgets for the overlay type selection.
+     *
+     * @param parent the parent composite
+     */
+    private void createOverlayTypeSelection( Composite parent )
+    {
+        Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 );
+        BaseWidgetUtils.createLabel( composite, "Type:", 1 );
+
+        overlayTypeCombo = new Combo( composite, SWT.READ_ONLY | SWT.SINGLE );
+        overlayTypeCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+        overlayTypeComboViewer = new ComboViewer( overlayTypeCombo );
+        overlayTypeComboViewer.setContentProvider( new ArrayContentProvider() );
+        overlayTypeComboViewer.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                if ( element instanceof OverlayType )
+                {
+                    OverlayType overlayType = ( OverlayType ) element;
+
+                    return getOverlayDisplayName( overlayType );
+                }
+
+                return super.getText( element );
+            }
+        } );
+        OverlayType[] databaseTypes = new OverlayType[]
+            {
+                OverlayType.ACCESS_LOG,
+                OverlayType.AUDIT_LOG,
+                OverlayType.MEMBER_OF,
+                OverlayType.PASSWORD_POLICY,
+                OverlayType.REFERENTIAL_INTEGRITY,
+                OverlayType.REWRITE_REMAP,
+                OverlayType.SYNC_PROV,
+                OverlayType.VALUE_SORTING
+        };
+        overlayTypeComboViewer.setInput( databaseTypes );
+    }
+
+
+    /**
+     * Gets the overlay display name.
+     *
+     * @param overlayType the overlay type
+     * @return the display name
+     */
+    public static String getOverlayDisplayName( OverlayType overlayType )
+    {
+        switch ( overlayType )
+        {
+            case ACCESS_LOG:
+                return "Access Log";
+            case AUDIT_LOG:
+                return "Audit Log";
+            case MEMBER_OF:
+                return "Member Of";
+            case PASSWORD_POLICY:
+                return "Password Policy";
+            case REFERENTIAL_INTEGRITY:
+                return "Referential Integrity";
+            case REWRITE_REMAP:
+                return "Rewrite/Remap";
+            case SYNC_PROV:
+                return "Sync Prov (Replication)";
+            case VALUE_SORTING:
+                return "Value Sorting";
+        }
+
+        return "Unknown";
+    }
+
+
+    public static String getOverlayDisplayName( OlcOverlayConfig overlay )
+    {
+        return getOverlayDisplayName( getOverlayType( overlay ) );
+    }
+
+
+    /**
+     * Gets the overlay type.
+     *
+     * @param overlay the overlay
+     * @return the overlay type
+     */
+    public static OverlayType getOverlayType( OlcOverlayConfig overlay )
+    {
+        if ( overlay instanceof OlcAccessLogConfig )
+        {
+            return OverlayType.ACCESS_LOG;
+        }
+        else if ( overlay instanceof OlcAuditlogConfig )
+        {
+            return OverlayType.AUDIT_LOG;
+        }
+        else if ( overlay instanceof OlcMemberOf )
+        {
+            return OverlayType.MEMBER_OF;
+        }
+        else if ( overlay instanceof OlcPPolicyConfig )
+        {
+            return OverlayType.PASSWORD_POLICY;
+        }
+        else if ( overlay instanceof OlcRefintConfig )
+        {
+            return OverlayType.REFERENTIAL_INTEGRITY;
+        }
+        else if ( overlay instanceof OlcRwmConfig )
+        {
+            return OverlayType.REWRITE_REMAP;
+        }
+        else if ( overlay instanceof OlcSyncProvConfig )
+        {
+            return OverlayType.SYNC_PROV;
+        }
+        else if ( overlay instanceof OlcValSortConfig )
+        {
+            return OverlayType.VALUE_SORTING;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Creates the configuration inner composite.
+     */
+    private void createConfigurationInnerComposite()
+    {
+        configurationInnerComposite = BaseWidgetUtils.createColumnContainer( configurationComposite, 1, 1 );
+    }
+
+
+    /**
+     * Disposes the configuration inner composite.
+     */
+    private void disposeConfigurationInnerComposite()
+    {
+        if ( configurationInnerComposite != null )
+        {
+            configurationInnerComposite.dispose();
+            configurationInnerComposite = null;
+        }
+    }
+
+
+    /**
+     * Initializes the dialog with the overlay.
+     */
+    private void initWithOverlay()
+    {
+        if ( overlay instanceof OlcAccessLogConfig )
+        {
+            configurationBlock = new AccessLogOverlayConfigurationBlock( this, browserConnection,
+                ( OlcAccessLogConfig ) overlay );
+        }
+        else if ( overlay instanceof OlcAuditlogConfig )
+        {
+            configurationBlock = new AuditLogOverlayConfigurationBlock( this, ( OlcAuditlogConfig ) overlay );
+        }
+        else if ( overlay instanceof OlcMemberOf )
+        {
+            configurationBlock = new MemberOfOverlayConfigurationBlock( this, browserConnection,
+                ( OlcMemberOf ) overlay );
+        }
+        else if ( overlay instanceof OlcPPolicyConfig )
+        {
+            configurationBlock = new PasswordPolicyOverlayConfigurationBlock( this, browserConnection,
+                ( OlcPPolicyConfig ) overlay );
+        }
+        else if ( overlay instanceof OlcRefintConfig )
+        {
+            configurationBlock = new ReferentialIntegrityOverlayConfigurationBlock( this, browserConnection,
+                ( OlcRefintConfig ) overlay );
+        }
+        else if ( overlay instanceof OlcRwmConfig )
+        {
+            configurationBlock = new RewriteRemapOverlayConfigurationBlock( this, browserConnection,
+                ( OlcRwmConfig ) overlay );
+        }
+        else if ( overlay instanceof OlcSyncProvConfig )
+        {
+            configurationBlock = new SyncProvOverlayConfigurationBlock( this, ( OlcSyncProvConfig ) overlay );
+        }
+        else if ( overlay instanceof OlcValSortConfig )
+        {
+            configurationBlock = new ValueSortingOverlayConfigurationBlock( this, browserConnection,
+                ( OlcValSortConfig ) overlay );
+        }
+
+        refreshOverlayContent();
+    }
+
+
+    /**
+     * Gets the overlay.
+     * 
+     * @return the overlay
+     */
+    public OlcOverlayConfig getOverlay()
+    {
+        return overlay;
+    }
+
+
+    /**
+     * Sets the overlay.
+     * 
+     * @param overlay the overlay to set
+     */
+    public void setOverlay( OlcOverlayConfig overlay )
+    {
+        this.overlay = overlay;
+    }
+
+
+    /**
+     * Calls the pack() method on the current shell, which forces the dialog to be resized.
+     */
+    private void autoresizeDialog()
+    {
+        this.getShell().pack();
+    }
+
+
+    /**
+     * Refreshes the overlay content.
+     */
+    private void refreshOverlayContent()
+    {
+        // Disposing existing configuration inner composite and creating a new one
+        disposeConfigurationInnerComposite();
+        createConfigurationInnerComposite();
+
+        // Displaying the specific settings
+        configurationBlock.createBlockContent( configurationInnerComposite );
+        configurationBlock.refresh();
+        configurationComposite.layout();
+
+        // Changing the dialog title
+        getShell().setText( getDialogText() );
+    }
+
+
+    /**
+     * Gets the browser connection.
+     *
+     * @return the browser connection
+     */
+    public IBrowserConnection getBrowserConnection()
+    {
+        return browserConnection;
+    }
+
+
+    /**
+     * Sets the browser connection.
+     *
+     * @param browserConnection the browser connection
+     */
+    public void setBrowserConnection( IBrowserConnection browserConnection )
+    {
+        this.browserConnection = browserConnection;
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayDialogConfigurationBlock.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/OverlayDialogConfigurationBlock.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayDialogConfigurationBlock.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayDialogConfigurationBlock.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,85 @@
+/*
+ *  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.eclipse.swt.widgets.Composite;
+
+import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig;
+
+
+/**
+ * This interface represents a configuration block for Overlay Dialog.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface OverlayDialogConfigurationBlock<Overlay extends OlcOverlayConfig>
+{
+    /**
+     * Creates the block content.
+     *
+     * @param parent the parent composite
+     */
+    public void createBlockContent( Composite parent );
+
+
+    /**
+     * Gets the dialog.
+     * 
+     * @return the dialog
+     */
+    public OverlayDialog getDialog();
+
+
+    /**
+     * Gets the overlay.
+     *
+     * @return the overlay
+     */
+    public Overlay getOverlay();
+
+
+    /**
+     * Refreshes the UI based on the input.
+     */
+    public void refresh();
+
+
+    /**
+     * Saves the data to the overlay.
+     */
+    public void save();
+
+
+    /**
+     * Sets the dialog.
+     * 
+     * @param dialog the dialog
+     */
+    public void setDialog( OverlayDialog dialog );
+
+
+    /**
+     * Sets the overlay.
+     *
+     * @param overlay the overlay
+     */
+    public void setOverlay( Overlay overlay );
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayType.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/OverlayType.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayType.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/OverlayType.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,53 @@
+/*
+ *  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;
+
+
+/**
+ * This enum describes the various types of overlays.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum OverlayType
+{
+    /** Access Log */
+    ACCESS_LOG,
+
+    /** Audit Log */
+    AUDIT_LOG,
+
+    /** Member Of */
+    MEMBER_OF,
+
+    /** Password Policy */
+    PASSWORD_POLICY,
+
+    /** Referential Integrity */
+    REFERENTIAL_INTEGRITY,
+
+    /** Rewrite/Remap */
+    REWRITE_REMAP,
+
+    /** Sync Prov (Replication) */
+    SYNC_PROV,
+    
+    /** Value Sorting */
+    VALUE_SORTING;
+}
\ No newline at end of file

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PurgeTimeSpan.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/PurgeTimeSpan.java?rev=1670531&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PurgeTimeSpan.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PurgeTimeSpan.java Wed Apr  1 01:01:42 2015
@@ -0,0 +1,435 @@
+/*
+ *  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.text.ParseException;
+
+
+/**
+ * This class represents the time span used for purge age and interval.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PurgeTimeSpan
+{
+    /** The days */
+    protected int days = 0;
+
+    /** The hours */
+    protected int hours = 0;
+
+    /** The minutes */
+    protected int minutes = 0;
+
+    /** The seconds */
+    protected int seconds = 0;
+
+
+    /**
+     * Creates a new instance of PurgeTimeSpan.
+     */
+    public PurgeTimeSpan()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of PurgeTimeSpan.
+     *
+     * @param s the string
+     */
+    public PurgeTimeSpan( String s ) throws ParseException
+    {
+        parse( s );
+    }
+
+
+    /**
+     * Creates a new instance of PurgeTimeSpan.
+     *
+     * @param days the days
+     * @param hours the hours
+     * @param minutes the minutes
+     * @param seconds the seconds
+     */
+    public PurgeTimeSpan( int days, int hours, int minutes, int seconds )
+    {
+        checkDaysArgument( days );
+        checkHoursArgument( hours );
+        checkMinutesSecondsArgument( minutes );
+        checkMinutesSecondsArgument( seconds );
+
+        this.days = days;
+        this.hours = hours;
+        this.minutes = minutes;
+        this.seconds = seconds;
+    }
+
+
+    /**
+     * Checks the days argument.
+     *
+     * @param value the days argument
+     * @throws IllegalArgumentException
+     */
+    private void checkDaysArgument( int value ) throws IllegalArgumentException
+    {
+        if ( checkDays( value ) )
+        {
+            throw new IllegalArgumentException( "Days need to be comprised between 0 and 99999." );
+        }
+    }
+
+
+    /**
+     * Checks the days value.
+     *
+     * @param value the days value
+     * @return <code>true</code> if the days value is correct,
+     *         <code>false</code> if not.
+     */
+    private boolean checkDays( int value )
+    {
+        return ( value < 0 ) || ( value > 99999 );
+    }
+
+
+    /**
+     * Checks the hours argument.
+     *
+     * @param value the hours argument
+     */
+    private void checkHoursArgument( int value )
+    {
+        if ( checkHours( value ) )
+        {
+            throw new IllegalArgumentException( "Hours, minutes, or seconds need to be comprised between 0 and 99999." );
+        }
+    }
+
+
+    /**
+     * Checks the hours value.
+     *
+     * @param value the hours value
+     * @return <code>true</code> if the hours value is correct,
+     *         <code>false</code> if not.
+     */
+    private boolean checkHours( int value )
+    {
+        return ( value < 0 ) || ( value > 23 );
+    }
+
+
+    /**
+     * Checks the minutes or seconds argument.
+     *
+     * @param value the minutes or seconds argument
+     */
+    private void checkMinutesSecondsArgument( int value )
+    {
+        if ( checkMinutesSeconds( value ) )
+        {
+            throw new IllegalArgumentException( "Hours, minutes, or seconds need to be comprised between 0 and 99999." );
+        }
+    }
+
+
+    /**
+     * Checks the minutes or seconds value.
+     *
+     * @param value the minutes or seconds value
+     * @return <code>true</code> if the minutes or seconds value is correct,
+     *         <code>false</code> if not.
+     */
+    private boolean checkMinutesSeconds( int value )
+    {
+        return ( value < 0 ) || ( value > 59 );
+    }
+
+
+    /**
+     * Parse the given string.
+     *
+     * @param s the string
+     * @throws ParseException in case of error during parsing.
+     */
+    private void parse( String s ) throws ParseException
+    {
+        if ( s == null )
+        {
+            throw new ParseException( "The string is null.", 0 );
+        }
+
+        // Removing leading and trailing whitespaces
+        s = s.trim();
+
+        // Checking the minimum size of the string
+        // It should be at least 5 chars ("HH:MM")
+        if ( s.length() < 5 )
+        {
+            throw new ParseException( "The string is too short.", 0 );
+        }
+
+        // Initializing parsing objects
+        int position = 0;
+        char c;
+        StringBuffer buffer = new StringBuffer();
+        boolean hoursParsed = false;
+        boolean minutesParsed = false;
+
+        try
+        {
+            while ( ( position < s.length() ) )
+            {
+                c = s.charAt( position );
+
+                // Figure
+                if ( ( '0' <= c ) && ( c <= '9' ) )
+                {
+                    buffer.append( c );
+                }
+                // Plus sign
+                else if ( '+' == c )
+                {
+                    int days = Integer.parseInt( buffer.toString() );
+
+                    if ( checkDays( days ) )
+                    {
+                        throw new ParseException( "Days need to be comprised between 0 and 99999.", position );
+                    }
+                    else
+                    {
+                        this.days = days;
+                    }
+
+                    buffer = new StringBuffer();
+                }
+                // Colon sign
+                else if ( ':' == c )
+                {
+                    if ( !hoursParsed )
+                    {
+                        int hours = Integer.parseInt( buffer.toString() );
+
+                        if ( checkHours( hours ) )
+                        {
+                            throw new ParseException( "Hours need to be comprised between 0 and 23.", position );
+                        }
+                        else
+                        {
+                            this.hours = hours;
+                        }
+
+                        hoursParsed = true;
+                        buffer = new StringBuffer();
+                    }
+                    else
+                    {
+                        int minutes = Integer.parseInt( buffer.toString() );
+
+                        if ( checkMinutesSeconds( minutes ) )
+                        {
+                            throw new ParseException( "Minutes need to be comprised between 0 and 59.", position );
+                        }
+                        else
+                        {
+                            this.minutes = minutes;
+                        }
+
+                        minutesParsed = true;
+                        buffer = new StringBuffer();
+                    }
+                }
+                else
+                {
+                    throw new ParseException( "Illegal character", position );
+                }
+
+                position++;
+            }
+        }
+        catch ( NumberFormatException e )
+        {
+            throw new ParseException( e.getMessage(), position );
+        }
+
+        if ( !hoursParsed )
+        {
+            throw new ParseException( "Hours need to be comprised between 0 and 23.", position );
+        }
+        else if ( !minutesParsed )
+        {
+            int minutes = Integer.parseInt( buffer.toString() );
+
+            if ( checkMinutesSeconds( minutes ) )
+            {
+                throw new ParseException( "Minutes need to be comprised between 0 and 59.", position );
+            }
+            else
+            {
+                this.minutes = minutes;
+            }
+        }
+        else
+        {
+            int seconds = Integer.parseInt( buffer.toString() );
+
+            if ( checkMinutesSeconds( seconds ) )
+            {
+                throw new ParseException( "Seconds need to be comprised between 0 and 59.", position );
+            }
+            else
+            {
+                this.seconds = seconds;
+            }
+        }
+    }
+
+
+    /**
+     * @return the days
+     */
+    public int getDays()
+    {
+        return days;
+    }
+
+
+    /**
+     * @return the hours
+     */
+    public int getHours()
+    {
+        return hours;
+    }
+
+
+    /**
+     * @return the minutes
+     */
+    public int getMinutes()
+    {
+        return minutes;
+    }
+
+
+    /**
+     * @return the seconds
+     */
+    public int getSeconds()
+    {
+        return seconds;
+    }
+
+
+    /**
+     * @param days the days to set
+     */
+    public void setDays( int days )
+    {
+        this.days = days;
+    }
+
+
+    /**
+     * @param hours the hours to set
+     */
+    public void setHours( int hours )
+    {
+        this.hours = hours;
+    }
+
+
+    /**
+     * @param minutes the minutes to set
+     */
+    public void setMinutes( int minutes )
+    {
+        this.minutes = minutes;
+    }
+
+
+    /**
+     * @param seconds the seconds to set
+     */
+    public void setSeconds( int seconds )
+    {
+        this.seconds = seconds;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        // Days (if needed)
+        if ( days > 0 )
+        {
+            sb.append( days );
+            sb.append( '+' );
+        }
+
+        // Hours
+        sb.append( toString( hours ) );
+        sb.append( ':' );
+
+        // Minutes
+        sb.append( toString( minutes ) );
+
+        // Seconds (if needed)
+        if ( seconds > 0 )
+        {
+            sb.append( ':' );
+            sb.append( toString( seconds ) );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Gets the string representation of an int
+     * (prefixed with a 0 if needed).
+     *
+     * @param value the value
+     * @return the string equivalent
+     */
+    private String toString( int value )
+    {
+        if ( ( value < 0 ) || ( value > 60 ) )
+        {
+            return "00";
+        }
+        else if ( value < 10 )
+        {
+            return "0" + value;
+        }
+        else
+        {
+            return "" + value;
+        }
+    }
+
+}