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 2012/10/24 18:18:41 UTC
svn commit: r1401759 - in
/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor:
PartitionDetailsPage.java PartitionsMasterDetailsBlock.java
Author: pamarcelot
Date: Wed Oct 24 16:18:41 2012
New Revision: 1401759
URL: http://svn.apache.org/viewvc?rev=1401759&view=rev
Log:
Fix for DIRSTUDIO-838 (Add support for configuring the context entry of a partition in the ApacheDS 2.0 Configuration Editor).
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
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=1401759&r1=1401758&r2=1401759&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 Wed Oct 24 16:18:41 2012
@@ -114,7 +114,7 @@ public class PartitionDetailsPage implem
private Text suffixText;
private Button enableOptimizerCheckbox;
private Button synchOnWriteCheckbox;
- private Table contextEntryTable;
+ private Button autoGenerateContextEntryCheckbox;
private TableViewer contextEntryTableViewer;
private Button contextEntryAddButton;
private Button contextEntryEditButton;
@@ -135,6 +135,14 @@ public class PartitionDetailsPage implem
}
};
+ private ModifyListener suffixTextModifyListener = new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ autoGenerateContextEntry();
+ }
+ };
+
/** The Checkbox Selection Listener */
private SelectionListener checkboxSelectionListener = new SelectionAdapter()
{
@@ -145,13 +153,21 @@ public class PartitionDetailsPage implem
}
};
+ private SelectionListener autoGenerateContextEntryCheckboxSelectionListener = new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ autoGenerateContextEntry();
+ updateContextEntryEnableState();
+ }
+ };
+
/** The Selection Changed Listener for the Context Entry Table Viewer */
private ISelectionChangedListener contextEntryTableViewerListener = new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
- contextEntryEditButton.setEnabled( !event.getSelection().isEmpty() );
- contextEntryDeleteButton.setEnabled( !event.getSelection().isEmpty() );
+ updateContextEntryEnableState();
}
};
@@ -397,7 +413,13 @@ public class PartitionDetailsPage implem
client.setLayout( new GridLayout( 2, false ) );
section.setClient( client );
- contextEntryTable = toolkit.createTable( client, SWT.NONE );
+ // Auto Generate Context Entry Checkbox
+ autoGenerateContextEntryCheckbox = toolkit.createButton( client, "Auto-generate context entry from suffix DN",
+ SWT.CHECK );
+ autoGenerateContextEntryCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 3, 1 ) );
+
+ // Context Entry Table Viewer
+ Table contextEntryTable = toolkit.createTable( client, SWT.NONE );
GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 );
gd.heightHint = 62;
gd.widthHint = 50;
@@ -494,13 +516,16 @@ public class PartitionDetailsPage implem
GridData buttonsGD = new GridData( SWT.FILL, SWT.BEGINNING, false, false );
buttonsGD.widthHint = IDialogConstants.BUTTON_WIDTH;
+ // Context Entry Add Button
contextEntryAddButton = toolkit.createButton( client, "Add...", SWT.PUSH );
contextEntryAddButton.setLayoutData( buttonsGD );
+ // Context Entry Edit Button
contextEntryEditButton = toolkit.createButton( client, "Edit...", SWT.PUSH );
contextEntryEditButton.setEnabled( false );
contextEntryEditButton.setLayoutData( buttonsGD );
+ // Context Entry Delete Button
contextEntryDeleteButton = toolkit.createButton( client, "Delete", SWT.PUSH );
contextEntryDeleteButton.setEnabled( false );
contextEntryDeleteButton.setLayoutData( buttonsGD );
@@ -508,6 +533,20 @@ public class PartitionDetailsPage implem
/**
+ * Updates the context entry widgets enable state.
+ */
+ private void updateContextEntryEnableState()
+ {
+ contextEntryTableViewer.getTable().setEnabled( !autoGenerateContextEntryCheckbox.getSelection() );
+ contextEntryAddButton.setEnabled( !autoGenerateContextEntryCheckbox.getSelection() );
+ contextEntryEditButton.setEnabled( ( !autoGenerateContextEntryCheckbox.getSelection() )
+ && ( !contextEntryTableViewer.getSelection().isEmpty() ) );
+ contextEntryDeleteButton.setEnabled( ( !autoGenerateContextEntryCheckbox.getSelection() )
+ && ( !contextEntryTableViewer.getSelection().isEmpty() ) );
+ }
+
+
+ /**
* Creates the Indexes Section
*
* @param parent
@@ -600,9 +639,11 @@ public class PartitionDetailsPage implem
idText.addModifyListener( textModifyListener );
cacheSizeText.addModifyListener( textModifyListener );
suffixText.addModifyListener( textModifyListener );
+ suffixText.addModifyListener( suffixTextModifyListener );
enableOptimizerCheckbox.addSelectionListener( checkboxSelectionListener );
synchOnWriteCheckbox.addSelectionListener( checkboxSelectionListener );
+ autoGenerateContextEntryCheckbox.addSelectionListener( autoGenerateContextEntryCheckboxSelectionListener );
contextEntryTableViewer.addDoubleClickListener( contextEntryTableViewerDoubleClickListener );
contextEntryTableViewer.addSelectionChangedListener( contextEntryTableViewerListener );
contextEntryAddButton.addSelectionListener( contextEntryAddButtonListener );
@@ -625,9 +666,11 @@ public class PartitionDetailsPage implem
idText.removeModifyListener( textModifyListener );
cacheSizeText.removeModifyListener( textModifyListener );
suffixText.removeModifyListener( textModifyListener );
+ suffixText.removeModifyListener( suffixTextModifyListener );
enableOptimizerCheckbox.removeSelectionListener( checkboxSelectionListener );
synchOnWriteCheckbox.removeSelectionListener( checkboxSelectionListener );
+ autoGenerateContextEntryCheckbox.removeSelectionListener( autoGenerateContextEntryCheckboxSelectionListener );
contextEntryTableViewer.removeDoubleClickListener( contextEntryTableViewerDoubleClickListener );
contextEntryTableViewer.removeSelectionChangedListener( contextEntryTableViewerListener );
contextEntryAddButton.removeSelectionListener( contextEntryAddButtonListener );
@@ -758,7 +801,22 @@ public class PartitionDetailsPage implem
// Synchronization on write
synchOnWriteCheckbox.setSelection( input.isPartitionSyncOnWrite() );
+ // Auto Generate Context Entry
+ autoGenerateContextEntryCheckbox.setSelection( true );
+
// Context Entry
+ refreshContextEntry();
+
+ // Indexed Attributes
+ indexesList = input.getIndexes();
+ indexesTableViewer.setInput( indexesList );
+
+ addListeners();
+ }
+
+
+ private void refreshContextEntry()
+ {
String contextEntryString = input.getContextEntry();
if ( ( contextEntryString != null ) && ( !"".equals( contextEntryString ) ) )
@@ -785,25 +843,47 @@ public class PartitionDetailsPage implem
contextEntryTableViewer.setInput( contextEntry );
resizeContextEntryTableColumnsToFit();
- // Indexed Attributes
- indexesList = input.getIndexes();
- indexesTableViewer.setInput( indexesList );
-
- addListeners();
+ boolean enabled = !autoGenerateContextEntryCheckbox.getSelection();
+ contextEntryTableViewer.getTable().setEnabled( enabled );
+ contextEntryAddButton.setEnabled( enabled );
+ contextEntryEditButton.setEnabled( enabled );
+ contextEntryDeleteButton.setEnabled( enabled );
}
+
+ /**
+ * Auto generates the context entry.
+ */
+ private void autoGenerateContextEntry()
+ {
+ if ( autoGenerateContextEntryCheckbox.getSelection() )
+ {
+ try
+ {
+ Dn suffixDn = new Dn( suffixText.getText() );
+ input.setContextEntry( PartitionsMasterDetailsBlock.getContextEntryLdif( suffixDn ) );
+ refreshContextEntry();
+ }
+ catch ( LdapInvalidDnException e1 )
+ {
+ // Silent
+ }
+ }
+ }
+
/**
* Resizes the columns to fit the size of the cells.
*/
private void resizeContextEntryTableColumnsToFit()
{
// Resizing the first column
- contextEntryTable.getColumn( 0 ).pack();
+ contextEntryTableViewer.getTable().getColumn( 0 ).pack();
// Adding a little space to the first column
- contextEntryTable.getColumn( 0 ).setWidth( contextEntryTable.getColumn( 0 ).getWidth() + 5 );
+ contextEntryTableViewer.getTable().getColumn( 0 )
+ .setWidth( contextEntryTableViewer.getTable().getColumn( 0 ).getWidth() + 5 );
// Resizing the second column
- contextEntryTable.getColumn( 1 ).pack();
+ contextEntryTableViewer.getTable().getColumn( 1 ).pack();
}
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=1401759&r1=1401758&r2=1401759&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 Wed Oct 24 16:18:41 2012
@@ -27,9 +27,13 @@ import org.apache.directory.server.confi
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.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
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.ldif.LdifEntry;
import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.Rdn;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -218,6 +222,7 @@ public class PartitionsMasterDetailsBloc
newPartitionBean.setPartitionCacheSize( 100 );
newPartitionBean.setJdbmPartitionOptimizerEnabled( true );
newPartitionBean.setPartitionSyncOnWrite( true );
+ newPartitionBean.setContextEntry( getContextEntryLdif( newPartitionBean.getPartitionSuffix() ) );
List<IndexBean> indexes = new ArrayList<IndexBean>();
indexes.add( createJdbmIndex( "apacheAlias", 100 ) ); //$NON-NLS-1$
indexes.add( createJdbmIndex( "apacheOneAlias", 100 ) ); //$NON-NLS-1$
@@ -274,6 +279,42 @@ public class PartitionsMasterDetailsBloc
/**
+ * Creates the context entry for the partition.
+ *
+ * @param dn the dn
+ * @return the LDIF representation of the
+ */
+ public static String getContextEntryLdif( Dn dn )
+ {
+ try
+ {
+ Entry entry = new DefaultEntry( dn );
+ entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.DOMAIN_OC );
+ entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC );
+
+ // Getting the RDN from the DN
+ Rdn rdn = dn.getRdn();
+
+ if ( !SchemaConstants.DC_AT.equalsIgnoreCase( rdn.getType() ) )
+ {
+ entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.EXTENSIBLE_OBJECT_OC );
+ entry.add( SchemaConstants.DC_AT, rdn.getValue() );
+ }
+
+ entry.add( rdn.getType(), rdn.getValue() );
+
+ LdifEntry ldifEntry = new LdifEntry( entry );
+
+ return ldifEntry.toString();
+ }
+ catch ( Exception e )
+ {
+ return null;
+ }
+ }
+
+
+ /**
* This method is called when the 'Delete' button is clicked.
*/
private void deleteSelectedPartition()