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/08 19:02:53 UTC

svn commit: r1672121 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases: DatabasesDetailsPage.java DatabasesMasterDetailsBlock.java MdbDatabaseSpecificDetailsBlock.java

Author: elecharny
Date: Wed Apr  8 17:02:53 2015
New Revision: 1672121

URL: http://svn.apache.org/r1672121
Log:
o Added some Javadoc
o Some code simplification

Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesDetailsPage.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java

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=1672121&r1=1672120&r2=1672121&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  8 17:02:53 2015
@@ -150,23 +150,39 @@ public class DatabasesDetailsPage implem
     private FormToolkit toolkit;
     private ComboViewer databaseTypeComboViewer;
     private EntryWidget suffixEntryWidget;
+
+    /** The olcRootDN attribute */
     private EntryWidget rootDnEntryWidget;
+
+    /** The olcRootPW attribute */
     private PasswordWidget rootPasswordWidget;
+
+    /** The olcReadOnly attribute */
     private BooleanWithDefaultWidget readOnlyBooleanWithDefaultWidget;
+
+    /** The olcHidden attribute */
     private BooleanWithDefaultWidget hiddenBooleanWithDefaultWidget;
+
+    /** The associated overlays */
     private TableViewer overlaysTableViewer;
     private Button addOverlayButton;
     private Button editOverlayButton;
     private Button deleteOverlayButton;
+
     private Section specificSettingsSection;
     private Composite specificSettingsSectionComposite;
     private Composite databaseSpecificDetailsComposite;
+
+    /** The Syncrepl part */
     private TableViewer replicationConsumersTableViewer;
     private Button addReplicationConsumerButton;
     private Button editReplicationConsumerButton;
     private Button deleteReplicationConsumerButton;
 
     // Listeners
+    /**
+     * A listener for changes on the Overlay table 
+     */
     private ISelectionChangedListener overlaysTableViewerSelectionChangedListener = new ISelectionChangedListener()
     {
         public void selectionChanged( SelectionChangedEvent event )
@@ -174,6 +190,10 @@ public class DatabasesDetailsPage implem
             updateOverlaysTableButtonsState();
         }
     };
+
+    /**
+     * A listener for selections on the Overlay table 
+     */
     private IDoubleClickListener overlaysTableViewerDoubleClickListener = new IDoubleClickListener()
     {
         public void doubleClick( DoubleClickEvent event )
@@ -181,6 +201,10 @@ public class DatabasesDetailsPage implem
             editOverlayButtonAction();
         }
     };
+
+    /**
+     * A listener for the Overlay table Add button 
+     */
     private SelectionListener addOverlayButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -188,6 +212,10 @@ public class DatabasesDetailsPage implem
             addOverlayButtonAction();
         }
     };
+
+    /**
+     * A listener for the Overlay table Edit button 
+     */
     private SelectionListener editOverlayButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -195,6 +223,10 @@ public class DatabasesDetailsPage implem
             editOverlayButtonAction();
         }
     };
+
+    /**
+     * A listener for the Overlay table Delete button 
+     */
     private SelectionListener deleteOverlayButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -202,6 +234,10 @@ public class DatabasesDetailsPage implem
             deleteOverlayButtonAction();
         }
     };
+
+    /**
+     * A listener for changes on the Replication Consumers table 
+     */
     private ISelectionChangedListener replicationConsumersTableViewerSelectionChangedListener = new ISelectionChangedListener()
     {
         public void selectionChanged( SelectionChangedEvent event )
@@ -209,6 +245,10 @@ public class DatabasesDetailsPage implem
             updateReplicationConsumersTableButtonsState();
         }
     };
+
+    /**
+     * A listener for selections on the Replication Consumers table 
+     */
     private IDoubleClickListener replicationConsumersTableViewerDoubleClickListener = new IDoubleClickListener()
     {
         public void doubleClick( DoubleClickEvent event )
@@ -216,6 +256,10 @@ public class DatabasesDetailsPage implem
             editReplicationConsumerButtonAction();
         }
     };
+
+    /**
+     * A listener for the Replication Consumers table Add button 
+     */
     private SelectionListener addReplicationConsumerButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -223,6 +267,10 @@ public class DatabasesDetailsPage implem
             addReplicationConsumerButtonAction();
         }
     };
+
+    /**
+     * A listener for the Replication Consumers table Edit button 
+     */
     private SelectionListener editReplicationConsumerButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -230,6 +278,10 @@ public class DatabasesDetailsPage implem
             editReplicationConsumerButtonAction();
         }
     };
