directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1688029 - 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/editor/databases/ src/main/java/org/...
Date Sun, 28 Jun 2015 17:50:28 GMT
Author: elecharny
Date: Sun Jun 28 17:50:27 2015
New Revision: 1688029

URL: http://svn.apache.org/r1688029
Log:
o Added an icon for a disabled Database
o Fixed a bug in the prefix computation (negatove values weren't correctly handled)
o The DatabaseWrapperLabelProvider class now extends the StyledCellLabelProvider, so that
we can grey disabled databases
o Add a MouseListener to the Database TableViewer to be able to enable or disabled a Database
using aright-click (not fully implemented yet)
o 

Added:
    directory/studio/trunk/plugins/openldap.config.editor/resources/icons/disabledDatabase.gif
  (with props)
Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginConstants.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginUtils.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/wrappers/DatabaseWrapperLabelProvider.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java

Added: directory/studio/trunk/plugins/openldap.config.editor/resources/icons/disabledDatabase.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/resources/icons/disabledDatabase.gif?rev=1688029&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/plugins/openldap.config.editor/resources/icons/disabledDatabase.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginConstants.java?rev=1688029&r1=1688028&r2=1688029&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginConstants.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginConstants.java
Sun Jun 28 17:50:27 2015
@@ -36,6 +36,7 @@ public interface OpenLdapConfigurationPl
     // ------
     public static final String IMG_ATTRIBUTE = "resources/icons/attribute.gif"; //$NON-NLS-1$
     public static final String IMG_DATABASE = "resources/icons/database.gif"; //$NON-NLS-1$
+    public static final String IMG_DISABLED_DATABASE = "resources/icons/disabledDatabase.gif";
//$NON-NLS-1$
     public static final String IMG_EDITOR = "resources/icons/editor.gif"; //$NON-NLS-1$
     public static final String IMG_EXPORT = "resources/icons/export.gif"; //$NON-NLS-1$
     public static final String IMG_INDEX = "resources/icons/index.png"; //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginUtils.java?rev=1688029&r1=1688028&r2=1688029&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginUtils.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/OpenLdapConfigurationPluginUtils.java
Sun Jun 28 17:50:27 2015
@@ -127,6 +127,7 @@ public class OpenLdapConfigurationPlugin
         if ( Strings.isCharASCII( prefixString, pos, '-') )
         {
             positive = false;
+            pos++;
         }
 
         char car;
@@ -243,7 +244,11 @@ public class OpenLdapConfigurationPlugin
 
 
     /**
-     * Gets the ordering prefix value (or -1 if none is found).
+     * Gets the ordering prefix value (or -1 if none is found). The String's prefix
+     * is at the beginning :
+     * <pre>
+     * {n}blah
+     * </pre>
      *
      * @param prefixString the string
      * @return the precedence value (or -1 if none is found).

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=1688029&r1=1688028&r2=1688029&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
Sun Jun 28 17:50:27 2015
@@ -42,13 +42,18 @@ import org.eclipse.jface.viewers.Structu
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.forms.DetailsPart;
 import org.eclipse.ui.forms.IManagedForm;
@@ -251,8 +256,20 @@ public class DatabasesMasterDetailsBlock
                 if ( newSelection != currentSelection )
                 {
                     currentSelection = newSelection;
-                    detailsPart.commit( false );
-                    managedForm.fireSelectionChanged( spart, event.getSelection() );
+                    
+                    OlcDatabaseConfig database = ((DatabaseWrapper)currentSelection).getDatabase();
+                    Boolean disabled = database.getOlcDisabled();
+                    
+                    if ( ( disabled != null ) && ( disabled == true ) )
+                    {
+                        // Do nothing
+                    }
+                    else
+                    {
+                        detailsPart.commit( false );
+                        managedForm.fireSelectionChanged( spart, event.getSelection() );
+                    }
+
                 }
             }
         } );
@@ -260,6 +277,48 @@ public class DatabasesMasterDetailsBlock
         viewer.setContentProvider( new ArrayContentProvider() );
         viewer.setLabelProvider( new DatabaseWrapperLabelProvider() );
         viewer.setSorter( new DatabaseWrapperViewerSorter() );
+        
+        viewer.getTable().addMouseListener ( new MouseListener()
+            {
+                public void mouseUp( MouseEvent e ) 
+                {
+                }
+                
+                public void mouseDown( MouseEvent event ) 
+                {
+                    if ( event.button == 3 )
+                    {
+                        Table table = (Table)event.getSource();
+                        int selectedItem = table.getSelectionIndex();
+                        DatabaseWrapper database = databaseWrappers.get( selectedItem );
+                        
+                        Menu menu = new Menu( viewer.getTable().getShell(), SWT.POP_UP );
+                        MenuItem enabled = new MenuItem ( menu, SWT.PUSH );
+                        
+                        Boolean disabled = database.getDatabase().getOlcDisabled();
+                        
+                        if ( ( disabled != null ) && ( disabled == true ) )
+                        {
+                            enabled.setText ( "Enable" );
+                        }
+                        else
+                        {
+                            enabled.setText ( "Disable" );
+                        }
+            
+                        // draws pop up menu:
+                        Point pt = new Point( event.x, event.y );
+                        pt = table.toDisplay( pt );
+                        menu.setLocation( pt.x, pt.y );
+                        menu.setVisible ( true );
+                    }
+                }
+                
+                public void mouseDoubleClick( MouseEvent e ) 
+                {
+                }
+            }
+        ); 
 
         // Creating the button(s)
         addButton = toolkit.createButton( client, "Add", SWT.PUSH );

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapperLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapperLabelProvider.java?rev=1688029&r1=1688028&r2=1688029&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapperLabelProvider.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/DatabaseWrapperLabelProvider.java
Sun Jun 28 17:50:27 2015
@@ -22,96 +22,127 @@ package org.apache.directory.studio.open
 import java.util.List;
 
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.common.ui.CommonUIConstants;
 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.databases.DatabaseTypeEnum;
 import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig;
-import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.jface.viewers.ViewerCell;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.TextStyle;
 
 /**
- * This class defines a label provider for a database wrapper viewer.
+ * This class defines a label provider for a database wrapper viewer. We use a StyledCellLabelProvider
+ * parent, to be able to grey the disabled databases.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DatabaseWrapperLabelProvider extends LabelProvider
+public class DatabaseWrapperLabelProvider extends StyledCellLabelProvider
 {
+    
+    private final Styler grayedStyle;
+    
+    
+    public DatabaseWrapperLabelProvider()
+    {
+        grayedStyle = new Styler() 
+        {
+            @Override
+            public void applyStyles( TextStyle textStyle ) 
+            {
+                textStyle.foreground = CommonUIConstants.L_GREY_COLOR;
+            }
+        };
+    }
+
     /**
-     * Construct the label for a database. It's the type, followed by the suffixDN.
+     * Get the Database image, if it's a Database. We can show two different icons, depending
+     * on the Database status : enabled or disabled.
      */
-    public String getText( Object element )
+    public Image getImage( Object element )
     {
         if ( element instanceof DatabaseWrapper )
         {
-            OlcDatabaseConfig database = ( ( DatabaseWrapper ) element ).getDatabase();
-
-            return getDatabaseType( database ) + " (" + getSuffix( database ) + ")";
+            DatabaseWrapper database = (DatabaseWrapper) element;
+            Boolean disabled = database.getDatabase().getOlcDisabled();
+            
+            if ( ( disabled == null ) || !disabled )
+            {
+                return OpenLdapConfigurationPlugin.getDefault().getImage(
+                    OpenLdapConfigurationPluginConstants.IMG_DATABASE );
+            }
+            else
+            {
+                return OpenLdapConfigurationPlugin.getDefault().getImage(
+                    OpenLdapConfigurationPluginConstants.IMG_DISABLED_DATABASE );
+            }
         }
 
-        return super.getText( element );
+        return null;
     };
-
-
+    
+    
     /**
-     * Get the Database image, if it's a Database
+     * Shows the Database name, and grey it if it's disabled.
+     * 
+     * {@inheritDoc}
      */
-    public Image getImage( Object element )
+    @Override
+    public void update( ViewerCell cell ) 
     {
-        if ( element instanceof DatabaseWrapper )
+        Object element = cell.getElement();
+
+        if ( element instanceof DatabaseWrapper ) 
         {
-            return OpenLdapConfigurationPlugin.getDefault().getImage(
-                OpenLdapConfigurationPluginConstants.IMG_DATABASE );
+            DatabaseWrapper database = (DatabaseWrapper) element;
+
+            Boolean disabled = database.getDatabase().getOlcDisabled();
+            String databaseName = getDatabaseType( database.getDatabase() ) + " (" + getSuffix(
database.getDatabase() ) + ")";
+            
+            StyledString styledString = null;
+            
+            // Gry the database if it's disabled.
+            if ( ( disabled == null ) || !disabled )
+            {  
+                styledString = new StyledString( databaseName, grayedStyle );
+            }
+            else
+            {
+                styledString= new StyledString( databaseName, null );
+            }
+            
+            cell.setText( styledString.toString() );
+            cell.setStyleRanges( styledString.getStyleRanges() );
+            cell.setImage( getImage( database ) );
         }
 
-        return super.getImage( element );
-    };
+        super.update(cell);
+    }
 
 
+    /**
+     * Return the database type.
+     */
     private String getDatabaseType( OlcDatabaseConfig database )
     {
         if ( database != null )
         {
             String databaseType = OpenLdapConfigurationPluginUtils.stripOrderingPrefix( database.getOlcDatabase()
);
 
-            if ( "bdb".equalsIgnoreCase( databaseType ) )
-            {
-                return "BDB";
-            }
-            else if ( "hdb".equalsIgnoreCase( databaseType ) )
-            {
-                return "HDB";
-            }
-            else if ( "mdb".equalsIgnoreCase( databaseType ) )
-            {
-                return "MDB";
-            }
-            else if ( "ldap".equalsIgnoreCase( databaseType ) )
+            DatabaseTypeEnum databasetype = DatabaseTypeEnum.valueOf( Strings.toUpperCase(
databaseType ) );
+            
+            if ( databaseType != null )
             {
-                return "LDAP";
-            }
-            else if ( "ldif".equalsIgnoreCase( databaseType ) )
-            {
-                return "LDIF";
-            }
-            else if ( "null".equalsIgnoreCase( databaseType ) )
-            {
-                return "Null";
-            }
-            else if ( "relay".equalsIgnoreCase( databaseType ) )
-            {
-                return "Relay";
-            }
-            else if ( "frontend".equalsIgnoreCase( databaseType ) )
-            {
-                return "FrontEnd";
-            }
-            else if ( "config".equalsIgnoreCase( databaseType ) )
-            {
-                return "Config";
+                return databasetype.getName();
             }
             else
             {
-                return "None";
+                return DatabaseTypeEnum.NONE.getName();
             }
         }
 
@@ -134,7 +165,6 @@ public class DatabaseWrapperLabelProvide
             }
         }
 
