directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1037767 - in /directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2: editor/ jobs/
Date Mon, 22 Nov 2010 16:26:07 GMT
Author: pamarcelot
Date: Mon Nov 22 16:26:06 2010
New Revision: 1037767

URL: http://svn.apache.org/viewvc?rev=1037767&view=rev
Log:
Added various Modify and Selection Listeners which brings the updates of UI back of configuration
beans.

Modified:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/KerberosServerPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditor.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorPage.java
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/jobs/LoadConfigurationRunnable.java

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/KerberosServerPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/KerberosServerPage.java?rev=1037767&r1=1037766&r2=1037767&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/KerberosServerPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/KerberosServerPage.java
Mon Nov 22 16:26:06 2010
@@ -23,7 +23,6 @@ package org.apache.directory.studio.apac
 import org.apache.directory.server.config.beans.ChangePasswordServerBean;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.KdcServerBean;
-import org.apache.directory.server.config.beans.LdapServerBean;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -31,7 +30,6 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapData;

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java?rev=1037767&r1=1037766&r2=1037767&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/LdapLdapsServersPage.java
Mon Nov 22 16:26:06 2010
@@ -20,20 +20,22 @@
 package org.apache.directory.studio.apacheds.configuration.v2.editor;
 
 
-import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.LdapServerBean;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.apache.directory.server.config.beans.TransportBean;
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.name.DN;
 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;
 import org.eclipse.swt.layout.GridData;
 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.editor.FormEditor;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapData;
@@ -311,15 +313,13 @@ public class LdapLdapsServersPage extend
 
     private void initUI()
     {
-        ConfigBean configBean = getConfigBean();
-
-        LdapServerBean ldapServerBean = configBean.getDirectoryServiceBean().getLdapServerBean();
+        LdapServerBean ldapServerBean = getLdapServerBean();
 
         enableLdapCheckbox.setSelection( ldapServerBean.isEnabled() );
-        ldapPortText.setText( ldapServerBean.getTransports()[0].getSystemPort() + "" );
+        ldapPortText.setText( getLdapServerTransportBean().getSystemPort() + "" );
 
         enableLdapsCheckbox.setSelection( true );
-        ldapsPortText.setText( "10636" );
+        ldapsPortText.setText( getLdapsServerTransportBean().getSystemPort() + "" );
 
         saslHostText.setText( ldapServerBean.getLdapServerSaslHost() );
         saslPrincipalText.setText( ldapServerBean.getLdapServerSaslPrincipal() );
@@ -332,20 +332,193 @@ public class LdapLdapsServersPage extend
      */
     private void addListeners()
     {
+        // Enable LDAP Checkbox
         addDirtyListener( enableLdapCheckbox );
+        enableLdapCheckbox.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                getLdapServerTransportBean().setEnabled( enableLdapCheckbox.getSelection()
);
+            }
+        } );
+
+        // LDAP Port Text
         addDirtyListener( ldapPortText );
+        ldapPortText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                getLdapsServerTransportBean().setSystemPort( Integer.parseInt( ldapPortText.getText()
) );
+            }
+        } );
+
+        // Enable LDAPS Checkbox
         addDirtyListener( enableLdapsCheckbox );
+        enableLdapsCheckbox.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                getLdapsServerTransportBean().setEnabled( enableLdapsCheckbox.getSelection()
);
+            }
+        } );
+
+        // LDAPS Port Text
         addDirtyListener( ldapsPortText );
+        ldapsPortText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                getLdapsServerTransportBean().setSystemPort( Integer.parseInt( ldapsPortText.getText()
) );
+            }
+        } );
+
+        // Max Time Limit Text
         addDirtyListener( maxTimeLimitText );
+
+        // Max Size Limit Text
         addDirtyListener( maxSizeLimitText );
+
+        // Auth Mechanisms Simple Checkbox
         addDirtyListener( authMechSimpleCheckbox );
+
+        // Auth Mechanisms CRAM-MD5 Checkbox
         addDirtyListener( authMechCramMd5Checkbox );
+
+        // Auth Mechanisms DIGEST-MD5 Checkbox
         addDirtyListener( authMechDigestMd5Checkbox );
+
+        // Auth Mechanisms GSSAPI Checkbox
         addDirtyListener( authMechGssapiCheckbox );
