directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r661017 - in /directory/studio/branches/apacheds-plugin-branch/apacheds: ./ src/main/java/org/apache/directory/studio/apacheds/ src/main/java/org/apache/directory/studio/apacheds/actions/ src/main/java/org/apache/directory/studio/apacheds/v...
Date Wed, 28 May 2008 17:04:04 GMT
Author: pamarcelot
Date: Wed May 28 10:04:03 2008
New Revision: 661017

URL: http://svn.apache.org/viewvc?rev=661017&view=rev
Log:
o Added commands, key bindings and context definitions.
o Assigned commands and keybindings to actions.
o Added a listener in the Servers view to activate/de-activated the context when it is active/inactive.

Modified:
    directory/studio/branches/apacheds-plugin-branch/apacheds/plugin.xml
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/NewServerInstanceAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceRunAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceStopAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/plugin.xml?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/plugin.xml (original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/plugin.xml Wed May 28 10:04:03
2008
@@ -48,5 +48,108 @@
          </enabledWhen>
       </page>
    </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <category
+            id="org.apache.directory.studio.apacheds.commands"
+            name="Apache DS">
+      </category>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.NewServerInstanceAction"
+            description="Creates a new server"
+            id="org.apache.directory.studio.apacheds.commands.newServer"
+            name="New Server">
+      </command>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.DeleteAction"
+            description="Deletes a server"
+            id="org.apache.directory.studio.apacheds.commands.delete"
+            name="Delete">
+      </command>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.OpenAction"
+            description="Opens the server configuration"
+            id="org.apache.directory.studio.apacheds.commands.open"
+            name="Open">
+      </command>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.RenameAction"
+            description="Renames the server"
+            id="org.apache.directory.studio.apacheds.commands.rename"
+            name="Rename">
+      </command>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.ServerInstanceRunAction"
+            description="Runs the server"
+            id="org.apache.directory.studio.apacheds.commands.run"
+            name="Run">
+      </command>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.ServerInstanceStopAction"
+            description="Stops the server"
+            id="org.apache.directory.studio.apacheds.commands.stop"
+            name="Stop">
+      </command>
+      <command
+            categoryId="org.apache.directory.studio.apacheds.commands"
+            defaultHandler="org.apache.directory.studio.apacheds.actions.PropertiesAction"
+            description="Shows the properties of the server"
+            id="org.apache.directory.studio.apacheds.commands.properties"
+            name="Properties">
+      </command>
+   </extension>
+   <extension
+         point="org.eclipse.ui.contexts">
+      <context
+            description="In Servers View of Apache DS"
+            id="org.apache.directory.studio.apacheds.contexts.serversView"
+            name="In Servers View of Apache DS"
+            parentId="org.eclipse.ui.contexts.window">
+      </context>
+   </extension>
+   <extension
+         point="org.eclipse.ui.bindings">
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.newServer"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="M1+E"/>
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.open"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="F3"/>
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.delete"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="DEL"/>
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.rename"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="F2"/>
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.run"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="M1+R"/>
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.stop"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="M1+T"/>
+      <key
+            commandId="org.apache.directory.studio.apacheds.commands.properties"
+            contextId="org.apache.directory.studio.apacheds.contexts.serversView"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="ALT+RETURN"/>
+   </extension>
 
 </plugin>

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginConstants.java
Wed May 28 10:04:03 2008
@@ -46,16 +46,21 @@
     public static final String IMG_RUN = "resources/icons/run.gif";
     public static final String IMG_STOP = "resources/icons/stop.gif";
 
-    // -------
-    // ACTIONS
-    // -------
-    public static final String ACTION_NEW_SERVER = "org.apache.directory.studio.apacheds.actions.newServerAction";
-    public static final String ACTION_SERVER_INSTANCE_RUN = "org.apache.directory.studio.apacheds.actions.serverInstanceRunAction";
-    public static final String ACTION_SERVER_INSTANCE_STOP = "org.apache.directory.studio.apacheds.actions.serverInstanceStopAction";
-    public static final String ACTION_PROPERTIES = "org.apache.directory.studio.apacheds.actions.propertiesAction";
-    public static final String ACTION_OPEN = "org.apache.directory.studio.apacheds.actions.openAction";
-    public static final String ACTION_DELETE = "org.apache.directory.studio.apacheds.actions.deleteAction";
-    public static final String ACTION_RENAME = "org.apache.directory.studio.apacheds.actions.renameAction";
+    // --------
+    // COMMANDS
+    // --------
+    public static final String CMD_NEW_SERVER = "org.apache.directory.studio.apacheds.commands.newServer";
+    public static final String CMD_RUN = "org.apache.directory.studio.apacheds.commands.run";
+    public static final String CMD_STOP = "org.apache.directory.studio.apacheds.commands.stop";
+    public static final String CMD_PROPERTIES = "org.apache.directory.studio.apacheds.commands.properties";
+    public static final String CMD_OPEN = "org.apache.directory.studio.apacheds.commands.open";
+    public static final String CMD_DELETE = "org.apache.directory.studio.apacheds.commands.delete";
+    public static final String CMD_RENAME = "org.apache.directory.studio.apacheds.commands.rename";
+
+    // --------
+    // CONTEXTS
+    // --------
+    public static final String CONTEXTS_SERVERS_VIEW = "org.apache.directory.studio.apacheds.contexts.serversView";
 
     // -----------
     // PREFERENCES

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
Wed May 28 10:04:03 2008
@@ -58,12 +58,13 @@
      */
     public DeleteAction( ServersView view )
     {
-        super( "Delete" );
+        super( "&Delete" );
         this.view = view;
+        setId( ApacheDsPluginConstants.CMD_DELETE );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_DELETE );
         setToolTipText( "Delete" );
         setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
             ISharedImages.IMG_TOOL_DELETE ) );
