directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1188172 - in /directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2: dialogs/ editor/
Date Mon, 24 Oct 2011 15:28:03 GMT
Author: pamarcelot
Date: Mon Oct 24 15:28:02 2011
New Revision: 1188172

URL: http://svn.apache.org/viewvc?rev=1188172&view=rev
Log:
Added support for modifying the indexes of a partition.
Added a new IndexDialog which is used to edit the properties of an index.

Added:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/Messages.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties
Modified:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java?rev=1188172&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java
Mon Oct 24 15:28:02 2011
@@ -0,0 +1,193 @@
+/*
+ *  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.apacheds.configuration.v2.dialogs;
+
+
+import org.apache.directory.server.config.beans.JdbmIndexBean;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the Dialog for an Index.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class IndexDialog extends Dialog
+{
+    /** The Indexed Attribute */
+    private JdbmIndexBean<String, Entry> index;
+
+    /** The dirty flag */
+    private boolean dirty = false;
+
+    // UI Fields
+    private Text attributeIdText;
+    private Text cacheSizeText;
+
+
+    /**
+     * Creates a new instance of IndexDialog.
+     */
+    public IndexDialog( JdbmIndexBean<String, Entry> index )
+    {
+        super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+        this.index = index;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( Messages.getString( "IndexDialog.IndexedAttributeDialog" ) ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout layout = new GridLayout( 2, false );
+        composite.setLayout( layout );
+        composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true )
);
+
+        Label attributeIdLabel = new Label( composite, SWT.NONE );
+        attributeIdLabel.setText( Messages.getString( "IndexDialog.AttributeID" ) ); //$NON-NLS-1$
+
+        attributeIdText = new Text( composite, SWT.BORDER );
+        attributeIdText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        Label cacheSizeLabel = new Label( composite, SWT.NONE );
+        cacheSizeLabel.setText( Messages.getString( "IndexDialog.CacheSize" ) ); //$NON-NLS-1$
+
+        cacheSizeText = new Text( composite, SWT.BORDER );
+        cacheSizeText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+        cacheSizeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+        initFromInput();
+        addListeners();
+
+        return composite;
+    }
+
+
+    /**
+     * Initializes the UI from the input.
+     */
+    private void initFromInput()
+    {
+        String attributeId = index.getIndexAttributeId();
+        attributeIdText.setText( ( attributeId == null ) ? "" : attributeId ); //$NON-NLS-1$
+        cacheSizeText.setText( "" + index.getIndexCacheSize() ); //$NON-NLS-1$
+    }
+
+
+    /**
+     * Adds listeners to the UI Fields.
+     */
+    private void addListeners()
+    {
+        attributeIdText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dirty = true;
+            }
+        } );
+
+        cacheSizeText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                dirty = true;
+            }
+        } );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void okPressed()
+    {
+        index.setIndexAttributeId( attributeIdText.getText() );
+        try
+        {
+            index.setIndexCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
+        }
+        catch ( NumberFormatException e )
+        {
+            // Nothing to do, it won't happen
+        }
+
+        super.okPressed();
+    }
+
+
+    /**
+     * Gets the Indexed Attribute.
+     *
+     * @return
+     *      the Indexed Attribute
+     */
+    public JdbmIndexBean<String, Entry> getIndex()
+    {
+        return index;
+    }
+
+
+    /**
+     * Returns the dirty flag of the dialog.
+     *
+     * @return
+     *      the dirty flag of the dialog
+     */
+    public boolean isDirty()
+    {
+        return dirty;
+    }
+}

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/Messages.java?rev=1188172&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/Messages.java
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/Messages.java
Mon Oct 24 15:28:02 2011
@@ -0,0 +1,50 @@
+/*
+ *  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.apacheds.configuration.v2.dialogs;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.studio.apacheds.configuration.v2.dialogs.messages";
//$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME
);
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties?rev=1188172&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties
Mon Oct 24 15:28:02 2011
@@ -0,0 +1,20 @@
+#  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.
+
+IndexDialog.AttributeID=Attribute ID:
+IndexDialog.CacheSize=Cache Size:
+IndexDialog.IndexedAttributeDialog=Indexed Attribute Dialog

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties?rev=1188172&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties
Mon Oct 24 15:28:02 2011
@@ -0,0 +1,20 @@
+#  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.
+
+IndexDialog.AttributeID=Attribut ID:
+IndexDialog.CacheSize=Cachegr\u00F6\u00DFe:
+IndexDialog.IndexedAttributeDialog=Indiziertes Attribut

Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties?rev=1188172&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties
(added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties
Mon Oct 24 15:28:02 2011
@@ -0,0 +1,20 @@
+#  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.
+
+IndexDialog.AttributeID=ID de l'attribut:
+IndexDialog.CacheSize=Taille du cache:
+IndexDialog.IndexedAttributeDialog=Dialogue d'attribut index\u00E9

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java?rev=1188172&r1=1188171&r2=1188172&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionDetailsPage.java
Mon Oct 24 15:28:02 2011
@@ -28,6 +28,8 @@ import org.apache.directory.server.confi
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.studio.apacheds.configuration.v2.dialogs.IndexDialog;
+import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -79,8 +81,8 @@ public class PartitionDetailsPage implem
     /** The input Partition */
     private JdbmPartitionBean input;
 