+
+        // Auth Mechanisms NTLM Checkbox
         addDirtyListener( authMechNtlmCheckbox );
+
+        // Auth Mechanisms GSS SPENEGO Checkbox
         addDirtyListener( authMechGssSpnegoCheckbox );
+
+        // SASL Host Text
         addDirtyListener( saslHostText );
+        saslHostText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                getLdapServerBean().setLdapServerSaslHost( saslHostText.getText() );
+            }
+        } );
+
+        // SASL Principal Text
         addDirtyListener( saslPrincipalText );
+        saslPrincipalText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                getLdapServerBean().setLdapServerSaslPrincipal( saslPrincipalText.getText()
);
+            }
+        } );
+
+        // SASL Seach Base DN Text
         addDirtyListener( saslSearchBaseDnText );
+        saslSearchBaseDnText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                String searchBaseDnValue = saslSearchBaseDnText.getText();
+
+                try
+                {
+                    DN searchBaseDn = new DN( searchBaseDnValue );
+                    getLdapServerBean().setSearchBaseDn( searchBaseDn );
+                }
+                catch ( LdapInvalidDnException e1 )
+                {
+                    // TODO Auto-generated catch block
+                    e1.printStackTrace();
+                }
+            }
+        } );
+    }
+
+
+    /**
+     * Gets the LDAP Server bean.
+     *
+     * @return
+     *      the LDAP Server bean
+     */
+    private LdapServerBean getLdapServerBean()
+    {
+        LdapServerBean ldapServerBean = getDirectoryServiceBean().getLdapServerBean();
+
+        if ( ldapServerBean == null )
+        {
+            ldapServerBean = new LdapServerBean();
+            getDirectoryServiceBean().addServers( ldapServerBean );
+        }
+
+        return ldapServerBean;
+    }
+
+
+    /**
+     * Gets the LDAP Server transport bean.
+     *
+     * @return
+     *      the LDAP Server transport bean
+     */
+    private TransportBean getLdapServerTransportBean()
+    {
+        return getTransportBean( "ldap" );
+    }
+
+
+    /**
+     * Gets the LDAPS Server transport bean.
+     *
+     * @return
+     *      the LDAPS Server transport bean
+     */
+    private TransportBean getLdapsServerTransportBean()
+    {
+        return getTransportBean( "ldaps" );
+    }
+
+
+    /**
+     * Gets a transport bean based on its id.
+     *
+     * @param id
+     *      the id
+     * @return
+     *      the corresponding transport bean
+     */
+    private TransportBean getTransportBean( String id )
+    {
+        LdapServerBean ldapServerBean = getLdapServerBean();
+
+        TransportBean transportBean = null;
+
+        // Looking for the transport in the list
+        TransportBean[] ldapServerTransportBeans = ldapServerBean.getTransports();
+        if ( ldapServerTransportBeans != null )
+        {
+            for ( TransportBean ldapServerTransportBean : ldapServerTransportBeans )
+            {
+                if ( id.equals( ldapServerTransportBean.getTransportId() ) )
+                {
+                    transportBean = ldapServerTransportBean;
+                    break;
+                }
+            }
+        }
+
+        // No corresponding transport has been found
+        if ( transportBean == null )
+        {
+            transportBean = new TransportBean();
+            transportBean.setTransportId( id );
+            ldapServerBean.addTransports( transportBean );
+        }
+
+        return transportBean;
     }
 }

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java?rev=1037767&r1=1037766&r2=1037767&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/PartitionsPage.java
Mon Nov 22 16:26:06 2010
@@ -21,7 +21,6 @@ package org.apache.directory.studio.apac
 
 
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
 

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditor.java?rev=1037767&r1=1037766&r2=1037767&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditor.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditor.java
Mon Nov 22 16:26:06 2010
@@ -153,7 +153,7 @@ public class ServerConfigurationEditor e
      * @param configBean
      *      the configuration bean
      */
-    private void setConfigBean( ConfigBean configBean )
+    public void setConfigBean( ConfigBean configBean )
     {
         this.configBean = configBean;
     }

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorPage.java?rev=1037767&r1=1037766&r2=1037767&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/ServerConfigurationEditorPage.java
Mon Nov 22 16:26:06 2010
@@ -21,6 +21,7 @@ package org.apache.directory.studio.apac
 
 
 import org.apache.directory.server.config.beans.ConfigBean;
