You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/01 03:01:43 UTC
svn commit: r1670531 [4/14] - in
/directory/studio/trunk/plugins/openldap.config.editor: ./ resources/icons/
src/main/java/org/apache/directory/studio/openldap/config/
src/main/java/org/apache/directory/studio/openldap/config/actions/
src/main/java/org...
Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java?rev=1670531&r1=1670530&r2=1670531&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java Wed Apr 1 01:01:42 2015
@@ -22,17 +22,30 @@ package org.apache.directory.studio.open
import java.util.List;
-import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.common.ui.CommonUIUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.fieldassist.ControlDecoration;
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.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -42,158 +55,265 @@ 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.Label;
+import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IDetailsPage;
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;
-import org.apache.directory.studio.openldap.config.model.AuxiliaryObjectClass;
+import org.apache.directory.studio.openldap.common.ui.widgets.BooleanWithDefaultWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.EntryWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.PasswordWidget;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils;
+import org.apache.directory.studio.openldap.config.editor.dialogs.OverlayDialog;
+import org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog;
import org.apache.directory.studio.openldap.config.model.OlcBdbConfig;
import org.apache.directory.studio.openldap.config.model.OlcDatabaseConfig;
-import org.apache.directory.studio.openldap.config.model.OlcFrontendConfig;
+import org.apache.directory.studio.openldap.config.model.OlcHdbConfig;
import org.apache.directory.studio.openldap.config.model.OlcLdifConfig;
+import org.apache.directory.studio.openldap.config.model.OlcMdbConfig;
+import org.apache.directory.studio.openldap.config.model.OlcNullConfig;
+import org.apache.directory.studio.openldap.config.model.OlcOverlayConfig;
+import org.apache.directory.studio.openldap.config.model.OlcRelayConfig;
+import org.apache.directory.studio.openldap.syncrepl.Provider;
+import org.apache.directory.studio.openldap.syncrepl.SyncRepl;
+import org.apache.directory.studio.openldap.syncrepl.SyncReplParser;
+import org.apache.directory.studio.openldap.syncrepl.SyncReplParserException;
/**
* This class represents the Details Page of the Server Configuration Editor for the Database type
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class DatabasesDetailsPage implements IDetailsPage
{
+ /** The editable database types array */
+ private static DatabaseTypeEnum[] EDITABLE_DATABASE_TYPES = new DatabaseTypeEnum[]
+ {
+ DatabaseTypeEnum.NONE,
+ DatabaseTypeEnum.BDB,
+ DatabaseTypeEnum.HDB,
+ DatabaseTypeEnum.LDIF,
+ DatabaseTypeEnum.MDB,
+ DatabaseTypeEnum.NULL,
+ DatabaseTypeEnum.RELAY
+ };
+
+ /** The frontend database type array */
+ private static DatabaseTypeEnum[] FRONTEND_DATABASE_TYPES = new DatabaseTypeEnum[]
+ {
+ DatabaseTypeEnum.FRONTEND
+ };
+
+ /** The frontend database type array */
+ private static DatabaseTypeEnum[] CONFIG_DATABASE_TYPES = new DatabaseTypeEnum[]
+ {
+ DatabaseTypeEnum.CONFIG
+ };
+
+ /** The class instance */
+ private DatabasesDetailsPage instance;
+
/** The associated Master Details Block */
private DatabasesMasterDetailsBlock masterDetailsBlock;
- /** The Managed Form */
- private IManagedForm mform;
-
- /** The input Partition */
- private OlcDatabaseConfig database;
+ /** The database wrapper */
+ private DatabaseWrapper databaseWrapper;
+ /** The database specific details block */
private DatabaseSpecificDetailsBlock databaseSpecificDetailsBlock;
+ /** The browser connection */
+ private IBrowserConnection browserConnection;
+
/** The dirty flag */
private boolean dirty = false;
// UI widgets
+ private Composite parentComposite;
private FormToolkit toolkit;
- private Text idText;
- private Text suffixText;
- private Text rootDnText;
- private Text rootPasswordText;
- private Button readOnlyCheckbox;
- private Button hiddenCheckbox;
- private Combo databaseTypeCombo;
private ComboViewer databaseTypeComboViewer;
- private Composite specificSettingsComposite;
- private Composite innerSpecificSettingsComposite;
+ private EntryWidget suffixEntryWidget;
+ private EntryWidget rootDnEntryWidget;
+ private PasswordWidget rootPasswordWidget;
+ private BooleanWithDefaultWidget readOnlyBooleanWithDefaultWidget;
+ private BooleanWithDefaultWidget hiddenBooleanWithDefaultWidget;
+ private TableViewer overlaysTableViewer;
+ private Button addOverlayButton;
+ private Button editOverlayButton;
+ private Button deleteOverlayButton;
+ private Section specificSettingsSection;
+ private Composite specificSettingsSectionComposite;
+ private Composite databaseSpecificDetailsComposite;
+ private TableViewer replicationConsumersTableViewer;
+ private Button addReplicationConsumerButton;
+ private Button editReplicationConsumerButton;
+ private Button deleteReplicationConsumerButton;
- //
// Listeners
- //
-
- private ModifyListener idTextModifylistener = new ModifyListener()
+ private ISelectionChangedListener overlaysTableViewerSelectionChangedListener = new ISelectionChangedListener()
{
- public void modifyText( ModifyEvent e )
+ public void selectionChanged( SelectionChangedEvent event )
{
- String id = idText.getText();
- if ( Strings.isNotEmpty( id ) )
- {
- database.setOlcDatabase( id );
- }
+ updateOverlaysTableButtonsState();
}
};
-
- private ModifyListener suffixTextModifyListener = new ModifyListener()
+ private IDoubleClickListener overlaysTableViewerDoubleClickListener = new IDoubleClickListener()
{
- public void modifyText( ModifyEvent e )
+ public void doubleClick( DoubleClickEvent event )
{
- String suffixes = suffixText.getText();
- if ( Strings.isNotEmpty( suffixes ) )
- {
- database.clearOlcSuffix();
-
- String[] suffixesArray = suffixes.split( ", " );
- for ( String suffix : suffixesArray )
- {
- try
- {
- database.addOlcSuffix( new Dn( suffix ) );
- }
- catch ( LdapInvalidDnException e1 )
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- }
+ editOverlayButtonAction();
}
};
-
- private ModifyListener rootDnTextModifyListener = new ModifyListener()
+ private SelectionListener addOverlayButtonListener = new SelectionAdapter()
{
- public void modifyText( ModifyEvent e )
+ public void widgetSelected( SelectionEvent e )
{
- String rootDn = rootDnText.getText();
- if ( Strings.isNotEmpty( rootDn ) )
- {
- try
- {
- database.setOlcRootDN( new Dn( rootDn ) );
- }
- catch ( LdapInvalidDnException e1 )
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
+ addOverlayButtonAction();
}
};
-
- private ModifyListener rootPasswordModifyListener = new ModifyListener()
+ private SelectionListener editOverlayButtonListener = new SelectionAdapter()
{
- public void modifyText( ModifyEvent e )
+ public void widgetSelected( SelectionEvent e )
{
- String rootPassword = rootPasswordText.getText();
- if ( Strings.isNotEmpty( rootPassword ) )
- {
- database.setOlcRootPW( rootPassword );
- }
+ editOverlayButtonAction();
}
};
-
- private SelectionListener readOnlyCheckboxSelectionListener = new SelectionAdapter()
+ private SelectionListener deleteOverlayButtonListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
- database.setOlcReadOnly( new Boolean( readOnlyCheckbox.getSelection() ) );
+ deleteOverlayButtonAction();
}
};
-
- private SelectionListener hiddenCheckboxSelectionListener = new SelectionAdapter()
+ private ISelectionChangedListener replicationConsumersTableViewerSelectionChangedListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ updateReplicationConsumersTableButtonsState();
+ }
+ };
+ private IDoubleClickListener replicationConsumersTableViewerDoubleClickListener = new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ editReplicationConsumerButtonAction();
+ }
+ };
+ private SelectionListener addReplicationConsumerButtonListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
- database.setOlcHidden( new Boolean( hiddenCheckbox.getSelection() ) );
+ addReplicationConsumerButtonAction();
}
};
-
- /** The modify listener which set the editor dirty */
- private ModifyListener dirtyModifyListener = new ModifyListener()
+ private SelectionListener editReplicationConsumerButtonListener = new SelectionAdapter()
{
- public void modifyText( ModifyEvent e )
+ public void widgetSelected( SelectionEvent e )
{
- setEditorDirty();
+ editReplicationConsumerButtonAction();
}
};
-
- /** The selection listener which set the editor dirty */
- private SelectionListener dirtySelectionListener = new SelectionAdapter()
+ private SelectionListener deleteReplicationConsumerButtonListener = new SelectionAdapter()
{
public void widgetSelected( SelectionEvent e )
{
+ deleteReplicationConsumerButtonAction();
+ }
+ };
+
+
+ private ISelectionChangedListener databaseTypeComboViewerSelectionChangedListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ DatabaseTypeEnum type = ( DatabaseTypeEnum ) ( ( StructuredSelection ) databaseTypeComboViewer.getSelection() )
+ .getFirstElement();
+
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ OlcDatabaseConfig database = databaseWrapper.getDatabase();
+
+ switch ( type )
+ {
+ case BDB:
+ OlcBdbConfig newBdbDatabase = new OlcBdbConfig();
+ copyDatabaseProperties( database, newBdbDatabase );
+ databaseWrapper.setDatabase( newBdbDatabase );
+ databaseSpecificDetailsBlock = new BerkeleyDbDatabaseSpecificDetailsBlock<OlcBdbConfig>(
+ instance, newBdbDatabase, browserConnection );
+ break;
+ case HDB:
+ OlcHdbConfig newHdbDatabase = new OlcHdbConfig();
+ copyDatabaseProperties( database, newHdbDatabase );
+ databaseWrapper.setDatabase( newHdbDatabase );
+ databaseSpecificDetailsBlock = new BerkeleyDbDatabaseSpecificDetailsBlock<OlcHdbConfig>(
+ instance, newHdbDatabase, browserConnection );
+ break;
+
+ case MDB:
+ // The MDB database
+ OlcMdbConfig newMdbDatabase = new OlcMdbConfig();
+ copyDatabaseProperties( database, newMdbDatabase );
+ databaseWrapper.setDatabase( newMdbDatabase );
+ databaseSpecificDetailsBlock = new MdbDatabaseSpecificDetailsBlock( instance, newMdbDatabase,
+ browserConnection );
+ break;
+
+ case LDIF:
+ OlcLdifConfig newLdifDatabase = new OlcLdifConfig();
+ copyDatabaseProperties( database, newLdifDatabase );
+ databaseWrapper.setDatabase( newLdifDatabase );
+ databaseSpecificDetailsBlock = new LdifDatabaseSpecificDetailsBlock( instance,
+ newLdifDatabase );
+ break;
+ // case LDAP:
+ // OlcLDAPConfig newLdapDatabase = new OlcLDAPConfig();
+ // copyDatabaseProperties( database, newLdapDatabase );
+ // databaseWrapper.setDatabase( newLdapDatabase );
+ // // databaseSpecificDetailsBlock = new LdapDatabaseSpecificDetailsBlock( newLdapDatabase ); // TODO
+ // break;
+ case NULL:
+ OlcNullConfig newNullDatabase = new OlcNullConfig();
+ copyDatabaseProperties( database, newNullDatabase );
+ databaseWrapper.setDatabase( newNullDatabase );
+ databaseSpecificDetailsBlock = new NullDatabaseSpecificDetailsBlock( instance,
+ newNullDatabase );
+ break;
+ case RELAY:
+ OlcRelayConfig newRelayDatabase = new OlcRelayConfig();
+ copyDatabaseProperties( database, newRelayDatabase );
+ databaseWrapper.setDatabase( newRelayDatabase );
+ databaseSpecificDetailsBlock = new RelayDatabaseSpecificDetailsBlock( instance,
+ newRelayDatabase, browserConnection );
+ break;
+ case NONE:
+ OlcDatabaseConfig newNoneDatabase = new OlcDatabaseConfig();
+ copyDatabaseProperties( database, newNoneDatabase );
+ databaseWrapper.setDatabase( newNoneDatabase );
+ databaseSpecificDetailsBlock = null;
+ break;
+ default:
+ break;
+ }
+
+ updateDatabaseSpecificSettingsSection();
+
+ setEditorDirty();
+ }
+ }
+ };
+ /** The modify listener which set the editor dirty */
+ private WidgetModifyListener dirtyWidgetModifyListener = new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
setEditorDirty();
}
};
@@ -207,77 +327,202 @@ public class DatabasesDetailsPage implem
*/
public DatabasesDetailsPage( DatabasesMasterDetailsBlock pmdb )
{
+ instance = this;
masterDetailsBlock = pmdb;
+
+ // Getting the browser connection associated with the connection in the configuration
+ browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
+ .getBrowserConnection( masterDetailsBlock.getPage().getConfiguration().getConnection() );
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
+ /**
+ * {@inheritDoc}
*/
public void createContents( Composite parent )
{
- 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() );
createGeneralSettingsSection( parent, toolkit );
+ createOverlaySettingsSection( parent, toolkit );
createDatabaseSpecificSettingsSection( parent, toolkit );
+ createReplicationConsumersSettingsSection( parent, toolkit );
}
/**
* Creates the General Settings Section
*
- * @param parent
- * the parent composite
- * @param toolkit
- * the toolkit to use
+ * @param parent the parent composite
+ * @param toolkit the toolkit to use
*/
private void createGeneralSettingsSection( Composite parent, FormToolkit toolkit )
{
+ // Creating the Section
Section section = toolkit.createSection( parent, Section.TITLE_BAR );
- section.marginWidth = 10;
section.setText( "Database General Settings" );
- 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 composite = toolkit.createComposite( section );
toolkit.paintBordersFor( composite );
- GridLayout glayout = new GridLayout( 2, false );
- composite.setLayout( glayout );
+ GridLayout gl = new GridLayout( 2, false );
+ gl.marginRight = 18;
+ composite.setLayout( gl );
section.setClient( composite );
- // ID
- toolkit.createLabel( composite, "ID:" );
- idText = toolkit.createText( composite, "" ); //$NON-NLS-1$
- idText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
-
- // Suffixes
- toolkit.createLabel( composite, "Suffixes:" ); //$NON-NLS-1$
- suffixText = toolkit.createText( composite, "" ); //$NON-NLS-1$
- suffixText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ // Database Type
+ toolkit.createLabel( composite, "Database Type:" );
+ Combo databaseTypeCombo = new Combo( composite, SWT.READ_ONLY | SWT.SINGLE );
+ databaseTypeCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ databaseTypeComboViewer = new ComboViewer( databaseTypeCombo );
+ databaseTypeComboViewer.setContentProvider( new ArrayContentProvider() );
+ databaseTypeComboViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof DatabaseTypeEnum )
+ {
+ DatabaseTypeEnum databaseType = ( DatabaseTypeEnum ) element;
+
+ return databaseType.getName();
+ }
+
+ return super.getText( element );
+ }
+ } );
+
+ // Suffix
+ toolkit.createLabel( composite, "Suffix:" );
+ suffixEntryWidget = new EntryWidget( browserConnection, null, true );
+ suffixEntryWidget.createWidget( composite, toolkit );
+ suffixEntryWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ ControlDecoration suffixTextDecoration = new ControlDecoration( suffixEntryWidget.getControl(), SWT.CENTER
+ | SWT.RIGHT );
+ suffixTextDecoration.setImage( OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
+ OpenLdapConfigurationPluginConstants.IMG_INFORMATION ).createImage() );
+ suffixTextDecoration.setMarginWidth( 4 );
+ suffixTextDecoration
+ .setDescriptionText( "The DN suffix of queries that will be passed to this backend database." );
// Root DN
toolkit.createLabel( composite, "Root DN:" );
- rootDnText = toolkit.createText( composite, "" ); //$NON-NLS-1$
- rootDnText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ rootDnEntryWidget = new EntryWidget( browserConnection, null, true );
+ rootDnEntryWidget.createWidget( composite, toolkit );
+ rootDnEntryWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ ControlDecoration rootDnTextDecoration = new ControlDecoration( rootDnEntryWidget.getControl(), SWT.CENTER
+ | SWT.RIGHT );
+ rootDnTextDecoration.setImage( OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
+ OpenLdapConfigurationPluginConstants.IMG_INFORMATION ).createImage() );
+ rootDnTextDecoration.setMarginWidth( 4 );
+ rootDnTextDecoration
+ .setDescriptionText( "The DN that is not subject to access control or administrative limit restrictions for operations on this database." );
// Root Password
- toolkit.createLabel( composite, "Root Password:" );
- rootPasswordText = toolkit.createText( composite, "" ); //$NON-NLS-1$
- rootPasswordText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ Label rootPasswordLabel = toolkit.createLabel( composite, "Root Password:" );
+ rootPasswordLabel.setLayoutData( new GridData( SWT.NONE, SWT.TOP, false, false ) );
+ rootPasswordWidget = new PasswordWidget( true );
+ rootPasswordWidget.createWidget( composite, toolkit );
+ rootPasswordWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ ControlDecoration rootPasswordTextDecoration = new ControlDecoration( rootPasswordWidget.getControl(),
+ SWT.TOP | SWT.RIGHT );
+ rootPasswordTextDecoration.setImage( OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
+ OpenLdapConfigurationPluginConstants.IMG_INFORMATION ).createImage() );
+ rootPasswordTextDecoration.setMarginWidth( 4 );
+ rootPasswordTextDecoration
+ .setDescriptionText( "The password for the the Root DN." );
// Read Only
- readOnlyCheckbox = toolkit.createButton( composite, "Read Only", SWT.CHECK );
- readOnlyCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+ toolkit.createLabel( composite, "Read Only:" );
+ readOnlyBooleanWithDefaultWidget = new BooleanWithDefaultWidget();
+ readOnlyBooleanWithDefaultWidget.create( composite, toolkit );
+ readOnlyBooleanWithDefaultWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ ControlDecoration readOnlyCheckboxDecoration = new ControlDecoration(
+ readOnlyBooleanWithDefaultWidget.getControl(), SWT.CENTER | SWT.RIGHT );
+ readOnlyCheckboxDecoration.setImage( OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
+ OpenLdapConfigurationPluginConstants.IMG_INFORMATION ).createImage() );
+ readOnlyCheckboxDecoration.setMarginWidth( 4 );
+ readOnlyCheckboxDecoration
+ .setDescriptionText( "Sets the database into \"read-only\" mode. Any attempts to modify the database will return an \"unwilling to perform\" error." );
// Hidden
- hiddenCheckbox = toolkit.createButton( composite, "Hidden", SWT.CHECK );
- hiddenCheckbox.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+ toolkit.createLabel( composite, "Hidden:" );
+ hiddenBooleanWithDefaultWidget = new BooleanWithDefaultWidget( false );
+ hiddenBooleanWithDefaultWidget.create( composite, toolkit );
+ hiddenBooleanWithDefaultWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ ControlDecoration hiddenCheckboxDecoration = new ControlDecoration(
+ hiddenBooleanWithDefaultWidget.getControl(), SWT.CENTER | SWT.RIGHT );
+ hiddenCheckboxDecoration.setImage( OpenLdapConfigurationPlugin.getDefault().getImageDescriptor(
+ OpenLdapConfigurationPluginConstants.IMG_INFORMATION ).createImage() );
+ hiddenCheckboxDecoration.setMarginWidth( 4 );
+ hiddenCheckboxDecoration
+ .setDescriptionText( "Sets whether the database will be used to answer queries." );
+ }
+
+
+ /**
+ * Creates the Overlay Settings Section
+ *
+ * @param parent
+ * the parent composite
+ * @param toolkit
+ * the toolkit to use
+ */
+ private void createOverlaySettingsSection( Composite parent, FormToolkit toolkit )
+ {
+ // Creating the Section
+ Section section = toolkit.createSection( parent, Section.TWISTIE | Section.EXPANDED | Section.TITLE_BAR );
+ section.setText( "Overlays Settings" );
+ section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ Composite composite = toolkit.createComposite( section );
+ toolkit.paintBordersFor( composite );
+ composite.setLayout( new GridLayout( 2, false ) );
+ section.setClient( composite );
+
+ // Creating the Table and Table Viewer
+ Table table = toolkit.createTable( composite, SWT.NULL );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 );
+ gd.heightHint = 20;
+ gd.widthHint = 100;
+ table.setLayoutData( gd );
+
+ overlaysTableViewer = new TableViewer( table );
+ overlaysTableViewer.setContentProvider( new ArrayContentProvider() );
+ overlaysTableViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof OlcOverlayConfig )
+ {
+ return getOverlayText( ( OlcOverlayConfig ) element );
+ }
+
+ return super.getText( element );
+ };
+ } );
+
+ // Creating the buttons
+ addOverlayButton = toolkit.createButton( composite, "Add...", SWT.PUSH );
+ addOverlayButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ editOverlayButton = toolkit.createButton( composite, "Edit...", SWT.PUSH );
+ editOverlayButton.setEnabled( false );
+ editOverlayButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ deleteOverlayButton = toolkit.createButton( composite, "Delete...", SWT.PUSH );
+ deleteOverlayButton.setEnabled( false );
+ deleteOverlayButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+ }
+
+
+ /**
+ * Gets the overlay text.
+ *
+ * @param overlay the overlay
+ * @return the text corresponding to the overlay
+ */
+ private String getOverlayText( OlcOverlayConfig overlay )
+ {
+ return OverlayDialog.getOverlayDisplayName( overlay );
}
@@ -291,61 +536,127 @@ public class DatabasesDetailsPage implem
*/
private void createDatabaseSpecificSettingsSection( Composite parent, FormToolkit toolkit )
{
+ // Creating the Section
+ specificSettingsSection = toolkit.createSection( parent, Section.TWISTIE | Section.EXPANDED
+ | Section.TITLE_BAR );
+ specificSettingsSection.setText( "Database 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 );
+ }
+
+
+ /**
+ * Creates the Replication Consumers Settings Section
+ *
+ * @param parent
+ * the parent composite
+ * @param toolkit
+ * the toolkit to use
+ */
+ private void createReplicationConsumersSettingsSection( Composite parent, FormToolkit toolkit )
+ {
+ // Creating the Section
Section section = toolkit.createSection( parent, Section.TWISTIE | Section.EXPANDED | Section.TITLE_BAR );
- section.marginWidth = 10;
- section.setText( "Database Specific Settings" );
- section.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
- specificSettingsComposite = toolkit.createComposite( section );
- toolkit.paintBordersFor( specificSettingsComposite );
- specificSettingsComposite.setLayout( new GridLayout( 2, false ) );
- section.setClient( specificSettingsComposite );
-
- // Type
- toolkit.createLabel( specificSettingsComposite, "Database Type:" );
- databaseTypeCombo = new Combo( specificSettingsComposite, SWT.READ_ONLY | SWT.SINGLE );
- databaseTypeCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
- databaseTypeComboViewer = new ComboViewer( databaseTypeCombo );
- databaseTypeComboViewer.setContentProvider( new ArrayContentProvider() );
- databaseTypeComboViewer.setLabelProvider( new LabelProvider()
+ section.setText( "Replication Consumers Settings" );
+ section.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ Composite composite = toolkit.createComposite( section );
+ toolkit.paintBordersFor( composite );
+ composite.setLayout( new GridLayout( 2, false ) );
+ section.setClient( composite );
+
+ // Creating the Table and Table Viewer
+ Table table = toolkit.createTable( composite, SWT.NULL );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 );
+ gd.heightHint = 20;
+ gd.widthHint = 100;
+ table.setLayoutData( gd );
+
+ replicationConsumersTableViewer = new TableViewer( table );
+ replicationConsumersTableViewer.setContentProvider( new ArrayContentProvider() );
+ replicationConsumersTableViewer.setLabelProvider( new LabelProvider()
{
public String getText( Object element )
{
- if ( element instanceof DatabaseType )
+ if ( element instanceof String )
{
- DatabaseType databaseType = ( DatabaseType ) element;
-
- switch ( databaseType )
- {
- case NONE:
- return "None";
- case FRONTEND:
- return "Frontend DB";
- case BDB:
- return "Oracle Berkerly DB";
- case HDB:
- return "Hybrid DB";
- case LDAP:
- return "LDAP DB";
- case LDIF:
- return "LDIF DB";
- }
+ return getReplicationConsumerText( ( String ) element );
}
return super.getText( element );
- }
+ };
} );
- DatabaseType[] databaseTypes = new DatabaseType[]
+
+ // Creating the buttons
+ addReplicationConsumerButton = toolkit.createButton( composite, "Add...", SWT.PUSH );
+ addReplicationConsumerButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ editReplicationConsumerButton = toolkit.createButton( composite, "Edit...", SWT.PUSH );
+ editReplicationConsumerButton.setEnabled( false );
+ editReplicationConsumerButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+
+ deleteReplicationConsumerButton = toolkit.createButton( composite, "Delete...", SWT.PUSH );
+ deleteReplicationConsumerButton.setEnabled( false );
+ deleteReplicationConsumerButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+ }
+
+
+ /**
+ * Gets the replication consumer text.
+ *
+ * @param syncReplValue the replication consumer value
+ * @return the text corresponding to the replication consumer
+ */
+ private String getReplicationConsumerText( String syncReplValue )
+ {
+ if ( syncReplValue != null )
+ {
+ try
{
- DatabaseType.NONE,
- DatabaseType.FRONTEND,
- DatabaseType.BDB,
- DatabaseType.HDB,
- DatabaseType.LDAP,
- DatabaseType.LDIF
- };
- databaseTypeComboViewer.setInput( databaseTypes );
+ // Parsing the SyncRepl value
+ SyncReplParser parser = new SyncReplParser();
+ SyncRepl syncRepl = parser.parse( syncReplValue );
+
+ // Creating a string builder to hold the SyncRepl description
+ StringBuilder sb = new StringBuilder();
+
+ // Replica ID
+ sb.append( "rid=" + syncRepl.getRid() );
+
+ // Provider
+ Provider provider = syncRepl.getProvider();
+
+ if ( provider != null )
+ {
+ sb.append( " provider=" + provider.toString() );
+ }
+
+ // Search Base
+ String searchBase = syncRepl.getSearchBase();
+
+ if ( ( searchBase != null ) && ( !"".equals( searchBase ) ) )
+ {
+ sb.append( " searchBase=\"" + searchBase + "\"" );
+ }
+
+ sb.append( " (and more options)" );
- createInnerSpecificSettingsComposite();
+ return sb.toString();
+ }
+ catch ( SyncReplParserException e )
+ {
+ // Silent
+ }
+ }
+
+ return syncReplValue;
}
@@ -357,11 +668,11 @@ public class DatabasesDetailsPage implem
IStructuredSelection ssel = ( IStructuredSelection ) selection;
if ( ssel.size() == 1 )
{
- database = ( OlcDatabaseConfig ) ssel.getFirstElement();
+ databaseWrapper = ( DatabaseWrapper ) ssel.getFirstElement();
}
else
{
- database = null;
+ databaseWrapper = null;
}
refresh();
}
@@ -372,6 +683,42 @@ public class DatabasesDetailsPage implem
*/
public void commit( boolean onSave )
{
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ OlcDatabaseConfig database = databaseWrapper.getDatabase();
+
+ // Suffix
+ database.clearOlcSuffix();
+ Dn suffixDn = suffixEntryWidget.getDn();
+
+ if ( suffixDn != null )
+ {
+ database.addOlcSuffix( suffixDn );
+ }
+
+ // Root DN
+ database.setOlcRootDN( rootDnEntryWidget.getDn() );
+
+ // Root Password
+ String rootPassword = rootPasswordWidget.getPasswordAsString();
+
+ if ( Strings.isNotEmpty( rootPassword ) )
+ {
+ database.setOlcRootPW( rootPassword );
+ }
+
+ // Read Only
+ database.setOlcReadOnly( readOnlyBooleanWithDefaultWidget.getValue() );
+
+ // Hidden
+ database.setOlcHidden( hiddenBooleanWithDefaultWidget.getValue() );
+
+ // Database specific details block
+ if ( databaseSpecificDetailsBlock != null )
+ {
+ databaseSpecificDetailsBlock.commit( onSave );
+ }
+ }
}
@@ -388,7 +735,7 @@ public class DatabasesDetailsPage implem
*/
public void initialize( IManagedForm form )
{
- this.mform = form;
+ toolkit = form.getToolkit();
}
@@ -415,7 +762,7 @@ public class DatabasesDetailsPage implem
*/
public void setFocus()
{
- idText.setFocus();
+ // suffixText.setFocus();
}
@@ -435,131 +782,148 @@ public class DatabasesDetailsPage implem
{
removeListeners();
- if ( database == null )
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
{
- // Blank out all fields
-
- // ID
- idText.setEnabled( false );
- idText.setText( "" ); //$NON-NLS-1$
-
- // Suffixes
- suffixText.setEnabled( false );
- suffixText.setText( "" ); //$NON-NLS-1$
-
- // Root DN
- rootDnText.setEnabled( false );
- rootDnText.setText( "" ); //$NON-NLS-1$
-
- // Root PW
- rootPasswordText.setEnabled( false );
- rootPasswordText.setText( "" ); //$NON-NLS-1$
-
- // Read Only
- readOnlyCheckbox.setEnabled( false );
- readOnlyCheckbox.setSelection( false );
+ OlcDatabaseConfig database = databaseWrapper.getDatabase();
- // Hidden
- hiddenCheckbox.setEnabled( false );
- hiddenCheckbox.setSelection( false );
- }
- else
- {
- // ID
- String id = database.getOlcDatabase();
- idText.setEnabled( true );
- idText.setText( ( id == null ) ? "" : id ); //$NON-NLS-1$
+ // Enabling or disabling UI elements depending on the database
+ if ( isFrontendDatabase( database ) )
+ {
+ databaseTypeComboViewer.getControl().setEnabled( false );
+ suffixEntryWidget.setEnabled( false );
+ rootDnEntryWidget.setEnabled( false );
+ rootPasswordWidget.setEnabled( false );
+ readOnlyBooleanWithDefaultWidget.setEnabled( false );
+ hiddenBooleanWithDefaultWidget.setEnabled( false );
+ }
+ else if ( isConfigDatabase( database ) )
+ {
+ databaseTypeComboViewer.getControl().setEnabled( false );
+ suffixEntryWidget.setEnabled( false );
+ rootDnEntryWidget.setEnabled( true );
+ rootPasswordWidget.setEnabled( true );
+ readOnlyBooleanWithDefaultWidget.setEnabled( false );
+ hiddenBooleanWithDefaultWidget.setEnabled( false );
+ }
+ else
+ {
+ databaseTypeComboViewer.getControl().setEnabled( true );
+ suffixEntryWidget.setEnabled( true );
+ rootDnEntryWidget.setEnabled( true );
+ rootPasswordWidget.setEnabled( true );
+ readOnlyBooleanWithDefaultWidget.setEnabled( true );
+ hiddenBooleanWithDefaultWidget.setEnabled( true );
+ }
// Suffixes
List<Dn> suffixesDnList = database.getOlcSuffix();
- StringBuilder sb = new StringBuilder();
- for ( Dn suffixDn : suffixesDnList )
- {
- sb.append( suffixDn.toString() );
- sb.append( ", " );
- }
- if ( sb.length() > 1 )
+ Dn suffixDn = null;
+ if ( suffixesDnList.size() == 1 )
{
- sb.deleteCharAt( sb.length() - 1 );
- sb.deleteCharAt( sb.length() - 1 );
+ suffixDn = suffixesDnList.get( 0 );
}
- suffixText.setEnabled( true );
- suffixText.setText( sb.toString() );
+ suffixEntryWidget.setInput( suffixDn );
// Root DN
Dn rootDn = database.getOlcRootDN();
- rootDnText.setEnabled( true );
- rootDnText.setText( ( rootDn == null ) ? "" : rootDn.toString() ); //$NON-NLS-1$
+ rootDnEntryWidget.setInput( rootDn );
// Root PW
String rootPassword = database.getOlcRootPW();
- rootPasswordText.setEnabled( true );
- rootPasswordText.setText( ( rootPassword == null ) ? "" : rootPassword ); //$NON-NLS-1$
+ rootPasswordWidget.setPassword( ( rootPassword == null ) ? null : rootPassword.getBytes() );
+ // rootPasswordText.setText( ( rootPassword == null ) ? "" : rootPassword ); //$NON-NLS-1$
// Read Only
- readOnlyCheckbox.setEnabled( true );
- Boolean readOnly = database.getOlcReadOnly();
- if ( readOnly != null )
- {
- readOnlyCheckbox.setSelection( readOnly.booleanValue() );
- }
- else
- {
- readOnlyCheckbox.setSelection( false );
- }
+ readOnlyBooleanWithDefaultWidget.setValue( database.getOlcReadOnly() );
// Hidden
- hiddenCheckbox.setEnabled( true );
- Boolean hidden = database.getOlcHidden();
- if ( hidden != null )
- {
- hiddenCheckbox.setSelection( hidden.booleanValue() );
- }
- else
- {
- hiddenCheckbox.setSelection( false );
- }
+ hiddenBooleanWithDefaultWidget.setValue( database.getOlcHidden() );
+
+ // Overlays
+ refreshOverlaysTableViewer();
+
+ // Replication Consumers
+ refreshReplicationConsumersTableViewer();
//
// Specific Settings
//
-
+ // OlcHdbConfig Type
+ if ( database instanceof OlcHdbConfig )
+ {
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.HDB ) );
+ databaseSpecificDetailsBlock = new BerkeleyDbDatabaseSpecificDetailsBlock<OlcHdbConfig>( instance,
+ ( OlcHdbConfig ) database, browserConnection );
+ }
// OlcBdbConfig Type
- if ( database instanceof OlcBdbConfig )
+ else if ( database instanceof OlcBdbConfig )
+ {
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.BDB ) );
+ databaseSpecificDetailsBlock = new BerkeleyDbDatabaseSpecificDetailsBlock<OlcBdbConfig>( instance,
+ ( OlcBdbConfig ) database, browserConnection );
+ }
+ // OlcMdbConfig Type
+ else if ( database instanceof OlcMdbConfig )
{
- databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseType.BDB ) );
- databaseSpecificDetailsBlock = new BdbDatabaseSpecificDetailsBlock( ( OlcBdbConfig ) database );
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.MDB ) );
+ databaseSpecificDetailsBlock = new MdbDatabaseSpecificDetailsBlock( instance,
+ ( OlcMdbConfig ) database, browserConnection );
}
+ // OlcLdifConfig Type
else if ( database instanceof OlcLdifConfig )
{
- databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseType.LDIF ) );
- databaseSpecificDetailsBlock = new LdifDatabaseSpecificDetailsBlock( ( OlcLdifConfig ) database );
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.LDIF ) );
+ databaseSpecificDetailsBlock = new LdifDatabaseSpecificDetailsBlock( instance,
+ ( OlcLdifConfig ) database );
+ }
+ // OlcNullConfig Type
+ else if ( database instanceof OlcNullConfig )
+ {
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.NULL ) );
+ databaseSpecificDetailsBlock = new NullDatabaseSpecificDetailsBlock( instance,
+ ( OlcNullConfig ) database );
+ }
+ // OlcRelayConfig Type
+ else if ( database instanceof OlcRelayConfig )
+ {
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.RELAY ) );
+ databaseSpecificDetailsBlock = new RelayDatabaseSpecificDetailsBlock( instance,
+ ( OlcRelayConfig ) database, browserConnection );
}
// None of these types
else
{
- // Looking for a frontend configuration
- OlcFrontendConfig frontendConfiguration = getFrontendConfig( database );
- if ( frontendConfiguration != null )
+ // Looking for the frontend database
+ if ( isFrontendDatabase( database ) )
+ {
+ databaseTypeComboViewer.setInput( FRONTEND_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.FRONTEND ) );
+ databaseSpecificDetailsBlock = new FrontendDatabaseSpecificDetailsBlock( instance, database,
+ browserConnection );
+ }
+ // Looking for the config database
+ else if ( isConfigDatabase( database ) )
{
- databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseType.FRONTEND ) );
- databaseSpecificDetailsBlock = new FrontendDatabaseSpecificDetailsBlock( frontendConfiguration );
+ databaseTypeComboViewer.setInput( CONFIG_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.CONFIG ) );
+ databaseSpecificDetailsBlock = null;
}
+ // Any other type of database
else
{
- databaseSpecificDetailsBlock = new NoneDatabaseSpecificDetailsBlock();
- databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseType.NONE ) );
+ databaseTypeComboViewer.setInput( EDITABLE_DATABASE_TYPES );
+ databaseTypeComboViewer.setSelection( new StructuredSelection( DatabaseTypeEnum.NONE ) );
+ databaseSpecificDetailsBlock = null;
}
}
- // Disposing existing specific settings composite and creating a new one
- disposeInnerSpecificSettingsComposite();
- createInnerSpecificSettingsComposite();
-
- // Displaying the specific settings
- databaseSpecificDetailsBlock.createFormContent( innerSpecificSettingsComposite, toolkit );
- databaseSpecificDetailsBlock.refresh();
- specificSettingsComposite.layout();
+ updateDatabaseSpecificSettingsSection();
}
addListeners();
@@ -567,117 +931,440 @@ public class DatabasesDetailsPage implem
/**
+ * Refreshes overlays table viewer.
+ */
+ private void refreshOverlaysTableViewer()
+ {
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ overlaysTableViewer.setInput( databaseWrapper.getDatabase().getOverlays().toArray() );
+ }
+ else
+ {
+ overlaysTableViewer.setInput( new Object[0] );
+ }
+
+ updateOverlaysTableButtonsState();
+ }
+
+
+ /**
+ * Updates the state of the overlays table buttons.
+ */
+ private void updateOverlaysTableButtonsState()
+ {
+ StructuredSelection selection = ( StructuredSelection ) overlaysTableViewer.getSelection();
+
+ editOverlayButton.setEnabled( !selection.isEmpty() );
+ deleteOverlayButton.setEnabled( !selection.isEmpty() );
+ }
+
+
+ /**
+ * Refreshes replication consumers table viewer.
+ */
+ private void refreshReplicationConsumersTableViewer()
+ {
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ replicationConsumersTableViewer.setInput( databaseWrapper.getDatabase().getOlcSyncrepl() );
+ }
+ else
+ {
+ replicationConsumersTableViewer.setInput( new Object[0] );
+ }
+
+ updateReplicationConsumersTableButtonsState();
+ }
+
+
+ /**
+ * Updates the state of the replication consumers table buttons.
+ */
+ private void updateReplicationConsumersTableButtonsState()
+ {
+ StructuredSelection selection = ( StructuredSelection ) replicationConsumersTableViewer.getSelection();
+
+ editReplicationConsumerButton.setEnabled( !selection.isEmpty() );
+ deleteReplicationConsumerButton.setEnabled( !selection.isEmpty() );
+ }
+
+
+ /**
* Adds listeners to UI widgets.
*/
private void addListeners()
{
- // ID
- addModifyListener( idText, dirtyModifyListener );
- addModifyListener( idText, idTextModifylistener );
-
- // Suffixes
- addModifyListener( suffixText, dirtyModifyListener );
- addModifyListener( suffixText, suffixTextModifyListener );
-
- // Root DN
- addModifyListener( rootDnText, dirtyModifyListener );
- addModifyListener( rootDnText, rootDnTextModifyListener );
+ addModifyListener( suffixEntryWidget, dirtyWidgetModifyListener );
+ addModifyListener( rootDnEntryWidget, dirtyWidgetModifyListener );
+ addModifyListener( rootPasswordWidget, dirtyWidgetModifyListener );
+ addModifyListener( readOnlyBooleanWithDefaultWidget, dirtyWidgetModifyListener );
+ addModifyListener( hiddenBooleanWithDefaultWidget, dirtyWidgetModifyListener );
- // Root PW
- addModifyListener( rootPasswordText, dirtyModifyListener );
- addModifyListener( rootPasswordText, rootPasswordModifyListener );
+ addSelectionChangedListener( databaseTypeComboViewer, databaseTypeComboViewerSelectionChangedListener );
- // Read Only
- addSelectionListener( readOnlyCheckbox, dirtySelectionListener );
- addSelectionListener( readOnlyCheckbox, readOnlyCheckboxSelectionListener );
+ addDoubleClickListener( overlaysTableViewer, overlaysTableViewerDoubleClickListener );
+ addSelectionChangedListener( overlaysTableViewer, overlaysTableViewerSelectionChangedListener );
+ addSelectionListener( addOverlayButton, addOverlayButtonListener );
+ addSelectionListener( editOverlayButton, editOverlayButtonListener );
+ addSelectionListener( deleteOverlayButton, deleteOverlayButtonListener );
- // Hidden
- addSelectionListener( hiddenCheckbox, dirtySelectionListener );
- addSelectionListener( hiddenCheckbox, hiddenCheckboxSelectionListener );
+ addDoubleClickListener( replicationConsumersTableViewer, replicationConsumersTableViewerDoubleClickListener );
+ addSelectionChangedListener( replicationConsumersTableViewer,
+ replicationConsumersTableViewerSelectionChangedListener );
+ addSelectionListener( addReplicationConsumerButton, addReplicationConsumerButtonListener );
+ addSelectionListener( editReplicationConsumerButton, editReplicationConsumerButtonListener );
+ addSelectionListener( deleteReplicationConsumerButton, deleteReplicationConsumerButtonListener );
}
/**
- * Removes listeners from UI widgets.
+ * Removes listeners from UI widgets.
*/
private void removeListeners()
{
- // ID
- removeModifyListener( idText, dirtyModifyListener );
- removeModifyListener( idText, idTextModifylistener );
-
- // Suffixes
- removeModifyListener( suffixText, dirtyModifyListener );
- removeModifyListener( suffixText, suffixTextModifyListener );
+ removeModifyListener( suffixEntryWidget, dirtyWidgetModifyListener );
+ removeModifyListener( rootDnEntryWidget, dirtyWidgetModifyListener );
+ removeModifyListener( rootPasswordWidget, dirtyWidgetModifyListener );
+ removeModifyListener( readOnlyBooleanWithDefaultWidget, dirtyWidgetModifyListener );
+ removeModifyListener( hiddenBooleanWithDefaultWidget, dirtyWidgetModifyListener );
+
+ removeSelectionChangedListener( databaseTypeComboViewer, databaseTypeComboViewerSelectionChangedListener );
+
+ removeDoubleClickListener( overlaysTableViewer, overlaysTableViewerDoubleClickListener );
+ removeSelectionChangedListener( overlaysTableViewer, overlaysTableViewerSelectionChangedListener );
+ removeSelectionListener( addOverlayButton, addOverlayButtonListener );
+ removeSelectionListener( editOverlayButton, editOverlayButtonListener );
+ removeSelectionListener( deleteOverlayButton, deleteOverlayButtonListener );
+
+ removeDoubleClickListener( replicationConsumersTableViewer, replicationConsumersTableViewerDoubleClickListener );
+ removeSelectionChangedListener( replicationConsumersTableViewer,
+ replicationConsumersTableViewerSelectionChangedListener );
+ removeSelectionListener( addReplicationConsumerButton, addReplicationConsumerButtonListener );
+ removeSelectionListener( editReplicationConsumerButton, editReplicationConsumerButtonListener );
+ removeSelectionListener( deleteReplicationConsumerButton, deleteReplicationConsumerButtonListener );
+ }
- // Root DN
- removeModifyListener( rootDnText, dirtyModifyListener );
- removeModifyListener( rootDnText, rootDnTextModifyListener );
- // Root PW
- removeModifyListener( rootPasswordText, dirtyModifyListener );
- removeModifyListener( rootPasswordText, rootPasswordModifyListener );
+ /**
+ * Disposes the inner specific settings composite.
+ */
+ private void disposeSpecificSettingsComposite()
+ {
+ if ( ( databaseSpecificDetailsComposite != null ) && !( databaseSpecificDetailsComposite.isDisposed() ) )
+ {
+ databaseSpecificDetailsComposite.dispose();
+ }
+
+ databaseSpecificDetailsComposite = null;
+ }
- // Read Only
- removeSelectionListener( readOnlyCheckbox, dirtySelectionListener );
- removeSelectionListener( readOnlyCheckbox, readOnlyCheckboxSelectionListener );
- // Hidden
- removeSelectionListener( hiddenCheckbox, dirtySelectionListener );
- removeSelectionListener( hiddenCheckbox, hiddenCheckboxSelectionListener );
+ /**
+ * Updates the database specific settings section.
+ */
+ private void updateDatabaseSpecificSettingsSection()
+ {
+ // Disposing existing specific settings composite
+ disposeSpecificSettingsComposite();
+
+ // Create the specific settings block content
+ if ( databaseSpecificDetailsBlock != null )
+ {
+ databaseSpecificDetailsComposite = databaseSpecificDetailsBlock.createBlockContent(
+ specificSettingsSectionComposite,
+ toolkit );
+ databaseSpecificDetailsBlock.refresh();
+ }
+
+ parentComposite.layout( true, true );
+
+ // Making the section visible or not
+ specificSettingsSection.setVisible( databaseSpecificDetailsBlock != null );
}
/**
- * Creates the inner specific settings composite.
+ * Action launched when the add overlay button is clicked.
*/
- private void createInnerSpecificSettingsComposite()
+ private void addOverlayButtonAction()
{
- innerSpecificSettingsComposite = toolkit.createComposite( specificSettingsComposite );
- GridLayout gl = new GridLayout( 2, false );
- gl.marginWidth = gl.marginHeight = 0;
- innerSpecificSettingsComposite.setLayout( gl );
- innerSpecificSettingsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+ OverlayDialog dialog = new OverlayDialog( addOverlayButton.getShell(), true );
+ dialog.setBrowserConnection( browserConnection );
+
+ if ( dialog.open() == OverlayDialog.OK )
+ {
+ OlcOverlayConfig overlay = dialog.getOverlay();
+
+ if ( overlay != null )
+ {
+ // Updating the 'overlay' value with the ordering prefix
+ overlay.setOlcOverlay( "{" + getNewOverlayOrderingValue() + "}" + overlay.getOlcOverlay() );
+
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ databaseWrapper.getDatabase().addOverlay( overlay );
+ refreshOverlaysTableViewer();
+ setEditorDirty();
+ }
+ }
+ }
}
/**
- * Disposes the inner specific settings composite.
+ * Gets the new overlay ordering value.
+ *
+ * @return the new overlay ordering value
+ */
+ private int getNewOverlayOrderingValue()
+ {
+ return getMaxOverlayOrderingValue() + 1;
+ }
+
+
+ /**
+ * Gets the maximum ordering value.
+ *
+ * @return the maximum ordering value
+ */
+ private int getMaxOverlayOrderingValue()
+ {
+ int maxOrderingValue = -1;
+
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ for ( OlcOverlayConfig overlay : databaseWrapper.getDatabase().getOverlays() )
+ {
+ if ( OpenLdapConfigurationPluginUtils
+ .hasOrderingPrefix( overlay.getOlcOverlay() ) )
+ {
+ int overlayOrderingValue = OpenLdapConfigurationPluginUtils.getOrderingPrefix( overlay
+ .getOlcOverlay() );
+
+ if ( overlayOrderingValue > maxOrderingValue )
+ {
+ maxOrderingValue = overlayOrderingValue;
+ }
+ }
+ }
+ }
+
+ return maxOrderingValue;
+ }
+
+
+ /**
+ * Action launched when the edit overlay button is clicked, or
+ * when the overlays table viewer is double-clicked.
+ */
+ private void editOverlayButtonAction()
+ {
+ StructuredSelection selection = ( StructuredSelection ) overlaysTableViewer.getSelection();
+
+ if ( !selection.isEmpty() )
+ {
+ OlcOverlayConfig selectedOverlay = ( OlcOverlayConfig ) selection.getFirstElement();
+
+ OverlayDialog dialog = new OverlayDialog( addOverlayButton.getShell() );
+ dialog.setBrowserConnection( browserConnection );
+ dialog.setOverlay( selectedOverlay );
+
+ if ( dialog.open() == OverlayDialog.OK )
+ {
+ refreshOverlaysTableViewer();
+ setEditorDirty();
+ }
+ }
+ }
+
+
+ /**
+ * Action launched when the delete overlay button is clicked.
+ */
+ private void deleteOverlayButtonAction()
+ {
+ StructuredSelection selection = ( StructuredSelection ) overlaysTableViewer.getSelection();
+
+ if ( !selection.isEmpty() )
+ {
+ OlcOverlayConfig overlay = ( OlcOverlayConfig ) selection.getFirstElement();
+
+ if ( MessageDialog.openConfirm( overlaysTableViewer.getControl().getShell(), "Delete Overlay?",
+ NLS.bind( "Are you sure you want to delete the ''{0}'' overlay?", getOverlayText( overlay ) ) ) )
+ {
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ databaseWrapper.getDatabase().removeOverlay( overlay );
+ refreshOverlaysTableViewer();
+ setEditorDirty();
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Indicates if the given database is the frontend one.
+ *
+ * @param database the database
+ * @return <code>true</code> if the given database if the frontend one,
+ * <code>false</code> if not.
*/
- private void disposeInnerSpecificSettingsComposite()
+ private boolean isFrontendDatabase( OlcDatabaseConfig database )
{
- if ( innerSpecificSettingsComposite != null )
+ if ( database != null )
{
- innerSpecificSettingsComposite.dispose();
- innerSpecificSettingsComposite = null;
+ int orderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( database.getOlcDatabase() );
+ String databaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase() );
+
+ return ( ( orderingPrefix == -1 ) && "frontend".equalsIgnoreCase( databaseName ) );
+
}
+
+ return false;
}
/**
- * Gets the front-end configuration (if any).
+ * Indicates if the given database is the config one.
*
* @param database the database
- * @return the front-end configuration or <code>null</code>
+ * @return <code>true</code> if the given database if the config one,
+ * <code>false</code> if not.
*/
- private OlcFrontendConfig getFrontendConfig( OlcDatabaseConfig database )
+ private boolean isConfigDatabase( OlcDatabaseConfig database )
{
if ( database != null )
{
- List<AuxiliaryObjectClass> auxiliaryObjectClasses = database.getAuxiliaryObjectClasses();
- if ( auxiliaryObjectClasses != null )
+ int orderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( database.getOlcDatabase() );
+ String databaseName = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase() );
+
+ return ( ( orderingPrefix == 0 ) && "config".equalsIgnoreCase( databaseName ) );
+
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Action launched when the add replication consumer button is clicked.
+ */
+ private void addReplicationConsumerButtonAction()
+ {
+ ReplicationConsumerDialog dialog = new ReplicationConsumerDialog( addReplicationConsumerButton.getShell(),
+ browserConnection );
+
+ if ( dialog.open() == OverlayDialog.OK )
+ {
+ SyncRepl syncRepl = dialog.getSyncRepl();
+
+ if ( syncRepl != null )
+ {
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ String newSyncReplValue = dialog.getSyncRepl().toString();
+
+ databaseWrapper.getDatabase().getOlcSyncrepl().add( newSyncReplValue );
+ refreshReplicationConsumersTableViewer();
+ replicationConsumersTableViewer.setSelection( new StructuredSelection( newSyncReplValue ) );
+ setEditorDirty();
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Action launched when the edit replication consumer button is clicked, or
+ * when the replication consumers table viewer is double-clicked.
+ */
+ private void editReplicationConsumerButtonAction()
+ {
+ StructuredSelection selection = ( StructuredSelection ) replicationConsumersTableViewer.getSelection();
+
+ if ( !selection.isEmpty() )
+ {
+ // Getting the raw SyncRepl value
+ String syncReplValue = ( String ) selection.getFirstElement();
+ String syncReplValueWithoutOrderingPrefix = syncReplValue;
+
+ // Getting the ordering prefix (if it exists)
+ int orderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( syncReplValue );
+
+ // If an ordering prefix was found, lets remove it before parsing the string
+ if ( orderingPrefix > 0 )
{
- for ( AuxiliaryObjectClass auxiliaryObjectClass : auxiliaryObjectClasses )
+ syncReplValueWithoutOrderingPrefix = OpenLdapConfigurationPluginUtils
+ .stripOrderingPrefix( syncReplValue );
+ }
+
+ // Parsing the SyncRepl value
+ SyncReplParser parser = new SyncReplParser();
+ try
+ {
+ SyncRepl syncRepl = parser.parse( syncReplValueWithoutOrderingPrefix );
+
+ // Opening a replication consumer dialog
+ ReplicationConsumerDialog dialog = new ReplicationConsumerDialog(
+ addReplicationConsumerButton.getShell(), syncRepl, browserConnection );
+
+ if ( dialog.open() == OverlayDialog.OK )
{
- if ( auxiliaryObjectClass instanceof OlcFrontendConfig )
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
{
- return ( OlcFrontendConfig ) auxiliaryObjectClass;
+ String newSyncReplValue = dialog.getSyncRepl().toString();
+
+ // Add back the ordering prefix if it was present
+ if ( orderingPrefix > 0 )
+ {
+ newSyncReplValue = "{" + orderingPrefix + "}" + newSyncReplValue;
+ }
+
+ databaseWrapper.getDatabase().getOlcSyncrepl().remove( syncReplValue );
+ databaseWrapper.getDatabase().getOlcSyncrepl().add( newSyncReplValue );
+ refreshReplicationConsumersTableViewer();
+ replicationConsumersTableViewer.setSelection( new StructuredSelection( newSyncReplValue ) );
+ setEditorDirty();
}
}
}
+ catch ( SyncReplParserException e )
+ {
+ CommonUIUtils
+ .openErrorDialog( NLS
+ .bind(
+ "The replication consumer definition could not be read correctly.\nThe following error occured:\n {0}",
+ e ) );
+ }
}
+ }
+
+
+ /**
+ * Action launched when the delete replication consumer button is clicked.
+ */
+ private void deleteReplicationConsumerButtonAction()
+ {
+ StructuredSelection selection = ( StructuredSelection ) replicationConsumersTableViewer.getSelection();
+
+ if ( !selection.isEmpty() )
+ {
+ String syncReplValue = ( String ) selection.getFirstElement();
- return null;
+ if ( MessageDialog.openConfirm( overlaysTableViewer.getControl().getShell(), "Delete Overlay?",
+ NLS.bind( "Are you sure you want to delete the ''{0}'' replication consumer ?",
+ getReplicationConsumerText( syncReplValue ) ) ) )
+ {
+ if ( ( databaseWrapper != null ) && ( databaseWrapper.getDatabase() != null ) )
+ {
+ databaseWrapper.getDatabase().getOlcSyncrepl().remove( syncReplValue );
+ refreshReplicationConsumersTableViewer();
+ setEditorDirty();
+ }
+ }
+ }
}
@@ -699,6 +1386,23 @@ public class DatabasesDetailsPage implem
/**
+ * Adds a modify listener to the given BrowserWidget.
+ *
+ * @param widget
+ * the widget
+ * @param listener
+ * the listener
+ */
+ protected void addModifyListener( BrowserWidget widget, WidgetModifyListener listener )
+ {
+ if ( ( widget != null ) && ( listener != null ) )
+ {
+ widget.addWidgetModifyListener( listener );
+ }
+ }
+
+
+ /**
* Adds a selection listener to the given Button.
*
* @param button
@@ -716,6 +1420,40 @@ public class DatabasesDetailsPage implem
/**
+ * Adds a selection changed listener to the given Viewer.
+ *
+ * @param viewer
+ * the Viewer control
+ * @param listener
+ * the listener
+ */
+ protected void addSelectionChangedListener( Viewer viewer, ISelectionChangedListener listener )
+ {
+ if ( ( viewer != null ) && ( !viewer.getControl().isDisposed() ) && ( listener != null ) )
+ {
+ viewer.addSelectionChangedListener( listener );
+ }
+ }
+
+
+ /**
+ * Adds a double-click listener to the given Viewer.
+ *
+ * @param viewer
+ * the Viewer control
+ * @param listener
+ * the listener
+ */
+ protected void addDoubleClickListener( TableViewer viewer, IDoubleClickListener listener )
+ {
+ if ( ( viewer != null ) && ( !viewer.getControl().isDisposed() ) && ( listener != null ) )
+ {
+ viewer.addDoubleClickListener( listener );
+ }
+ }
+
+
+ /**
* Removes a modify listener to the given Text.
*
* @param text
@@ -733,6 +1471,23 @@ public class DatabasesDetailsPage implem
/**
+ * Adds a modify listener to the given BrowserWidget.
+ *
+ * @param widget
+ * the widget
+ * @param listener
+ * the listener
+ */
+ protected void removeModifyListener( BrowserWidget widget, WidgetModifyListener listener )
+ {
+ if ( ( widget != null ) && ( listener != null ) )
+ {
+ widget.removeWidgetModifyListener( listener );
+ }
+ }
+
+
+ /**
* Removes a selection listener to the given Button.
*
* @param button
@@ -750,10 +1505,93 @@ public class DatabasesDetailsPage implem
/**
+ * Removes a selection changed listener to the given Button.
+ *
+ * @param button
+ * the Button control
+ * @param listener
+ * the listener
+ */
+ protected void removeSelectionChangedListener( Viewer viewer, ISelectionChangedListener listener )
+ {
+ if ( ( viewer != null ) && ( !viewer.getControl().isDisposed() ) && ( listener != null ) )
+ {
+ viewer.removeSelectionChangedListener( listener );
+ }
+ }
+
+
+ /**
+ * Removes a selection changed listener to the given Button.
+ *
+ * @param button
+ * the Button control
+ * @param listener
+ * the listener
+ */
+ protected void removeDoubleClickListener( TableViewer viewer, IDoubleClickListener listener )
+ {
+ if ( ( viewer != null ) && ( !viewer.getControl().isDisposed() ) && ( listener != null ) )
+ {
+ viewer.removeDoubleClickListener( listener );
+ }
+ }
+
+
+ /**
* Sets the associated editor dirty.
*/
- private void setEditorDirty()
+ public void setEditorDirty()
+ {
+ masterDetailsBlock.setEditorDirty();
+ }
+
+
+ /**
+ * Copies database properties from one instance to the other.
+ *
+ * @param original the original database
+ * @param destination the destination database
+ */
+ private void copyDatabaseProperties( OlcDatabaseConfig original, OlcDatabaseConfig destination )
{
- masterDetailsBlock.getPage().getServerConfigurationEditor().setDirty( true );
+ if ( ( original != null ) && ( destination != null ) )
+ {
+ // Special case for the 'olcDatabase' property
+ destination.setOlcDatabase( "{"
+ + OpenLdapConfigurationPluginUtils.getOrderingPrefix( original.getOlcDatabase() ) + "}"
+ + destination.getOlcDatabaseType() );
+
+ // All other properties
+ destination.setOlcAccess( original.getOlcAccess() );
+ destination.setOlcAddContentAcl( original.getOlcAddContentAcl() );
+ destination.setOlcHidden( original.getOlcHidden() );
+ destination.setOlcLastMod( original.getOlcLastMod() );
+ destination.setOlcLimits( original.getOlcLimits() );
+ destination.setOlcMaxDerefDepth( original.getOlcMaxDerefDepth() );
+ destination.setOlcMirrorMode( original.getOlcMirrorMode() );
+ destination.setOlcMonitoring( original.getOlcMonitoring() );
+ destination.setOlcPlugin( original.getOlcPlugin() );
+ destination.setOlcReadOnly( original.getOlcReadOnly() );
+ destination.setOlcReplica( original.getOlcReplica() );
+ destination.setOlcReplicaArgsFile( original.getOlcReplicaArgsFile() );
+ destination.setOlcReplicaPidFile( original.getOlcReplicaPidFile() );
+ destination.setOlcReplicationInterval( original.getOlcReplicationInterval() );
+ destination.setOlcReplogFile( original.getOlcReplogFile() );
+ destination.setOlcRequires( original.getOlcRequires() );
+ destination.setOlcRestrict( original.getOlcRestrict() );
+ destination.setOlcRootDN( original.getOlcRootDN() );
+ destination.setOlcRootPW( original.getOlcRootPW() );
+ destination.setOlcSchemaDN( original.getOlcSchemaDN() );
+ destination.setOlcSecurity( original.getOlcSecurity() );
+ destination.setOlcSizeLimit( original.getOlcSizeLimit() );
+ destination.setOlcSubordinate( original.getOlcSubordinate() );
+ destination.setOlcSuffix( original.getOlcSuffix() );
+ destination.setOlcSyncrepl( original.getOlcSyncrepl() );
+ destination.setOlcTimeLimit( original.getOlcTimeLimit() );
+ destination.setOlcUpdateDN( original.getOlcUpdateDN() );
+ destination.setOlcUpdateRef( original.getOlcUpdateRef() );
+ destination.setOverlays( original.getOverlays() );
+ }
}
}