directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r667120 - /directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/
Date Thu, 12 Jun 2008 14:56:08 GMT
Author: pamarcelot
Date: Thu Jun 12 07:56:08 2008
New Revision: 667120

URL: http://svn.apache.org/viewvc?rev=667120&view=rev
Log:
Refactored actions.

Modified:
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenConfigurationAction.java
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/CreateConnectionAction.java
Thu Jun 12 07:56:08 2008
@@ -52,6 +52,8 @@
  */
 public class CreateConnectionAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "Create a Connection";
+
     /** The associated view */
     private ServersView view;
 
@@ -59,15 +61,37 @@
     /**
      * Creates a new instance of CreateConnectionAction.
      */
+    public CreateConnectionAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of CreateConnectionAction.
+     * 
+     * @param view
+     *      the associated view
+     */
     public CreateConnectionAction( ServersView view )
     {
-        super( "Create a Connection" );
+        super( ACTION_TEXT );
+        this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
         setId( ApacheDsPluginConstants.CMD_CREATE_CONNECTION );
         setActionDefinitionId( ApacheDsPluginConstants.CMD_CREATE_CONNECTION );
         setToolTipText( "Stop" );
         setImageDescriptor( ApacheDsPlugin.getDefault().getImageDescriptor(
             ApacheDsPluginConstants.IMG_CREATE_CONNECTION ) );
-        this.view = view;
     }
 
 
@@ -76,53 +100,57 @@
      */
     public void run()
     {
-        // Getting the selection
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
-        if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+        if ( view != null )
         {
-            // Getting the server
-            Server server = ( Server ) selection.getFirstElement();
-
-            // Parsing the 'server.xml' file
-            ServerXmlIOV152 serverXmlIOV152 = new ServerXmlIOV152();
-            ServerConfigurationV152 serverConfiguration = null;
-            try
-            {
-                serverConfiguration = ( ServerConfigurationV152 ) serverXmlIOV152.parse(
new FileInputStream( new File(
-                    ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId()
).append( "conf" ).append(
-                        "server.xml" ).toOSString() ) ) );
-            }
-            catch ( FileNotFoundException e )
-            {
-                reportErrorReadingServerConfiguration( e.getMessage() );
-                return;
-            }
-            catch ( ServerXmlIOException e )
+            // Getting the selection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
             {
-                reportErrorReadingServerConfiguration( e.getMessage() );
-                return;
-            }
+                // Getting the server
+                Server server = ( Server ) selection.getFirstElement();
 
-            // Checking if we could read the 'server.xml' file
-            if ( serverConfiguration == null )
-            {
-                reportErrorReadingServerConfiguration( null );
-                return;
-            }
+                // Parsing the 'server.xml' file
+                ServerXmlIOV152 serverXmlIOV152 = new ServerXmlIOV152();
+                ServerConfigurationV152 serverConfiguration = null;
+                try
+                {
+                    serverConfiguration = ( ServerConfigurationV152 ) serverXmlIOV152.parse(
new FileInputStream(
+                        new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() ).append(
+                            "conf" ).append( "server.xml" ).toOSString() ) ) );
+                }
+                catch ( FileNotFoundException e )
+                {
+                    reportErrorReadingServerConfiguration( e.getMessage() );
+                    return;
+                }
+                catch ( ServerXmlIOException e )
+                {
+                    reportErrorReadingServerConfiguration( e.getMessage() );
+                    return;
+                }
 
-            if ( ( serverConfiguration.isEnableLdap() ) || ( serverConfiguration.isEnableLdaps()
) )
-            {
-                // Creating the connection using the helper class
-                CreateConnectionActionHelper.createLdapBrowserConnection( server.getName(),
serverConfiguration );
-            }
-            else
-            {
-                // LDAP and LDAPS protocols are disabled, we report this error to the user
-                MessageDialog dialog = new MessageDialog( view.getSite().getShell(), "Unable
to create a connection",
-                    null, "LDAP and LDAPS protocols are disabled. A connection cannot be
created.",
-                    MessageDialog.ERROR, new String[]
-                        { IDialogConstants.OK_LABEL }, MessageDialog.OK );
-                dialog.open();
+                // Checking if we could read the 'server.xml' file
+                if ( serverConfiguration == null )
+                {
+                    reportErrorReadingServerConfiguration( null );
+                    return;
+                }
+
+                if ( ( serverConfiguration.isEnableLdap() ) || ( serverConfiguration.isEnableLdaps()
) )
+                {
+                    // Creating the connection using the helper class
+                    CreateConnectionActionHelper.createLdapBrowserConnection( server.getName(),
serverConfiguration );
+                }
+                else
+                {
+                    // LDAP and LDAPS protocols are disabled, we report this error to the
user
+                    MessageDialog dialog = new MessageDialog( view.getSite().getShell(),
+                        "Unable to create a connection", null,
+                        "LDAP and LDAPS protocols are disabled. A connection cannot be created.",
MessageDialog.ERROR,
+                        new String[]
+                            { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+                    dialog.open();
+                }
             }
         }
     }

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/DeleteAction.java
Thu Jun 12 07:56:08 2008
@@ -46,20 +46,41 @@
  */
 public class DeleteAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "&Delete";