-        setId( ApacheDsPluginConstants.ACTION_DELETE );
     }
 
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/NewServerInstanceAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/NewServerInstanceAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/NewServerInstanceAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/NewServerInstanceAction.java
Wed May 28 10:04:03 2008
@@ -46,11 +46,11 @@
      */
     public NewServerInstanceAction()
     {
-        super( "New Server" );
+        super( "New &Server" );
+        setId( ApacheDsPluginConstants.CMD_NEW_SERVER );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_NEW_SERVER );
         setToolTipText( "New Server" );
-        setId( ApacheDsPluginConstants.ACTION_NEW_SERVER );
         setImageDescriptor( ApacheDsPlugin.getDefault().getImageDescriptor( ApacheDsPluginConstants.IMG_SERVER_NEW
) );
-        setEnabled( true );
     }
 
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenAction.java
Wed May 28 10:04:03 2008
@@ -61,10 +61,11 @@
      */
     public OpenAction( ServersView view )
     {
-        super( "Open" );
+        super( "&Open" );
         this.view = view;
+        setId( ApacheDsPluginConstants.CMD_OPEN );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_OPEN );
         setToolTipText( "Open" );
-        setId( ApacheDsPluginConstants.ACTION_OPEN );
     }
 
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
Wed May 28 10:04:03 2008
@@ -53,10 +53,11 @@
      */
     public PropertiesAction( ServersView view )
     {
-        super( "Properties" );
+        super( "&Properties" );
         this.view = view;
+        setId( ApacheDsPluginConstants.CMD_PROPERTIES );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_PROPERTIES );
         setToolTipText( "Properties" );
-        setId( ApacheDsPluginConstants.ACTION_PROPERTIES );
     }
 
 
@@ -69,10 +70,8 @@
         if ( !selection.isEmpty() )
         {
             ServerInstance serverInstance = ( ServerInstance ) selection.getFirstElement();
-            PreferenceDialog dialog = PreferencesUtil
-                .createPropertyDialogOn( view.getViewSite().getShell(), serverInstance,
-                    "org.apache.directory.studio.apacheds.properties.serverInstanceProperties",
null,
-                    null );
+            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn( view.getViewSite().getShell(),
+                serverInstance, "org.apache.directory.studio.apacheds.properties.serverInstanceProperties",
null, null );
             dialog.getShell().setText( "Properties for '" + shorten( serverInstance.getName(),
30 ) + "'" );
             dialog.open();
         }

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
Wed May 28 10:04:03 2008
@@ -85,12 +85,13 @@
      */
     public RenameAction( ServersView view )
     {
-        super( "Rename..." );
+        super( "R&ename..." );
+        setId( ApacheDsPluginConstants.CMD_RENAME );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_RENAME );
+        setToolTipText( "Rename..." );
         this.view = view;
         this.tree = view.getViewer().getTree();
         this.treeEditor = new TreeEditor( tree );
-        setToolTipText( "Rename..." );
-        setId( ApacheDsPluginConstants.ACTION_RENAME );
     }
 
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceRunAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceRunAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceRunAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceRunAction.java
Wed May 28 10:04:03 2008
@@ -66,10 +66,11 @@
      */
     public ServerInstanceRunAction( ServersView view )
     {
-        super( "Run" );
+        super( "&Run" );
         this.view = view;
+        setId( ApacheDsPluginConstants.CMD_RUN );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_RUN );
         setToolTipText( "Run" );
