You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2013/09/16 16:36:11 UTC
svn commit: r1523681 [1/2] - in
/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2:
dialogs/ editor/
Author: pamarcelot
Date: Mon Sep 16 14:36:10 2013
New Revision: 1523681
URL: http://svn.apache.org/r1523681
Log:
Fix for DIRSTUDIO-949 (Add the ability to configure a Mavibot partition).
Added:
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/JdbmIndexDialog.java
- copied, changed from r1520231, 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/MavibotIndexDialog.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/AbstractPartitionSpecificDetailsBlock.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/JdbmPartitionSpecificDetailsBlock.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/MavibotPartitionSpecificDetailsBlock.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionSpecificDetailsBlock.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionType.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionWrapper.java
Removed:
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java
Modified:
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
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
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditor.java
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/messages.properties
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/messages_de.properties
directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/messages_fr.properties
Copied: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/JdbmIndexDialog.java (from r1520231, 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/JdbmIndexDialog.java?p2=directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/JdbmIndexDialog.java&p1=directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java&r1=1520231&r2=1523681&rev=1523681&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/IndexDialog.java (original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/JdbmIndexDialog.java Mon Sep 16 14:36:10 2013
@@ -20,7 +20,6 @@
package org.apache.directory.studio.apacheds.configuration.v2.dialogs;
-import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.server.config.beans.JdbmIndexBean;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
@@ -39,14 +38,14 @@ import org.eclipse.ui.PlatformUI;
/**
- * This class implements the Dialog for an Index.
+ * This class implements the Dialog for a JDBM index.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class IndexDialog extends Dialog
+public class JdbmIndexDialog extends Dialog
{
/** The Indexed Attribute */
- private JdbmIndexBean<String, Entry> index;
+ private JdbmIndexBean index;
/** The dirty flag */
private boolean dirty = false;
@@ -57,9 +56,9 @@ public class IndexDialog extends Dialog
/**
- * Creates a new instance of IndexDialog.
+ * Creates a new instance of JdbmIndexDialog.
*/
- public IndexDialog( JdbmIndexBean<String, Entry> index )
+ public JdbmIndexDialog( JdbmIndexBean index )
{
super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
this.index = index;
@@ -72,7 +71,7 @@ public class IndexDialog extends Dialog
protected void configureShell( Shell newShell )
{
super.configureShell( newShell );
- newShell.setText( Messages.getString( "IndexDialog.IndexedAttributeDialog" ) ); //$NON-NLS-1$
+ newShell.setText( Messages.getString( "JdbmIndexDialog.IndexedAttributeDialog" ) ); //$NON-NLS-1$
}
@@ -87,13 +86,13 @@ public class IndexDialog extends Dialog
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$
+ attributeIdLabel.setText( Messages.getString( "JdbmIndexDialog.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$
+ cacheSizeLabel.setText( Messages.getString( "JdbmIndexDialog.CacheSize" ) ); //$NON-NLS-1$
cacheSizeText = new Text( composite, SWT.BORDER );
cacheSizeText.addVerifyListener( new VerifyListener()
@@ -174,7 +173,7 @@ public class IndexDialog extends Dialog
* @return
* the Indexed Attribute
*/
- public JdbmIndexBean<String, Entry> getIndex()
+ public JdbmIndexBean getIndex()
{
return index;
}
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/MavibotIndexDialog.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/MavibotIndexDialog.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/MavibotIndexDialog.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/MavibotIndexDialog.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,156 @@
+/*
+ * 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.MavibotIndexBean;
+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.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 a Mavibot index.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MavibotIndexDialog extends Dialog
+{
+ /** The Indexed Attribute */
+ private MavibotIndexBean index;
+
+ /** The dirty flag */
+ private boolean dirty = false;
+
+ // UI Fields
+ private Text attributeIdText;
+
+
+ /**
+ * Creates a new instance of MavibotIndexDialog.
+ */
+ public MavibotIndexDialog( MavibotIndexBean index )
+ {
+ super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+ this.index = index;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void configureShell( Shell newShell )
+ {
+ super.configureShell( newShell );
+ newShell.setText( Messages.getString( "MavibotIndexDialog.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( "MavibotIndexDialog.AttributeID" ) ); //$NON-NLS-1$
+
+ attributeIdText = new Text( composite, SWT.BORDER );
+ attributeIdText.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$
+ }
+
+
+ /**
+ * Adds listeners to the UI Fields.
+ */
+ private void addListeners()
+ {
+ attributeIdText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dirty = true;
+ }
+ } );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void okPressed()
+ {
+ index.setIndexAttributeId( attributeIdText.getText() );
+
+ super.okPressed();
+ }
+
+
+ /**
+ * Gets the Indexed Attribute.
+ *
+ * @return
+ * the Indexed Attribute
+ */
+ public MavibotIndexBean getIndex()
+ {
+ return index;
+ }
+
+
+ /**
+ * Returns the dirty flag of the dialog.
+ *
+ * @return
+ * the dirty flag of the dialog
+ */
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+}
Modified: 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=1523681&r1=1523680&r2=1523681&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties (original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages.properties Mon Sep 16 14:36:10 2013
@@ -22,6 +22,9 @@ AttributeValueDialog.Attribute=Attribute
AttributeValueDialog.AttributeValueDialog=Attribute Value Dialog
AttributeValueDialog.Value=Value:
-IndexDialog.AttributeID=Attribute ID:
-IndexDialog.CacheSize=Cache Size:
-IndexDialog.IndexedAttributeDialog=Indexed Attribute Dialog
+JdbmIndexDialog.AttributeID=Attribute ID:
+JdbmIndexDialog.CacheSize=Cache Size:
+JdbmIndexDialog.IndexedAttributeDialog=Indexed Attribute Dialog
+
+MavibotIndexDialog.AttributeID=Attribute ID:
+MavibotIndexDialog.IndexedAttributeDialog=Indexed Attribute Dialog
Modified: 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=1523681&r1=1523680&r2=1523681&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties (original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_de.properties Mon Sep 16 14:36:10 2013
@@ -22,6 +22,9 @@ AttributeValueDialog.Attribute=Attribut:
AttributeValueDialog.AttributeValueDialog=Attribut Wert Dialog
AttributeValueDialog.Value=Wert:
-IndexDialog.AttributeID=Attribut ID:
-IndexDialog.CacheSize=Cachegr\u00F6\u00DFe:
-IndexDialog.IndexedAttributeDialog=Indiziertes Attribut
+JdbmIndexDialog.AttributeID=Attribut ID:
+JdbmIndexDialog.CacheSize=Cachegr\u00F6\u00DFe:
+JdbmIndexDialog.IndexedAttributeDialog=Indiziertes Attribut
+
+MavibotIndexDialog.AttributeID=Attribut ID:
+MavibotIndexDialog.IndexedAttributeDialog=Indiziertes Attribut
Modified: 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=1523681&r1=1523680&r2=1523681&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties (original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/dialogs/messages_fr.properties Mon Sep 16 14:36:10 2013
@@ -23,6 +23,9 @@ AttributeValueDialog.Attribute=Attribut:
AttributeValueDialog.AttributeValueDialog=Dialogue de valeur d'attribut
AttributeValueDialog.Value=Valeur:
-IndexDialog.AttributeID=ID de l'attribut:
-IndexDialog.CacheSize=Taille du cache:
-IndexDialog.IndexedAttributeDialog=Dialogue d'attribut index\u00E9
+JdbmIndexDialog.AttributeID=ID de l'attribut:
+JdbmIndexDialog.CacheSize=Taille du cache:
+JdbmIndexDialog.IndexedAttributeDialog=Dialogue d'attribut index\u00E9
+
+MavibotIndexDialog.AttributeID=ID de l'attribut:
+MavibotIndexDialog.IndexedAttributeDialog=Dialogue d'attribut index\u00E9
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/AbstractPartitionSpecificDetailsBlock.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/AbstractPartitionSpecificDetailsBlock.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/AbstractPartitionSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/AbstractPartitionSpecificDetailsBlock.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,91 @@
+/*
+ * 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.editor;
+
+
+import org.apache.directory.server.config.beans.PartitionBean;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+
+
+/**
+ * This interface represents a block for Partition configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractPartitionSpecificDetailsBlock<P extends PartitionBean> implements
+ PartitionSpecificDetailsBlock
+{
+ /** The details page*/
+ protected PartitionDetailsPage detailsPage;
+
+ /** The partition */
+ protected P partition;
+
+ // Listeners
+ protected ModifyListener dirtyModifyListener = new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ detailsPage.setEditorDirty();
+ }
+ };
+ protected WidgetModifyListener dirtyWidgetModifyListener = new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ detailsPage.setEditorDirty();
+ }
+ };
+ protected SelectionListener dirtySelectionListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ detailsPage.setEditorDirty();
+ }
+ };
+
+
+ /**
+ * Creates a new instance of AbstractPartitionSpecificDetailsBlock.
+ *
+ * @param detailsPage the details page
+ * @param partition the partition
+ */
+ public AbstractPartitionSpecificDetailsBlock( PartitionDetailsPage detailsPage, P partition )
+ {
+ this.detailsPage = detailsPage;
+ this.partition = partition;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public PartitionDetailsPage getDetailsPage()
+ {
+ return detailsPage;
+ }
+}
\ No newline at end of file
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/JdbmPartitionSpecificDetailsBlock.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/JdbmPartitionSpecificDetailsBlock.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/JdbmPartitionSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/JdbmPartitionSpecificDetailsBlock.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,154 @@
+/*
+ * 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.editor;
+
+
+import org.apache.directory.server.config.beans.JdbmPartitionBean;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+
+/**
+ * This class implements a specific details block for the JDBM partition.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JdbmPartitionSpecificDetailsBlock extends AbstractPartitionSpecificDetailsBlock<JdbmPartitionBean>
+{
+ // UI widgets
+ private Text cacheSizeText;
+ private Button enableOptimizerCheckbox;
+
+
+ /**
+ * Creates a new instance of JdbmPartitionSpecificDetailsBlock.
+ *
+ * @param detailsPage the details page
+ * @param partition the partition
+ */
+ public JdbmPartitionSpecificDetailsBlock( PartitionDetailsPage detailsPage, JdbmPartitionBean partition )
+ {
+ super( detailsPage, partition );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createBlockContent( Composite parent, FormToolkit toolkit )
+ {
+ // Composite
+ Composite composite = toolkit.createComposite( parent );
+ composite.setLayout( new GridLayout( 2, false ) );
+ composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Cache Size
+ toolkit.createLabel( composite, Messages.getString( "PartitionDetailsPage.CacheSize" ) ); //$NON-NLS-1$
+ cacheSizeText = toolkit.createText( composite, "" ); //$NON-NLS-1$
+ 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 ) );
+
+ // Enable Optimizer
+ enableOptimizerCheckbox = toolkit.createButton( composite,
+ Messages.getString( "PartitionDetailsPage.EnableOptimzer" ), SWT.CHECK ); //$NON-NLS-1$
+ enableOptimizerCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+
+ return composite;
+ }
+
+
+ /**
+ * Adds the listeners.
+ */
+ private void addListeners()
+ {
+ cacheSizeText.addModifyListener( dirtyModifyListener );
+ enableOptimizerCheckbox.addSelectionListener( dirtySelectionListener );
+ }
+
+
+ /**
+ * Removes the listeners
+ */
+ private void removeListeners()
+ {
+ cacheSizeText.removeModifyListener( dirtyModifyListener );
+ enableOptimizerCheckbox.removeSelectionListener( dirtySelectionListener );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void refresh()
+ {
+ removeListeners();
+
+ if ( partition != null )
+ {
+ // Cache Size
+ cacheSizeText.setText( "" + partition.getPartitionCacheSize() ); //$NON-NLS-1$
+
+ // Enable Optimizer
+ enableOptimizerCheckbox.setSelection( partition.isJdbmPartitionOptimizerEnabled() );
+ }
+
+ addListeners();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit( boolean onSave )
+ {
+ if ( partition != null )
+ {
+ // Cache Size
+ try
+ {
+ partition.setPartitionCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
+ }
+ catch ( NumberFormatException nfe )
+ {
+ // Nothing to do
+ }
+
+ // Enable Optimizer
+ partition.setJdbmPartitionOptimizerEnabled( enableOptimizerCheckbox.getSelection() );
+ }
+ }
+}
\ No newline at end of file
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/MavibotPartitionSpecificDetailsBlock.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/MavibotPartitionSpecificDetailsBlock.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/MavibotPartitionSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/MavibotPartitionSpecificDetailsBlock.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,83 @@
+/*
+ * 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.editor;
+
+
+import org.apache.directory.server.config.beans.MavibotPartitionBean;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+
+/**
+ * This class implements a specific details block for the Mavibot partition.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MavibotPartitionSpecificDetailsBlock extends AbstractPartitionSpecificDetailsBlock<MavibotPartitionBean>
+{
+ /**
+ * Creates a new instance of MavibotPartitionSpecificDetailsBlock.
+ *
+ * @param detailsPage the details page
+ * @param partition the partition
+ */
+ public MavibotPartitionSpecificDetailsBlock( PartitionDetailsPage detailsPage, MavibotPartitionBean partition )
+ {
+ super( detailsPage, partition );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createBlockContent( Composite parent, FormToolkit toolkit )
+ {
+ // Composite
+ Composite composite = toolkit.createComposite( parent );
+ composite.setLayout( new GridLayout() );
+ composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Information Label
+ toolkit.createLabel( composite, "No specific settings for a Mavibot partition." );
+
+ return composite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void refresh()
+ {
+ // Nothing to do
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit( boolean onSave )
+ {
+ // Nothing to do
+ }
+}
\ No newline at end of file
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=1523681&r1=1523680&r2=1523681&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 Sep 16 14:36:10 2013
@@ -39,13 +39,18 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.server.config.beans.IndexBean;
import org.apache.directory.server.config.beans.JdbmIndexBean;
import org.apache.directory.server.config.beans.JdbmPartitionBean;
+import org.apache.directory.server.config.beans.MavibotIndexBean;
+import org.apache.directory.server.config.beans.MavibotPartitionBean;
+import org.apache.directory.server.config.beans.PartitionBean;
import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPluginConstants;
import org.apache.directory.studio.apacheds.configuration.v2.dialogs.AttributeValueDialog;
-import org.apache.directory.studio.apacheds.configuration.v2.dialogs.IndexDialog;
+import org.apache.directory.studio.apacheds.configuration.v2.dialogs.JdbmIndexDialog;
+import org.apache.directory.studio.apacheds.configuration.v2.dialogs.MavibotIndexDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -66,12 +71,11 @@ import org.eclipse.swt.events.ModifyList
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
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.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -81,8 +85,6 @@ import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
/**
@@ -92,14 +94,17 @@ import org.eclipse.ui.forms.widgets.Tabl
*/
public class PartitionDetailsPage implements IDetailsPage
{
+ /** The class instance */
+ private PartitionDetailsPage instance;
+
/** The associated Master Details Block */
private PartitionsMasterDetailsBlock masterDetailsBlock;
- /** The Managed Form */
- private IManagedForm mform;
+ /** The partition wrapper */
+ private PartitionWrapper partitionWrapper;
- /** The input Partition */
- private JdbmPartitionBean input;
+ /** The partition specific details block */
+ private PartitionSpecificDetailsBlock partitionSpecificDetailsBlock;
/** The Context Entry */
private Entry contextEntry;
@@ -108,10 +113,14 @@ public class PartitionDetailsPage implem
private List<IndexBean> indexesList;
// UI fields
+ private Composite parentComposite;
+ private FormToolkit toolkit;
+ private Composite partitionSpecificDetailsComposite;
+ private Section specificSettingsSection;
+ private Composite specificSettingsSectionComposite;
+ private ComboViewer partitionTypeComboViewer;
private Text idText;
- private Text cacheSizeText;
private Text suffixText;
- private Button enableOptimizerCheckbox;
private Button synchOnWriteCheckbox;
private Button autoGenerateContextEntryCheckbox;
private TableViewer contextEntryTableViewer;
@@ -198,7 +207,7 @@ public class PartitionDetailsPage implem
}
catch ( LdapInvalidAttributeValueException liave )
{
- // TODO : handle the exception
+ // Will never occur
}
}
else
@@ -223,6 +232,43 @@ public class PartitionDetailsPage implem
}
};
+ private ISelectionChangedListener partitionTypeComboViewerSelectionChangedListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ PartitionType type = ( PartitionType ) ( ( StructuredSelection ) partitionTypeComboViewer.getSelection() )
+ .getFirstElement();
+
+ if ( ( partitionWrapper != null ) && ( partitionWrapper.getPartition() != null ) )
+ {
+ PartitionBean partition = partitionWrapper.getPartition();
+
+ // Only change the type if it's a different one
+ if ( type != PartitionType.fromPartition( partition ) )
+ {
+ switch ( type )
+ {
+ case JDBM:
+ JdbmPartitionBean newJdbmPartition = new JdbmPartitionBean();
+ copyPartitionProperties( partition, newJdbmPartition );
+ partitionWrapper.setPartition( newJdbmPartition );
+ break;
+ case MAVIBOT:
+ MavibotPartitionBean newMavibotPartition = new MavibotPartitionBean();
+ copyPartitionProperties( partition, newMavibotPartition );
+ partitionWrapper.setPartition( newMavibotPartition );
+ break;
+ default:
+ break;
+ }
+
+ refresh();
+ setEditorDirty();
+ }
+ }
+ }
+ };
+
/** The Listener for the Edit button of the Context Entry Section */
private SelectionListener contextEntryEditButtonListener = new SelectionAdapter()
{
@@ -311,6 +357,7 @@ public class PartitionDetailsPage implem
*/
public PartitionDetailsPage( PartitionsMasterDetailsBlock pmdb )
{
+ instance = this;
masterDetailsBlock = pmdb;
}
@@ -320,77 +367,60 @@ public class PartitionDetailsPage implem
*/
public void createContents( Composite parent )
{
- FormToolkit toolkit = mform.getToolkit();
- TableWrapLayout layout = new TableWrapLayout();
- layout.topMargin = 5;
- layout.leftMargin = 5;
- layout.rightMargin = 2;
- layout.bottomMargin = 2;
- parent.setLayout( layout );
+ this.parentComposite = parent;
+ parent.setLayout( new GridLayout() );
- createDetailsSection( parent, toolkit );
+ createGeneralDetailsSection( parent, toolkit );
createContextEntrySection( parent, toolkit );
+ createPartitionSpecificSettingsSection( parent, toolkit );
createIndexesSection( parent, toolkit );
}
/**
- * Creates the Details Section
+ * Creates the General Details Section
*
* @param parent
* the parent composite
* @param toolkit
* the toolkit to use
*/
- private void createDetailsSection( Composite parent, FormToolkit toolkit )
+ private void createGeneralDetailsSection( Composite parent, FormToolkit toolkit )
{
Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR );
section.marginWidth = 10;
- section.setText( Messages.getString( "PartitionDetailsPage.PartitionsDetails" ) ); //$NON-NLS-1$
+ section.setText( Messages.getString( "PartitionDetailsPage.PartitionsGeneralDetails" ) ); //$NON-NLS-1$
section.setDescription( Messages.getString( "PartitionDetailsPage.SetPropertiesOfPartition" ) ); //$NON-NLS-1$
- TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP );
- td.grabHorizontal = true;
- section.setLayoutData( td );
+ section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite client = toolkit.createComposite( section );
toolkit.paintBordersFor( client );
- GridLayout glayout = new GridLayout( 3, false );
+ GridLayout glayout = new GridLayout( 2, false );
client.setLayout( glayout );
section.setClient( client );
+ // Type
+ toolkit.createLabel( client, "Partition Type:" );
+ Combo partitionTypeCombo = new Combo( client, SWT.READ_ONLY | SWT.SINGLE );
+ partitionTypeCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ partitionTypeComboViewer = new ComboViewer( partitionTypeCombo );
+ partitionTypeComboViewer.setContentProvider( new ArrayContentProvider() );
+ partitionTypeComboViewer.setInput( new Object[]
+ { PartitionType.JDBM, PartitionType.MAVIBOT } );
+
// ID
toolkit.createLabel( client, Messages.getString( "PartitionDetailsPage.Id" ) ); //$NON-NLS-1$
idText = toolkit.createText( client, "" ); //$NON-NLS-1$
- idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
-
- // Cache Size
- toolkit.createLabel( client, Messages.getString( "PartitionDetailsPage.CacheSize" ) ); //$NON-NLS-1$
- cacheSizeText = toolkit.createText( client, "" ); //$NON-NLS-1$
- 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, 2, 1 ) );
+ idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Suffix
toolkit.createLabel( client, "Suffix:" ); //$NON-NLS-1$
suffixText = toolkit.createText( client, "" ); //$NON-NLS-1$
- suffixText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
-
- // Enable Optimizer
- enableOptimizerCheckbox = toolkit.createButton( client,
- Messages.getString( "PartitionDetailsPage.EnableOptimzer" ), SWT.CHECK ); //$NON-NLS-1$
- enableOptimizerCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
+ suffixText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
// Synchronisation On Write
synchOnWriteCheckbox = toolkit.createButton( client,
Messages.getString( "PartitionDetailsPage.SynchronizationOnWrite" ), SWT.CHECK ); //$NON-NLS-1$
- synchOnWriteCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
+ synchOnWriteCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
}
@@ -408,7 +438,7 @@ public class PartitionDetailsPage implem
section.marginWidth = 10;
section.setText( "Context Entry" ); //$NON-NLS-1$
section.setDescription( "Set the attribute/value pairs for the Context Entry of the partition." ); //$NON-NLS-1$
- section.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite client = toolkit.createComposite( section );
toolkit.paintBordersFor( client );
client.setLayout( new GridLayout( 2, false ) );
@@ -552,6 +582,72 @@ public class PartitionDetailsPage implem
/**
+ * Creates the Partition Specific Settings Section
+ *
+ * @param parent
+ * the parent composite
+ * @param toolkit
+ * the toolkit to use
+ */
+ private void createPartitionSpecificSettingsSection( Composite parent, FormToolkit toolkit )
+ {
+ // Creating the Section
+ specificSettingsSection = toolkit.createSection( parent, Section.TWISTIE | Section.EXPANDED
+ | Section.TITLE_BAR );
+ specificSettingsSection.marginWidth = 10;
+ specificSettingsSection.setText( "Partition Specific Settings" );
+ specificSettingsSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Creating the Composite
+ specificSettingsSectionComposite = toolkit.createComposite( specificSettingsSection );
+ toolkit.paintBordersFor( specificSettingsSectionComposite );
+ GridLayout gd = new GridLayout();
+ gd.marginHeight = gd.marginWidth = 0;
+ gd.verticalSpacing = gd.horizontalSpacing = 0;
+ specificSettingsSectionComposite.setLayout( gd );
+ specificSettingsSection.setClient( specificSettingsSectionComposite );
+ }
+
+
+ /**
+ * Disposes the inner specific settings composite.
+ */
+ private void disposeSpecificSettingsComposite()
+ {
+ if ( ( partitionSpecificDetailsComposite != null ) && !( partitionSpecificDetailsComposite.isDisposed() ) )
+ {
+ partitionSpecificDetailsComposite.dispose();
+ }
+
+ partitionSpecificDetailsComposite = null;
+ }
+
+
+ /**
+ * Updates the partition specific settings section.
+ */
+ private void updatePartitionSpecificSettingsSection()
+ {
+ // Disposing existing specific settings composite
+ disposeSpecificSettingsComposite();
+
+ // Create the specific settings block content
+ if ( partitionSpecificDetailsBlock != null )
+ {
+ partitionSpecificDetailsComposite = partitionSpecificDetailsBlock.createBlockContent(
+ specificSettingsSectionComposite,
+ toolkit );
+ partitionSpecificDetailsBlock.refresh();
+ }
+
+ parentComposite.layout( true, true );
+
+ // Making the section visible or not
+ specificSettingsSection.setVisible( partitionSpecificDetailsBlock != null );
+ }
+
+
+ /**
* Creates the Indexes Section
*
* @param parent
@@ -567,7 +663,7 @@ public class PartitionDetailsPage implem
indexedAttributesSection.setText( Messages.getString( "PartitionDetailsPage.IndexedAttributes" ) ); //$NON-NLS-1$
indexedAttributesSection.setDescription( Messages
.getString( "PartitionDetailsPage.SetIndexedAttributesOfPartition" ) ); //$NON-NLS-1$
- indexedAttributesSection.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ indexedAttributesSection.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
Composite indexedAttributesClient = toolkit.createComposite( indexedAttributesSection );
toolkit.paintBordersFor( indexedAttributesClient );
indexedAttributesClient.setLayout( new GridLayout( 2, false ) );
@@ -582,17 +678,21 @@ public class PartitionDetailsPage implem
indexesTableViewer.setContentProvider( new ArrayContentProvider() );
indexesTableViewer.setLabelProvider( new LabelProvider()
{
- @SuppressWarnings("unchecked")
public String getText( Object element )
{
if ( element instanceof JdbmIndexBean )
{
- JdbmIndexBean<String, Entry> jdbmIndexBean = ( JdbmIndexBean<String, Entry> ) element;
+ JdbmIndexBean jdbmIndexBean = ( JdbmIndexBean ) element;
- return NLS.bind(
- Messages.getString( "PartitionDetailsPage.IndexAttributeIdAndCacheSize" ), jdbmIndexBean.getIndexAttributeId(), //$NON-NLS-1$
+ return NLS.bind( "{0} [{1}]", jdbmIndexBean.getIndexAttributeId(), //$NON-NLS-1$
jdbmIndexBean.getIndexCacheSize() );
}
+ else if ( element instanceof MavibotIndexBean )
+ {
+ MavibotIndexBean mavibotIndexBean = ( MavibotIndexBean ) element;
+
+ return mavibotIndexBean.getIndexAttributeId();
+ }
return super.getText( element );
}
@@ -600,7 +700,7 @@ public class PartitionDetailsPage implem
public Image getImage( Object element )
{
- if ( element instanceof JdbmIndexBean )
+ if ( element instanceof IndexBean )
{
return ApacheDS2ConfigurationPlugin.getDefault().getImage(
ApacheDS2ConfigurationPluginConstants.IMG_INDEX );
@@ -647,11 +747,11 @@ public class PartitionDetailsPage implem
*/
private void addListeners()
{
+ partitionTypeComboViewer.addSelectionChangedListener( partitionTypeComboViewerSelectionChangedListener );
+
idText.addModifyListener( textModifyListener );
- cacheSizeText.addModifyListener( textModifyListener );
suffixText.addModifyListener( textModifyListener );
suffixText.addModifyListener( suffixTextModifyListener );
- enableOptimizerCheckbox.addSelectionListener( checkboxSelectionListener );
synchOnWriteCheckbox.addSelectionListener( checkboxSelectionListener );
autoGenerateContextEntryCheckbox.addSelectionListener( autoGenerateContextEntryCheckboxSelectionListener );
@@ -674,11 +774,11 @@ public class PartitionDetailsPage implem
*/
private void removeListeners()
{
+ partitionTypeComboViewer.removeSelectionChangedListener( partitionTypeComboViewerSelectionChangedListener );
+
idText.removeModifyListener( textModifyListener );
- cacheSizeText.removeModifyListener( textModifyListener );
suffixText.removeModifyListener( textModifyListener );
suffixText.removeModifyListener( suffixTextModifyListener );
- enableOptimizerCheckbox.removeSelectionListener( checkboxSelectionListener );
synchOnWriteCheckbox.removeSelectionListener( checkboxSelectionListener );
autoGenerateContextEntryCheckbox.removeSelectionListener( autoGenerateContextEntryCheckboxSelectionListener );
@@ -704,11 +804,11 @@ public class PartitionDetailsPage implem
IStructuredSelection ssel = ( IStructuredSelection ) selection;
if ( ssel.size() == 1 )
{
- input = ( JdbmPartitionBean ) ssel.getFirstElement();
+ partitionWrapper = ( PartitionWrapper ) ssel.getFirstElement();
}
else
{
- input = null;
+ partitionWrapper = null;
}
refresh();
}
@@ -719,30 +819,44 @@ public class PartitionDetailsPage implem
*/
public void commit( boolean onSave )
{
- if ( input != null )
+ if ( ( partitionWrapper != null ) && ( partitionWrapper.getPartition() != null ) )
{
- input.setPartitionId( idText.getText() );
- input.setPartitionCacheSize( Integer.parseInt( cacheSizeText.getText() ) );
+ PartitionBean partition = partitionWrapper.getPartition();
+
+ // ID
+ partition.setPartitionId( idText.getText() );
+
+ // Suffix
try
{
- input.setPartitionSuffix( new Dn( suffixText.getText() ) );
+ partition.setPartitionSuffix( new Dn( suffixText.getText() ) );
}
catch ( LdapInvalidDnException e )
{
// Stay silent
}
- input.setJdbmPartitionOptimizerEnabled( enableOptimizerCheckbox.getSelection() );
- input.setPartitionSyncOnWrite( synchOnWriteCheckbox.getSelection() );
+ // Context Entry
if ( contextEntry.size() > 0 )
{
LdifEntry ldifEntry = new LdifEntry( contextEntry );
- ldifEntry.setDn( input.getPartitionSuffix() );
- input.setContextEntry( ldifEntry.toString() );
+ ldifEntry.setDn( partition.getPartitionSuffix() );
+ partition.setContextEntry( ldifEntry.toString() );
}
else
{
- input.setContextEntry( null );
+ partition.setContextEntry( null );
+ }
+
+ // Synchronization on write
+ partition.setPartitionSyncOnWrite( synchOnWriteCheckbox.getSelection() );
+
+ //
+ // Specific Settings
+ //
+ if ( partitionSpecificDetailsBlock != null )
+ {
+ partitionSpecificDetailsBlock.commit( onSave );
}
}
}
@@ -761,7 +875,7 @@ public class PartitionDetailsPage implem
*/
public void initialize( IManagedForm form )
{
- this.mform = form;
+ toolkit = form.getToolkit();
}
@@ -790,37 +904,67 @@ public class PartitionDetailsPage implem
{
removeListeners();
- // Checking if the selected partition is the system partition
- boolean isSystemPartition = PartitionsPage.isSystemPartition( input );
+ if ( ( partitionWrapper != null ) && ( partitionWrapper.getPartition() != null ) )
+ {
+ PartitionBean partition = partitionWrapper.getPartition();
- // ID
- String id = input.getPartitionId();
- idText.setText( ( id == null ) ? "" : id ); //$NON-NLS-1$
- idText.setEnabled( !isSystemPartition );
+ // Checking if the selected partition is the system partition
+ boolean isSystemPartition = PartitionsPage.isSystemPartition( partition );
- // Cache Size
- cacheSizeText.setText( "" + input.getPartitionCacheSize() ); //$NON-NLS-1$
+ // Type
+ PartitionType partitionType = PartitionType.fromPartition( partition );
+ partitionTypeComboViewer.setSelection( new StructuredSelection( partitionType ) );
+ partitionTypeComboViewer.getCombo().setEnabled( !isSystemPartition );
- // Suffix
- Dn suffix = input.getPartitionSuffix();
- suffixText.setText( ( suffix == null ) ? "" : suffix.toString() ); //$NON-NLS-1$
- suffixText.setEnabled( !isSystemPartition );
+ // ID
+ String id = partition.getPartitionId();
+ idText.setText( ( id == null ) ? "" : id ); //$NON-NLS-1$
+ idText.setEnabled( !isSystemPartition );
- // Enable Optimizer
- enableOptimizerCheckbox.setSelection( input.isJdbmPartitionOptimizerEnabled() );
+ // Suffix
+ Dn suffix = partition.getPartitionSuffix();
+ suffixText.setText( ( suffix == null ) ? "" : suffix.toString() ); //$NON-NLS-1$
+ suffixText.setEnabled( !isSystemPartition );
- // Synchronization on write
- synchOnWriteCheckbox.setSelection( input.isPartitionSyncOnWrite() );
+ // Auto Generate Context Entry
+ autoGenerateContextEntryCheckbox.setSelection( true ); // TODO review this
- // Auto Generate Context Entry
- autoGenerateContextEntryCheckbox.setSelection( true );
+ // Context Entry
+ refreshContextEntry();
- // Context Entry
- refreshContextEntry();
+ // Indexed Attributes
+ indexesList = partition.getIndexes();
+ indexesTableViewer.setInput( indexesList );
- // Indexed Attributes
- indexesList = input.getIndexes();
- indexesTableViewer.setInput( indexesList );
+ // Synchronization on write
+ synchOnWriteCheckbox.setSelection( partition.isPartitionSyncOnWrite() );
+
+ //
+ // Specific Settings
+ //
+
+ // JdbmPartitionBean Type
+ if ( partition instanceof JdbmPartitionBean )
+ {
+ partitionTypeComboViewer.setSelection( new StructuredSelection( PartitionType.JDBM ) );
+ partitionSpecificDetailsBlock = new JdbmPartitionSpecificDetailsBlock( instance,
+ ( JdbmPartitionBean ) partition );
+ }
+ // MavibotPartitionBean Type
+ else if ( partition instanceof MavibotPartitionBean )
+ {
+ partitionTypeComboViewer.setSelection( new StructuredSelection( PartitionType.MAVIBOT ) );
+ partitionSpecificDetailsBlock = new MavibotPartitionSpecificDetailsBlock( instance,
+ ( MavibotPartitionBean ) partition );
+ }
+ else
+ {
+ partitionTypeComboViewer.setSelection( null );
+ partitionSpecificDetailsBlock = null;
+ }
+
+ updatePartitionSpecificSettingsSection();
+ }
addListeners();
}
@@ -828,37 +972,44 @@ public class PartitionDetailsPage implem
private void refreshContextEntry()
{
- String contextEntryString = input.getContextEntry();
-
- if ( ( contextEntryString != null ) && ( !"".equals( contextEntryString ) ) ) //$NON-NLS-1$
+ if ( ( partitionWrapper != null ) && ( partitionWrapper.getPartition() != null ) )
{
- try
+ PartitionBean partition = partitionWrapper.getPartition();
+
+ String contextEntryString = partition.getContextEntry();
+
+ if ( ( contextEntryString != null ) && ( !"".equals( contextEntryString ) ) ) //$NON-NLS-1$
{
- // Replace '\n' to real LF
- contextEntryString = contextEntryString.replaceAll( "\\\\n", "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
+ try
+ {
+ // Replace '\n' to real LF
+ contextEntryString = contextEntryString.replaceAll( "\\\\n", "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
- LdifReader reader = new LdifReader( new StringReader( contextEntryString ) );
- contextEntry = reader.next().getEntry();
- reader.close();
+ LdifReader reader = new LdifReader( new StringReader( contextEntryString ) );
+ contextEntry = reader.next().getEntry();
+ reader.close();
+ }
+ catch ( Exception e )
+ {
+ contextEntry = new DefaultEntry();
+ }
}
- catch ( Exception e )
+ else
{
contextEntry = new DefaultEntry();
}
- }
- else
- {
- contextEntry = new DefaultEntry();
- }
- contextEntryTableViewer.setInput( contextEntry );
- resizeContextEntryTableColumnsToFit();
+ contextEntryTableViewer.setInput( contextEntry );
+ resizeContextEntryTableColumnsToFit();
+
+ // TODO Verify this
- boolean enabled = !autoGenerateContextEntryCheckbox.getSelection();
- contextEntryTableViewer.getTable().setEnabled( enabled );
- contextEntryAddButton.setEnabled( enabled );
- contextEntryEditButton.setEnabled( enabled );
- contextEntryDeleteButton.setEnabled( enabled );
+ boolean enabled = !autoGenerateContextEntryCheckbox.getSelection();
+ contextEntryTableViewer.getTable().setEnabled( enabled );
+ contextEntryAddButton.setEnabled( enabled );
+ contextEntryEditButton.setEnabled( enabled );
+ contextEntryDeleteButton.setEnabled( enabled );
+ }
}
@@ -867,17 +1018,22 @@ public class PartitionDetailsPage implem
*/
private void autoGenerateContextEntry()
{
- if ( autoGenerateContextEntryCheckbox.getSelection() )
+ if ( ( partitionWrapper != null ) && ( partitionWrapper.getPartition() != null ) )
{
- try
- {
- Dn suffixDn = new Dn( suffixText.getText() );
- input.setContextEntry( PartitionsMasterDetailsBlock.getContextEntryLdif( suffixDn ) );
- refreshContextEntry();
- }
- catch ( LdapInvalidDnException e1 )
+ PartitionBean partition = partitionWrapper.getPartition();
+
+ if ( autoGenerateContextEntryCheckbox.getSelection() )
{
- // Silent
+ try
+ {
+ Dn suffixDn = new Dn( suffixText.getText() );
+ partition.setContextEntry( PartitionsMasterDetailsBlock.getContextEntryLdif( suffixDn ) );
+ refreshContextEntry();
+ }
+ catch ( LdapInvalidDnException e1 )
+ {
+ // Silent
+ }
}
}
}
@@ -919,19 +1075,53 @@ public class PartitionDetailsPage implem
/**
* Opens an indexed dialog with the selected index in the indexes table viewer.
*/
- @SuppressWarnings("unchecked")
private void editSelectedIndex()
{
StructuredSelection selection = ( StructuredSelection ) indexesTableViewer.getSelection();
if ( !selection.isEmpty() )
{
- JdbmIndexBean<String, Entry> index = ( JdbmIndexBean<String, Entry> ) selection.getFirstElement();
+ PartitionType partitionType = ( PartitionType ) ( ( StructuredSelection ) partitionTypeComboViewer
+ .getSelection() ).getFirstElement();
- IndexDialog dialog = new IndexDialog( index );
- if ( IndexDialog.OK == dialog.open() && dialog.isDirty() )
+ if ( partitionType != null )
{
- indexesTableViewer.refresh();
- masterDetailsBlock.setEditorDirty();
+ IndexBean editedIndex = null;
+
+ // JDBM partition
+ if ( partitionType == PartitionType.JDBM )
+ {
+ // Getting the selected JDBM index
+ JdbmIndexBean index = ( JdbmIndexBean ) selection.getFirstElement();
+
+ // Creating a JDBM dialog
+ JdbmIndexDialog dialog = new JdbmIndexDialog( index );
+
+ if ( JdbmIndexDialog.OK == dialog.open() && dialog.isDirty() )
+ {
+ editedIndex = index;
+ }
+ }
+ // Mavibot Partition
+ else if ( partitionType == PartitionType.MAVIBOT )
+ {
+ // Getting the selected Mavibot index
+ MavibotIndexBean index = ( MavibotIndexBean ) selection.getFirstElement();
+
+ // Creating a Mavibot dialog
+ MavibotIndexDialog dialog = new MavibotIndexDialog( index );
+
+ if ( MavibotIndexDialog.OK == dialog.open() && dialog.isDirty() )
+ {
+ editedIndex = index;
+ }
+ }
+
+ // Checking the new index
+ if ( editedIndex != null )
+ {
+ indexesTableViewer.refresh();
+ masterDetailsBlock.setEditorDirty();
+ }
}
}
}
@@ -942,17 +1132,57 @@ public class PartitionDetailsPage implem
*/
private void addNewIndex()
{
- JdbmIndexBean<String, Entry> newIndex = new JdbmIndexBean<String, Entry>();
- newIndex.setIndexAttributeId( "" ); //$NON-NLS-1$
- newIndex.setIndexCacheSize( 100 );
-
- IndexDialog dialog = new IndexDialog( newIndex );
- if ( IndexDialog.OK == dialog.open() )
- {
- indexesList.add( dialog.getIndex() );
- indexesTableViewer.refresh();
- indexesTableViewer.setSelection( new StructuredSelection( dialog.getIndex() ) );
- masterDetailsBlock.setEditorDirty();
+ PartitionType partitionType = ( PartitionType ) ( ( StructuredSelection ) partitionTypeComboViewer
+ .getSelection() ).getFirstElement();
+
+ if ( partitionType != null )
+ {
+ IndexBean newIndex = null;
+
+ // JDBM partition
+ if ( partitionType == PartitionType.JDBM )
+ {
+ JdbmIndexBean newJdbmIndex = new JdbmIndexBean();
+ newJdbmIndex.setIndexAttributeId( "" ); //$NON-NLS-1$
+ newJdbmIndex.setIndexCacheSize( 100 );
+
+ JdbmIndexDialog dialog = new JdbmIndexDialog( newJdbmIndex );
+ if ( JdbmIndexDialog.OK == dialog.open() )
+ {
+ newIndex = dialog.getIndex();
+ }
+ else
+ {
+ // Cancel
+ return;
+ }
+ }
+ // Mavibot Partition
+ else if ( partitionType == PartitionType.MAVIBOT )
+ {
+ MavibotIndexBean newMavibotIndex = new MavibotIndexBean();
+ newMavibotIndex.setIndexAttributeId( "" ); //$NON-NLS-1$
+
+ MavibotIndexDialog dialog = new MavibotIndexDialog( newMavibotIndex );
+ if ( MavibotIndexDialog.OK == dialog.open() )
+ {
+ newIndex = dialog.getIndex();
+ }
+ else
+ {
+ // Cancel
+ return;
+ }
+ }
+
+ // Checking the new index
+ if ( newIndex != null )
+ {
+ indexesList.add( newIndex );
+ indexesTableViewer.refresh();
+ indexesTableViewer.setSelection( new StructuredSelection( newIndex ) );
+ masterDetailsBlock.setEditorDirty();
+ }
}
}
@@ -960,16 +1190,16 @@ public class PartitionDetailsPage implem
/**
* Deletes the selected index in the indexes table viewer
*/
- @SuppressWarnings("unchecked")
private void deleteSelectedIndex()
{
StructuredSelection selection = ( StructuredSelection ) indexesTableViewer.getSelection();
+
if ( !selection.isEmpty() )
{
- JdbmIndexBean<String, Entry> selectedIndex = ( JdbmIndexBean<String, Entry> ) selection.getFirstElement();
+ IndexBean selectedIndex = ( IndexBean ) selection.getFirstElement();
if ( MessageDialog
- .openConfirm( mform.getForm().getShell(),
+ .openConfirm( indexesDeleteButton.getShell(),
Messages.getString( "PartitionDetailsPage.ConfirmDelete" ), //$NON-NLS-1$
NLS.bind(
Messages.getString( "PartitionDetailsPage.AreYouSureDeleteIndex" ), selectedIndex.getIndexAttributeId() ) ) ) //$NON-NLS-1$
@@ -1016,7 +1246,7 @@ public class PartitionDetailsPage implem
}
catch ( LdapInvalidAttributeValueException liave )
{
- // TODO : handle the exception
+ // Will never occur
}
}
else
@@ -1040,4 +1270,66 @@ public class PartitionDetailsPage implem
}
}
}
+
+
+ /**
+ * Sets the associated editor dirty.
+ */
+ public void setEditorDirty()
+ {
+ masterDetailsBlock.setEditorDirty();
+ }
+
+
+ /**
+ * Copies partition properties from one instance to the other.
+ *
+ * @param original the original partition
+ * @param destination the destination partition
+ */
+ private void copyPartitionProperties( PartitionBean original, PartitionBean destination )
+ {
+ if ( ( original != null ) && ( destination != null ) )
+ {
+ // Simple properties
+ destination.setContextEntry( original.getContextEntry() );
+ destination.setDescription( original.getDescription() );
+ destination.setDn( original.getDn() );
+ destination.setEnabled( original.isEnabled() );
+ destination.setPartitionId( original.getPartitionId() );
+ destination.setPartitionSuffix( original.getPartitionSuffix() );
+ destination.setPartitionSyncOnWrite( original.isPartitionSyncOnWrite() );
+
+ // Indexes
+ List<IndexBean> originalIndexes = original.getIndexes();
+ List<IndexBean> destinationIndexes = new ArrayList<IndexBean>();
+
+ if ( originalIndexes != null )
+ {
+ for ( IndexBean originalIndexBean : originalIndexes )
+ {
+ if ( destination instanceof JdbmPartitionBean )
+ {
+ JdbmIndexBean destinationIndexBean = new JdbmIndexBean();
+
+ destinationIndexBean.setIndexAttributeId( originalIndexBean.getIndexAttributeId() );
+ destinationIndexBean.setIndexHasReverse( originalIndexBean.getIndexHasReverse() );
+
+ destinationIndexes.add( destinationIndexBean );
+ }
+ else if ( destination instanceof MavibotPartitionBean )
+ {
+ MavibotIndexBean destinationIndexBean = new MavibotIndexBean();
+
+ destinationIndexBean.setIndexAttributeId( originalIndexBean.getIndexAttributeId() );
+ destinationIndexBean.setIndexHasReverse( originalIndexBean.getIndexHasReverse() );
+
+ destinationIndexes.add( destinationIndexBean );
+ }
+ }
+ }
+
+ destination.setIndexes( destinationIndexes );
+ }
+ }
}
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionSpecificDetailsBlock.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/PartitionSpecificDetailsBlock.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionSpecificDetailsBlock.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionSpecificDetailsBlock.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,68 @@
+/*
+ * 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.editor;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+
+
+/**
+ * This interface represents a block for Partition Specific Details.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface PartitionSpecificDetailsBlock
+{
+ /**
+ * Creates the block content.
+ *
+ * @param parent the parent composite
+ * @param toolkit the toolkit
+ */
+ public Composite createBlockContent( Composite parent, FormToolkit toolkit );
+
+
+ /**
+ * Gets the associated details page.
+ *
+ * @return the associated details page.
+ */
+ public PartitionDetailsPage getDetailsPage();
+
+
+ /**
+ * Refreshes the UI based on the input.
+ */
+ public void refresh();
+
+
+ /**
+ * If part is displaying information loaded from a model, this method
+ * instructs it to commit the new (modified) data back into the model.
+ *
+ * @param onSave
+ * indicates if commit is called during 'save' operation or for
+ * some other reason (for example, if form is contained in a
+ * wizard or a multi-page editor and the user is about to leave
+ * the page).
+ */
+ void commit( boolean onSave );
+}
\ No newline at end of file
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionType.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/PartitionType.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionType.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionType.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,77 @@
+/*
+ * 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.editor;
+
+
+import org.apache.directory.server.config.beans.JdbmPartitionBean;
+import org.apache.directory.server.config.beans.MavibotPartitionBean;
+import org.apache.directory.server.config.beans.PartitionBean;
+
+
+/**
+ * This class represents the General Page of the Server Configuration Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum PartitionType
+{
+ /** The JDBM partition type */
+ JDBM,
+
+ /** The Mavibot partition type */
+ MAVIBOT;
+
+ /**
+ * Gets the partition type.
+ *
+ * @param partition the partition
+ * @return the type corresponding to the partition (or <code>null</code>)
+ */
+ public static PartitionType fromPartition( PartitionBean partition )
+ {
+ if ( partition instanceof JdbmPartitionBean )
+ {
+ return JDBM;
+ }
+ else if ( partition instanceof MavibotPartitionBean )
+ {
+ return MAVIBOT;
+ }
+
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Enum#toString()
+ */
+ public String toString()
+ {
+ switch ( this )
+ {
+ case JDBM:
+ return "JDBM";
+ case MAVIBOT:
+ return "Mavibot";
+ }
+
+ return super.toString();
+ }
+}
Added: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionWrapper.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/PartitionWrapper.java?rev=1523681&view=auto
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionWrapper.java (added)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionWrapper.java Mon Sep 16 14:36:10 2013
@@ -0,0 +1,68 @@
+/*
+ * 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.editor;
+
+
+import org.apache.directory.server.config.beans.PartitionBean;
+
+
+/**
+ * This class defines a simple wrapper for a partition.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PartitionWrapper
+{
+ /** The wrapped partition */
+ private PartitionBean partition;
+
+
+ /**
+ * Creates a new instance of PartitionWrapper.
+ *
+ * @param partition the partition
+ */
+ public PartitionWrapper( PartitionBean partition )
+ {
+ this.partition = partition;
+ }
+
+
+ /**
+ * Gets the partition.
+ *
+ * @return the partition
+ */
+ public PartitionBean getPartition()
+ {
+ return partition;
+ }
+
+
+ /**
+ * Sets the partition.
+ *
+ * @param partition the partition
+ */
+ public void setPartition( PartitionBean partition )
+ {
+ this.partition = partition;
+ }
+}
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=1523681&r1=1523680&r2=1523681&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 Sep 16 14:36:10 2013
@@ -30,10 +30,12 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.ldif.LdifEntry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.name.Rdn;
+import org.apache.directory.server.config.beans.DirectoryServiceBean;
import org.apache.directory.server.config.beans.IndexBean;
import org.apache.directory.server.config.beans.JdbmIndexBean;
import org.apache.directory.server.config.beans.JdbmPartitionBean;
import org.apache.directory.server.config.beans.PartitionBean;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -72,6 +74,9 @@ public class PartitionsMasterDetailsBloc
/** The Details Page */
private PartitionDetailsPage detailsPage;
+ /** The partition wrappers */
+ private List<PartitionWrapper> partitionWrappers = new ArrayList<PartitionWrapper>();
+
// UI Fields
private TableViewer viewer;
private Button addButton;
@@ -151,7 +156,14 @@ public class PartitionsMasterDetailsBloc
*/
private void initFromInput()
{
- viewer.setInput( page.getConfigBean().getDirectoryServiceBean().getPartitions() );
+ partitionWrappers.clear();
+
+ for ( PartitionBean partition : page.getConfigBean().getDirectoryServiceBean().getPartitions() )
+ {
+ partitionWrappers.add( new PartitionWrapper( partition ) );
+ }
+
+ viewer.setInput( partitionWrappers );
}
@@ -185,8 +197,8 @@ public class PartitionsMasterDetailsBloc
// Delete button is not enabled in the case of the system partition
if ( !selection.isEmpty() )
{
- JdbmPartitionBean partition = ( JdbmPartitionBean ) selection.getFirstElement();
- if ( PartitionsPage.isSystemPartition( partition ) )
+ PartitionWrapper partitionWrapper = ( PartitionWrapper ) selection.getFirstElement();
+ if ( PartitionsPage.isSystemPartition( partitionWrapper.getPartition() ) )
{
deleteButton.setEnabled( false );
}
@@ -252,9 +264,10 @@ public class PartitionsMasterDetailsBloc
indexes.add( createJdbmIndex( "uid", 100 ) ); //$NON-NLS-1$
newPartitionBean.setIndexes( indexes );
- page.getConfigBean().getDirectoryServiceBean().addPartitions( newPartitionBean );
+ PartitionWrapper newPartitionWrapper = new PartitionWrapper( newPartitionBean );
+ partitionWrappers.add( newPartitionWrapper );
viewer.refresh();
- viewer.setSelection( new StructuredSelection( newPartitionBean ) );
+ viewer.setSelection( new StructuredSelection( newPartitionWrapper ) );
setEditorDirty();
}
@@ -332,9 +345,13 @@ public class PartitionsMasterDetailsBloc
private void deleteSelectedPartition()
{
StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+
if ( !selection.isEmpty() )
{
- JdbmPartitionBean partition = ( JdbmPartitionBean ) selection.getFirstElement();
+ PartitionWrapper partitionWrapper = ( PartitionWrapper ) selection.getFirstElement();
+
+ PartitionBean partition = partitionWrapper.getPartition();
+
if ( !PartitionsPage.isSystemPartition( partition ) )
{
if ( MessageDialog
@@ -345,7 +362,7 @@ public class PartitionsMasterDetailsBloc
Messages.getString( "PartitionsMasterDetailsBlock.AreYouSureDeletePartition" ), partition.getPartitionId(), //$NON-NLS-1$
partition.getPartitionSuffix() ) ) )
{
- page.getConfigBean().getDirectoryServiceBean().getPartitions().remove( partition );
+ partitionWrappers.remove( partitionWrapper );
setEditorDirty();
}
}
@@ -359,9 +376,9 @@ public class PartitionsMasterDetailsBloc
* @param indexAttributeId the attribute id
* @param indexCacheSize the cache size
*/
- private JdbmIndexBean<String, Entry> createJdbmIndex( String indexAttributeId, int indexCacheSize )
+ private JdbmIndexBean createJdbmIndex( String indexAttributeId, int indexCacheSize )
{
- JdbmIndexBean<String, Entry> index = new JdbmIndexBean<String, Entry>();
+ JdbmIndexBean index = new JdbmIndexBean();
index.setIndexAttributeId( indexAttributeId );
index.setIndexCacheSize( indexCacheSize );
@@ -371,12 +388,23 @@ public class PartitionsMasterDetailsBloc
/**
+ * Sets the Editor as dirty.
+ */
+ public void setEditorDirty()
+ {
+ ( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
+ detailsPage.commit( false );
+ viewer.refresh();
+ }
+
+
+ /**
* {@inheritDoc}
*/
protected void registerPages( DetailsPart detailsPart )
{
detailsPage = new PartitionDetailsPage( this );
- detailsPart.registerPage( JdbmPartitionBean.class, detailsPage );
+ detailsPart.registerPage( PartitionWrapper.class, detailsPage );
}
@@ -391,20 +419,37 @@ public class PartitionsMasterDetailsBloc
/**
- * Sets the Editor as dirty.
+ * Gets the associated editor page.
+ *
+ * @return the associated editor page
*/
- public void setEditorDirty()
+ public PartitionsPage getPage()
{
- ( ( ServerConfigurationEditor ) page.getEditor() ).setDirty( true );
- viewer.refresh();
+ return page;
}
+
/**
* Saves the necessary elements to the input model.
*/
- public void save()
+ public void doSave( IProgressMonitor monitor )
{
+ // Committing information on the details page
detailsPage.commit( true );
+
+ // Getting the directory service bean
+ DirectoryServiceBean directoryServiceBean = page.getConfigBean().getDirectoryServiceBean();
+
+ // Creating a new list of partitions
+ List<PartitionBean> newPartitions = new ArrayList<PartitionBean>();
+
+ // Saving the partitions
+ for ( PartitionWrapper partitionWrapper : partitionWrappers )
+ {
+ newPartitions.add( partitionWrapper.getPartition() );
+ }
+
+ directoryServiceBean.setPartitions( newPartitions );
}
}
Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.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/PartitionsPage.java?rev=1523681&r1=1523680&r2=1523681&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java (original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java Mon Sep 16 14:36:10 2013
@@ -23,6 +23,7 @@ package org.apache.directory.studio.apac
import org.apache.directory.server.config.beans.PartitionBean;
import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPlugin;
import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPluginConstants;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
@@ -44,7 +45,7 @@ public class PartitionsPage extends Serv
/** The Page Title */
private static final String TITLE = Messages.getString( "PartitionsPage.Partitions" ); //$NON-NLS-1$
-
+
/** The Master Details Block */
private PartitionsMasterDetailsBlock masterDetailsBlock;
@@ -57,13 +58,34 @@ public class PartitionsPage extends Serv
{
PartitionBean partition = ( PartitionBean ) element;
- return NLS.bind( "{0} ({1})", partition.getPartitionId(), partition.getPartitionSuffix() ); //$NON-NLS-1$
+ return NLS
+ .bind(
+ "{0} ({1}) [{2}]", new Object[] { partition.getPartitionId(), partition.getPartitionSuffix(), getPartitionType( partition ) } ); //$NON-NLS-1$
+ }
+ else if ( element instanceof PartitionWrapper )
+ {
+ return getText( ( ( PartitionWrapper ) element ).getPartition() );
}
return super.getText( element );
}
+ private String getPartitionType( PartitionBean partition )
+ {
+ PartitionType type = PartitionType.fromPartition( partition );
+
+ if ( type != null )
+ {
+ return type.toString();
+ }
+ else
+ {
+ return "Unknown";
+ }
+ }
+
+
public Image getImage( Object element )
{
if ( element instanceof PartitionBean )
@@ -81,6 +103,10 @@ public class PartitionsPage extends Serv
ApacheDS2ConfigurationPluginConstants.IMG_PARTITION );
}
}
+ else if ( element instanceof PartitionWrapper )
+ {
+ return getImage( ( ( PartitionWrapper ) element ).getPartition() );
+ }
return super.getImage( element );
}
@@ -104,6 +130,11 @@ public class PartitionsPage extends Serv
return partition1Id.compareTo( partition2Id );
}
}
+ if ( ( e1 instanceof PartitionWrapper ) && ( e2 instanceof PartitionWrapper ) )
+ {
+ return compare( viewer, ( ( PartitionWrapper ) e1 ).getPartition(),
+ ( ( PartitionWrapper ) e2 ).getPartition() );
+ }
return super.compare( viewer, e1, e2 );
}
@@ -153,6 +184,23 @@ public class PartitionsPage extends Serv
*/
public static boolean isSystemPartition( PartitionBean partition )
{
- return "system".equalsIgnoreCase( partition.getPartitionId() ); //$NON-NLS-1$
+ if ( partition != null )
+ {
+ return "system".equalsIgnoreCase( partition.getPartitionId() ); //$NON-NLS-1$
+ }
+
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSave( IProgressMonitor monitor )
+ {
+ if ( masterDetailsBlock != null )
+ {
+ masterDetailsBlock.doSave( monitor );
+ }
}
}