directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1213790 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions: DeleteSchemaElementAction.java OpenElementAction.java OpenTypeHierarchyAction.java
Date Tue, 13 Dec 2011 17:14:23 GMT
Author: pamarcelot
Date: Tue Dec 13 17:14:23 2011
New Revision: 1213790

URL: http://svn.apache.org/viewvc?rev=1213790&view=rev
Log:
Fixed the 'enabled' state of various actions which were enabled in situation where they shouldn't.

Modified:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java?rev=1213790&r1=1213789&r2=1213790&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/DeleteSchemaElementAction.java
Tue Dec 13 17:14:23 2011
@@ -78,33 +78,10 @@ public class DeleteSchemaElementAction e
             public void selectionChanged( SelectionChangedEvent event )
             {
                 StructuredSelection selection = ( StructuredSelection ) event.getSelection();
-                if ( selection.size() > 0 )
-                {
-                    boolean enabled = false;
-
-                    for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext();
)
-                    {
-                        Object selectedItem = iterator.next();
-                        if ( selectedItem instanceof SchemaWrapper )
-                        {
-                            enabled = true;
-                        }
-                        else if ( selectedItem instanceof AttributeTypeWrapper )
-                        {
-                            enabled = true;
-                        }
-                        else if ( selectedItem instanceof ObjectClassWrapper )
-                        {
-                            enabled = true;
-                        }
-                    }
-
-                    setEnabled( enabled );
-                }
-                else
-                {
-                    setEnabled( false );
-                }
+                setEnabled( ( selection.size() == 1 )
+                    && ( ( selection.getFirstElement() instanceof SchemaWrapper )
+                        || ( selection.getFirstElement() instanceof AttributeTypeWrapper
)
+                        || ( selection.getFirstElement() instanceof ObjectClassWrapper )
) );
             }
         } );
     }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java?rev=1213790&r1=1213789&r2=1213790&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenElementAction.java
Tue Dec 13 17:14:23 2011
@@ -38,6 +38,8 @@ import org.apache.directory.studio.schem
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.ui.IWorkbenchWindow;
@@ -66,8 +68,19 @@ public class OpenElementAction extends A
         setToolTipText( Messages.getString( "OpenElementAction.OpenToolTip" ) ); //$NON-NLS-1$
         setId( PluginConstants.CMD_OPEN_ELEMENT );
         setActionDefinitionId( PluginConstants.CMD_OPEN_ELEMENT );
-        setEnabled( true );
+        setEnabled( false );
         this.viewer = viewer;
+        this.viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+                setEnabled( ( selection.size() == 1 )
+                    && ( ( selection.getFirstElement() instanceof SchemaWrapper )
+                        || ( selection.getFirstElement() instanceof AttributeTypeWrapper
)
+                        || ( selection.getFirstElement() instanceof ObjectClassWrapper )
) );
+            }
+        } );
     }
 
 

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java?rev=1213790&r1=1213789&r2=1213790&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
Tue Dec 13 17:14:23 2011
@@ -30,6 +30,7 @@ import org.apache.directory.studio.schem
 import org.apache.directory.studio.schemaeditor.view.views.SchemaView;
 import org.apache.directory.studio.schemaeditor.view.wrappers.AttributeTypeWrapper;
 import org.apache.directory.studio.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.schemaeditor.view.wrappers.SchemaWrapper;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
@@ -64,33 +65,16 @@ public class OpenTypeHierarchyAction ext
         setToolTipText( Messages.getString( "OpenTypeHierarchyAction.OpenTypeToolTip" ) );
//$NON-NLS-1$
         setId( PluginConstants.CMD_OPEN_TYPE_HIERARCHY );
         setActionDefinitionId( PluginConstants.CMD_OPEN_TYPE_HIERARCHY );
-        setEnabled( true );
+        setEnabled( false );
         this.viewer = viewer;
         this.viewer.addSelectionChangedListener( new ISelectionChangedListener()
         {
             public void selectionChanged( SelectionChangedEvent event )
             {
                 StructuredSelection selection = ( StructuredSelection ) event.getSelection();
-                if ( selection.size() == 1 )
-                {
-                    Object obj = selection.getFirstElement();
-                    if ( obj instanceof AttributeTypeWrapper )
-                    {
-                        setEnabled( true );
-                    }
-                    else if ( obj instanceof ObjectClassWrapper )
-                    {
-                        setEnabled( true );
-                    }
-                    else
-                    {
-                        setEnabled( false );
-                    }
-                }
-                else
-                {
-                    setEnabled( false );
-                }
+                setEnabled( ( selection.size() == 1 )
+                    && ( ( selection.getFirstElement() instanceof AttributeTypeWrapper
)
+                        || ( selection.getFirstElement() instanceof ObjectClassWrapper )
) );
             }
         } );
     }



Mime
View raw message