+import org.apache.directory.server.config.beans.DirectoryServiceBean;
 import org.apache.directory.studio.apacheds.configuration.v2.actions.EditorAddPageAction;
 import org.apache.directory.studio.apacheds.configuration.v2.actions.EditorExportConfigurationAction;
 import org.apache.directory.studio.apacheds.configuration.v2.actions.EditorImportConfigurationAction;
@@ -43,7 +44,6 @@ import org.eclipse.swt.widgets.Composite
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
@@ -96,14 +96,7 @@ public abstract class ServerConfiguratio
      */
     public ServerConfigurationEditor getServerConfigurationEditor()
     {
-        FormEditor editor = getEditor();
-
-        if ( editor instanceof ServerConfigurationEditor )
-        {
-            return ( ServerConfigurationEditor ) editor;
-        }
-
-        return null;
+        return ( ServerConfigurationEditor ) getEditor();
     }
 
 
@@ -112,12 +105,7 @@ public abstract class ServerConfiguratio
      */
     private void setEditorDirty()
     {
-        ServerConfigurationEditor editor = getServerConfigurationEditor();
-
-        if ( editor != null )
-        {
-            editor.setDirty( true );
-        }
+        getServerConfigurationEditor().setDirty( true );
     }
 
 
@@ -129,14 +117,35 @@ public abstract class ServerConfiguratio
      */
     public ConfigBean getConfigBean()
     {
-        ServerConfigurationEditor editor = getServerConfigurationEditor();
+        ConfigBean configBean = getServerConfigurationEditor().getConfigBean();
+
+        if ( configBean == null )
+        {
+            configBean = new ConfigBean();
+            getServerConfigurationEditor().setConfigBean( configBean );
+        }
+
+        return configBean;
+    }
+
+
+    /**
+     * Gets the directory service associated with the editor.
+     *
+     * @return
+     *      the directory service bean associated with the editor
+     */
+    public DirectoryServiceBean getDirectoryServiceBean()
+    {
+        DirectoryServiceBean directoryServiceBean = getConfigBean().getDirectoryServiceBean();
 
-        if ( editor != null )
+        if ( directoryServiceBean == null )
         {
-            return editor.getConfigBean();
+            directoryServiceBean = new DirectoryServiceBean();
+            getConfigBean().addDirectoryService( directoryServiceBean );
         }
 
-        return null;
+        return directoryServiceBean;
     }
 
 
@@ -230,12 +239,16 @@ public abstract class ServerConfiguratio
 
 
     /**
-     * TODO createDefaultValueLabel.
+     * Creates default value Label.
      *
      * @param toolkit
+     *      the toolkit
      * @param parent
+     *      the parent
      * @param text
+     *      the text string
      * @return
+     *      a default value Label
      */
     protected Label createDefaultValueLabel( FormToolkit toolkit, Composite parent, String
text )
     {
@@ -246,12 +259,24 @@ public abstract class ServerConfiguratio
     }
 
 
+    /**
+     * Adds a 'dirty' listener to the given Text.
+     *
+     * @param text
+     *      the Text control
+     */
     public void addDirtyListener( Text text )
     {
         text.addModifyListener( dirtyModifyListener );
     }
 
 
+    /**
+     * Adds a 'dirty' listener to the given Button.
+     *
+     * @param button
+     *      the Button control
+     */
     public void addDirtyListener( Button button )
     {
         button.addSelectionListener( dirtySelectionListener );

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/jobs/LoadConfigurationRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/jobs/LoadConfigurationRunnable.java?rev=1037767&r1=1037766&r2=1037767&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/jobs/LoadConfigurationRunnable.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/jobs/LoadConfigurationRunnable.java
Mon Nov 22 16:26:06 2010
@@ -47,8 +47,10 @@ import org.eclipse.swt.widgets.Display;
  */
 public class LoadConfigurationRunnable implements StudioRunnableWithProgress
 {
+    /** The associated editor */
     private ServerConfigurationEditor editor;
 
+    /** The configuration bean */
     private ConfigBean configBean;
 
 



Mime
View raw message