-    /** The Indexed Attributes List */
-    private List<IndexBean> indexedAttributes;
+    /** The Indexes List */
+    private List<IndexBean> indexesList;
 
     /** The dirty flag */
     private boolean dirty = false;
@@ -91,10 +93,10 @@ public class PartitionDetailsPage implem
     private Text suffixText;
     private Button enableOptimizerCheckbox;
     private Button synchOnWriteCheckbox;
-    private TableViewer indexedAttributesTableViewer;
-    private Button indexedAttributeAddButton;
-    private Button indexedAttributeEditButton;
-    private Button indexedAttributeDeleteButton;
+    private TableViewer indexesTableViewer;
+    private Button indexesAddButton;
+    private Button indexesEditButton;
+    private Button indexesDeleteButton;
 
     // Listeners
     /** The Text Modify Listener */
@@ -104,6 +106,7 @@ public class PartitionDetailsPage implem
         {
             masterDetailsBlock.setEditorDirty();
             dirty = true;
+            commit( true );
         }
     };
 
@@ -114,6 +117,7 @@ public class PartitionDetailsPage implem
         {
             masterDetailsBlock.setEditorDirty();
             dirty = true;
+            commit( true );
         }
     };
 
@@ -122,8 +126,8 @@ public class PartitionDetailsPage implem
     {
         public void selectionChanged( SelectionChangedEvent event )
         {
-            indexedAttributeEditButton.setEnabled( !event.getSelection().isEmpty() );
-            indexedAttributeDeleteButton.setEnabled( !event.getSelection().isEmpty() );
+            indexesEditButton.setEnabled( !event.getSelection().isEmpty() );
+            indexesDeleteButton.setEnabled( !event.getSelection().isEmpty() );
         }
     };
 
@@ -132,7 +136,7 @@ public class PartitionDetailsPage implem
     {
         public void doubleClick( DoubleClickEvent event )
         {
-            //            editSelectedIndexedAttribute();
+            editSelectedIndex();
         }
     };
 
@@ -141,14 +145,7 @@ public class PartitionDetailsPage implem
     {
         public void widgetSelected( SelectionEvent e )
         {
-            //            IndexedAttributeDialog dialog = new IndexedAttributeDialog( new
IndexedAttribute( "", 0 ) ); //$NON-NLS-1$
-            //            if ( Dialog.OK == dialog.open() )
-            //            {
-            //                indexedAttributes.add( dialog.getIndexedAttribute() );
-            //                indexedAttributesTableViewer.refresh();
-            //                masterDetailsBlock.setEditorDirty();
-            //                dirty = true;
-            //            }
+            addNewIndex();
         }
     };
 
@@ -157,7 +154,7 @@ public class PartitionDetailsPage implem
     {
         public void widgetSelected( SelectionEvent e )
         {
-            //            editSelectedIndexedAttribute();
+            editSelectedIndex();
         }
     };
 
@@ -166,16 +163,7 @@ public class PartitionDetailsPage implem
     {
         public void widgetSelected( SelectionEvent e )
         {
-            StructuredSelection selection = ( StructuredSelection ) indexedAttributesTableViewer.getSelection();
-            if ( !selection.isEmpty() )
-            {
-                //                IndexedAttribute indexedAttribute = ( IndexedAttribute
) selection.getFirstElement();
-                //
-                //                indexedAttributes.remove( indexedAttribute );
-                //                indexedAttributesTableViewer.refresh();
-                //                masterDetailsBlock.setEditorDirty();
-                //                dirty = true;
-            }
+            deleteSelectedIndex();
         }
     };
 
@@ -206,7 +194,7 @@ public class PartitionDetailsPage implem
         parent.setLayout( layout );
 
         createDetailsSection( parent, toolkit );
-        createIndexedAttributesSection( parent, toolkit );
+        createIndexesSection( parent, toolkit );
     }
 
 
