directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1037718 - 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 13:49:51 GMT
Author: pamarcelot
Date: Mon Nov 22 13:49:51 2010
New Revision: 1037718

URL: http://svn.apache.org/viewvc?rev=1037718&view=rev
Log:
Added listeners to all UI Controls to set the editor dirty when a value is edited in the UI.

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/OverviewPage.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=1037718&r1=1037717&r2=1037718&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 13:49:51 2010
@@ -51,7 +51,7 @@ public class KerberosServerPage extends 
     /** The Page Title */
     private static final String TITLE = "Kerberos Server";
 
-    // UI Fields
+    // UI Controls
     private Button enableKerberosCheckbox;
     private Text kerberosPortText;
     private Button enableChangePasswordCheckbox;
@@ -109,6 +109,8 @@ public class KerberosServerPage extends 
         createTicketSettingsSection( toolkit, leftComposite );
 
         initUI();
+
+        addListeners();
     }
 
 
@@ -237,7 +239,6 @@ public class KerberosServerPage extends 
         maximumTicketLifetimeComposite.setLayout( new GridLayout( 2, false ) );
         toolkit.createLabel( maximumTicketLifetimeComposite, "Maximum Ticket Lifetime:" );
         maximumTicketLifetimeText = createIntegerText( toolkit, maximumTicketLifetimeComposite
);
-
     }
 
 
@@ -268,4 +269,29 @@ public class KerberosServerPage extends 
         maximumRenewableLifetimeText.setText( kdcServerBean.getKrbMaximumRenewableLifetime()
+ "" );
         maximumTicketLifetimeText.setText( kdcServerBean.getKrbMaximumTicketLifetime() +
"" );
     }
+
+
+    /**
+     * Adds listeners to UI Controls.
+     */
+    private void addListeners()
+    {
+        addDirtyListener( enableKerberosCheckbox );
+        addDirtyListener( kerberosPortText );
+        addDirtyListener( enableChangePasswordCheckbox );
+        addDirtyListener( changePasswordPortText );
+        addDirtyListener( kdcPrincipalText );
+        addDirtyListener( primaryKdcRealmText );
+        addDirtyListener( kdcSearchBaseDnText );
+        addDirtyListener( encryptionTypesText );
+        addDirtyListener( allowClockSkewButton );
+        addDirtyListener( verifyBodyChecksumButton );
+        addDirtyListener( allowEmptyAddressesButton );
+        addDirtyListener( allowForwardableAddressesButton );
+        addDirtyListener( requirePreAuthenticationByEncryptedTimeStampButton );
+        addDirtyListener( allowPostdatedTicketsButtons );
+        addDirtyListener( allowRenewableTicketsButton );
+        addDirtyListener( maximumRenewableLifetimeText );
+        addDirtyListener( maximumTicketLifetimeText );
+    }
 }

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=1037718&r1=1037717&r2=1037718&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 13:49:51 2010
@@ -53,7 +53,7 @@ public class LdapLdapsServersPage extend
     /** The Page Title */
     private static final String TITLE = "LDAP/LDAPS Servers";
 
-    // UI Fields
+    // UI Controls
     private Button enableLdapCheckbox;
     private Text ldapPortText;
     private Button enableLdapsCheckbox;
@@ -66,10 +66,6 @@ public class LdapLdapsServersPage extend
     private Button authMechGssapiCheckbox;
     private Button authMechNtlmCheckbox;
     private Button authMechGssSpnegoCheckbox;
-    private CheckboxTableViewer supportedMechanismsTableViewer;
-    private Button editSupportedMechanismButton;
-    private Button selectAllSupportedMechanismsButton;
-    private Button deselectAllSupportedMechanismsButton;
     private Text saslHostText;
     private Text saslPrincipalText;
     private Text saslSearchBaseDnText;
@@ -115,6 +111,8 @@ public class LdapLdapsServersPage extend
         createSaslSettingsSection( toolkit, rightComposite );
 
         initUI();