+
+    /**
+     * A listener for the Replication Consumers table Delete button 
+     */
     private SelectionListener deleteReplicationConsumerButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -238,6 +290,9 @@ public class DatabasesDetailsPage implem
         }
     };
 
+    /**
+     * The listener that manage the specific database parameters
+     */
     private ISelectionChangedListener databaseTypeComboViewerSelectionChangedListener = new ISelectionChangedListener()
     {
         public void selectionChanged( SelectionChangedEvent event )
@@ -319,7 +374,10 @@ public class DatabasesDetailsPage implem
             }
         }
     };
-    /** The modify listener which set the editor dirty */
+
+    /** 
+     * The modify listener which set the editor dirty 
+     **/
     private WidgetModifyListener dirtyWidgetModifyListener = new WidgetModifyListener()
     {
         public void widgetModified( WidgetModifyEvent event )
@@ -351,7 +409,7 @@ public class DatabasesDetailsPage implem
      */
     public void createContents( Composite parent )
     {
-        this.parentComposite = parent;
+        parentComposite = parent;
         parent.setLayout( new GridLayout() );
 
         createGeneralSettingsSection( parent, toolkit );
@@ -362,7 +420,10 @@ public class DatabasesDetailsPage implem
 
 
     /**
-     * Creates the General Settings Section
+     * Creates the General Settings Section. This will expose the following attributes :
+     * <ul>
+     * <li></li>
+     * </ul>
      *
      * @param parent the parent composite
      * @param toolkit the toolkit to use
@@ -401,7 +462,7 @@ public class DatabasesDetailsPage implem
             }
         } );
 
-        // Suffix
+        // Suffix DN
         toolkit.createLabel( composite, "Suffix:" );
         suffixEntryWidget = new EntryWidget( browserConnection, null, true );
         suffixEntryWidget.createWidget( composite, toolkit );
@@ -676,6 +737,7 @@ public class DatabasesDetailsPage implem
     public void selectionChanged( IFormPart part, ISelection selection )
     {
         IStructuredSelection ssel = ( IStructuredSelection ) selection;
+
         if ( ssel.size() == 1 )
         {
             databaseWrapper = ( DatabaseWrapper ) ssel.getFirstElement();
@@ -684,6 +746,7 @@ public class DatabasesDetailsPage implem
         {
             databaseWrapper = null;
         }
+
         refresh();
     }
 
@@ -796,7 +859,8 @@ public class DatabasesDetailsPage implem
         {
             OlcDatabaseConfig database = databaseWrapper.getDatabase();
 
-            // Enabling or disabling UI elements depending on the database
+            // Enabling or disabling UI elements depending on the database, dealing with
+            // the two specific Database (Frontend and Config)
             if ( isFrontendDatabase( database ) )
             {
                 databaseTypeComboViewer.getControl().setEnabled( false );
@@ -828,10 +892,12 @@ public class DatabasesDetailsPage implem
             // Suffixes
             List<Dn> suffixesDnList = database.getOlcSuffix();
             Dn suffixDn = null;
+
             if ( suffixesDnList.size() == 1 )
             {
                 suffixDn = suffixesDnList.get( 0 );
             }
+
             suffixEntryWidget.setInput( suffixDn );
 
             // Root DN

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.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/DatabasesMasterDetailsBlock.java?rev=1672121&r1=1672120&r2=1672121&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/DatabasesMasterDetailsBlock.java Wed Apr  8 17:02:53 2015
@@ -98,6 +98,10 @@ public class DatabasesMasterDetailsBlock
     private Button downButton;
 
     // Listeners
+    /**
+     * A listener called when the Database table content has changed. It will enable
+     * or disabled button accordingly to the changes.
+     */
     private ISelectionChangedListener viewerSelectionChangedListener = new ISelectionChangedListener()
     {
         public void selectionChanged( SelectionChangedEvent event )
@@ -106,6 +110,10 @@ public class DatabasesMasterDetailsBlock
             refreshButtonStates();
         }
     };
+
+    /**
+     * A listener called when the Add button is clicked
+     */
     private SelectionAdapter addButtonSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -113,6 +121,10 @@ public class DatabasesMasterDetailsBlock
             addNewDatabase();
         }
     };
+
+    /**
+     * A listener called when the Delete button is clicked
+     */
     private SelectionAdapter deleteButtonSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -120,6 +132,10 @@ public class DatabasesMasterDetailsBlock
             deleteSelectedDatabase();
         }
     };