-        return "none";
+        return DatabaseTypeEnum.NONE.getName();
     }
-
 }

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java?rev=1688029&r1=1688028&r2=1688029&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/model/database/OlcDatabaseConfig.java
Sun Jun 28 17:50:27 2015
@@ -33,16 +33,38 @@ import org.apache.directory.studio.openl
  * Java bean for the 'olcDatabaseConfig' object class. It stores the common parameters
  * for any DB :
  * <ul>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
+ * <li>olcAccess</li>
+ * <li>olcAddContentAcl</li>
+ * <li>olcDatabase (MUST)</li>
+ * <li>olcDisabled</li>
+ * <li>olcExtraAttrs</li>
+ * <li>olcHidden</li>
+ * <li>olcLastMod</li>
+ * <li>olcLimits</li>
+ * <li>olcMaxDerefDepth</li>
+ * <li>olcMirrorMode</li>
+ * <li>olcMonitoring</li>
+ * <li>olcPlugin</li>
+ * <li>olcReadOnly</li>
+ * <li>olcReplica</li>
+ * <li>olcReplicaArgsFile</li>
+ * <li>olcReplicaPidFile</li>
+ * <li>olcReplicationInterval</li>
+ * <li>olcReplogFile</li>
+ * <li>olcRequires</li>
+ * <li>olcRestrict</li>
+ * <li>olcRootDN</li>
+ * <li>olcRootPW</li>
+ * <li>olcSchemaDN</li>
+ * <li>olcSecurity</li>
+ * <li>olcSizeLimit</li>
+ * <li>olcSubordinate</li>
+ * <li>olcSuffix</li>
+ * <li>olcSyncrepl</li>
+ * <li>olcSyncUseSubentry</li>
+ * <li>olcTimeLimit</li>
+ * <li>olcUpdateDN</li>
+ * <li>olcUpdateRef</li>
  * </ul>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -50,22 +72,12 @@ import org.apache.directory.studio.openl
 public class OlcDatabaseConfig extends OlcConfig
 {
     /**
-     * The overlays list
-     */
-    private List<OlcOverlayConfig> overlays = new ArrayList<OlcOverlayConfig>();
-
-    /**
-     * Field for the 'olcDatabase' attribute.
-     */
-    @ConfigurationElement(attributeType = "olcDatabase", isOptional = false, isRdn = true)
-    private String olcDatabase;
-
-    /**
-     * Field for the 'olcAccess' attribute.
+     * Field for the 'olcAccess' attribute, which is an ordered multi-value String attribute
      */
     @ConfigurationElement(attributeType = "olcAccess")
     private List<String> olcAccess = new ArrayList<String>();
 
+
     /**
      * Field for the 'olcAddContentAcl' attribute.
      */
@@ -73,6 +85,12 @@ public class OlcDatabaseConfig extends O
     private Boolean olcAddContentAcl;
 
     /**
+     * Field for the 'olcDatabase' attribute.
+     */
+    @ConfigurationElement(attributeType = "olcDatabase", isOptional = false, isRdn = true)
+    private String olcDatabase;
+
+    /**
      * Field for the 'olcDisabled' attribute. (Added in OpenLDAP 2.4.36)
      */
     @ConfigurationElement(attributeType = "olcDisabled")
@@ -245,6 +263,11 @@ public class OlcDatabaseConfig extends O
      */
     @ConfigurationElement(attributeType = "olcUpdateRef")
     private List<String> olcUpdateRef = new ArrayList<String>();
+    
+    /**
+     * The overlays list
+     */
+    private List<OlcOverlayConfig> overlays = new ArrayList<OlcOverlayConfig>();
 
 
     /**



Mime
View raw message