@@ -269,14 +257,14 @@ public class PartitionDetailsPage implem
 
 
     /**
-     * Creates the Indexed Attributes Section
+     * Creates the Indexes Section
      *
      * @param parent
      *      the parent composite
      * @param toolkit
      *      the toolkit to use
      */
-    private void createIndexedAttributesSection( Composite parent, FormToolkit toolkit )
+    private void createIndexesSection( Composite parent, FormToolkit toolkit )
     {
         Section indexedAttributesSection = toolkit.createSection( parent, Section.DESCRIPTION
| Section.TITLE_BAR );
         indexedAttributesSection.marginWidth = 10;
@@ -292,9 +280,9 @@ public class PartitionDetailsPage implem
         GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
         gd.heightHint = 80;
         indexedAttributesTable.setLayoutData( gd );
-        indexedAttributesTableViewer = new TableViewer( indexedAttributesTable );
-        indexedAttributesTableViewer.setContentProvider( new ArrayContentProvider() );
-        indexedAttributesTableViewer.setLabelProvider( new LabelProvider()
+        indexesTableViewer = new TableViewer( indexedAttributesTable );
+        indexesTableViewer.setContentProvider( new ArrayContentProvider() );
+        indexesTableViewer.setLabelProvider( new LabelProvider()
         {
             public String getText( Object element )
             {
@@ -313,16 +301,16 @@ public class PartitionDetailsPage implem
         GridData buttonsGD = new GridData( SWT.FILL, SWT.BEGINNING, false, false );
         buttonsGD.widthHint = IDialogConstants.BUTTON_WIDTH;
 
-        indexedAttributeAddButton = toolkit.createButton( indexedAttributesClient, "Add",
SWT.PUSH );
-        indexedAttributeAddButton.setLayoutData( buttonsGD );
+        indexesAddButton = toolkit.createButton( indexedAttributesClient, "Add", SWT.PUSH
);
+        indexesAddButton.setLayoutData( buttonsGD );
 
-        indexedAttributeEditButton = toolkit.createButton( indexedAttributesClient, "Edit",
SWT.PUSH );
-        indexedAttributeEditButton.setEnabled( false );
-        indexedAttributeEditButton.setLayoutData( buttonsGD );
-
-        indexedAttributeDeleteButton = toolkit.createButton( indexedAttributesClient, "Delete",
SWT.PUSH );
-        indexedAttributeDeleteButton.setEnabled( false );
-        indexedAttributeDeleteButton.setLayoutData( buttonsGD );
+        indexesEditButton = toolkit.createButton( indexedAttributesClient, "Edit", SWT.PUSH
);
+        indexesEditButton.setEnabled( false );
+        indexesEditButton.setLayoutData( buttonsGD );
+
+        indexesDeleteButton = toolkit.createButton( indexedAttributesClient, "Delete", SWT.PUSH
);
+        indexesDeleteButton.setEnabled( false );
+        indexesDeleteButton.setLayoutData( buttonsGD );
     }
 
 
@@ -337,11 +325,11 @@ public class PartitionDetailsPage implem
         enableOptimizerCheckbox.addSelectionListener( checkboxSelectionListener );
         synchOnWriteCheckbox.addSelectionListener( checkboxSelectionListener );
 
-        indexedAttributesTableViewer.addSelectionChangedListener( indexedAttributesTableViewerListener
);
-        indexedAttributesTableViewer.addDoubleClickListener( indexedAttributesTableViewerDoubleClickListener
);
-        indexedAttributeAddButton.addSelectionListener( indexedAttributeAddButtonListener
);
-        indexedAttributeEditButton.addSelectionListener( indexedAttributeEditButtonListener
);
-        indexedAttributeDeleteButton.addSelectionListener( indexedAttributeDeleteButtonListener
);
+        indexesTableViewer.addSelectionChangedListener( indexedAttributesTableViewerListener
);
+        indexesTableViewer.addDoubleClickListener( indexedAttributesTableViewerDoubleClickListener
);
+        indexesAddButton.addSelectionListener( indexedAttributeAddButtonListener );
+        indexesEditButton.addSelectionListener( indexedAttributeEditButtonListener );
+        indexesDeleteButton.addSelectionListener( indexedAttributeDeleteButtonListener );
     }
 
 
@@ -356,11 +344,11 @@ public class PartitionDetailsPage implem
         enableOptimizerCheckbox.removeSelectionListener( checkboxSelectionListener );
         synchOnWriteCheckbox.removeSelectionListener( checkboxSelectionListener );
 
-        indexedAttributesTableViewer.removeSelectionChangedListener( indexedAttributesTableViewerListener
);
-        indexedAttributesTableViewer.removeDoubleClickListener( indexedAttributesTableViewerDoubleClickListener
);
-        indexedAttributeAddButton.removeSelectionListener( indexedAttributeAddButtonListener
);
-        indexedAttributeEditButton.removeSelectionListener( indexedAttributeEditButtonListener
);
-        indexedAttributeDeleteButton.removeSelectionListener( indexedAttributeDeleteButtonListener
);
+        indexesTableViewer.removeSelectionChangedListener( indexedAttributesTableViewerListener
);
+        indexesTableViewer.removeDoubleClickListener( indexedAttributesTableViewerDoubleClickListener
);
+        indexesAddButton.removeSelectionListener( indexedAttributeAddButtonListener );
+        indexesEditButton.removeSelectionListener( indexedAttributeEditButtonListener );
+        indexesDeleteButton.removeSelectionListener( indexedAttributeDeleteButtonListener
);
     }
 
 
@@ -466,15 +454,15 @@ public class PartitionDetailsPage implem
         synchOnWriteCheckbox.setSelection( input.isPartitionSyncOnWrite() );
 
         // Indexed Attributes
-        indexedAttributes = input.getIndexes();
-        indexedAttributesTableViewer.setInput( indexedAttributes );
+        indexesList = input.getIndexes();
+        indexesTableViewer.setInput( indexesList );
 
         addListeners();
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.forms.IFormPart#setFocus()
+    /**
+     * {@inheritDoc}
      */
     public void setFocus()
     {
@@ -482,11 +470,71 @@ public class PartitionDetailsPage implem
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
+    /**
+     * {@inheritDoc}
      */
     public boolean setFormInput( Object input )
     {
         return false;
     }
+
+
+    /**
+     * Opens an indexed dialog with the selected index in the indexes table viewer.
+     */
+    private void editSelectedIndex()
+    {
+        StructuredSelection selection = ( StructuredSelection ) indexesTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            JdbmIndexBean<String, Entry> index = ( JdbmIndexBean<String, Entry>
) selection.getFirstElement();
+
+            IndexDialog dialog = new IndexDialog( index );
+            if ( Dialog.OK == dialog.open() && dialog.isDirty() )
+            {
+                indexesTableViewer.refresh();
+                masterDetailsBlock.setEditorDirty();
+                dirty = true;
+            }
+        }
+    }
+
+
+    /**
+     * Adds a new index and opens the index dialog.
+     */
+    private void addNewIndex()
+    {
+        JdbmIndexBean<String, Entry> newIndex = new JdbmIndexBean<String, Entry>();
+        newIndex.setIndexAttributeId( "" ); //$NON-NLS-1$
+        newIndex.setIndexCacheSize( 1000 );
+
+        IndexDialog dialog = new IndexDialog( newIndex );
+        if ( Dialog.OK == dialog.open() )
+        {
+            indexesList.add( dialog.getIndex() );
+            indexesTableViewer.refresh();
+            indexesTableViewer.setSelection( new StructuredSelection( dialog.getIndex() )
);
+            masterDetailsBlock.setEditorDirty();
+            dirty = true;
+        }
+    }
+
+
+    /**
+     * Deletes the selected index in the indexes table viewer
+     */
+    private void deleteSelectedIndex()
+    {
+        StructuredSelection selection = ( StructuredSelection ) indexesTableViewer.getSelection();
+        if ( !selection.isEmpty() )
+        {
+            JdbmIndexBean<String, Entry> selectedIndex = ( JdbmIndexBean<String,
Entry> ) selection.getFirstElement();
+
+            indexesList.remove( selectedIndex );
+            indexesTableViewer.refresh();
+            masterDetailsBlock.setEditorDirty();
+            dirty = true;
+        }
+    }
 }

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java?rev=1188172&r1=1188171&r2=1188172&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsMasterDetailsBlock.java
Mon Oct 24 15:28:02 2011
@@ -228,7 +228,6 @@ public class PartitionsMasterDetailsBloc
                     if ( !PartitionsPage.isSystemPartition( partition ) )
                     {
                         page.getConfigBean().getDirectoryServiceBean().getPartitions().remove(
partition );
-                        viewer.refresh();
                         setEditorDirty();
                     }
                 }
@@ -309,6 +308,7 @@ public class PartitionsMasterDetailsBloc
     public void setEditorDirty()
     {
         ( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
+        viewer.refresh();
     }
 
 
@@ -318,6 +318,5 @@ public class PartitionsMasterDetailsBloc
     public void save()
     {
         detailsPage.commit( true );
-        //        viewer.setInput( partitions );
     }
 }



Mime
View raw message