+
+        addListeners();
     }
 
 
@@ -327,4 +325,27 @@ public class LdapLdapsServersPage extend
         saslPrincipalText.setText( ldapServerBean.getLdapServerSaslPrincipal() );
         saslSearchBaseDnText.setText( ldapServerBean.getSearchBaseDn().toString() );
     }
+
+
+    /**
+     * Adds listeners to UI Controls.
+     */
+    private void addListeners()
+    {
+        addDirtyListener( enableLdapCheckbox );
+        addDirtyListener( ldapPortText );
+        addDirtyListener( enableLdapsCheckbox );
+        addDirtyListener( ldapsPortText );
+        addDirtyListener( maxTimeLimitText );
+        addDirtyListener( maxSizeLimitText );
+        addDirtyListener( authMechSimpleCheckbox );
+        addDirtyListener( authMechCramMd5Checkbox );
+        addDirtyListener( authMechDigestMd5Checkbox );
+        addDirtyListener( authMechGssapiCheckbox );
+        addDirtyListener( authMechNtlmCheckbox );
+        addDirtyListener( authMechGssSpnegoCheckbox );
+        addDirtyListener( saslHostText );
+        addDirtyListener( saslPrincipalText );
+        addDirtyListener( saslSearchBaseDnText );
+    }
 }

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.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/OverviewPage.java?rev=1037718&r1=1037717&r2=1037718&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java
(original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/editor/OverviewPage.java
Mon Nov 22 13:49:51 2010
@@ -120,6 +120,8 @@ public class OverviewPage extends Server
         createOptionsSection( toolkit, rightComposite );
 
         initUI();
+        
+        addListeners();
     }
 
 
@@ -290,10 +292,18 @@ public class OverviewPage extends Server
 
 
     /**
-     * {@inheritDoc}
+     * Adds listeners to UI Controls.
      */
-    public void setFocus()
+    private void addListeners()
     {
-        // Does Nothing
+        addDirtyListener( enableLdapCheckbox );
+        addDirtyListener( ldapPortText );
+        addDirtyListener( enableLdapsCheckbox );
+        addDirtyListener( ldapsPortText );
+        addDirtyListener( enableKerberosCheckbox );
+        addDirtyListener( kerberosPortText );
+        addDirtyListener( enableChangePasswordCheckbox );
+        addDirtyListener( allowAnonymousAccessCheckbox );
+        addDirtyListener( enableAccesControlCheckbox );
     }
 }

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=1037718&r1=1037717&r2=1037718&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 13:49:51 2010
@@ -21,8 +21,6 @@ package org.apache.directory.studio.apac
 
 
 import org.apache.directory.server.config.beans.ConfigBean;
-import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPlugin;
-import org.apache.directory.studio.apacheds.configuration.v2.ApacheDS2ConfigurationPluginConstants;
 import org.apache.directory.studio.apacheds.configuration.v2.jobs.LoadConfigurationRunnable;
 import org.apache.directory.studio.common.core.jobs.StudioJob;
 import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
@@ -46,9 +44,12 @@ import org.eclipse.ui.forms.editor.FormE
  */
 public class ServerConfigurationEditor extends FormEditor
 {
-    /** The Page ID*/
+    /** The Editor ID */
     public static final String ID = ServerConfigurationEditor.class.getName();
 
+    /** The flag indicating if the editor is dirty */
+    private boolean dirty = false;
+
     /** The configuration bean */
     private ConfigBean configBean;
 
@@ -61,9 +62,11 @@ public class ServerConfigurationEditor e
         super.init( site, input );
         setPartName( input.getName() );
 
+        System.out.println( ID );
 
         // Creating and scheduling the job to delete the server
-        StudioJob<StudioRunnableWithProgress> job = new StudioJob<StudioRunnableWithProgress>(
new LoadConfigurationRunnable( this ) );
+        StudioJob<StudioRunnableWithProgress> job = new StudioJob<StudioRunnableWithProgress>(
+            new LoadConfigurationRunnable( this ) );
         job.schedule();
     }
 