+
     /** The associated view */
     private ServersView view;
 
 
     /**
      * Creates a new instance of DeleteAction.
+     */
+    public DeleteAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of DeleteAction.
      * 
      * @param view
      *      the associated view
      */
     public DeleteAction( ServersView view )
     {
-        super( "&Delete" );
+        super( ACTION_TEXT );
         this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
         setId( ApacheDsPluginConstants.CMD_DELETE );
         setActionDefinitionId( ApacheDsPluginConstants.CMD_DELETE );
         setToolTipText( "Delete" );
@@ -73,22 +94,25 @@
      */
     public void run()
     {
-        // What we get from the TableViewer is a StructuredSelection
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+        if ( view != null )
+        {
+            // What we get from the TableViewer is a StructuredSelection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
 
-        // Here's the real object
-        Server server = ( Server ) selection.getFirstElement();
+            // Here's the real object
+            Server server = ( Server ) selection.getFirstElement();
 
-        // Asking for confirmation
-        DeleteServerDialog dsd = new DeleteServerDialog( view.getSite().getShell(), server
);
-        if ( dsd.open() == DeleteServerDialog.OK )
-        {
-            // Removing the server
-            ServersHandler.getDefault().removeServer( server );
+            // Asking for confirmation
+            DeleteServerDialog dsd = new DeleteServerDialog( view.getSite().getShell(), server
);
+            if ( dsd.open() == DeleteServerDialog.OK )
+            {
+                // Removing the server
+                ServersHandler.getDefault().removeServer( server );
 
-            // Deleting the associated directory on disk
-            deleteDirectory( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() )
-                .toOSString() ) );
+                // Deleting the associated directory on disk
+                deleteDirectory( new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() )
+                    .toOSString() ) );
+            }
         }
     }
 

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenConfigurationAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenConfigurationAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenConfigurationAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/OpenConfigurationAction.java
Thu Jun 12 07:56:08 2008
@@ -49,20 +49,41 @@
  */
 public class OpenConfigurationAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "&Open Configuration";
