directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r674867 - in /directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds: actions/DeleteAction.java dialogs/DeleteServerDialog.java
Date Tue, 08 Jul 2008 16:11:06 GMT
Author: pamarcelot
Date: Tue Jul  8 09:11:05 2008
New Revision: 674867

URL: http://svn.apache.org/viewvc?rev=674867&view=rev
Log:
Fixed an issue when the server been deleted was running.

Modified:
    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/dialogs/DeleteServerDialog.java

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=674867&r1=674866&r2=674867&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
Tue Jul  8 09:11:05 2008
@@ -25,9 +25,13 @@
 import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
 import org.apache.directory.studio.apacheds.ApacheDsPluginUtils;
 import org.apache.directory.studio.apacheds.dialogs.DeleteServerDialog;
+import org.apache.directory.studio.apacheds.jobs.LaunchServerJob;
 import org.apache.directory.studio.apacheds.model.Server;
+import org.apache.directory.studio.apacheds.model.ServerStateEnum;
 import org.apache.directory.studio.apacheds.model.ServersHandler;
 import org.apache.directory.studio.apacheds.views.ServersView;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
@@ -106,6 +110,35 @@
             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.getState() == ServerStateEnum.STARTED )
+                {
+                    // 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() ) )
+                        {
+                            // Terminating the launch
+                            try
+                            {
+                                launch.terminate();
+                            }
+                            catch ( DebugException e )
+                            {
+                                ApacheDsPluginUtils.reportError( "An error occurred when
stopping the server.\n\n"
+                                    + e.getMessage() );
+                            }
+                        }
+                    }
+                }
+
                 // Removing the server
                 ServersHandler.getDefault().removeServer( server );
 

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/dialogs/DeleteServerDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/dialogs/DeleteServerDialog.java?rev=674867&r1=674866&r2=674867&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/dialogs/DeleteServerDialog.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/dialogs/DeleteServerDialog.java
Tue Jul  8 09:11:05 2008
@@ -21,19 +21,9 @@
 
 
 import org.apache.directory.studio.apacheds.model.Server;
-import org.apache.directory.studio.apacheds.model.ServerStateEnum;
-import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 
 
@@ -47,9 +37,6 @@
 {
     protected Server server;
 
-    protected Button checkDeleteRunning;
-    protected Button checkDeleteRunningStop;
-
 
     /**
      * Creates a new DeleteServerDialog.
@@ -74,51 +61,6 @@
 
 
     /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
-     */
-    protected Control createCustomArea( Composite parent )
-    {
-        // create a composite with standard margins and spacing
-        Composite composite = new Composite( parent, SWT.NONE );
-        GridLayout layout = new GridLayout();
-        layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN
);
-        layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN
);
-        layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING
);
-        layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING
);
-        composite.setLayout( layout );
-        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
-        composite.setFont( parent.getFont() );
-
-        // prompt for stopping running server
-        if ( server.getState() != ServerStateEnum.STOPPED )
-        {
-            checkDeleteRunning = new Button( composite, SWT.CHECK );
-            checkDeleteRunning.setText( "Delete running server" );
-            checkDeleteRunning.setSelection( true );
-
-            checkDeleteRunningStop = new Button( composite, SWT.CHECK );
-            checkDeleteRunningStop.setText( "Stop server before deleting" );
-            checkDeleteRunningStop.setSelection( true );
-            GridData data = new GridData();
-            data.horizontalIndent = 15;
-            checkDeleteRunningStop.setLayoutData( data );
-
-            checkDeleteRunning.addSelectionListener( new SelectionAdapter()
-            {
-                public void widgetSelected( SelectionEvent e )
-                {
-                    checkDeleteRunningStop.setEnabled( checkDeleteRunning.getSelection()
);
-                }
-            } );
-        }
-
-        Dialog.applyDialogFont( composite );
-
-        return composite;
-    }
-
-
-    /* (non-Javadoc)
      * @see org.eclipse.jface.dialogs.MessageDialog#buttonPressed(int)
      */
     protected void buttonPressed( int buttonId )



Mime
View raw message