@@ -76,14 +79,6 @@ public class ServerConfigurationEditor e
         try
         {
             addPage( new LoadingPage( this ) );
-            setPageImage( 0, ApacheDS2ConfigurationPlugin.getDefault().getImage(
-                ApacheDS2ConfigurationPluginConstants.IMG_IMPORT ) );
-
-            //            addPage( new OverviewPage( this ) );
-            //            addPage( new LdapLdapsServersPage( this ) );
-            //            addPage( new KerberosServerPage( this ) );
-            //            addPage( new PartitionsPage( this ) );
-            //            addPage( new ReplicationPage( this ) );
         }
         catch ( PartInitException e )
         {
@@ -119,6 +114,28 @@ public class ServerConfigurationEditor e
 
 
     /**
+     * {@inheritDoc}
+     */
+    public boolean isDirty()
+    {
+        return dirty;
+    }
+
+
+    /**
+     * Sets the 'dirty' flag.
+     *
+     * @param dirty
+     *      the 'dirty' flag
+     */
+    public void setDirty( boolean dirty )
+    {
+        this.dirty = dirty;
+        firePropertyChange( PROP_DIRTY );
+    }
+
+
+    /**
      * Gets the configuration bean.
      *
      * @return
@@ -136,46 +153,53 @@ public class ServerConfigurationEditor e
      * @param configBean
      *      the configuration bean
      */
-    public void setConfigBean( ConfigBean configBean )
+    private void setConfigBean( ConfigBean configBean )
     {
         this.configBean = configBean;
     }
 
 
     /**
-     * TODO configBeanLoaded.
+     * This method is called by the job responsible for loading the configuration.
      *
      * @param configBean
-     * @throws PartInitException
+     *      the loaded configuration bean
      */
-    public void configBeanLoaded( ConfigBean configBean ) throws PartInitException
+    public void configBeanLoaded( ConfigBean configBean )
     {
         setConfigBean( configBean );
-        
+
         hideLoadingPageAndDisplayConfigPages();
     }
 
 
     /**
-     * TODO hideLoadingPageAndDisplayConfigPages.
-     *
-     * @throws PartInitException
+     * Hides the loading page and displays the standard configuration pages.
      */
-    private void hideLoadingPageAndDisplayConfigPages() throws PartInitException
+    private void hideLoadingPageAndDisplayConfigPages()
     {
         // Removing the loading page
         removePage( 0 );
-        
+
         // Adding the configuration pages
-        addPage( new OverviewPage( this ) );
-        addPage( new LdapLdapsServersPage( this ) );
-        addPage( new KerberosServerPage( this ) );
-        addPage( new PartitionsPage( this ) );
-        addPage( new ReplicationPage( this ) );
-        
+        try
+        {
+            addPage( new OverviewPage( this ) );
+            addPage( new LdapLdapsServersPage( this ) );
+            addPage( new KerberosServerPage( this ) );
+            addPage( new PartitionsPage( this ) );
+            addPage( new ReplicationPage( this ) );
+        }
+        catch ( PartInitException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
         // Activating the first page
         setActivePage( 0 );
     }
+
 }
 
 /**

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=1037718&r1=1037717&r2=1037718&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 13:49:51 2010
@@ -28,11 +28,17 @@ import org.eclipse.jface.action.IToolBar
 import org.eclipse.jface.action.Separator;
 import org.eclipse.osgi.util.NLS;
 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.events.SelectionListener;
 import org.eclipse.swt.events.VerifyEvent;
 import org.eclipse.swt.events.VerifyListener;
 import org.eclipse.swt.graphics.Color;
 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.Text;
@@ -53,6 +59,22 @@ public abstract class ServerConfiguratio
     protected static final Color GRAY_COLOR = new Color( null, 120, 120, 120 );
     protected static final String TABULATION = "      ";
 
+    private ModifyListener dirtyModifyListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            setEditorDirty();
+        }
+    };
+
+    private SelectionListener dirtySelectionListener = new SelectionAdapter()
+    {
+        public void widgetSelected( SelectionEvent e )
+        {
+            setEditorDirty();
+        }
+    };
+
 
     /**
      * Creates a new instance of GeneralPage.
@@ -67,17 +89,51 @@ public abstract class ServerConfiguratio
 
 
     /**
-     * TODO getConfigBean.
+     * Gets the ServerConfigurationEditor object associated with the page.
      *
      * @return
+     *      the ServerConfigurationEditor object associated with the page
      */
-    public ConfigBean getConfigBean()
+    public ServerConfigurationEditor getServerConfigurationEditor()
     {
         FormEditor editor = getEditor();
 
         if ( editor instanceof ServerConfigurationEditor )
         {
-            return ( ( ServerConfigurationEditor ) editor ).getConfigBean();
+            return ( ServerConfigurationEditor ) editor;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Sets the associated editor dirty.
+     */
+    private void setEditorDirty()
+    {
+        ServerConfigurationEditor editor = getServerConfigurationEditor();
+
+        if ( editor != null )
+        {
+            editor.setDirty( true );
+        }
+    }
+
+
+    /**
+     * Gets the configuration bean associated with the editor.
+     *
+     * @return
+     *      the configuration bean associated with the editor
+     */
+    public ConfigBean getConfigBean()
+    {
+        ServerConfigurationEditor editor = getServerConfigurationEditor();
+
+        if ( editor != null )
+        {
+            return editor.getConfigBean();
         }
 
         return null;
@@ -173,6 +229,14 @@ public abstract class ServerConfiguratio
     }
 
 
+    /**
+     * TODO createDefaultValueLabel.
+     *
+     * @param toolkit
+     * @param parent
+     * @param text
+     * @return
+     */
     protected Label createDefaultValueLabel( FormToolkit toolkit, Composite parent, String
text )
     {
         Label label = toolkit.createLabel( parent, NLS.bind( "(Default: {0})", text ) );
@@ -180,4 +244,16 @@ public abstract class ServerConfiguratio
 
         return label;
     }
+
+
+    public void addDirtyListener( Text text )
+    {
+        text.addModifyListener( dirtyModifyListener );
+    }
+
+
+    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=1037718&r1=1037717&r2=1037718&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 13:49:51 2010
@@ -38,7 +38,6 @@ import org.apache.directory.studio.commo
 import org.apache.directory.studio.common.core.jobs.StudioRunnableWithProgress;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
 
 
 /**
@@ -49,7 +48,7 @@ import org.eclipse.ui.PartInitException;
 public class LoadConfigurationRunnable implements StudioRunnableWithProgress
 {
     private ServerConfigurationEditor editor;
-    
+
     private ConfigBean configBean;
 
 
@@ -71,7 +70,7 @@ public class LoadConfigurationRunnable i
      */
     public String getErrorMessage()
     {
-        return "Unable to load the configuration";
+        return "Unable to load the configuration.";
     }
 
 
@@ -101,22 +100,14 @@ public class LoadConfigurationRunnable i
         try
         {
             initConfigBean();
-            
+
             Display.getDefault().asyncExec( new Runnable()
             {
                 public void run()
                 {
-                    try
-                    {
-                        editor.configBeanLoaded( configBean );
-                    }
-                    catch ( PartInitException e )
-                    {
-                        // TODO Auto-generated catch block
-                        e.printStackTrace();
-                    }
+                    editor.configBeanLoaded( configBean );
                 }
-            });
+            } );
         }
         catch ( Exception e )
         {
@@ -124,7 +115,7 @@ public class LoadConfigurationRunnable i
             monitor.reportError( e );
         }
     }
-    
+
 
     private void initConfigBean() throws Exception
     {



Mime
View raw message