Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2003-04-22 16:36:04 +0000
committerJared Burns2003-04-22 16:36:04 +0000
commitda55fb16dba62e660bd62b595361041c8b29979a (patch)
tree22d4e9321fcdedea1da0969fc61c187f5d428c36 /org.eclipse.ui.externaltools/Program Tools Support
parentcee5b3aabfa5b87fbcd618681a91627a5cb46cf5 (diff)
downloadeclipse.platform.debug-da55fb16dba62e660bd62b595361041c8b29979a.tar.gz
eclipse.platform.debug-da55fb16dba62e660bd62b595361041c8b29979a.tar.xz
eclipse.platform.debug-da55fb16dba62e660bd62b595361041c8b29979a.zip
Bug 36581 - External tool closed when Eclipse exits
Diffstat (limited to 'org.eclipse.ui.externaltools/Program Tools Support')
-rw-r--r--org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.properties2
-rw-r--r--org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java62
2 files changed, 61 insertions, 3 deletions
diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.properties b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.properties
index 7b7f05813..24984e1a3 100644
--- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.properties
+++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.properties
@@ -10,3 +10,5 @@
###############################################################################
ProgramMainTab.Select=&Select a program:
+ProgramLaunchDelegate.Workbench_Closing_1=Workbench Closing
+ProgramLaunchDelegate.The_workbench_is_exiting_and_a_program_launched_from_an_external_tool_appears_to_still_be_running._These_programs_will_be_terminated_when_the_workbench_exits._It_is_recommended_that_you_exit_any_external_programs_launched_from_the_workbench_before_you_proceed._n_nClick_OK_to_continue_exiting_the_workbench._2=The workbench is exiting and a program launched from an external tool appears to still be running. These programs will be terminated when the workbench exits. It is recommended that you exit any external programs launched from the workbench before you proceed.\n\nClick OK to continue exiting the workbench.
diff --git a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java
index 03922f2c8..a109868f9 100644
--- a/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java
+++ b/org.eclipse.ui.externaltools/Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java
@@ -21,9 +21,16 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
+import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext;
/**
@@ -31,6 +38,53 @@ import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext;
*/
public class ProgramLaunchDelegate implements ILaunchConfigurationDelegate {
+ private static IWindowListener windowListener;
+
+ /**
+ * A window listener that warns the user about any running programs when
+ * the workbench closes. Programs are killed when the VM exits.
+ */
+ private class ProgramLaunchWindowListener implements IWindowListener {
+ public void windowActivated(IWorkbenchWindow window) {
+ }
+ public void windowDeactivated(IWorkbenchWindow window) {
+ }
+ public void windowClosed(IWorkbenchWindow window) {
+ IWorkbenchWindow windows[]= PlatformUI.getWorkbench().getWorkbenchWindows();
+ if (windows.length > 1) {
+ // There are more windows still open.
+ return;
+ }
+ ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType programType= manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
+ if (programType == null) {
+ return;
+ }
+ ILaunch launches[]= manager.getLaunches();
+ ILaunchConfigurationType configType;
+ ILaunchConfiguration config;
+ for (int i = 0; i < launches.length; i++) {
+ try {
+ config= launches[i].getLaunchConfiguration();
+ if (config == null) {
+ continue;
+ }
+ configType= config.getType();
+ } catch (CoreException e) {
+ continue;
+ }
+ if (configType.equals(programType)) {
+ if (!launches[i].isTerminated()) {
+ MessageDialog.openWarning(window.getShell(), "Workbench Closing", "The workbench is exiting and a program launched from an external tool appears to still be running. These programs will be terminated when the workbench exits. It is recommended that you exit any external programs launched from the workbench before you proceed.\n\nClick OK to continue exiting the workbench.");
+ break;
+ }
+ }
+ }
+ }
+ public void windowOpened(IWorkbenchWindow window) {
+ }
+ }
+
/**
* Constructor for ProgramLaunchDelegate.
*/
@@ -93,7 +147,11 @@ public class ProgramLaunchDelegate implements ILaunchConfigurationDelegate {
if (monitor.isCanceled()) {
return;
}
-
+
+ if (windowListener == null) {
+ windowListener= new ProgramLaunchWindowListener();
+ PlatformUI.getWorkbench().addWindowListener(windowListener);
+ }
Process p = DebugPlugin.exec(cmdLine, workingDir);
IProcess process = null;
@@ -134,8 +192,6 @@ public class ProgramLaunchDelegate implements ILaunchConfigurationDelegate {
// refresh resources
ExternalToolsUtil.refreshResources(configuration, resourceContext, monitor);
}
-
-
}
protected static String renderCommandLine(String[] commandLine) {

Back to the top