-        setId( ApacheDsPluginConstants.ACTION_SERVER_INSTANCE_RUN );
         setImageDescriptor( ApacheDsPlugin.getDefault().getImageDescriptor( ApacheDsPluginConstants.IMG_RUN
) );
     }
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceStopAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceStopAction.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceStopAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/ServerInstanceStopAction.java
Wed May 28 10:04:03 2008
@@ -53,11 +53,12 @@
      */
     public ServerInstanceStopAction( ServersView view )
     {
-        super( "Stop" );
-        this.view = view;
+        super( "&Stop" );
+        setId( ApacheDsPluginConstants.CMD_STOP );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_STOP );
         setToolTipText( "Stop" );
-        setId( ApacheDsPluginConstants.ACTION_SERVER_INSTANCE_STOP );
         setImageDescriptor( ApacheDsPlugin.getDefault().getImageDescriptor( ApacheDsPluginConstants.IMG_STOP
) );
+        this.view = view;
     }
 
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java?rev=661017&r1=661016&r2=661017&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/views/ServersView.java
Wed May 28 10:04:03 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.apacheds.views;
 
 
+import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
 import org.apache.directory.studio.apacheds.actions.DeleteAction;
 import org.apache.directory.studio.apacheds.actions.NewServerInstanceAction;
 import org.apache.directory.studio.apacheds.actions.OpenAction;
@@ -35,6 +36,7 @@
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -50,8 +52,14 @@
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPartListener2;
 import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPartReference;
 import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
 import org.eclipse.ui.part.ViewPart;
 
 
@@ -74,13 +82,19 @@
     /** The table viewer */
     private ServersTableViewer tableViewer;
 
+    /** The view instance */
+    private ServersView instance;
+
+    /** Token used to activate and deactivate shortcuts in the view */
+    private IContextActivation contextActivation;
+
     private static final String TAG_COLUMN_WIDTH = "columnWidth";
     protected int[] columnWidths;
 
     // Actions
-    private NewServerInstanceAction newServerInstance;
-    private ServerInstanceRunAction serverInstanceRun;
-    private ServerInstanceStopAction serverInstanceStop;
+    private NewServerInstanceAction newServer;
+    private ServerInstanceRunAction run;
+    private ServerInstanceStopAction stop;
     private PropertiesAction properties;
     private DeleteAction delete;
     private OpenAction open;
@@ -122,6 +136,8 @@
      */
     public void createPartControl( Composite parent )
     {
+        instance = this;
+
         // Creating the Tree
         tree = new Tree( parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL
);
         tree.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
@@ -233,13 +249,13 @@
      */
     private void initActions()
     {
-        newServerInstance = new NewServerInstanceAction();
+        newServer = new NewServerInstanceAction();
 
-        serverInstanceRun = new ServerInstanceRunAction( this );
-        serverInstanceRun.setEnabled( false );
+        run = new ServerInstanceRunAction( this );
+        run.setEnabled( false );
 
-        serverInstanceStop = new ServerInstanceStopAction( this );
-        serverInstanceStop.setEnabled( false );
+        stop = new ServerInstanceStopAction( this );
+        stop.setEnabled( false );
 
         properties = new PropertiesAction( this );
         properties.setEnabled( false );
@@ -261,10 +277,10 @@
     private void initToolbar()
     {
         IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
-        toolbar.add( newServerInstance );
+        toolbar.add( newServer );
         toolbar.add( new Separator() );
-        toolbar.add( serverInstanceRun );
-        toolbar.add( serverInstanceStop );
+        toolbar.add( run );
+        toolbar.add( stop );
     }
 
 
@@ -279,16 +295,16 @@
         {
             public void menuAboutToShow( IMenuManager manager )
             {
-                MenuManager newManager = new MenuManager( "New" );
-                newManager.add( newServerInstance );
+                MenuManager newManager = new MenuManager( "&New" );
+                newManager.add( newServer );
                 manager.add( newManager );
                 manager.add( open );
                 manager.add( new Separator() );
                 manager.add( delete );
                 manager.add( rename );
                 manager.add( new Separator() );
-                manager.add( serverInstanceRun );
-                manager.add( serverInstanceStop );
+                manager.add( run );
+                manager.add( stop );
                 manager.add( new Separator() );
                 manager.add( properties );
             }
@@ -325,6 +341,101 @@
                 updateActionsStates();
             }
         } );
