directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1686467 - in /directory/studio/trunk/plugins: openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/ openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/
Date Fri, 19 Jun 2015 17:46:26 GMT
Author: elecharny
Date: Fri Jun 19 17:46:26 2015
New Revision: 1686467

URL: http://svn.apache.org/r1686467
Log:
o Added a Dialog for the selection of AllowFeature
o Added a getFeature(int) method 
o Added Messages for Dialogs

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/Messages.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages.properties
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_de.properties
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_fr.properties
Modified:
    directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/AllowFeatureEnum.java
    directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/PasswordHashEnum.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.java

Modified: directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/AllowFeatureEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/AllowFeatureEnum.java?rev=1686467&r1=1686466&r2=1686467&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/AllowFeatureEnum.java
(original)
+++ directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/AllowFeatureEnum.java
Fri Jun 19 17:46:26 2015
@@ -33,12 +33,12 @@ package org.apache.directory.studio.open
  */
 public enum AllowFeatureEnum
 {
-    BIND_V2( "bind_v2" ),
+    UNKNOWN( "---" ),
     BIND_ANON_CRED( "bind_anon_cred" ),
     BIND_ANON_DN( "bind_anon_dn" ),
-    UPDATE_ANON( "update_anon" ),
+    BIND_V2( "bind_v2" ),
     PROXY_AUTHZ_ANON( "proxy_authz_anon" ),
-    UNKNOWN( "---" );
+    UPDATE_ANON( "update_anon" );
     
     /** The interned name */
     private String name;
@@ -50,6 +50,36 @@ public enum AllowFeatureEnum
     {
         this.name = name;
     }
+    
+    
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+    
+    
+    /**
+     * Get the PassworAllowFeatureEnumdHashEnum instance from its number
+     * 
+     * @param number The number we are looking for
+     * @return The associated AllowFeatureEnum instance
+     */
+    public static AllowFeatureEnum getFeature( int number )
+    {
+        AllowFeatureEnum[] values = AllowFeatureEnum.values();
+        
+        if ( ( number > 0 ) && ( number < values.length ) )
+        {
+            return values[number];
+        }
+        else
+        {
+            return UNKNOWN;
+        }
+    }
 
     
     /**
@@ -87,13 +117,4 @@ public enum AllowFeatureEnum
         
         return UNKNOWN;
     }
-    
-    
-    /**
-     * @return the name
-     */
-    public String getName()
-    {
-        return name;
-    }
 }

