Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations')
-rw-r--r--org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java89
-rw-r--r--org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java274
-rw-r--r--org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java30
-rw-r--r--org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties23
-rw-r--r--org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java207
5 files changed, 623 insertions, 0 deletions
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java
new file mode 100644
index 000000000..de772967d
--- /dev/null
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.externaltools.internal.launchConfigurations;
+
+
+import org.eclipse.core.externaltools.internal.ExternalToolsCore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.RefreshUtil;
+import org.eclipse.debug.core.model.IProcess;
+
+/**
+ * Refreshes resources as specified by a launch configuration, when
+ * an associated process terminates.
+ */
+public class BackgroundResourceRefresher implements IDebugEventSetListener {
+
+ private ILaunchConfiguration fConfiguration;
+ private IProcess fProcess;
+
+
+
+ public BackgroundResourceRefresher(ILaunchConfiguration configuration, IProcess process) {
+ fConfiguration = configuration;
+ fProcess = process;
+ }
+
+ /**
+ * If the process has already terminated, resource refreshing is done
+ * immediately in the current thread. Otherwise, refreshing is done when the
+ * process terminates.
+ */
+ public void startBackgroundRefresh() {
+ synchronized (fProcess) {
+ if (fProcess.isTerminated()) {
+ refresh();
+ } else {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ refresh();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Submits a job to do the refresh
+ */
+ protected void refresh() {
+ Job job= new Job(ExternalToolsProgramMessages.BackgroundResourceRefresher_0) {
+ public IStatus run(IProgressMonitor monitor) {
+ try {
+ RefreshUtil.refreshResources(fConfiguration, monitor);
+ } catch (CoreException e) {
+ ExternalToolsCore.log(e);
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+}
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java
new file mode 100644
index 000000000..aba44bbcd
--- /dev/null
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java
@@ -0,0 +1,274 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution)
+ * dakshinamurthy.karra@gmail.com - bug 165371
+ *******************************************************************************/
+package org.eclipse.core.externaltools.internal.launchConfigurations;
+
+
+import java.io.File;
+
+import org.eclipse.core.externaltools.internal.ExternalToolsCore;
+import org.eclipse.core.externaltools.internal.IExternalToolConstants;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.RefreshUtil;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Utilities for external tool launch configurations.
+ * <p>
+ * This class it not intended to be instantiated.
+ * </p>
+ */
+public class ExternalToolsCoreUtil {
+
+ /**
+ * Throws a core exception with an error status object built from
+ * the given message, lower level exception, and error code.
+ * @param message the status message
+ * @param exception lower level exception associated with the
+ * error, or <code>null</code> if none
+ * @param code error code
+ */
+ protected static void abort(String message, Throwable exception, int code) throws CoreException {
+ throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception));
+ }
+
+ /**
+ * Expands and returns the location attribute of the given launch
+ * configuration. The location is
+ * verified to point to an existing file, in the local file system.
+ *
+ * @param configuration launch configuration
+ * @return an absolute path to a file in the local file system
+ * @throws CoreException if unable to retrieve the associated launch
+ * configuration attribute, if unable to resolve any variables, or if the
+ * resolved location does not point to an existing file in the local file
+ * system
+ */
+ public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
+ String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
+ if (location == null) {
+ abort(NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0);
+ } else {
+ String expandedLocation = getStringVariableManager().performStringSubstitution(location);
+ if (expandedLocation == null || expandedLocation.length() == 0) {
+ String msg = NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
+ abort(msg, null, 0);
+ } else {
+ File file = new File(expandedLocation);
+ if (file.isFile()) {
+ return new Path(expandedLocation);
+ }
+
+ String msg = NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
+ abort(msg, null, 0);
+ }
+ }
+ // execution will not reach here
+ return null;
+ }
+
+ /**
+ * Returns a boolean specifying whether or not output should be captured for
+ * the given configuration
+ *
+ * @param configuration the configuration from which the value will be
+ * extracted
+ * @return boolean specifying whether or not output should be captured
+ * @throws CoreException if unable to access the associated attribute
+ */
+ public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
+ return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
+ }
+
+ /**
+ * Expands and returns the working directory attribute of the given launch
+ * configuration. Returns <code>null</code> if a working directory is not
+ * specified. If specified, the working is verified to point to an existing
+ * directory in the local file system.
+ *
+ * @param configuration launch configuration
+ * @return an absolute path to a directory in the local file system, or
+ * <code>null</code> if unspecified
+ * @throws CoreException if unable to retrieve the associated launch
+ * configuration attribute, if unable to resolve any variables, or if the
+ * resolved location does not point to an existing directory in the local
+ * file system
+ */
+ public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
+ String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ if (location != null) {
+ String expandedLocation = getStringVariableManager().performStringSubstitution(location);
+ if (expandedLocation.length() > 0) {
+ File path = new File(expandedLocation);
+ if (path.isDirectory()) {
+ return new Path(expandedLocation);
+ }
+ String msg = NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()});
+ abort(msg, null, 0);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Expands and returns the arguments attribute of the given launch
+ * configuration. Returns <code>null</code> if arguments are not specified.
+ *
+ * @param configuration launch configuration
+ * @return an array of resolved arguments, or <code>null</code> if
+ * unspecified
+ * @throws CoreException if unable to retrieve the associated launch
+ * configuration attribute, or if unable to resolve any variables
+ */
+ public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
+ String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
+ if (args != null) {
+ String expanded = getStringVariableManager().performStringSubstitution(args);
+ return parseStringIntoList(expanded);
+ }
+ return null;
+ }
+
+ private static IStringVariableManager getStringVariableManager() {
+ return VariablesPlugin.getDefault().getStringVariableManager();
+ }
+
+ /**
+ * Returns whether the given launch configuration is enabled. This property
+ * is intended only to apply to external tool builder configurations and
+ * determines whether the project builder will launch the configuration
+ * when it builds.
+ *
+ * @param configuration the configuration for which the enabled state should
+ * be determined.
+ * @return whether the given configuration is enabled to be run when a build occurs.
+ * @throws CoreException if unable to access the associated attribute
+ */
+ public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
+ return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true);
+ }
+
+ /**
+ * Returns the collection of resources for the build scope as specified by the given launch configuration.
+ *
+ * @param configuration launch configuration
+ * @throws CoreException if an exception occurs while retrieving the resources
+ */
+ public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
+ String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
+ if (scope == null) {
+ return null;
+ }
+
+ return RefreshUtil.toResources(scope);
+ }
+
+ /**
+ * Parses the argument text into an array of individual
+ * strings using the space character as the delimiter.
+ * An individual argument containing spaces must have a
+ * double quote (") at the start and end. Two double
+ * quotes together is taken to mean an embedded double
+ * quote in the argument text.
+ *
+ * @param arguments the arguments as one string
+ * @return the array of arguments
+ */
+ public static String[] parseStringIntoList(String arguments) {
+ if (arguments == null || arguments.length() == 0) {
+ return new String[0];
+ }
+ String[] res= DebugPlugin.parseArguments(arguments);
+ return res;
+ }
+ /**
+ * Returns a collection of projects referenced by a build scope attribute.
+ *
+ * @return collection of projects referred to by configuration
+ */
+ public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
+
+ String scope = null;
+ String id = buildScopeId ;
+ if (id == null) {
+ id = IExternalToolConstants.ATTR_BUILD_SCOPE ;
+ }
+ try {
+ scope = configuration.getAttribute(id, (String)null);
+ } catch (CoreException e) {
+ return null;
+ }
+ if (scope == null) {
+ return null;
+ }
+ if (scope.startsWith("${projects:")) { //$NON-NLS-1$
+ String pathString = scope.substring(11, scope.length() - 1);
+ if (pathString.length() > 1) {
+ String[] names = pathString.split(","); //$NON-NLS-1$
+ IProject[] projects = new IProject[names.length];
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ for (int i = 0; i < names.length; i++) {
+ projects[i] = root.getProject(names[i]);
+ }
+ return projects;
+ }
+ } else if (scope.equals("${project}")) { //$NON-NLS-1$
+ if(configuration.getFile()!=null)
+ return new IProject[]{((IResource)configuration.getFile()).getProject()};
+ }
+ return new IProject[0];
+ }
+
+ /**
+ * Whether referenced projects should be considered when building. Only valid
+ * when a set of projects is to be built.
+ *
+ * @param configuration
+ * @return whether referenced projects should be considerd when building
+ * @throws CoreException if unable to access the associated attribute
+ */
+ public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
+ String id = includeReferencedProjectsId;
+ if (id == null) {
+ id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ;
+ }
+ return configuration.getAttribute(id, true);
+ }
+
+ /**
+ * Returns whether the given external builder configuration should build asynchronously.
+ *
+ * @param configuration the configuration
+ * @return whether the configuration is configured to build asynchronously
+ */
+ public static boolean isAsynchronousBuild(ILaunchConfiguration configuration) {
+ boolean launchInBackground= false;
+ try {
+ launchInBackground= configuration.getAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
+ } catch (CoreException ce) {
+ ExternalToolsCore.log(ce);
+ }
+ return launchInBackground;
+ }
+}
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java
new file mode 100644
index 000000000..889fe2b12
--- /dev/null
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.core.externaltools.internal.launchConfigurations;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ExternalToolsProgramMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsProgramMessages";//$NON-NLS-1$
+
+ public static String BackgroundResourceRefresher_0;
+
+ public static String ProgramLaunchDelegate_3;
+ public static String ProgramLaunchDelegate_4;
+
+ public static String ExternalToolsUtil_Location_not_specified_by__0__1;
+ public static String ExternalToolsUtil_invalidLocation__0_;
+ public static String ExternalToolsUtil_invalidDirectory__0_;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, ExternalToolsProgramMessages.class);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties
new file mode 100644
index 000000000..cd07b549a
--- /dev/null
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2000, 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+BackgroundResourceRefresher_0=Refreshing resources...
+
+ProgramLaunchDelegate_Workbench_Closing_1=Workbench Closing
+ProgramLaunchDelegate_The_workbench_is_exiting=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.
+ProgramLaunchDelegate_3=Running {0}...
+ProgramLaunchDelegate_4=An IProcess could not be created for the launch
+
+ProgramMainTab_Select=&Select a program:
+
+ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
+ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
+ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}. \ No newline at end of file
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java
new file mode 100644
index 000000000..635f340fd
--- /dev/null
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Keith Seitz (keiths@redhat.com) - environment variables contribution (Bug 27243)
+ * dakshinamurthy.karra@gmail.com - bug 165371
+ *******************************************************************************/
+package org.eclipse.core.externaltools.internal.launchConfigurations;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.externaltools.internal.IExternalToolConstants;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.RefreshUtil;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Launch delegate for a program.
+ */
+public class ProgramLaunchDelegate extends LaunchConfigurationDelegate {
+
+ /**
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
+ * java.lang.String, org.eclipse.debug.core.ILaunch,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ // resolve location
+ IPath location = ExternalToolsCoreUtil.getLocation(configuration);
+
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ // resolve working directory
+ IPath workingDirectory = ExternalToolsCoreUtil
+ .getWorkingDirectory(configuration);
+
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ // resolve arguments
+ String[] arguments = ExternalToolsCoreUtil.getArguments(configuration);
+
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ int cmdLineLength = 1;
+ if (arguments != null) {
+ cmdLineLength += arguments.length;
+ }
+ String[] cmdLine = new String[cmdLineLength];
+ cmdLine[0] = location.toOSString();
+ if (arguments != null) {
+ System.arraycopy(arguments, 0, cmdLine, 1, arguments.length);
+ }
+
+ File workingDir = null;
+ if (workingDirectory != null) {
+ workingDir = workingDirectory.toFile();
+ }
+
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ String[] envp = DebugPlugin.getDefault().getLaunchManager()
+ .getEnvironment(configuration);
+
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ Process p = DebugPlugin.exec(cmdLine, workingDir, envp);
+ IProcess process = null;
+
+ // add process type to process attributes
+ Map processAttributes = new HashMap();
+ String programName = location.lastSegment();
+ String extension = location.getFileExtension();
+ if (extension != null) {
+ programName = programName.substring(0, programName.length()
+ - (extension.length() + 1));
+ }
+ programName = programName.toLowerCase();
+ processAttributes.put(IProcess.ATTR_PROCESS_TYPE, programName);
+
+ if (p != null) {
+ monitor.beginTask(NLS.bind(
+ ExternalToolsProgramMessages.ProgramLaunchDelegate_3,
+ new String[] { configuration.getName() }),
+ IProgressMonitor.UNKNOWN);
+ process = DebugPlugin.newProcess(launch, p, location.toOSString(),
+ processAttributes);
+ }
+ if (p == null || process == null) {
+ if (p != null)
+ p.destroy();
+ throw new CoreException(new Status(IStatus.ERROR,
+ IExternalToolConstants.PLUGIN_ID,
+ IExternalToolConstants.ERR_INTERNAL_ERROR,
+ ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null));
+ }
+ process.setAttribute(IProcess.ATTR_CMDLINE,
+ generateCommandLine(cmdLine));
+
+// if (launchManager.isLaunchInBackground(configuration)) {
+// // refresh resources after process finishes
+// if (launchManager.getRefreshScope(configuration) != null) {
+// BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
+// configuration, process);
+// refresher.startBackgroundRefresh();
+// }
+// } else {
+ // wait for process to exit
+ while (!process.isTerminated()) {
+ try {
+ if (monitor.isCanceled()) {
+ process.terminate();
+ break;
+ }
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ // refresh resources
+ RefreshUtil.refreshResources(configuration, monitor);
+// }
+ }
+
+ private String generateCommandLine(String[] commandLine) {
+ if (commandLine.length < 1)
+ return ""; //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < commandLine.length; i++) {
+ buf.append(' ');
+ char[] characters = commandLine[i].toCharArray();
+ StringBuffer command = new StringBuffer();
+ boolean containsSpace = false;
+ for (int j = 0; j < characters.length; j++) {
+ char character = characters[j];
+ if (character == '\"') {
+ command.append('\\');
+ } else if (character == ' ') {
+ containsSpace = true;
+ }
+ command.append(character);
+ }
+ if (containsSpace) {
+ buf.append('\"');
+ buf.append(command);
+ buf.append('\"');
+ } else {
+ buf.append(command);
+ }
+ }
+ return buf.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder
+ * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration,
+ String mode) throws CoreException {
+ IProject[] projects = ExternalToolsCoreUtil.getBuildProjects(
+ configuration, null);
+ if (projects == null) {
+ return null;
+ }
+ boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects(
+ configuration, null);
+ if (isRef) {
+ return computeReferencedBuildOrder(projects);
+ }
+ return computeBuildOrder(projects);
+ }
+}

Back to the top