+
+    /**
+     * A listener called when the Up button is clicked
+     */
     private SelectionAdapter upButtonSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -127,6 +143,10 @@ public class DatabasesMasterDetailsBlock
             moveSelectedDatabaseUp();
         }
     };
+
+    /**
+     * A listener called when the Down button is clicked
+     */
     private SelectionAdapter downButtonSelectionListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
@@ -139,8 +159,7 @@ public class DatabasesMasterDetailsBlock
     /**
      * Creates a new instance of DatabasesMasterDetailsBlock.
      *
-     * @param page
-     *      the associated page
+     * @param page the associated page
      */
     public DatabasesMasterDetailsBlock( DatabasesPage page )
     {
@@ -163,7 +182,22 @@ public class DatabasesMasterDetailsBlock
 
 
     /**
-     * {@inheritDoc}
+     * Create the form with the list of existing Database, and the button to update it :
+     * <pre>
+     * .------------------------------.
+     * | All Databases                |
+     * |+------------------+          |
+     * ||DB1               | ( Add  ) |
+     * ||DB2               | (Delete) |
+     * ||DB3               | -------- |
+     * ||                  | (  Up  ) |
+     * ||                  | ( Down ) |
+     * ||                  |          |
+     * ||                  |          |
+     * ||                  |          |
+     * |+------------------+          |
+     * +------------------------------+
+     * </pre>
      */
     protected void createMasterPart( final IManagedForm managedForm, Composite parent )
     {
@@ -191,6 +225,7 @@ public class DatabasesMasterDetailsBlock
         final SectionPart spart = new SectionPart( section );
         managedForm.addPart( spart );
         viewer = new TableViewer( table );
+
         viewer.addSelectionChangedListener( new ISelectionChangedListener()
         {
             public void selectionChanged( SelectionChangedEvent event )
@@ -205,6 +240,7 @@ public class DatabasesMasterDetailsBlock
                 }
             }
         } );
+
         viewer.setContentProvider( new ArrayContentProvider() );
         viewer.setLabelProvider( new DatabaseWrapperLabelProvider() );
         viewer.setSorter( new DatabaseWrapperViewerSorter() );
@@ -345,10 +381,9 @@ public class DatabasesMasterDetailsBlock
 
 
     /**
-     * Gets a new ID for a new database.
+     * Gets a new ID for a new database. They are incremental
      *
-     * @return 
-     *      a new ID for a new database
+     * @return  a new ID for a new database
      */
     private String getNewId()
     {
@@ -369,6 +404,7 @@ public class DatabasesMasterDetailsBlock
                     ok = false;
                 }
             }
+
             counter++;
         }
 
@@ -457,6 +493,7 @@ public class DatabasesMasterDetailsBlock
                 .getOlcDatabase() );
 
             OlcDatabaseConfig swapDatabase = findPreviousDatabase( selectedDatabaseOrderingPrefix );
+
             if ( swapDatabase != null )
             {
                 int swapDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( swapDatabase
@@ -519,6 +556,7 @@ public class DatabasesMasterDetailsBlock
                 .getOlcDatabase() );
 
             OlcDatabaseConfig swapDatabase = findNextDatabase( selectedDatabaseOrderingPrefix );
+
             if ( swapDatabase != null )
             {
                 int swapDatabaseOrderingPrefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( swapDatabase
@@ -565,6 +603,14 @@ public class DatabasesMasterDetailsBlock
     }
 
 
+    /**
+     * Update the button according to the content of the table. If we have
+     * no Database, we just enable the Add button. If we only have one Database,
+     * we don't enable the Add and Delete buttons. We also enable the Up and
+     * Down button accordingly to the selected database : if it's the first one,
+     * the Up butto is disabled, if it's the last one, the Down button is
+     * disabled.
+     */
     private void refreshButtonStates()
     {
         // Getting the selection of the table viewer
@@ -640,6 +686,7 @@ public class DatabasesMasterDetailsBlock
 
         // Saving the databases
         getPage().getConfiguration().clearDatabases();
+
         for ( DatabaseWrapper databaseWrapper : databaseWrappers )
         {
             getPage().getConfiguration().addDatabase( databaseWrapper.getDatabase() );
@@ -651,6 +698,9 @@ public class DatabasesMasterDetailsBlock
      */
     private class DatabaseWrapperLabelProvider extends LabelProvider
     {
+        /**
+         * Construct the label for a database. It's the type, followed by the suffixDN.
+         */
         public String getText( Object element )
         {
             if ( element instanceof DatabaseWrapper )
@@ -664,6 +714,9 @@ public class DatabasesMasterDetailsBlock
         };
 
 
+        /**
+         * Get the Database image, if it's a Database
+         */
         public Image getImage( Object element )
         {
             if ( element instanceof DatabaseWrapper )
@@ -728,6 +781,9 @@ public class DatabasesMasterDetailsBlock
         }
 
 
+        /**
+         * Return the Database suffix DN
+         */
         private String getSuffix( OlcDatabaseConfig database )
         {
             if ( database != null )
@@ -756,9 +812,12 @@ public class DatabasesMasterDetailsBlock
             {
                 OlcDatabaseConfig database1 = ( ( DatabaseWrapper ) e1 ).getDatabase();
                 OlcDatabaseConfig database2 = ( ( DatabaseWrapper ) e2 ).getDatabase();
+                boolean db1HasOrderingPrefix = OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1
+                    .getOlcDatabase() );
+                boolean db2HasOrderingPrefix = OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2
+                    .getOlcDatabase() );
 
-                if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1.getOlcDatabase() )
-                    && ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2.getOlcDatabase() ) ) )
+                if ( db1HasOrderingPrefix && db2HasOrderingPrefix )
                 {
                     int orderingPrefix1 = OpenLdapConfigurationPluginUtils.getOrderingPrefix( database1
                         .getOlcDatabase() );
@@ -778,13 +837,11 @@ public class DatabasesMasterDetailsBlock
                         return 0;
                     }
                 }