Modified: directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/PasswordHashEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/PasswordHashEnum.java?rev=1686467&r1=1686466&r2=1686467&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/PasswordHashEnum.java
(original)
+++ directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/PasswordHashEnum.java
Fri Jun 19 17:46:26 2015
@@ -42,7 +42,7 @@ public enum PasswordHashEnum
     private String name;
     
     /**
-     * Instanciation of the values
+     * A private constructor for this enum
      */
     private PasswordHashEnum( int number, String name )
     {

Added: 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=1686467&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/AllowFeatureDialog.java
Fri Jun 19 17:46:26 2015
@@ -0,0 +1,226 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.openldap.config.editor.dialogs;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.common.ui.AddEditDialog;
+import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.apache.directory.studio.openldap.common.ui.model.AllowFeatureEnum;
+
+
+/**
+ * The AllowFeatureDialog is used to select one feature to allow. The possible
+ * features are :
+ * <ul>
+ * <li>bind_v2</li>
+ * <li>bind_anon_cred</li>
+ * <li>bind_anon_dn</li>
+ * <li>update_anon</li>
+ * <li>proxy_authz_anon</li>
+ * </ul>
+ * 
+ * The dialog overlay is like :
+ * 
+ * <pre>
+ * +----------------------------+
+ * | Allowed feature            |
+ * | .------------------------. |
+ * | | bind_v2 :          [ ] | |
+ * | | bond_anon_cred :   [ ] | |
+ * | | bind_anon_dn :     [ ] | |
+ * | | update_anon :      [ ] | |
+ * | | proxy_authz_anon : [ ] | |
+ * | '------------------------' |
+ * |                            |
+ * |  (Cancel)            (OK)  |
+ * +----------------------------+
+ * </pre>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AllowFeatureDialog extends AddEditDialog<AllowFeatureEnum>
+{
+    /** The array of buttons */
+    private Button[] allowFeatureCheckboxes = new Button[5];
+    
+    /** The already selected allowed features */
+    List<AllowFeatureEnum> features = new ArrayList<AllowFeatureEnum>();
+    
+    /**
+     * Create a new instance of the AllowFeatureDialog
+     * 
+     * @param parentShell The parent Shell
+     */
+    public AllowFeatureDialog( Shell parentShell )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+    }
+    
+    
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( Messages.getString( "AllowFeature.Title" ) );
+    }
+    
+
+    /**
+     * The listener in charge of exposing the changes when some checkbox is selected
+     */
+    private SelectionListener checkboxSelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            Object object = e.getSource();
+            
+            if ( object instanceof Button )
+            {
+                Button selectedCheckbox = (Button)object;
+                
+                for ( int i = 1; i < allowFeatureCheckboxes.length; i++ )
+                {
+                    if ( selectedCheckbox == allowFeatureCheckboxes[i] )
+                    {
+                        setEditedElement( AllowFeatureEnum.getFeature( i ) );
+                    }
+                    else if ( allowFeatureCheckboxes[i].isEnabled() )
+                    {
+                        allowFeatureCheckboxes[i].setSelection( false );
+                    }
+                }
+            }
+        }
+    };
+
+
+    /**
+     * Create the Dialog for AllowFeature :
+     * <pre>
+     * +----------------------------+
+     * | Allowed feature            |
+     * | .------------------------. |
+     * | | bind_v2 :          [ ] | |
+     * | | bond_anon_cred :   [ ] | |
+     * | | bind_anon_dn :     [ ] | |
+     * | | update_anon :      [ ] | |
+     * | | proxy_authz_anon : [ ] | |
+     * | '------------------------' |
+     * |                            |
+     * |  (Cancel)            (OK)  |
+     * +----------------------------+
+     * </pre>
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        composite.setLayoutData( gd );
+        
+        createAllowFeatureEditGroup( composite );
+        initDialog();
+        
+        applyDialogFont( composite );
+        
+        return composite;
+    }
+
+
+    /**
+     * Creates the AllowFeature input group. This is the part of the dialog
+     * where one can insert the TimeLimit values
+     * 
+     * <pre>
+     * Allowed feature
+     * .------------------------.
+     * | bind_v2 :          [ ] |
+     * | bond_anon_cred :   [ ] |
+     * | bind_anon_dn :     [ ] |
+     * | update_anon :      [ ] |
+     * | proxy_authz_anon : [ ] |
+     * '------------------------'
+     * </pre>
+     * @param parent the parent composite
+     */
+    private void createAllowFeatureEditGroup( Composite parent )
+    {
+        // Allow Feature Group
+        Group allowFeatureGroup = BaseWidgetUtils.createGroup( parent, "", 2 );
+        GridLayout allowFeatureGridLayout = new GridLayout( 2, false );
+        allowFeatureGroup.setLayout( allowFeatureGridLayout );
+        allowFeatureGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false )
);
+
+        // The various buttons
+        for ( int i = 1; i < allowFeatureCheckboxes.length; i++ )
+        {
+            AllowFeatureEnum allowFeature = AllowFeatureEnum.getFeature( i );
+            Button button = BaseWidgetUtils.createCheckbox( allowFeatureGroup, allowFeature.getName(),
1 );
+            allowFeatureCheckboxes[i] = button;
+            allowFeatureCheckboxes[i].addSelectionListener( checkboxSelectionListener );
+        }
+    }
+    
+    
+    protected void initDialog()
+    {
+        List<AllowFeatureEnum> elements = getElements();
+        
+        for ( int i = 1; i < allowFeatureCheckboxes.length; i++ )
+        {
+            AllowFeatureEnum value = AllowFeatureEnum.getFeature( allowFeatureCheckboxes[i].getText()
);
+            
+            // Disable the featrues already selected
+            if ( elements.contains( value ) )
+            {
+                allowFeatureCheckboxes[i].setSelection( true );
+                allowFeatureCheckboxes[i].setEnabled( false );
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addNewElement()
+    {
+        // Default to none
+        setEditedElement( AllowFeatureEnum.UNKNOWN );
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/Messages.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/Messages.java?rev=1686467&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/Messages.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/Messages.java
Fri Jun 19 17:46:26 2015
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.openldap.config.editor.dialogs;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+/**
+ * This class get messages from the resources file for the OpenLDAP pages.
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class Messages
+{
+    /** The resource name */
+    private static final ResourceBundle RESOURCE_BUNDLE = 
+        ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" );
+    
+    /**
+     * Get back a message from the resource file given a key
+     * 
+     * @param key The key associated with the message
+     * @return The found message
+     */
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.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/PasswordHashDialog.java?rev=1686467&r1=1686466&r2=1686467&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/PasswordHashDialog.java
Fri Jun 19 17:46:26 2015
@@ -96,7 +96,7 @@ public class PasswordHashDialog extends
     protected void configureShell( Shell shell )
     {
         super.configureShell( shell );
-        shell.setText( "Password Hash" );
+        shell.setText( Messages.getString( "PasswordHash.Title" ) );
     }
 
     /**

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages.properties?rev=1686467&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages.properties
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages.properties
Fri Jun 19 17:46:26 2015
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#---------------------------------------------------------------------------------------
+# The AllowFeature dialog
+#---------------------------------------------------------------------------------------
+AllowFeature.Title=Allowed Feature
+
+#---------------------------------------------------------------------------------------
+# The PasswordHash dialog
+#---------------------------------------------------------------------------------------
+PasswordHash.Title=Password Hash

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_de.properties?rev=1686467&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_de.properties
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_de.properties
Fri Jun 19 17:46:26 2015
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#---------------------------------------------------------------------------------------
+# The AllowFeature dialog
+#---------------------------------------------------------------------------------------
+AllowFeature.Title=Allowed Feature
+
+#---------------------------------------------------------------------------------------
+# The PasswordHash dialog
+#---------------------------------------------------------------------------------------
+PasswordHash.Title=Password Hash
+

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_fr.properties?rev=1686467&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_fr.properties
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/messages_fr.properties
Fri Jun 19 17:46:26 2015
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#---------------------------------------------------------------------------------------
+# The AllowFeature dialog
+#---------------------------------------------------------------------------------------
+AllowFeature.Title=Fonction autoris\u00E9
+
+#---------------------------------------------------------------------------------------
+# The PasswordHash dialog
+#---------------------------------------------------------------------------------------
+PasswordHash.Title=Hash du mot de passe



Mime
View raw message