directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r964405 - in /directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers: ./ actions/ apacheds/ dialogs/ model/ views/ wizards/
Date Thu, 15 Jul 2010 12:45:56 GMT
Author: pamarcelot
Date: Thu Jul 15 12:45:55 2010
New Revision: 964405

URL: http://svn.apache.org/viewvc?rev=964405&view=rev
Log:
Added the DeleteAction.
Modified the LdapServersManager to be able to use a Memento with every LDAP Server in order to store any additional configuration parameter (The memento is saved inside the server's folder).

Added:
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/DeleteServerDialog.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/Messages.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages.properties
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_de.properties
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_fr.properties
Modified:
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServerAdapterExtensionsManager.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersManager.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS156LdapServerAdapter.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS157LdapServerAdapter.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapterExtension.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/views/ServersView.java
    directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServerAdapterExtensionsManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServerAdapterExtensionsManager.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServerAdapterExtensionsManager.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServerAdapterExtensionsManager.java Thu Jul 15 12:45:55 2010
@@ -25,7 +25,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
 import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -41,6 +43,15 @@ import org.eclipse.ui.plugin.AbstractUIP
  */
 public class LdapServerAdapterExtensionsManager
 {
+    // Attributes names used in 'plugin.xml' file
+    private static final String ID_ATTR = "id";
+    private static final String NAME_ATTR = "name";
+    private static final String VERSION_ATTR = "version";
+    private static final String VENDOR_ATTR = "vendor";
+    private static final String CLASS_ATTR = "class";
+    private static final String DESCRIPTION_ATTR = "description";
+    private static final String ICON_ATTR = "icon";
+
     /** The default instance */
     private static LdapServerAdapterExtensionsManager instance;
 
@@ -82,14 +93,23 @@ public class LdapServerAdapterExtensions
             // Getting the ID of the extending plugin
             String extendingPluginId = member.getDeclaringExtension().getNamespaceIdentifier();
 
-            // Setting 
-            ldapServerAdapterExtension.setId( member.getAttribute( "id" ) );
-            ldapServerAdapterExtension.setName( member.getAttribute( "name" ) );
-            ldapServerAdapterExtension.setVersion( member.getAttribute( "version" ) );
-            ldapServerAdapterExtension.setVendor( member.getAttribute( "vendor" ) );
-            ldapServerAdapterExtension.setClassName( member.getAttribute( "class" ) );
-            ldapServerAdapterExtension.setDescription( member.getAttribute( "description" ) );
-            String iconPath = member.getAttribute( "icon" );
+            // Setting each parameter to the LDAP Server Adapter Extension
+            ldapServerAdapterExtension.setId( member.getAttribute( ID_ATTR ) );
+            ldapServerAdapterExtension.setName( member.getAttribute( NAME_ATTR ) );
+            ldapServerAdapterExtension.setVersion( member.getAttribute( VERSION_ATTR ) );
+            ldapServerAdapterExtension.setVendor( member.getAttribute( VENDOR_ATTR ) );
+            ldapServerAdapterExtension.setClassName( member.getAttribute( CLASS_ATTR ) );
+            try
+            {
+                ldapServerAdapterExtension.setInstance( ( LdapServerAdapter ) member
+                    .createExecutableExtension( CLASS_ATTR ) );
+            }
+            catch ( CoreException e )
+            {
+                // Will never happen
+            }
+            ldapServerAdapterExtension.setDescription( member.getAttribute( DESCRIPTION_ATTR ) );
+            String iconPath = member.getAttribute( ICON_ATTR );
             if ( iconPath != null )
             {
                 ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin( extendingPluginId, iconPath );
@@ -100,16 +120,6 @@ public class LdapServerAdapterExtensions
                 ldapServerAdapterExtension.setIcon( icon );
             }
 
-            // TODO uncomment this...
-            //            try
-            //            {
-            //                bean.setEditorInstance( ( IEntryEditor ) member.createExecutableExtension( CLASS_ATTR ) );
-            //            }
-            //            catch ( CoreException e )
-            //            {
-            //                // Will never happen
-            //            }
-
             ldapServerAdapterExtensionsList.add( ldapServerAdapterExtension );
             ldapServerAdapterExtensionsByIdMap.put( ldapServerAdapterExtension.getId(), ldapServerAdapterExtension );
         }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersManager.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersManager.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersManager.java Thu Jul 15 12:45:55 2010
@@ -24,7 +24,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.FileReader;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -36,6 +36,8 @@ import org.apache.commons.io.FileUtils;
 import org.apache.directory.studio.common.CommonUiUtils;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.XMLMemento;
 
 
 /**
@@ -307,11 +309,7 @@ public class LdapServersManager
             String content = FileUtils.readFileToString( tempStore, "UTF-8" ); //$NON-NLS-1$
             FileUtils.writeStringToFile( store, content, "UTF-8" ); //$NON-NLS-1$
         }
-        catch ( FileNotFoundException e )
-        {
-            saveFailed = true;
-        }
-        catch ( IOException e )
+        catch ( Exception e )
         {
             saveFailed = true;
         }
@@ -330,7 +328,8 @@ public class LdapServersManager
             }
             catch ( Exception e )
             {
-                CommonUiUtils.reportError( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) + e.getMessage() ); //$NON-NLS-1$
+                CommonUiUtils
+                    .reportError( Messages.getString( "LdapServersManager.ErrorLoadingServer" ) + e.getMessage() ); //$NON-NLS-1$
             }
         }
     }
@@ -421,6 +420,26 @@ public class LdapServersManager
 
 
     /**
+     * Gets the path to the server's folder.
+     *
+     * @param server
+     *      the server
+     * @return
+     *      the path to the server's folder
+     */
+    public static IPath getServerFolder( LdapServer server )
+    {
+        if ( server != null )
+        {
+
+            return getServersFolder().append( server.getId() );
+        }
+
+        return null;
+    }
+
+
+    /**
     * Creates a new server folder for the given id.
     *
     * @param id
@@ -428,9 +447,51 @@ public class LdapServersManager
     */
     public static void createNewServerFolder( LdapServer server )
     {
-        // Creating the server folder
-        IPath serverFolderPath = getServersFolder().append( server.getId() );
-        File serverFolder = new File( serverFolderPath.toOSString() );
-        serverFolder.mkdir();
+        if ( server != null )
+        {
+            // Creating the server folder
+            File serverFolder = getServerFolder( server ).toFile();
+            serverFolder.mkdir();
+        }
+    }
+
+
+    /**
+     * Gets the memento for the given server.
+     *
+     * @param server
+     *      the server
+     * @return
+     *      the associated memento
+     */
+    public static IMemento getMementoForServer( LdapServer server )
+    {
+        try
+        {
+            if ( server != null )
+            {
+                // Creating the File of the memento (if needed)
+                File mementoFile = getServerFolder( server ).append( "memento.xml" ).toFile();
+                if ( !mementoFile.exists() )
+                {
+                    mementoFile.createNewFile();
+                }
+
+                // Getting a (read-only) memento from the File
+                XMLMemento readMemento = XMLMemento.createReadRoot( new FileReader( mementoFile ) );
+
+                // Converting the read memento to a writable memento
+                XMLMemento memento = XMLMemento.createWriteRoot( "memento" );
+                memento.putMemento( readMemento );
+
+                return memento;
+            }
+
+            return null;
+        }
+        catch ( Exception e )
+        {
+            return null;
+        }
     }
 }

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java?rev=964405&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/DeleteAction.java Thu Jul 15 12:45:55 2010
@@ -0,0 +1,219 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.ldapservers.actions;
+
+
+import java.io.File;
+
+import org.apache.directory.studio.ldapservers.LdapServersManager;
+import org.apache.directory.studio.ldapservers.dialogs.DeleteServerDialog;
+import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.apache.directory.studio.ldapservers.model.LdapServerStatus;
+import org.apache.directory.studio.ldapservers.views.ServersView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements the delete action for a server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DeleteAction extends Action implements IWorkbenchWindowActionDelegate
+{
+    /** The associated view */
+    private ServersView view;
+
+
+    /**
+     * Creates a new instance of DeleteAction.
+     */
+    public DeleteAction()
+    {
+        super( Messages.getString( "DeleteAction.Delete" ) ); //$NON-NLS-1$
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of DeleteAction.
+     * 
+     * @param view
+     *      the associated view
+     */
+    public DeleteAction( ServersView view )
+    {
+        super( Messages.getString( "DeleteAction.Delete" ) ); //$NON-NLS-1$
+        this.view = view;
+        init();
+    }
+
+
+    /**
+     * Initializes the action.
+     */
+    private void init()
+    {
+        //        setId( ApacheDsPluginConstants.CMD_DELETE ); // TODO
+        //        setActionDefinitionId( ApacheDsPluginConstants.CMD_DELETE ); // TODO
+        setToolTipText( Messages.getString( "DeleteAction.DeleteToolTip" ) ); //$NON-NLS-1$
+        setImageDescriptor( PlatformUI.getWorkbench().getSharedImages()
+            .getImageDescriptor( ISharedImages.IMG_TOOL_DELETE ) );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        if ( view != null )
+        {
+            // What we get from the TableViewer is a StructuredSelection
+            StructuredSelection selection = ( StructuredSelection ) view.getViewer().getSelection();
+
+            // Here's the real object
+            LdapServer server = ( LdapServer ) selection.getFirstElement();
+
+            // Asking for confirmation
+            DeleteServerDialog dsd = new DeleteServerDialog( view.getSite().getShell(), server );
+            if ( dsd.open() == DeleteServerDialog.OK )
+            {
+                // Checking if the server is running
+                // If yes, we need to shut it down before removing its data
+                if ( server.getStatus() == LdapServerStatus.STARTED )
+                {
+                    // Setting the server of the server to 'stopping'
+                    //                    server.setStatus( LdapServerStatus.STOPPING ); // TODO
+
+                    // Getting the launch job // TODO
+                    //                    LaunchServerJob launchJob = server.getLaunchJob();
+                    //                    if ( launchJob != null )
+                    //                    {
+                    //                        // Getting the launch
+                    //                        ILaunch launch = launchJob.getLaunch();
+                    //                        if ( ( launch != null ) && ( !launch.isTerminated() ) )
+                    //                        {
+                    //                            // Terminating the launch
+                    //                            try
+                    //                            {
+                    //                                launch.terminate();
+                    //                            }
+                    //                            catch ( DebugException e )
+                    //                            {
+                    //                                ApacheDsPluginUtils.reportError( Messages.getString( "DeleteAction.ErrorWhileStopping" ) //$NON-NLS-1$
+                    //                                    + e.getMessage() );
+                    //                            }
+                    //                        }
+                    //                    }
+                }
+
+                // Removing the server
+                LdapServersManager.getDefault().removeServer( server );
+
+                // Deleting the associated directory on disk
+                deleteDirectory( LdapServersManager.getServerFolder( server ).toFile() );
+
+                // Letting the LDAP Server Adapter finish the deletion of the server
+                try
+                {
+                    server.getLdapServerAdapterExtension().getInstance().delete( server );
+                }
+                catch ( Exception e )
+                {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Deletes the given directory
+     *
+     * @param path
+     *      the directory
+     * @return
+     *      <code>true</code> if and only if the directory is 
+     *      successfully deleted; <code>false</code> otherwise
+     */
+    private boolean deleteDirectory( File path )
+    {
+        if ( path.exists() )
+        {
+            File[] files = path.listFiles();
+            for ( int i = 0; i < files.length; i++ )
+            {
+                if ( files[i].isDirectory() )
+                {
+                    deleteDirectory( files[i] );
+                }
+                else
+                {
+                    files[i].delete();
+                }
+            }
+        }
+        return ( path.delete() );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run( IAction action )
+    {
+        run();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+     */
+    public void dispose()
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+     */
+    public void init( IWorkbenchWindow window )
+    {
+        // Nothing to do
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+     */
+    public void selectionChanged( IAction action, ISelection selection )
+    {
+        // Nothing to do
+    }
+}

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS156LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS156LdapServerAdapter.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS156LdapServerAdapter.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS156LdapServerAdapter.java Thu Jul 15 12:45:55 2010
@@ -21,6 +21,7 @@
 package org.apache.directory.studio.ldapservers.apacheds;
 
 
+import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
 
 
@@ -32,38 +33,32 @@ import org.apache.directory.studio.ldaps
  */
 public class ApacheDS156LdapServerAdapter implements LdapServerAdapter
 {
-    /**
-     * Starts the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void start() throws Exception
+    public void add( LdapServer server ) throws Exception
     {
-        System.out.println( "Start" );
+        System.out.println( "add " + server.getName() );
     }
 
 
-    /**
-     * Stops the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void stop() throws Exception
+    public void delete( LdapServer server ) throws Exception
     {
-        System.out.println( "Stop" );
+        System.out.println( "delete " + server.getName() );
     }
 
 
-    /**
-     * Restarts the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void restart() throws Exception
+    public void start( LdapServer server ) throws Exception
     {
-        System.out.println( "Restart" );
+        System.out.println( "start " + server.getName() );
+    }
+
+
+    public void stop( LdapServer server ) throws Exception
+    {
+        System.out.println( "stop " + server.getName() );
+    }
+
+
+    public void restart( LdapServer server ) throws Exception
+    {
+        System.out.println( "restart " + server.getName() );
     }
 }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS157LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS157LdapServerAdapter.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS157LdapServerAdapter.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/apacheds/ApacheDS157LdapServerAdapter.java Thu Jul 15 12:45:55 2010
@@ -21,6 +21,7 @@
 package org.apache.directory.studio.ldapservers.apacheds;
 
 
+import org.apache.directory.studio.ldapservers.model.LdapServer;
 import org.apache.directory.studio.ldapservers.model.LdapServerAdapter;
 
 
@@ -32,38 +33,32 @@ import org.apache.directory.studio.ldaps
  */
 public class ApacheDS157LdapServerAdapter implements LdapServerAdapter
 {
-    /**
-     * Starts the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void start() throws Exception
+    public void add( LdapServer server ) throws Exception
     {
-        System.out.println( "Start" );
+        System.out.println( "add " + server.getName() );
     }
 
 
-    /**
-     * Stops the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void stop() throws Exception
+    public void delete( LdapServer server ) throws Exception
     {
-        System.out.println( "Stop" );
+        System.out.println( "delete " + server.getName() );
     }
 
 
-    /**
-     * Restarts the server.
-     *
-     * @throws Exception
-     *      if an error occurs when restarting the server
-     */
-    public void restart() throws Exception
+    public void start( LdapServer server ) throws Exception
     {
-        System.out.println( "Restart" );
+        System.out.println( "start " + server.getName() );
+    }
+
+
+    public void stop( LdapServer server ) throws Exception
+    {
+        System.out.println( "stop " + server.getName() );
+    }
+
+
+    public void restart( LdapServer server ) throws Exception
+    {
+        System.out.println( "restart " + server.getName() );
     }
 }

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/DeleteServerDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/DeleteServerDialog.java?rev=964405&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/DeleteServerDialog.java (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/DeleteServerDialog.java Thu Jul 15 12:45:55 2010
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapservers.dialogs;
+
+
+import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Dialog that prompts a user to delete server(s) and/or server configuration(s).
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DeleteServerDialog extends MessageDialog
+{
+    protected LdapServer server;
+
+
+    /**
+     * Creates a new DeleteServerDialog.
+     * 
+     * @param parentShell a shell
+     * @param server
+     *      the server
+     */
+    public DeleteServerDialog( Shell parentShell, LdapServer server )
+    {
+        super( parentShell, Messages.getString( "DeleteServerDialog.DeleteServer" ), null, null, QUESTION, new String[] //$NON-NLS-1$
+            { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, OK );
+
+        if ( server == null )
+        {
+            throw new IllegalArgumentException();
+        }
+
+        this.server = server;
+        message = NLS.bind( Messages.getString( "DeleteServerDialog.SureToDelete" ), server.getName() ); //$NON-NLS-1$
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.MessageDialog#buttonPressed(int)
+     */
+    protected void buttonPressed( int buttonId )
+    {
+        super.buttonPressed( buttonId );
+    }
+}
\ No newline at end of file

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/Messages.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/Messages.java?rev=964405&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/Messages.java (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/Messages.java Thu Jul 15 12:45:55 2010
@@ -0,0 +1,51 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapservers.dialogs;
+
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.studio.ldapservers.dialogs.messages"; //$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+
+    private Messages()
+    {
+    }
+
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+}

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages.properties?rev=964405&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages.properties (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages.properties Thu Jul 15 12:45:55 2010
@@ -0,0 +1,19 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+DeleteServerDialog.DeleteServer=Delete Server
+DeleteServerDialog.SureToDelete=Are you sure you want to delete the server "{0}"?

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_de.properties?rev=964405&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_de.properties (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_de.properties Thu Jul 15 12:45:55 2010
@@ -0,0 +1,19 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+DeleteServerDialog.DeleteServer=Server l\u00F6schen
+DeleteServerDialog.SureToDelete=Wollen Sie den Server "{0}" wirklich l\u00F6schen?

Added: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_fr.properties?rev=964405&view=auto
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_fr.properties (added)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/dialogs/messages_fr.properties Thu Jul 15 12:45:55 2010
@@ -0,0 +1,19 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+DeleteServerDialog.DeleteServer=Supprimer le serveur
+DeleteServerDialog.SureToDelete=Etes-vous s\u00FBr de vouloir supprimer le serveur "{0}"?

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServer.java Thu Jul 15 12:45:55 2010
@@ -21,6 +21,8 @@
 package org.apache.directory.studio.ldapservers.model;
 
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.UUID;
 
 import org.eclipse.core.runtime.IAdaptable;
@@ -46,6 +48,9 @@ public class LdapServer implements IAdap
     /** The LDAP Server Adapter Extension */
     private LdapServerAdapterExtension ldapServerAdapterExtension;
 
+    /** The list of listeners */
+    private List<LdapServerListener> listeners = new ArrayList<LdapServerListener>();
+
 
     /**
      * Creates a new instance of LDAP Server.
@@ -93,7 +98,10 @@ public class LdapServer implements IAdap
      */
     public void addListener( LdapServerListener listener )
     {
-
+        if ( !listeners.contains( listener ) )
+        {
+            listeners.add( listener );
+        }
     }
 
 
@@ -153,7 +161,10 @@ public class LdapServer implements IAdap
      */
     public void removeListener( LdapServerListener listener )
     {
-
+        if ( !listeners.contains( listener ) )
+        {
+            listeners.remove( listener );
+        }
     }
 
 
@@ -230,4 +241,5 @@ public class LdapServer implements IAdap
     {
         return null;
     }
+
 }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapter.java Thu Jul 15 12:45:55 2010
@@ -30,28 +30,54 @@ package org.apache.directory.studio.ldap
 public interface LdapServerAdapter
 {
     /**
-     * Starts the server.
+     * This method is called when a server is added.
      *
+     * @param server
+     *      the server
+     * @throws Exception
+     */
+    public void add( LdapServer server ) throws Exception;
+
+
+    /**
+     * This method is called when a server is deleted.
+     *
+     * @param server
+     *      the server
+     * @throws Exception
+     */
+    public void delete( LdapServer server ) throws Exception;
+
+
+    /**
+     * This method is called when a server needs to be started.
+     *
+     * @param server
+     *      the server
      * @throws Exception
      *      if an error occurs when restarting the server
      */
-    public void start() throws Exception;
+    public void start( LdapServer server ) throws Exception;
 
 
     /**
-     * Stops the server.
+     * This method is called when a server needs to be restarted.
      *
+     * @param server
+     *      the server
      * @throws Exception
      *      if an error occurs when restarting the server
      */
-    public void stop() throws Exception;
+    public void stop( LdapServer server ) throws Exception;
 
 
     /**
-     * Restarts the server.
+     * This method is called when a server needs to be stopped.
      *
+     * @param server
+     *      the server
      * @throws Exception
      *      if an error occurs when restarting the server
      */
-    public void restart() throws Exception;
+    public void restart( LdapServer server ) throws Exception;
 }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapterExtension.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapterExtension.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapterExtension.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/model/LdapServerAdapterExtension.java Thu Jul 15 12:45:55 2010
@@ -37,6 +37,7 @@ public class LdapServerAdapterExtension
     private String version;
     private String vendor;
     private String className;
+    private LdapServerAdapter instance;
     private String description;
     private ImageDescriptor icon;
 
@@ -86,6 +87,17 @@ public class LdapServerAdapterExtension
 
 
     /**
+     * TODO getInstance.
+     *
+     * @return
+     */
+    public LdapServerAdapter getInstance()
+    {
+        return instance;
+    }
+
+
+    /**
      * TODO getName.
      *
      * @return
@@ -163,6 +175,17 @@ public class LdapServerAdapterExtension
 
 
     /**
+     * TODO setInstance.
+     *
+     * @param instance
+     */
+    public void setInstance( LdapServerAdapter instance )
+    {
+        this.instance = instance;
+    }
+
+
+    /**
      * TODO setName.
      *
      * @param name

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/views/ServersView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/views/ServersView.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/views/ServersView.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/views/ServersView.java Thu Jul 15 12:45:55 2010
@@ -22,6 +22,7 @@ package org.apache.directory.studio.ldap
 
 import org.apache.directory.studio.ldapservers.LdapServersManager;
 import org.apache.directory.studio.ldapservers.LdapServersManagerListener;
+import org.apache.directory.studio.ldapservers.actions.DeleteAction;
 import org.apache.directory.studio.ldapservers.actions.NewServerAction;
 import org.apache.directory.studio.ldapservers.actions.PropertiesAction;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
@@ -64,7 +65,7 @@ import org.eclipse.ui.part.ViewPart;
 public class ServersView extends ViewPart
 {
     /** The ID of the view */
-//    public static final String ID = ApacheDsPluginConstants.VIEW_SERVERS_VIEW;
+    //    public static final String ID = ApacheDsPluginConstants.VIEW_SERVERS_VIEW;
 
     /** The tree*/
     private Tree tree;
@@ -83,12 +84,12 @@ public class ServersView extends ViewPar
 
     // Actions
     private NewServerAction newServer;
-//    private OpenConfigurationAction openConfiguration;
-//    private DeleteAction delete;
-//    private RenameAction rename;
-//    private RunAction run;
-//    private StopAction stop;
-//    private CreateConnectionAction createConnection;
+    //    private OpenConfigurationAction openConfiguration;
+    private DeleteAction delete;
+    //    private RenameAction rename;
+    //    private RunAction run;
+    //    private StopAction stop;
+    //    private CreateConnectionAction createConnection;
     private PropertiesAction properties;
 
     // Listeners
@@ -149,8 +150,8 @@ public class ServersView extends ViewPar
 
         // set help context
         // TODO
-//        PlatformUI.getWorkbench().getHelpSystem()
-//            .setHelp( parent, ApacheDsPluginConstants.PLUGIN_ID + "." + "gettingstarted_views_servers" ); //$NON-NLS-1$ //$NON-NLS-2$
+        //        PlatformUI.getWorkbench().getHelpSystem()
+        //            .setHelp( parent, ApacheDsPluginConstants.PLUGIN_ID + "." + "gettingstarted_views_servers" ); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
 
@@ -238,24 +239,24 @@ public class ServersView extends ViewPar
     {
         newServer = new NewServerAction();
 
-//        openConfiguration = new OpenConfigurationAction( this );
-//        openConfiguration.setEnabled( false );
-//
-//        delete = new DeleteAction( this );
-//        delete.setEnabled( false );
-//
-//        rename = new RenameAction( this );
-//        rename.setEnabled( false );
-//
-//        run = new RunAction( this );
-//        run.setEnabled( false );
-//
-//        stop = new StopAction( this );
-//        stop.setEnabled( false );
-//
-//        createConnection = new CreateConnectionAction( this );
-//        createConnection.setEnabled( false );
-//
+        //        openConfiguration = new OpenConfigurationAction( this );
+        //        openConfiguration.setEnabled( false );
+        //
+        delete = new DeleteAction( this );
+        delete.setEnabled( false );
+
+        //        rename = new RenameAction( this );
+        //        rename.setEnabled( false );
+        //
+        //        run = new RunAction( this );
+        //        run.setEnabled( false );
+        //
+        //        stop = new StopAction( this );
+        //        stop.setEnabled( false );
+        //
+        //        createConnection = new CreateConnectionAction( this );
+        //        createConnection.setEnabled( false );
+        //
         properties = new PropertiesAction( this );
         properties.setEnabled( false );
     }
@@ -268,9 +269,9 @@ public class ServersView extends ViewPar
     {
         IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
         toolbar.add( newServer );
-//        toolbar.add( new Separator() );
-//        toolbar.add( run );
-//        toolbar.add( stop );
+        //        toolbar.add( new Separator() );
+        //        toolbar.add( run );
+        //        toolbar.add( stop );
     }
 
 
@@ -288,17 +289,17 @@ public class ServersView extends ViewPar
                 MenuManager newManager = new MenuManager( Messages.getString( "ServersView.new" ) ); //$NON-NLS-1$
                 newManager.add( newServer );
                 manager.add( newManager );
-//                manager.add( openConfiguration );
-//                manager.add( new Separator() );
-//                manager.add( delete );
-//                manager.add( rename );
-//                manager.add( new Separator() );
-//                manager.add( run );
-//                manager.add( stop );
-//                manager.add( new Separator() );
-//                MenuManager ldapBrowserManager = new MenuManager( Messages.getString( "ServersView.ldapBrowser" ) ); //$NON-NLS-1$
-//                ldapBrowserManager.add( createConnection );
-//                manager.add( ldapBrowserManager );
+                //                manager.add( openConfiguration );
+                manager.add( new Separator() );
+                manager.add( delete );
+                //                manager.add( rename );
+                //                manager.add( new Separator() );
+                //                manager.add( run );
+                //                manager.add( stop );
+                //                manager.add( new Separator() );
+                //                MenuManager ldapBrowserManager = new MenuManager( Messages.getString( "ServersView.ldapBrowser" ) ); //$NON-NLS-1$
+                //                ldapBrowserManager.add( createConnection );
+                //                manager.add( ldapBrowserManager );
                 manager.add( new Separator() );
                 manager.add( properties );
             }
@@ -320,13 +321,13 @@ public class ServersView extends ViewPar
         LdapServersManager serversHandler = LdapServersManager.getDefault();
         serversHandler.addListener( ldapServersManagerListener );
 
-//        tableViewer.addDoubleClickListener( new IDoubleClickListener()
-//        {
-//            public void doubleClick( DoubleClickEvent event )
-//            {
-//                openConfiguration.run();
-//            }
-//        } );
+        //        tableViewer.addDoubleClickListener( new IDoubleClickListener()
+        //        {
+        //            public void doubleClick( DoubleClickEvent event )
+        //            {
+        //                openConfiguration.run();
+        //            }
+        //        } );
 
         tableViewer.addSelectionChangedListener( new ISelectionChangedListener()
         {
@@ -351,12 +352,12 @@ public class ServersView extends ViewPar
                     if ( commandService != null )
                     {
                         commandService.getCommand( newServer.getActionDefinitionId() ).setHandler( null );
-//                        commandService.getCommand( openConfiguration.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 );
+                        //                        commandService.getCommand( openConfiguration.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(
@@ -374,28 +375,28 @@ public class ServersView extends ViewPar
             {
                 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( openConfiguration.getActionDefinitionId() ).setHandler(
-//                            new ActionHandler( openConfiguration ) );
-//                        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 ) );
-//                    }
+                    //                    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( openConfiguration.getActionDefinitionId() ).setHandler(
+                    //                            new ActionHandler( openConfiguration ) );
+                    //                        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 ) );
+                    //                    }
                 }
             }
 
@@ -449,41 +450,41 @@ public class ServersView extends ViewPar
             switch ( server.getStatus() )
             {
                 case STARTED:
-//                    run.setEnabled( false );
-//                    stop.setEnabled( true );
+                    //                    run.setEnabled( false );
+                    //                    stop.setEnabled( true );
                     break;
                 case STARTING:
-//                    run.setEnabled( false );
-//                    stop.setEnabled( false );
+                    //                    run.setEnabled( false );
+                    //                    stop.setEnabled( false );
                     break;
                 case STOPPED:
-//                    run.setEnabled( true );
-//                    stop.setEnabled( false );
+                    //                    run.setEnabled( true );
+                    //                    stop.setEnabled( false );
                     break;
                 case STOPPING:
-//                    run.setEnabled( false );
-//                    stop.setEnabled( false );
+                    //                    run.setEnabled( false );
+                    //                    stop.setEnabled( false );
                     break;
                 case UNKNOWN:
-//                    run.setEnabled( false );
-//                    stop.setEnabled( false );
+                    //                    run.setEnabled( false );
+                    //                    stop.setEnabled( false );
                     break;
             }
 
-//            openConfiguration.setEnabled( true );
-//            delete.setEnabled( true );
-//            rename.setEnabled( true );
-//            createConnection.setEnabled( true );
+            //            openConfiguration.setEnabled( true );
+            delete.setEnabled( true );
+            //            rename.setEnabled( true );
+            //            createConnection.setEnabled( true );
             properties.setEnabled( true );
         }
         else
         {
-//            openConfiguration.setEnabled( false );
-//            delete.setEnabled( false );
-//            rename.setEnabled( false );
-//            run.setEnabled( false );
-//            stop.setEnabled( false );
-//            createConnection.setEnabled( false );
+            //            openConfiguration.setEnabled( false );
+            delete.setEnabled( false );
+            //            rename.setEnabled( false );
+            //            run.setEnabled( false );
+            //            stop.setEnabled( false );
+            //            createConnection.setEnabled( false );
             properties.setEnabled( false );
         }
     }

Modified: directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java?rev=964405&r1=964404&r2=964405&view=diff
==============================================================================
--- directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java (original)
+++ directory/studio/trunk/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/wizards/NewServerWizard.java Thu Jul 15 12:45:55 2010
@@ -22,6 +22,7 @@ package org.apache.directory.studio.ldap
 
 import org.apache.directory.studio.ldapservers.LdapServersManager;
 import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.apache.directory.studio.ldapservers.model.LdapServerAdapterExtension;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
@@ -57,7 +58,10 @@ public class NewServerWizard extends Wiz
         // Creating the new server
         LdapServer server = new LdapServer();
         server.setName( page.getServerName() );
-        server.setLdapServerAdapterExtension( page.getLdapServerAdapterExtension() );
+
+        // Getting the LDAP Server Adapter Extension associated with the server
+        LdapServerAdapterExtension ldapServerAdapterExtension = page.getLdapServerAdapterExtension();
+        server.setLdapServerAdapterExtension( ldapServerAdapterExtension );
 
         // Adding the new server to the servers handler
         LdapServersManager.getDefault().addServer( server );
@@ -65,6 +69,17 @@ public class NewServerWizard extends Wiz
         // Creating the folder for the new server
         LdapServersManager.createNewServerFolder( server );
 
+        // Letting the LDAP Server Adapter finish the creation of the server
+        try
+        {
+            ldapServerAdapterExtension.getInstance().add( server );
+        }
+        catch ( Exception e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
         return true;
     }
 



Mime
View raw message