directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1686687 - in /directory/studio/trunk/plugins: common.ui/src/main/java/org/apache/directory/studio/common/ui/ openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/
Date Sun, 21 Jun 2015 05:46:42 GMT
Author: elecharny
Date: Sun Jun 21 05:46:41 2015
New Revision: 1686687

URL: http://svn.apache.org/r1686687
Log:
Make it possible to disable the OK button in a AddEditDialog when we create the Dialog

Modified:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java?rev=1686687&r1=1686686&r2=1686687&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java
(original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/AddEditDialog.java
Sun Jun 21 05:46:41 2015
@@ -23,6 +23,10 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 
 /**
@@ -40,7 +44,10 @@ public abstract class AddEditDialog<E> e
     
     /** The table's elements */
     private List<E> elements;
-    
+
+    /** A flag used to tell if the okButton must be disabled */
+    protected boolean okDisabled = false;
+
     /**
      * Create a new instance of the TableAddEditDialog
      * 
@@ -59,6 +66,23 @@ public abstract class AddEditDialog<E> e
         // Nothing to do
     }
     
+
+    /**
+     * Override the createButtonBar method to be able to hide the OK button if needed
+     */
+    protected Control createButtonBar( Composite parent ) 
+    {
+        Control buttonBar = super.createButtonBar( parent );
+        
+        if ( okDisabled )
+        {
+            Button okButton = getButton( IDialogConstants.OK_ID );
+            okButton.setEnabled( false );
+        }
+        
+        return buttonBar;
+    }
+    
     
     /**
      * Add a new Element that will be edited

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java?rev=1686687&r1=1686686&r2=1686687&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java
Sun Jun 21 05:46:41 2015
@@ -76,7 +76,7 @@ public class AllowFeatureDialog extends
     
     /** The already selected allowed features */
     List<AllowFeatureEnum> features = new ArrayList<AllowFeatureEnum>();
-    
+
     /**
      * Create a new instance of the AllowFeatureDialog
      * 
@@ -159,7 +159,7 @@ public class AllowFeatureDialog extends
         
         return composite;
     }
-
+    
 
     /**
      * Creates the AllowFeature input group.
@@ -197,6 +197,8 @@ public class AllowFeatureDialog extends
     protected void initDialog()
     {
         List<AllowFeatureEnum> elements = getElements();
+        boolean allSelected = true;
+        okDisabled = false;
         
         for ( int i = 1; i < allowFeatureCheckboxes.length; i++ )
         {
@@ -208,6 +210,16 @@ public class AllowFeatureDialog extends
                 allowFeatureCheckboxes[i].setSelection( true );
                 allowFeatureCheckboxes[i].setEnabled( false );
             }
+            else
+            {
+                allSelected = false;
+            }
+        }
+        
+        if ( allSelected )
+        {
+            // Disable the OK button
+            okDisabled = true;
         }
     }
 



Mime
View raw message