-                else if ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1.getOlcDatabase() )
-                    && ( !OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2.getOlcDatabase() ) ) )
+                else if ( db1HasOrderingPrefix )
                 {
                     return Integer.MIN_VALUE;
                 }
-                else if ( !OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database1.getOlcDatabase() )
-                    && ( OpenLdapConfigurationPluginUtils.hasOrderingPrefix( database2.getOlcDatabase() ) ) )
+                else if ( db2HasOrderingPrefix )
                 {
                     return Integer.MAX_VALUE;
                 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.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/MdbDatabaseSpecificDetailsBlock.java?rev=1672121&r1=1672120&r2=1672121&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java (original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/databases/MdbDatabaseSpecificDetailsBlock.java Wed Apr  8 17:02:53 2015
@@ -24,6 +24,9 @@ import org.apache.directory.api.util.Str
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.openldap.config.model.database.OlcMdbConfig;
 import org.apache.directory.studio.openldap.config.model.widgets.IndicesWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.BooleanWithDefaultWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.DirectoryBrowserWidget;
+import org.apache.directory.studio.openldap.common.ui.widgets.UnixPermissionsWidget;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.VerifyEvent;
 import org.eclipse.swt.events.VerifyListener;
@@ -147,6 +150,11 @@ public class MdbDatabaseSpecificDetailsB
      * <li>Directory : the directory on disk where the file will be stored</li>
      * <li>mode : the file mode for this directory</li>
      * </ul>
+     * It covers the following attributes :
+     * <ul>
+     * <li>olcDbDirectory</li>
+     * <li>olcDbMode</li>
+     * </ul>
      *
      * @param parent the parent composite
      * @param toolkit the toolkit
@@ -183,6 +191,10 @@ public class MdbDatabaseSpecificDetailsB
 
     /**
      * Creates the database indexes section.
+     * It covers the following attribute :
+     * <ul>
+     * <li>olcDbIndex</li>
+     * </ul>
      *
      * @param parent the parent composite
      * @param toolkit the toolkit
@@ -207,6 +219,14 @@ public class MdbDatabaseSpecificDetailsB
 
     /**
      * Creates the database limits section.
+     * It covers the following attributes :
+     * <ul>
+     * <li>olcDbCheckpoint</li>
+     * <li>olcDbMaxEntrySize (for OpenLDAP 2.4.41)</li>
+     * <li>olcDbMaxReaders</li>
+     * <li>olcDbMaxSize</li>
+     * <li>olcDbSearchStack</li>
+     * </ul>
      *
      * @param parent the parent composite
      * @param toolkit the toolkit
@@ -253,7 +273,12 @@ public class MdbDatabaseSpecificDetailsB
 
 
     /**
-     * Creates the database options section.
+     * Creates the database options section. 
+     * It covers the following attributes :
+     * <ul>
+     * <li>olcDbNoSync</li>
+     * <li>olcDbEnvFlags (for OpenLDAP 2.4.33)</li>
+     * </ul>
      *
      * @param parent the parent composite
      * @param toolkit the toolkit