directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r561740 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions: CloseProjectAction.java OpenProjectAction.java
Date Wed, 01 Aug 2007 09:27:50 GMT
Author: pamarcelot
Date: Wed Aug  1 02:27:49 2007
New Revision: 561740

URL: http://svn.apache.org/viewvc?view=rev&rev=561740
Log:
Fixed issues with the enable state of the Actions.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/CloseProjectAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenProjectAction.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/CloseProjectAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/CloseProjectAction.java?view=diff&rev=561740&r1=561739&r2=561740
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/CloseProjectAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/CloseProjectAction.java
Wed Aug  1 02:27:49 2007
@@ -23,6 +23,8 @@
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandlerAdapter;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectState;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ProjectWrapper;
 import org.eclipse.jface.action.Action;
@@ -68,19 +70,35 @@
         {
             public void selectionChanged( SelectionChangedEvent event )
             {
-                StructuredSelection selection = ( StructuredSelection ) event.getSelection();
-                if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
-                {
-                    setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals(
-                        ProjectState.OPEN ) );
-                }
-                else
-                {
-                    setEnabled( false );
-                }
+                enableDisable();
             }
         } );
         projectsHandler = Activator.getDefault().getProjectsHandler();
+        projectsHandler.addListener( new ProjectsHandlerAdapter()
+        {
+            public void openProjectChanged( Project oldProject, Project newProject )
+            {
+                enableDisable();
+            }
+        } );
+    }
+
+
+    /**
+     * Enables or disables the Action.
+     */
+    private void enableDisable()
+    {
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+        if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+        {
+            setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals(
+                ProjectState.OPEN ) );
+        }
+        else
+        {
+            setEnabled( false );
+        }
     }
 
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenProjectAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenProjectAction.java?view=diff&rev=561740&r1=561739&r2=561740
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenProjectAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenProjectAction.java
Wed Aug  1 02:27:49 2007
@@ -23,6 +23,8 @@
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandlerAdapter;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project.ProjectState;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ProjectWrapper;
 import org.eclipse.jface.action.Action;
@@ -68,19 +70,35 @@
         {
             public void selectionChanged( SelectionChangedEvent event )
             {
-                StructuredSelection selection = ( StructuredSelection ) event.getSelection();
-                if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
-                {
-                    setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals(
-                        ProjectState.CLOSED ) );
-                }
-                else
-                {
-                    setEnabled( false );
-                }
+                enableDisable();
             }
         } );
         projectsHandler = Activator.getDefault().getProjectsHandler();
+        projectsHandler.addListener( new ProjectsHandlerAdapter()
+        {
+            public void openProjectChanged( Project oldProject, Project newProject )
+            {
+                enableDisable();
+            }
+        } );
+    }
+
+
+    /**
+     * Enables or disables the Action.
+     */
+    private void enableDisable()
+    {
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+        if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+        {
+            setEnabled( ( ( ProjectWrapper ) selection.getFirstElement() ).getProject().getState().equals(
+                ProjectState.CLOSED ) );
+        }
+        else
+        {
+            setEnabled( false );
+        }
     }
 
 



Mime
View raw message