+
+        // Initializing the PartListener
+        getSite().getPage().addPartListener( new IPartListener2()
+        {
+            /**
+              * This implementation deactivates the shortcuts when the part is deactivated.
+              */
+            public void partDeactivated( IWorkbenchPartReference partRef )
+            {
+                if ( partRef.getPart( false ) == instance && contextActivation !=
null )
+                {
+                    ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+                        ICommandService.class );
+                    if ( commandService != null )
+                    {
+                        commandService.getCommand( newServer.getActionDefinitionId() ).setHandler(
null );
+                        commandService.getCommand( open.getActionDefinitionId() ).setHandler(
null );
+                        commandService.getCommand( delete.getActionDefinitionId() ).setHandler(
null );
+                        commandService.getCommand( rename.getActionDefinitionId() ).setHandler(
null );
+                        commandService.getCommand( run.getActionDefinitionId() ).setHandler(
null );
+                        commandService.getCommand( stop.getActionDefinitionId() ).setHandler(
null );
+                        commandService.getCommand( properties.getActionDefinitionId() ).setHandler(
null );
+                    }
+
+                    IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                        IContextService.class );
+                    contextService.deactivateContext( contextActivation );
+                    contextActivation = null;
+                }
+            }
+
+
+            /**
+             * This implementation activates the shortcuts when the part is activated.
+             */
+            public void partActivated( IWorkbenchPartReference partRef )
+            {
+                if ( partRef.getPart( false ) == instance )
+                {
+                    IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                        IContextService.class );
+                    contextActivation = contextService.activateContext( ApacheDsPluginConstants.CONTEXTS_SERVERS_VIEW
);
+
+                    ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+                        ICommandService.class );
+                    if ( commandService != null )
+                    {
+                        commandService.getCommand( newServer.getActionDefinitionId() ).setHandler(
+                            new ActionHandler( newServer ) );
+                        commandService.getCommand( open.getActionDefinitionId() )
+                            .setHandler( new ActionHandler( open ) );
+                        commandService.getCommand( delete.getActionDefinitionId() ).setHandler(
+                            new ActionHandler( delete ) );
+                        commandService.getCommand( rename.getActionDefinitionId() ).setHandler(
+                            new ActionHandler( rename ) );
+                        commandService.getCommand( run.getActionDefinitionId() ).setHandler(
new ActionHandler( run ) );
+                        commandService.getCommand( stop.getActionDefinitionId() )
+                            .setHandler( new ActionHandler( stop ) );
+                        commandService.getCommand( properties.getActionDefinitionId() ).setHandler(
+                            new ActionHandler( properties ) );
+                    }
+                }
+            }
+
+
+            public void partBroughtToTop( IWorkbenchPartReference partRef )
+            {
+            }
+
+
+            public void partClosed( IWorkbenchPartReference partRef )
+            {
+            }
+
+
+            public void partHidden( IWorkbenchPartReference partRef )
+            {
+            }
+
+
+            public void partInputChanged( IWorkbenchPartReference partRef )
+            {
+            }
+
+
+            public void partOpened( IWorkbenchPartReference partRef )
+            {
+            }
+
+
+            public void partVisible( IWorkbenchPartReference partRef )
+            {
+            }
+
+        } );
     }
 
 
@@ -344,24 +455,24 @@
             switch ( serverInstance.getState() )
             {
                 case STARTED:
-                    serverInstanceRun.setEnabled( false );
-                    serverInstanceStop.setEnabled( true );
+                    run.setEnabled( false );
+                    stop.setEnabled( true );
                     break;
                 case STARTING:
-                    serverInstanceRun.setEnabled( false );
-                    serverInstanceStop.setEnabled( false );
+                    run.setEnabled( false );
+                    stop.setEnabled( false );
                     break;
                 case STOPPED:
-                    serverInstanceRun.setEnabled( true );
-                    serverInstanceStop.setEnabled( false );
+                    run.setEnabled( true );
+                    stop.setEnabled( false );
                     break;
                 case STOPPING:
-                    serverInstanceRun.setEnabled( false );
-                    serverInstanceStop.setEnabled( false );
+                    run.setEnabled( false );
+                    stop.setEnabled( false );
                     break;
                 case UNKNONW:
-                    serverInstanceRun.setEnabled( false );
-                    serverInstanceStop.setEnabled( false );
+                    run.setEnabled( false );
+                    stop.setEnabled( false );
                     break;
             }
 
@@ -372,8 +483,8 @@
         }
         else
         {
-            serverInstanceRun.setEnabled( false );
-            serverInstanceStop.setEnabled( false );
+            run.setEnabled( false );
+            stop.setEnabled( false );
             open.setEnabled( false );
             delete.setEnabled( false );
             properties.setEnabled( false );



Mime
View raw message