+
     /** The associated view */
     private ServersView view;
 
 
     /**
      * Creates a new instance of OpenConfigurationAction.
+     */
+    public OpenConfigurationAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of OpenConfigurationAction.
      * 
      * @param view
      *      the associated view
      */
     public OpenConfigurationAction( ServersView view )
     {
-        super( "&Open Configuration" );
+        super( ACTION_TEXT );
         this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
         setId( ApacheDsPluginConstants.CMD_OPEN_CONFIGURATION );
         setActionDefinitionId( ApacheDsPluginConstants.CMD_OPEN_CONFIGURATION );
         setToolTipText( "Open Configuration" );
@@ -74,26 +95,29 @@
      */
     public void run()
     {
-        // What we get from the TableViewer is a StructuredSelection
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+        if ( view != null )
+        {
+            // What we get from the TableViewer is a StructuredSelection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
 
-        // Here's the real object
-        Server server = ( Server ) selection.getFirstElement();
-        if ( server != null )
-        {
-            // Opening the editor
-            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-            PathEditorInput input = new PathEditorInput( ApacheDsPluginUtils.getApacheDsServersFolder().append(
-                server.getId() ).append( "conf" ).append( "server.xml" ) );
-            try
-            {
-                page.openEditor( input, ServerConfigurationEditor.ID );
-            }
-            catch ( PartInitException e )
-            {
-                ApacheDsPluginUtils
-                    .reportError( "An error occurred when opening the Apache DS Configuration
Editor.\n\n"
-                        + e.getMessage() );
+            // Here's the real object
+            Server server = ( Server ) selection.getFirstElement();
+            if ( server != null )
+            {
+                // Opening the editor
+                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                PathEditorInput input = new PathEditorInput( ApacheDsPluginUtils.getApacheDsServersFolder().append(
+                    server.getId() ).append( "conf" ).append( "server.xml" ) );
+                try
+                {
+                    page.openEditor( input, ServerConfigurationEditor.ID );
+                }
+                catch ( PartInitException e )
+                {
+                    ApacheDsPluginUtils
+                        .reportError( "An error occurred when opening the Apache DS Configuration
Editor.\n\n"
+                            + e.getMessage() );
+                }
             }
         }
     }

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/PropertiesAction.java
Thu Jun 12 07:56:08 2008
@@ -42,20 +42,41 @@
  */
 public class PropertiesAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "&Properties";
+
     /** The associated view */
     private ServersView view;
 
 
     /**
      * Creates a new instance of PropertiesAction.
+     */
+    public PropertiesAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of PropertiesAction.
      * 
      * @param view
      *      the associated view
      */
     public PropertiesAction( ServersView view )
     {
-        super( "&Properties" );
+        super( ACTION_TEXT );
         this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
         setId( ApacheDsPluginConstants.CMD_PROPERTIES );
         setActionDefinitionId( ApacheDsPluginConstants.CMD_PROPERTIES );
         setToolTipText( "Properties" );
@@ -67,14 +88,17 @@
      */
     public void run()
     {
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
-        if ( !selection.isEmpty() )
+        if ( view != null )
         {
-            Server server = ( Server ) selection.getFirstElement();
-            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn( view.getViewSite().getShell(),
server,
-                ServerPropertyPage.ID, null, null );
-            dialog.getShell().setText( "Properties for '" + shorten( server.getName(), 30
) + "'" );
-            dialog.open();
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+            if ( !selection.isEmpty() )
+            {
+                Server server = ( Server ) selection.getFirstElement();
+                PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn( view.getViewSite().getShell(),
+                    server, ServerPropertyPage.ID, null, null );
+                dialog.getShell().setText( "Properties for '" + shorten( server.getName(),
30 ) + "'" );
+                dialog.open();
+            }
         }
     }
 

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RenameAction.java
Thu Jun 12 07:56:08 2008
@@ -64,6 +64,8 @@
  */
 public class RenameAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "R&ename...";
+
     /** The associated view */
     private ServersView view;
     private Tree tree;
@@ -79,19 +81,38 @@
 
     /**
      * Creates a new instance of RenameAction.
+     */
+    public RenameAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of RenameAction.
      * 
      * @param view
      *      the associated view
      */
     public RenameAction( ServersView view )
     {
-        super( "R&ename..." );
-        setId( ApacheDsPluginConstants.CMD_RENAME );
-        setActionDefinitionId( ApacheDsPluginConstants.CMD_RENAME );
-        setToolTipText( "Rename..." );
+        super( ACTION_TEXT );
         this.view = view;
         this.tree = view.getViewer().getTree();
         this.treeEditor = new TreeEditor( tree );
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
+        setId( ApacheDsPluginConstants.CMD_RENAME );
+        setActionDefinitionId( ApacheDsPluginConstants.CMD_RENAME );
+        setToolTipText( "Rename..." );
     }
 
 
@@ -100,14 +121,17 @@
      */
     public void run()
     {
-        // What we get from the TableViewer is a StructuredSelection
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
-
-        // Here's the real object
-        Server server = ( Server ) selection.getFirstElement();
-        if ( server != null )
+        if ( view != null )
         {
-            queryNewServerNameInline( server );
+            // What we get from the TableViewer is a StructuredSelection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+
+            // Here's the real object
+            Server server = ( Server ) selection.getFirstElement();
+            if ( server != null )
+            {
+                queryNewServerNameInline( server );
+            }
         }
     }
 

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/RunAction.java
Thu Jun 12 07:56:08 2008
@@ -54,20 +54,41 @@
  */
 public class RunAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "&Run";
+
     /** The associated view */
     private ServersView view;
 
 
     /**
      * Creates a new instance of RunAction.
+     */
+    public RunAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of RunAction.
      *
      * @param view
      *      the associated view
      */
     public RunAction( ServersView view )
     {
-        super( "&Run" );
+        super( ACTION_TEXT );
         this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
         setId( ApacheDsPluginConstants.CMD_RUN );
         setActionDefinitionId( ApacheDsPluginConstants.CMD_RUN );
         setToolTipText( "Run" );
@@ -80,83 +101,87 @@
      */
     public void run()
     {
-        // Getting the selection
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
-        if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+        if ( view != null )
         {
-            // Getting the server
-            final Server server = ( Server ) selection.getFirstElement();
-
-            // Parsing the 'server.xml' file
-            ServerXmlIOV152 serverXmlIOV152 = new ServerXmlIOV152();
-            ServerConfigurationV152 serverConfiguration = null;
-            try
-            {
-                serverConfiguration = ( ServerConfigurationV152 ) serverXmlIOV152.parse(
new FileInputStream( new File(
-                    ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId()
).append( "conf" ).append(
-                        "server.xml" ).toOSString() ) ) );
-            }
-            catch ( FileNotFoundException e )
-            {
-                reportErrorReadingServerConfiguration( e.getMessage() );
-                return;
-            }
-            catch ( ServerXmlIOException e )
-            {
-                reportErrorReadingServerConfiguration( e.getMessage() );
-                return;
-            }
-
-            // Checking if we could read the 'server.xml' file
-            if ( serverConfiguration == null )
-            {
-                reportErrorReadingServerConfiguration( null );
-                return;
-            }
-
-            // Verifying if the protocol ports are currently available
-            String[] alreadyInUseProtocolPortsList = getAlreadyInUseProtocolPorts( serverConfiguration
);
-            if ( ( alreadyInUseProtocolPortsList != null ) && ( alreadyInUseProtocolPortsList.length
> 0 ) )
-            {
-                String title = null;
-                String message = null;
+            // Getting the selection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+            {
+                // Getting the server
+                final Server server = ( Server ) selection.getFirstElement();
+
+                // Parsing the 'server.xml' file
+                ServerXmlIOV152 serverXmlIOV152 = new ServerXmlIOV152();
+                ServerConfigurationV152 serverConfiguration = null;
+                try
+                {
+                    serverConfiguration = ( ServerConfigurationV152 ) serverXmlIOV152.parse(
new FileInputStream(
+                        new File( ApacheDsPluginUtils.getApacheDsServersFolder().append(
server.getId() ).append(
+                            "conf" ).append( "server.xml" ).toOSString() ) ) );
+                }
+                catch ( FileNotFoundException e )
+                {
+                    reportErrorReadingServerConfiguration( e.getMessage() );
+                    return;
+                }
+                catch ( ServerXmlIOException e )
+                {
+                    reportErrorReadingServerConfiguration( e.getMessage() );
+                    return;
+                }
 
-                if ( alreadyInUseProtocolPortsList.length == 1 )
+                // Checking if we could read the 'server.xml' file
+                if ( serverConfiguration == null )
                 {
-                    title = "Port already in use";
-                    message = "The port of the protocol " + alreadyInUseProtocolPortsList[0]
+ " is already in use.";
+                    reportErrorReadingServerConfiguration( null );
+                    return;
                 }
-                else
+
+                // Verifying if the protocol ports are currently available
+                String[] alreadyInUseProtocolPortsList = getAlreadyInUseProtocolPorts( serverConfiguration
);
+                if ( ( alreadyInUseProtocolPortsList != null ) && ( alreadyInUseProtocolPortsList.length
> 0 ) )
                 {
-                    title = "Ports already in use";
-                    message = "The ports of the following protocols are already in use:";
-                    for ( String alreadyInUseProtocolPort : alreadyInUseProtocolPortsList
)
+                    String title = null;
+                    String message = null;
+
+                    if ( alreadyInUseProtocolPortsList.length == 1 )
                     {
-                        message += ApacheDsPluginUtils.LINE_SEPARATOR + "    - " + alreadyInUseProtocolPort;
+                        title = "Port already in use";
+                        message = "The port of the protocol " + alreadyInUseProtocolPortsList[0]
+                            + " is already in use.";
+                    }
+                    else
+                    {
+                        title = "Ports already in use";
+                        message = "The ports of the following protocols are already in use:";
+                        for ( String alreadyInUseProtocolPort : alreadyInUseProtocolPortsList
)
+                        {
+                            message += ApacheDsPluginUtils.LINE_SEPARATOR + "    - " + alreadyInUseProtocolPort;
+                        }
                     }
-                }
 
-                message += ApacheDsPluginUtils.LINE_SEPARATOR + ApacheDsPluginUtils.LINE_SEPARATOR
-                    + "Do you wish to continue?";
+                    message += ApacheDsPluginUtils.LINE_SEPARATOR + ApacheDsPluginUtils.LINE_SEPARATOR
+                        + "Do you wish to continue?";
 
-                MessageDialog dialog = new MessageDialog( view.getSite().getShell(), title,
null, message,
-                    MessageDialog.WARNING, new String[]
-                        { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, MessageDialog.OK
);
-                if ( dialog.open() == MessageDialog.CANCEL )
-                {
-                    return;
+                    MessageDialog dialog = new MessageDialog( view.getSite().getShell(),
title, null, message,
+                        MessageDialog.WARNING, new String[]
+                            { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL },
MessageDialog.OK );
+                    if ( dialog.open() == MessageDialog.CANCEL )
+                    {
+                        return;
+                    }
                 }
-            }
 
-            // Verifying the libraries in the plugin's folder
-            ApacheDsPluginUtils.verifyLibrariesFolder();
+                // Verifying the libraries in the plugin's folder
+                ApacheDsPluginUtils.verifyLibrariesFolder();
 
-            // Creating, setting and launching the launch job
-            LaunchServerJob job = new LaunchServerJob( server, serverConfiguration );
-            job.setLogsLevel( ApacheDsPluginUtils.getServerLogsLevel() );
-            job.setLogsPattern( ApacheDsPluginUtils.getServerLogsPattern() );
-            server.setLaunchJob( job );
-            job.schedule();
+                // Creating, setting and launching the launch job
+                LaunchServerJob job = new LaunchServerJob( server, serverConfiguration );
+                job.setLogsLevel( ApacheDsPluginUtils.getServerLogsLevel() );
+                job.setLogsPattern( ApacheDsPluginUtils.getServerLogsPattern() );
+                server.setLaunchJob( job );
+                job.schedule();
+            }
         }
     }
 

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java?rev=667120&r1=667119&r2=667120&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
Thu Jun 12 07:56:08 2008
@@ -50,6 +50,8 @@
  */
 public class StopAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    private static final String ACTION_TEXT = "S&top";
+
     /** The associated view */
     private ServersView view;
 
@@ -60,14 +62,36 @@
     /**
      * Creates a new instance of StopAction.
      */
+    public StopAction()
+    {
+        super( ACTION_TEXT );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of StopAction.
+     *
+     * @param view
+     *      the associated view
+     */
     public StopAction( ServersView view )
     {
-        super( "S&top" );
+        super( ACTION_TEXT );
+        this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
         setId( ApacheDsPluginConstants.CMD_STOP );
         setActionDefinitionId( ApacheDsPluginConstants.CMD_STOP );
         setToolTipText( "Stop" );
         setImageDescriptor( ApacheDsPlugin.getDefault().getImageDescriptor( ApacheDsPluginConstants.IMG_STOP
) );
-        this.view = view;
     }
 
 
@@ -76,34 +100,37 @@
      */
     public void run()
     {
-        // Getting the selection
-        StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
-        if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+        if ( view != null )
         {
-            // Getting the server
-            server = ( Server ) selection.getFirstElement();
+            // Getting the selection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+            if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+            {
+                // Getting the server
+                server = ( Server ) selection.getFirstElement();
 
-            // Setting the server of the server to 'stopping'
-            server.setState( ServerStateEnum.STOPPING );
+                // Setting the server of the server to 'stopping'
+                server.setState( ServerStateEnum.STOPPING );
 
-            // Getting the launch job
-            LaunchServerJob launchJob = server.getLaunchJob();
-            if ( launchJob != null )
-            {
-                // Getting the launch
-                ILaunch launch = launchJob.getLaunch();
-                if ( ( launch != null ) && ( !launch.isTerminated() ) )
+                // Getting the launch job
+                LaunchServerJob launchJob = server.getLaunchJob();
+                if ( launchJob != null )
                 {
-                    // Terminating the launch
-                    try
+                    // Getting the launch
+                    ILaunch launch = launchJob.getLaunch();
+                    if ( ( launch != null ) && ( !launch.isTerminated() ) )
                     {
-                        launch.terminate();
-                        writeToInfoConsoleMessageStream( "Server stopped.\n" );
-                    }
-                    catch ( DebugException e )
-                    {
-                        ApacheDsPluginUtils.reportError( "An error occurred when stopping
the server.\n\n"
-                            + e.getMessage() );
+                        // Terminating the launch
+                        try
+                        {
+                            launch.terminate();
+                            writeToInfoConsoleMessageStream( "Server stopped.\n" );
+                        }
+                        catch ( DebugException e )
+                        {
+                            ApacheDsPluginUtils.reportError( "An error occurred when stopping
the server.\n\n"
+                                + e.getMessage() );
+                        }
                     }
                 }
             }



Mime
View raw message