Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/launch
diff options
context:
space:
mode:
authorDavid Inglis2002-08-13 04:05:02 +0000
committerDavid Inglis2002-08-13 04:05:02 +0000
commite55f65995084369987356e128cc72c5b3d8f1599 (patch)
tree020f5657c872cb14628dae275affca30f30b89de /launch
parenta4f0fa4e7e4e3f944bf9ec2811a3927ab15d88d5 (diff)
downloadorg.eclipse.cdt-e55f65995084369987356e128cc72c5b3d8f1599.tar.gz
org.eclipse.cdt-e55f65995084369987356e128cc72c5b3d8f1599.tar.xz
org.eclipse.cdt-e55f65995084369987356e128cc72c5b3d8f1599.zip
new CDT launcher plugin with local launch delegate
Diffstat (limited to 'launch')
-rw-r--r--launch/org.eclipse.cdt.launch/.classpath15
-rw-r--r--launch/org.eclipse.cdt.launch/.cvsignore1
-rw-r--r--launch/org.eclipse.cdt.launch/.project37
-rw-r--r--launch/org.eclipse.cdt.launch/build.properties1
-rw-r--r--launch/org.eclipse.cdt.launch/icons/arguments_tab.gifbin0 -> 108 bytes
-rw-r--r--launch/org.eclipse.cdt.launch/plugin.properties12
-rw-r--r--launch/org.eclipse.cdt.launch/plugin.xml60
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java92
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java328
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CLaunchConfigurationTab.java88
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java24
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java117
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java41
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java405
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java176
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java296
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java394
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java372
18 files changed, 2459 insertions, 0 deletions
diff --git a/launch/org.eclipse.cdt.launch/.classpath b/launch/org.eclipse.cdt.launch/.classpath
new file mode 100644
index 00000000000..06bef26a7a8
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/.classpath
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="src" path="/org.eclipse.core.resources"/>
+ <classpathentry kind="src" path="/org.eclipse.debug.core"/>
+ <classpathentry kind="src" path="/org.eclipse.debug.ui"/>
+ <classpathentry kind="src" path="/org.eclipse.ui"/>
+ <classpathentry kind="src" path="/org.eclipse.cdt.core"/>
+ <classpathentry kind="src" path="/org.eclipse.cdt.ui"/>
+ <classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
+ <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
+ <classpathentry kind="src" path="/org.eclipse.core.boot"/>
+ <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/launch/org.eclipse.cdt.launch/.cvsignore b/launch/org.eclipse.cdt.launch/.cvsignore
new file mode 100644
index 00000000000..ba077a4031a
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/launch/org.eclipse.cdt.launch/.project b/launch/org.eclipse.cdt.launch/.project
new file mode 100644
index 00000000000..607e46b81c4
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/.project
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.launch</name>
+ <comment></comment>
+ <projects>
+ <project>org.eclipse.cdt.core</project>
+ <project>org.eclipse.cdt.debug.core</project>
+ <project>org.eclipse.cdt.ui</project>
+ <project>org.eclipse.core.boot</project>
+ <project>org.eclipse.core.resources</project>
+ <project>org.eclipse.core.runtime</project>
+ <project>org.eclipse.debug.core</project>
+ <project>org.eclipse.debug.ui</project>
+ <project>org.eclipse.ui</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/launch/org.eclipse.cdt.launch/build.properties b/launch/org.eclipse.cdt.launch/build.properties
new file mode 100644
index 00000000000..c95a801c759
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/build.properties
@@ -0,0 +1 @@
+source.launch.jar = src/
diff --git a/launch/org.eclipse.cdt.launch/icons/arguments_tab.gif b/launch/org.eclipse.cdt.launch/icons/arguments_tab.gif
new file mode 100644
index 00000000000..8670a384bd3
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/icons/arguments_tab.gif
Binary files differ
diff --git a/launch/org.eclipse.cdt.launch/plugin.properties b/launch/org.eclipse.cdt.launch/plugin.properties
new file mode 100644
index 00000000000..b19f9ae9a45
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/plugin.properties
@@ -0,0 +1,12 @@
+######################################################################
+# Copyright (c) 2002 QNX Software Systems Ltd. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v0.5
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v05.html
+#
+# Contributors:
+# QNX Software Systems Ltd. - Initial implementation
+######################################################################
+
+LocalCDTLaunch.name= Local C/C++ Application
diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml
new file mode 100644
index 00000000000..880c77c6824
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/plugin.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin
+ id="org.eclipse.cdt.launch"
+ name="CDT Launch Plug-in"
+ version="0.0.1"
+ provider-name="QNX Software Systems Ltd."
+ class="org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin">
+
+ <runtime>
+ <library name="cdtlaunch.jar"/>
+ </runtime>
+ <requires>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.debug.core"/>
+ <import plugin="org.eclipse.debug.ui"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.cdt.core"/>
+ <import plugin="org.eclipse.cdt.ui"/>
+ <import plugin="org.eclipse.cdt.debug.core"/>
+ </requires>
+
+
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ name="%LocalCDTLaunch.name"
+ delegate="org.eclipse.cdt.launch.internal.LocalCLaunchConfigurationDelegate"
+ modes="run,debug"
+ public="true"
+ id="org.eclipse.cdt.launch.localCLaunch">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ icon="icon/localCLaunch.gif"
+ configTypeID="org.eclipse.cdt.launch.LocalCLaunch"
+ id="org.eclipse.cdt.launch.localCLaunchImage">
+ </launchConfigurationTypeImage>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ type="org.eclipse.cdt.launch.localCLaunch"
+ class="org.eclipse.cdt.launch.internal.ui.LocalCLaunchConfigurationTabGroup"
+ id="org.eclipse.cdt.launch.localClaunchConfigurationTabGroup">
+ </launchConfigurationTabGroup>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ label="org.eclipse.cdt.launch.shortcut1"
+ icon="org.eclipse.cdt.launch.shortcut1"
+ modes="run,debug"
+ class="org.eclipse.cdt.launch.LaunchShortcut1"
+ id="org.eclipse.cdt.launch.localCShortcut">
+ </shortcut>
+ </extension>
+
+</plugin>
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java
new file mode 100644
index 00000000000..48cb6f105b5
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ICDTLaunchConfigurationConstants.java
@@ -0,0 +1,92 @@
+package org.eclipse.cdt.launch;
+
+/*
+ * (c) Copyright QNX Software System 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+
+public interface ICDTLaunchConfigurationConstants {
+ /**
+ * Launch configuration attribute key. The value is a name of
+ * a C/C++ project associated with a C/C++ launch configuration.
+ */
+ public static final String ATTR_PROJECT_NAME = LaunchUIPlugin.getUniqueIdentifier() + ".PROJECT_ATTR"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * application a C/C++ launch configuration.
+ */
+ public static final String ATTR_PROGRAM_NAME = LaunchUIPlugin.getUniqueIdentifier() + ".PROGRAM_NAME"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying
+ * application arguments for a C/C++ launch configuration, as they should appear
+ * on the command line.
+ */
+ public static final String ATTR_PROGRAM_ARGUMENTS = LaunchUIPlugin.getUniqueIdentifier() + ".PROGRAM_ARGUMENTS"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a string specifying a
+ * path to the working directory to use when launching a the application.
+ * When unspecified, the working directory is inherited from the current process.
+ * When specified as an absolute path, the path represents a path in the local
+ * file system. When specified as a full path, the path represents a workspace
+ * relative path.
+ */
+ public static final String ATTR_WORKING_DIRECTORY = LaunchUIPlugin.getUniqueIdentifier() + ".WORKING_DIRECTORY"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a boolean specifying
+ * wheather the current enviroment should be inherited when the application
+ * is launched.
+ */
+ public static final String ATTR_PROGRAM_ENVIROMENT_INHERIT = LaunchUIPlugin.getUniqueIdentifier() + ".ENVIRONMENT_INHERIT"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is a Map specifying the
+ * enviroment to use when launching a C/C++ application.
+ */
+ public static final String ATTR_PROGRAM_ENVIROMENT_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".ENVIRONMENT_MAP"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is the debugger id
+ * used when launching a C/C++ application for debug.
+ */
+ public static final String ATTR_CDT_DEBUGGER_ID = LaunchUIPlugin.getUniqueIdentifier() + ".CDT_DEBUGGER"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is the platform string of the launch configuration
+ */
+ public static final String ATTR_CDT_PLATFORM = LaunchUIPlugin.getUniqueIdentifier() + ".CDT_PLATFFORM"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute key. The value is the platform string of the launch configuration
+ */
+ public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".CDT_DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$
+
+ /**
+ * Status code indicating that the Eclipse runtime does not support
+ * launching a program with a working directory. This feature is only
+ * available if Eclipse is run on a 1.3 runtime or higher.
+ * <p>
+ * A status handler may be registered for this error condition,
+ * and should return a Boolean indicating whether the program
+ * should be relaunched with the default working directory.
+ * </p>
+ */
+ public static final int ERR_WORKING_DIRECTORY_NOT_SUPPORTED = 115;
+
+ /**
+ * Status code indicating an unexpected internal error.
+ */
+ public static final int ERR_INTERNAL_ERROR = 150;
+
+ /**
+ * Status code indicating the specified working directory
+ * does not exist.
+ */
+ public static final int ERR_WORKING_DIRECTORY_DOES_NOT_EXIST = 108;
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java
new file mode 100644
index 00000000000..8027f54322e
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java
@@ -0,0 +1,328 @@
+package org.eclipse.cdt.launch.internal;
+
+/*
+ * (c) Copyright QNX Software System 2002.
+ * All Rights Reserved.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.CDebugModel;
+import org.eclipse.cdt.debug.core.ICDebugger;
+import org.eclipse.cdt.debug.core.ICDebuggerManager;
+import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
+import org.eclipse.cdt.debug.core.cdi.ICDISession;
+import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+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.ILaunchManager;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.debug.core.model.IProcess;
+
+/**
+ * Insert the type's description here.
+ * @see ILaunchConfigurationDelegate
+ */
+public class LocalCLaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
+
+ protected String renderDebugTarget(ICDISession session) {
+// String format= "{0} at localhost {1}";
+// return MessageFormat.format(format, new String[] { classToRun, String.valueOf(host) });
+ return "session -- TODO";
+ }
+
+ public static String renderProcessLabel(String[] commandLine) {
+ String format= "{0} ({1})";
+ String timestamp= DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
+ return MessageFormat.format(format, new String[] { commandLine[0], timestamp });
+ }
+
+ protected static String renderCommandLine(String[] commandLine) {
+ if (commandLine.length < 1)
+ return "";
+ StringBuffer buf= new StringBuffer(commandLine[0]);
+ for (int i= 1; i < commandLine.length; i++) {
+ buf.append(' ');
+ buf.append(commandLine[i]);
+ }
+ return buf.toString();
+ }
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
+ throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+
+ monitor.beginTask("Launching Local C Application", IProgressMonitor.UNKNOWN);
+ // check for cancellation
+ if (monitor.isCanceled()) {
+ return;
+ }
+ ICProject cproject = getCProject(configuration);
+ IPath projectPath = Platform.getLocation().append(cproject.getResource().getFullPath());
+ projectPath = projectPath.append(getProgramName(configuration));
+ String arguments[] = getProgramArgumentsArray(configuration);
+ ArrayList command = new ArrayList(1+arguments.length);
+ command.add(projectPath.toOSString());
+ command.addAll(Arrays.asList(arguments));
+
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ ICDebuggerManager dbgmanager = CDebugCorePlugin.getDefault().getDebuggerManager();
+ ICDebugger cdebugger = dbgmanager.createDebugger(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, ""));
+ IFile exe = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(projectPath);
+ ICDISession dsession = cdebugger.createLaunchSession(configuration, exe);
+ ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
+ opt.setArguments(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""));
+ File wd = getWorkingDir(configuration);
+ if ( wd != null ) {
+ opt.setWorkingDirectory(wd.toString());
+ }
+ opt.setEnvironment(getEnvironmentProperty(configuration));
+ ICDITarget dtarget = dsession.getTargets()[0];
+// Process process = dtarget.getProcess();
+// IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel((String [])command.toArray(new String[command.size()])));
+// CDebugModel.newDebugTarget(launch, dsession.getTargets()[0], renderDebugTarget(dsession), iprocess, true, false, false );
+ }
+ else {
+ Process process = exec((String [])command.toArray(new String[command.size()]), getEnvironmentArray(configuration), getWorkingDir(configuration));
+ DebugPlugin.getDefault().newProcess(launch, process, "label");
+ }
+ monitor.done();
+ }
+
+ private String[] getEnvironmentArray(ILaunchConfiguration configuration) {
+// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
+// TODO create env array;
+ return null;
+ }
+
+ private Properties getEnvironmentProperty(ILaunchConfiguration configuration) {
+// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
+ return new Properties();
+ }
+
+
+ protected File getWorkingDir(ILaunchConfiguration config) throws CoreException {
+ String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ if (path == null) {
+ return null;
+ }
+ File dir = new File(path);
+ if (!dir.isDirectory()) {
+ abort("Specified working directory does not exist or is not a directory", null, ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
+ }
+ return dir;
+ }
+
+ /**
+ * 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 void abort(String message, Throwable exception, int code) throws CoreException {
+ throw new CoreException(new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), code, message, exception));
+ }
+
+ /**
+ * Performs a runtime exec on the given command line in the context
+ * of the specified working directory, and returns
+ * the resulting process. If the current runtime does not support the
+ * specification of a working directory, the status handler for error code
+ * <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if the
+ * exec should be re-executed without specifying a working directory.
+ *
+ * @param cmdLine the command line
+ * @param workingDirectory the working directory, or <code>null</code>
+ * @return the resulting process or <code>null</code> if the exec is
+ * cancelled
+ * @see Runtime
+ */
+ protected Process exec(String[] cmdLine, String[] envp, File workingDirectory) throws CoreException {
+ Process p = null;
+ try {
+ if (workingDirectory == null) {
+ p = Runtime.getRuntime().exec(cmdLine, envp);
+ }
+ else {
+ p = Runtime.getRuntime().exec(cmdLine, envp, workingDirectory);
+ }
+ }
+ catch (IOException e) {
+ if (p != null) {
+ p.destroy();
+ }
+ abort("Exception starting process", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ }
+ catch (NoSuchMethodError e) {
+ //attempting launches on 1.2.* - no ability to set working directory
+
+ IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED, "Eclipse runtime does not support working directory", e);
+ IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
+
+ if (handler != null) {
+ Object result = handler.handleStatus(status, this);
+ if (result instanceof Boolean && ((Boolean) result).booleanValue()) {
+ p = exec(cmdLine, envp, null);
+ }
+ }
+ }
+ return p;
+ }
+
+ public ICProject getCProject(ILaunchConfiguration configuration) throws CoreException {
+ String projectName = getCProjectName(configuration);
+ if (projectName != null) {
+ projectName = projectName.trim();
+ if (projectName.length() > 0) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
+ if (cProject != null && cProject.exists()) {
+ return cProject;
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getCProjectName(ILaunchConfiguration configuration) throws CoreException {
+ return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
+ }
+
+ public String getProgramName(ILaunchConfiguration configuration) throws CoreException {
+ return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
+ }
+
+ /**
+ * Returns the program arguments as an array of individual arguments.
+ *
+ * @return the program arguments as an array of individual arguments
+ */
+ public String[] getProgramArgumentsArray(ILaunchConfiguration configuration) throws CoreException {
+ String args = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
+ return parseArguments(args);
+ }
+
+ private static class ArgumentParser {
+ private String fArgs;
+ private int fIndex= 0;
+ private int ch= -1;
+
+ public ArgumentParser(String args) {
+ fArgs= args;
+ }
+
+ public String[] parseArguments() {
+ List v= new ArrayList();
+
+ ch= getNext();
+ while (ch > 0) {
+ while (Character.isWhitespace((char)ch))
+ ch= getNext();
+
+ if (ch == '"') {
+ v.add(parseString());
+ } else {
+ v.add(parseToken());
+ }
+ }
+
+ String[] result= new String[v.size()];
+ v.toArray(result);
+ return result;
+ }
+
+ private int getNext() {
+ if (fIndex < fArgs.length())
+ return fArgs.charAt(fIndex++);
+ return -1;
+ }
+
+ private String parseString() {
+ StringBuffer buf= new StringBuffer();
+ ch= getNext();
+ while (ch > 0 && ch != '"') {
+ if (ch == '\\') {
+ ch= getNext();
+ if (ch != '"') { // Only escape double quotes
+ buf.append('\\');
+ }
+ }
+ if (ch > 0) {
+ buf.append((char)ch);
+ ch= getNext();
+ }
+ }
+
+ ch= getNext();
+
+ return buf.toString();
+ }
+
+ private String parseToken() {
+ StringBuffer buf= new StringBuffer();
+
+ while (ch > 0 && !Character.isWhitespace((char)ch)) {
+ if (ch == '\\') {
+ ch= getNext();
+ if (ch > 0) {
+ if (ch != '"') { // Only escape double quotes
+ buf.append('\\');
+ }
+ buf.append((char)ch);
+ ch= getNext();
+ } else if (ch == -1) { // Don't lose a trailing backslash
+ buf.append('\\');
+ }
+ } else if (ch == '"') {
+ buf.append(parseString());
+ } else {
+ buf.append((char)ch);
+ ch= getNext();
+ }
+ }
+ return buf.toString();
+ }
+ }
+
+ private static String[] parseArguments(String args) {
+ if (args == null)
+ return new String[0];
+ ArgumentParser parser= new ArgumentParser(args);
+ String[] res= parser.parseArguments();
+
+ return res;
+ }
+
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CLaunchConfigurationTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CLaunchConfigurationTab.java
new file mode 100644
index 00000000000..ee8dbcfaaf9
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CLaunchConfigurationTab.java
@@ -0,0 +1,88 @@
+package org.eclipse.cdt.launch.internal.ui;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICProjectDescriptor;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.boot.BootLoader;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
+
+ /**
+ * Returns the current C element context from which to initialize
+ * default settings, or <code>null</code> if none.
+ *
+ * @return C element context.
+ */
+ protected ICElement getContext(ILaunchConfigurationWorkingCopy config) throws CoreException {
+ IWorkbenchPage page = LaunchUIPlugin.getActivePage();
+ if (page != null) {
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ if (!ss.isEmpty()) {
+ Object obj = ss.getFirstElement();
+ if (obj instanceof ICElement) {
+ ICProjectDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(((ICElement)obj).getCProject().getProject());
+ if ( descriptor.getPlatform().equals(getPlatform(config)) )
+ return (ICElement) obj;
+ }
+ if (obj instanceof IResource) {
+ ICElement ce = CoreModel.getDefault().create((IResource) obj);
+ if (ce == null) {
+ IProject pro = ((IResource) obj).getProject();
+ ce = CoreModel.getDefault().create(pro);
+ }
+ if (ce != null) {
+ ICProjectDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
+ if ( descriptor.getPlatform().equals(getPlatform(config)) )
+ return ce;
+ }
+ }
+ }
+ }
+ IEditorPart part = page.getActiveEditor();
+ if (part != null) {
+ IEditorInput input = part.getEditorInput();
+ return (ICElement) input.getAdapter(ICElement.class);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Set the C project attribute based on the ICElement.
+ */
+ protected void initializeCProject(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
+ ICProject cProject = cElement.getCProject();
+ String name = null;
+ if (cProject != null && cProject.exists()) {
+ name = cProject.getElementName();
+ }
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
+
+ }
+
+ protected String getPlatform(ILaunchConfiguration config) throws CoreException {
+ String platform = BootLoader.getOS();
+ return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_PLATFORM, platform);
+ }
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java
new file mode 100644
index 00000000000..df3baf02d5f
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java
@@ -0,0 +1,24 @@
+package org.eclipse.cdt.launch.internal.ui;
+
+import org.eclipse.swt.graphics.Image;
+
+/*
+ * (c) Copyright QN Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+public class LaunchImages {
+ public static String IMG_VIEW_ARGUMENTS_TAB = "";
+ public static String IMG_VIEW_ENVIRONMENT_TAB = "";
+ public static String IMG_VIEW_MAIN_TAB = "";
+ public static String IMG_VIEW_DEBUGGER_TAB = "";
+
+ /**
+ * Method get.
+ * @param string
+ * @return Image
+ */
+ public static Image get(String string) {
+ return null;
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java
new file mode 100644
index 00000000000..53c6578c0ba
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java
@@ -0,0 +1,117 @@
+package org.eclipse.cdt.launch.internal.ui;
+
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.internal.ui.DebugUIMessages;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+public class LaunchUIPlugin extends AbstractUIPlugin {
+
+ /**
+ * Launch UI plug-in instance
+ */
+ private static LaunchUIPlugin fgPlugin;
+
+ /**
+ * Constructor for LaunchUIPlugin.
+ * @param descriptor
+ */
+ public LaunchUIPlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ setDefault(this);
+ }
+/**
+ * Sets the Java Debug UI plug-in instance
+ *
+ * @param plugin the plugin instance
+ */
+ private static void setDefault(LaunchUIPlugin plugin) {
+ fgPlugin = plugin;
+ }
+
+ /**
+ * Returns the Java Debug UI plug-in instance
+ *
+ * @return the Java Debug UI plug-in instance
+ */
+ public static LaunchUIPlugin getDefault() {
+ return fgPlugin;
+ }
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ */
+ public static String getUniqueIdentifier() {
+ if (getDefault() == null) {
+ // If the default instance is not yet initialized,
+ // return a static identifier. This identifier must
+ // match the plugin id defined in plugin.xml
+ return "org.eclipse.jdt.debug.ui"; //$NON-NLS-1$
+ }
+ return getDefault().getDescriptor().getUniqueIdentifier();
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status status to log
+ */
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+ /**
+ * Logs an internal error with the specified message.
+ *
+ * @param message the error message to log
+ */
+ public static void logErrorMessage(String message) {
+ log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
+ }
+
+ /**
+ * Logs an internal error with the specified throwable
+ *
+ * @param e the exception to be logged
+ */
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e)); //$NON-NLS-1$
+ }
+ /**
+ * Returns the active workbench window
+ *
+ * @return the active workbench window
+ */
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ }
+
+ public static IWorkbenchPage getActivePage() {
+ IWorkbenchWindow w = getActiveWorkbenchWindow();
+ if (w != null) {
+ return w.getActivePage();
+ }
+ return null;
+ }
+
+
+ /**
+ * Returns the active workbench shell or <code>null</code> if none
+ *
+ * @return the active workbench shell or <code>null</code> if none
+ */
+ public static Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
+ }
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java
new file mode 100644
index 00000000000..d714e09dbe9
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java
@@ -0,0 +1,41 @@
+package org.eclipse.cdt.launch.internal.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.ui.CArgumentsTab;
+import org.eclipse.cdt.launch.ui.CDebuggerTab;
+import org.eclipse.cdt.launch.ui.CEnvironmentTab;
+import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * Insert the type's description here.
+ * @see AbstractLaunchConfigurationTabGroup
+ */
+public class LocalCLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ /**
+ * Insert the method's description here.
+ * @see AbstractLaunchConfigurationTabGroup#createTabs
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ArrayList tabs = new ArrayList(5);
+
+ tabs.add(new CMainTab());
+ tabs.add(new CArgumentsTab());
+ tabs.add(new CEnvironmentTab());
+ if ( mode.equalsIgnoreCase(ILaunchManager.DEBUG_MODE) ) {
+ tabs.add(new CDebuggerTab() );
+ }
+ tabs.add(new CommonTab());
+
+ setTabs((ILaunchConfigurationTab[])tabs.toArray(new ILaunchConfigurationTab[tabs.size()]));
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java
new file mode 100644
index 00000000000..07e80526edc
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java
@@ -0,0 +1,405 @@
+package org.eclipse.cdt.launch.internal.ui;
+import java.io.File;
+
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.resources.IContainer;
+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.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+/**
+ * A control for setting the working directory associated with a launch
+ * configuration.
+ */
+public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
+
+ // Working directory UI widgets
+ protected Label fWorkingDirLabel;
+
+ // Local directory
+ protected Button fLocalDirButton;
+ protected Text fWorkingDirText;
+ protected Button fWorkingDirBrowseButton;
+
+
+ // Workspace directory
+ protected Button fWorkspaceDirButton;
+ protected Text fWorkspaceDirText;
+ protected Button fWorkspaceDirBrowseButton;
+
+ // use default button
+ protected Button fUseDefaultWorkingDirButton;
+
+ protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ /**
+ * The last launch config this tab was initialized from
+ */
+ protected ILaunchConfiguration fLaunchConfiguration;
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+
+ Composite workingDirComp = new Composite(parent, SWT.NONE);
+// WorkbenchHelp.setHelp(workingDirComp, IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK);;
+ GridLayout workingDirLayout = new GridLayout();
+ workingDirLayout.numColumns = 3;
+ workingDirLayout.marginHeight = 0;
+ workingDirLayout.marginWidth = 0;
+ workingDirComp.setLayout(workingDirLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ workingDirComp.setLayoutData(gd);
+ setControl(workingDirComp);
+
+ fWorkingDirLabel = new Label(workingDirComp, SWT.NONE);
+ fWorkingDirLabel.setText("Wor&king directory:");
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ fWorkingDirLabel.setLayoutData(gd);
+
+ fLocalDirButton = createRadioButton(workingDirComp, "&Local directory");
+ fLocalDirButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleLocationButtonSelected();
+ }
+ });
+
+ fWorkingDirText = new Text(workingDirComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fWorkingDirText.setLayoutData(gd);
+ fWorkingDirText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fWorkingDirBrowseButton = createPushButton(workingDirComp, "&Browse", null);
+ fWorkingDirBrowseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleWorkingDirBrowseButtonSelected();
+ }
+ });
+
+ fWorkspaceDirButton = createRadioButton(workingDirComp, "Works&pace");
+ fWorkspaceDirButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleLocationButtonSelected();
+ }
+ });
+
+ fWorkspaceDirText = new Text(workingDirComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fWorkspaceDirText.setLayoutData(gd);
+ fWorkspaceDirText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fWorkspaceDirBrowseButton = createPushButton(workingDirComp, "B&rowse...", null);
+ fWorkspaceDirBrowseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleWorkspaceDirBrowseButtonSelected();
+ }
+ });
+
+ fUseDefaultWorkingDirButton = new Button(workingDirComp,SWT.CHECK);
+ fUseDefaultWorkingDirButton.setText("Use de&fault working directory");
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ fUseDefaultWorkingDirButton.setLayoutData(gd);
+ fUseDefaultWorkingDirButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleUseDefaultWorkingDirButtonSelected();
+ }
+ });
+
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * Show a dialog that lets the user select a working directory
+ */
+ protected void handleWorkingDirBrowseButtonSelected() {
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setMessage("Select a &working directory for the launch configuration");
+ String currentWorkingDir = fWorkingDirText.getText();
+ if (!currentWorkingDir.trim().equals(EMPTY_STRING)) {
+ File path = new File(currentWorkingDir);
+ if (path.exists()) {
+ dialog.setFilterPath(currentWorkingDir);
+ }
+ }
+
+ String selectedDirectory = dialog.open();
+ if (selectedDirectory != null) {
+ fWorkingDirText.setText(selectedDirectory);
+ }
+ }
+
+ /**
+ * Show a dialog that lets the user select a working directory from
+ * the workspace
+ */
+ protected void handleWorkspaceDirBrowseButtonSelected() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),
+ ResourcesPlugin.getWorkspace().getRoot(),
+ false,
+ "Select a &workspace relative working directory");
+
+ IContainer currentContainer = getContainer();
+ if (currentContainer != null) {
+ IPath path = currentContainer.getFullPath();
+ dialog.setInitialSelections(new Object[] {path});
+ }
+
+ dialog.showClosedProjects(false);
+ dialog.open();
+ Object[] results = dialog.getResult();
+ if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
+ IPath path = (IPath)results[0];
+ String containerName = path.makeRelative().toString();
+ fWorkspaceDirText.setText(containerName);
+ }
+ }
+
+ /**
+ * Returns the selected workspace container,or <code>null</code>
+ */
+ protected IContainer getContainer() {
+ IResource res = getResource();
+ if (res instanceof IContainer) {
+ return (IContainer)res;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the selected workspace resource, or <code>null</code>
+ */
+ protected IResource getResource() {
+ IPath path = new Path(fWorkspaceDirText.getText());
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ return root.findMember(path);
+ }
+
+ /**
+ * The "local directory" or "workspace directory" button has been selected.
+ */
+ protected void handleLocationButtonSelected() {
+ if (!isDefaultWorkingDirectory()) {
+ boolean local = isLocalWorkingDirectory();
+ fWorkingDirText.setEnabled(local);
+ fWorkingDirBrowseButton.setEnabled(local);
+ fWorkspaceDirText.setEnabled(!local);
+ fWorkspaceDirBrowseButton.setEnabled(!local);
+ }
+ updateLaunchConfigurationDialog();
+ }
+
+ /**
+ * The default working dir check box has been toggled.
+ */
+ protected void handleUseDefaultWorkingDirButtonSelected() {
+ if (isDefaultWorkingDirectory()) {
+ setDefaultWorkingDir();
+ fLocalDirButton.setEnabled(false);
+ fWorkingDirText.setEnabled(false);
+ fWorkingDirBrowseButton.setEnabled(false);
+ fWorkspaceDirButton.setEnabled(false);
+ fWorkspaceDirText.setEnabled(false);
+ fWorkspaceDirBrowseButton.setEnabled(false);
+ } else {
+ fLocalDirButton.setEnabled(true);
+ fWorkspaceDirButton.setEnabled(true);
+ handleLocationButtonSelected();
+ }
+ }
+
+ /**
+ * Sets the default working directory
+ */
+ protected void setDefaultWorkingDir() {
+ ILaunchConfiguration config = getLaunchConfiguration();
+ if (config != null) {
+// IJavaProject javaProject = JavaRuntime.getJavaProject(config);
+ Object cProject = null;
+ if (cProject != null) {
+// fWorkspaceDirText.setText(cProject.getPath().makeRelative().toOSString());
+ fLocalDirButton.setSelection(false);
+ fWorkspaceDirButton.setSelection(true);
+ return;
+ }
+ }
+
+ fWorkingDirText.setText(System.getProperty("user.dir"));
+ fLocalDirButton.setSelection(true);
+ fWorkspaceDirButton.setSelection(false);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration config) {
+
+ setErrorMessage(null);
+ setMessage(null);
+
+ if (isLocalWorkingDirectory()) {
+ String workingDirPath = fWorkingDirText.getText().trim();
+ if (workingDirPath.length() > 0) {
+ File dir = new File(workingDirPath);
+ if (!dir.exists()) {
+ setErrorMessage("Working directory does not exist");
+ return false;
+ }
+ if (!dir.isDirectory()) {
+ setErrorMessage("Working directory is not a directory_11");
+ return false;
+ }
+ }
+ } else {
+ if (getContainer() == null) {
+ setErrorMessage("Specified project or folder does not exist.");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Defaults are empty.
+ *
+ * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ setLaunchConfiguration(configuration);
+ try {
+ String wd = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ fWorkspaceDirText.setText(EMPTY_STRING);
+ fWorkingDirText.setText(EMPTY_STRING);
+ if (wd == null) {
+ fUseDefaultWorkingDirButton.setSelection(true);
+ } else {
+ IPath path = new Path(wd);
+ if (path.isAbsolute()) {
+ fWorkingDirText.setText(wd);
+ fLocalDirButton.setSelection(true);
+ fWorkspaceDirButton.setSelection(false);
+ } else {
+ fWorkspaceDirText.setText(wd);
+ fWorkspaceDirButton.setSelection(true);
+ fLocalDirButton.setSelection(false);
+ }
+ fUseDefaultWorkingDirButton.setSelection(false);
+ }
+ handleUseDefaultWorkingDirButtonSelected();
+ } catch (CoreException e) {
+ setErrorMessage("Exception occurred reading configuration " + e.getStatus().getMessage());
+ LaunchUIPlugin.log(e);
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ String wd = null;
+ if (!isDefaultWorkingDirectory()) {
+ if (isLocalWorkingDirectory()) {
+ wd = getAttributeValueFrom(fWorkingDirText);
+ } else {
+ IPath path = new Path(fWorkspaceDirText.getText());
+ path = path.makeRelative();
+ wd = path.toString();
+ }
+ }
+ configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd);
+ }
+
+ /**
+ * Retuns the string in the text widget, or <code>null</code> if empty.
+ *
+ * @return text or <code>null</code>
+ */
+ protected String getAttributeValueFrom(Text text) {
+ String content = text.getText().trim();
+ if (content.length() > 0) {
+ return content;
+ }
+ return null;
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Working Directory";
+ }
+
+ /**
+ * Returns whether the default working directory is to be used
+ */
+ protected boolean isDefaultWorkingDirectory() {
+ return fUseDefaultWorkingDirButton.getSelection();
+ }
+
+ /**
+ * Returns whether the working directory is local
+ */
+ protected boolean isLocalWorkingDirectory() {
+ return fLocalDirButton.getSelection();
+ }
+
+ /**
+ * Sets the java project currently specified by the
+ * given launch config, if any.
+ */
+ protected void setLaunchConfiguration(ILaunchConfiguration config) {
+ fLaunchConfiguration = config;
+ }
+
+ /**
+ * Returns the current java project context
+ */
+ protected ILaunchConfiguration getLaunchConfiguration() {
+ return fLaunchConfiguration;
+ }
+
+}
+
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java
new file mode 100644
index 00000000000..e493207e6f9
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java
@@ -0,0 +1,176 @@
+package org.eclipse.cdt.launch.ui;
+
+/*
+ * (c) Copyright QNX Software System 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
+import org.eclipse.cdt.launch.internal.ui.LaunchImages;
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+import org.eclipse.cdt.launch.internal.ui.WorkingDirectoryBlock;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A launch configuration tab that displays and edits program arguments,
+ * and working directory launch configuration attributes.
+ * <p>
+ * This class may be instantiated. This class is not intended to be subclassed.
+ * </p>
+ */
+public class CArgumentsTab extends CLaunchConfigurationTab {
+
+ // Program arguments UI widgets
+ protected Label fPrgmArgumentsLabel;
+ protected Text fPrgmArgumentsText;
+
+ // Working directory
+ protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock();
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayout topLayout = new GridLayout();
+ comp.setLayout(topLayout);
+ GridData gd;
+
+ createVerticalSpacer(comp, 1);
+
+ fPrgmArgumentsLabel = new Label(comp, SWT.NONE);
+ fPrgmArgumentsLabel.setText("C/C++ Program Arguments:");
+ fPrgmArgumentsText = new Text(comp, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 40;
+ fPrgmArgumentsText.setLayoutData(gd);
+ fPrgmArgumentsText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ createVerticalSpacer(comp, 1);
+
+ fWorkingDirectoryBlock.createControl(comp);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration config) {
+ return fWorkingDirectoryBlock.isValid(config);
+ }
+
+ /**
+ * Defaults are empty.
+ *
+ * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ fPrgmArgumentsText.setText(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "")); //$NON-NLS-1$
+ fWorkingDirectoryBlock.initializeFrom(configuration);
+ }
+ catch (CoreException e) {
+ setErrorMessage("Exception occurred reading configuration " + e.getStatus().getMessage());
+ LaunchUIPlugin.log(e);
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+ getAttributeValueFrom(fPrgmArgumentsText));
+ fWorkingDirectoryBlock.performApply(configuration);
+ }
+
+ /**
+ * Retuns the string in the text widget, or <code>null</code> if empty.
+ *
+ * @return text or <code>null</code>
+ */
+ protected String getAttributeValueFrom(Text text) {
+ String content = text.getText().trim();
+ if (content.length() > 0) {
+ return content;
+ }
+ return null;
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Arguments";
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#setLaunchConfigurationDialog(ILaunchConfigurationDialog)
+ */
+ public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) {
+ super.setLaunchConfigurationDialog(dialog);
+ fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog);
+ }
+ /**
+ * @see ILaunchConfigurationTab#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ String m = super.getErrorMessage();
+ if (m == null) {
+ return fWorkingDirectoryBlock.getErrorMessage();
+ }
+ return m;
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getMessage()
+ */
+ public String getMessage() {
+ String m = super.getMessage();
+ if (m == null) {
+ return fWorkingDirectoryBlock.getMessage();
+ }
+ return m;
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB);
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
new file mode 100644
index 00000000000..220de56efc6
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
@@ -0,0 +1,296 @@
+/*
+ * (c) Copyright QNX Software System Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.launch.ui;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.ICDebuggerInfo;
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
+import org.eclipse.cdt.launch.internal.ui.LaunchImages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import sun.awt.windows.ModalityListener;
+
+public class CDebuggerTab extends CLaunchConfigurationTab {
+ ArrayList fDinfo;
+ int fDindex;
+ Combo fDlist;
+
+ // Dynamic Debugger UI widgets
+ protected ILaunchConfigurationTab fDynamicTab;
+ protected Composite fDynamicTabHolder;
+
+ protected ILaunchConfigurationWorkingCopy fWorkingCopy;
+ protected ILaunchConfiguration fLaunchConfiguration;
+
+
+
+ public void createControl(Composite parent) {
+ Composite comp= new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayout topLayout = new GridLayout(2, false);
+ comp.setLayout(topLayout);
+ Label dlabel = new Label(comp, SWT.NONE);
+ dlabel.setText("Debugger:");
+ fDlist = new Combo(comp, SWT.DROP_DOWN|SWT.READ_ONLY);
+ fDlist.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleDebuggerComboBoxModified();
+ }
+ });
+ Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ debuggerGroup.setLayoutData(gd);
+ debuggerGroup.setText("Debugger Options");
+ setDynamicTabHolder(new Composite(debuggerGroup, SWT.NONE));
+ GridLayout tabHolderLayout = new GridLayout();
+ tabHolderLayout.marginHeight= 0;
+ tabHolderLayout.marginWidth= 0;
+ tabHolderLayout.numColumns = 1;
+ getDynamicTabHolder().setLayout(tabHolderLayout);
+ gd = new GridData(GridData.FILL_BOTH);
+ getDynamicTabHolder().setLayoutData(gd);
+
+ }
+
+ protected void setDynamicTabHolder(Composite tabHolder) {
+ this.fDynamicTabHolder = tabHolder;
+ }
+
+ protected Composite getDynamicTabHolder() {
+ return fDynamicTabHolder;
+ }
+
+ protected void setDynamicTab(ILaunchConfigurationTab tab) {
+ fDynamicTab = tab;
+ }
+
+ protected ILaunchConfigurationTab getDynamicTab() {
+ return fDynamicTab;
+ }
+
+
+ /**
+ * Notification that the user changed the selection in the JRE combo box.
+ */
+ protected void handleDebuggerComboBoxModified() {
+ loadDynamicDebugArea();
+
+ // always set the newly created area with defaults
+ ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationWorkingCopy();
+ if (getDynamicTab() == null) {
+ // remove any VM specfic args from the config
+ if (wc == null) {
+ if (getLaunchConfiguration().isWorkingCopy()) {
+ wc = (ILaunchConfigurationWorkingCopy)getLaunchConfiguration();
+ }
+ }
+ if (wc != null) {
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
+ }
+ } else {
+ if (wc == null) {
+ try {
+ if (getLaunchConfiguration().isWorkingCopy()) {
+ // get a fresh copy to work on
+ wc = ((ILaunchConfigurationWorkingCopy)getLaunchConfiguration()).getOriginal().getWorkingCopy();
+ } else {
+ wc = getLaunchConfiguration().getWorkingCopy();
+ }
+ } catch (CoreException e) {
+ return;
+ }
+ }
+ getDynamicTab().setDefaults(wc);
+ getDynamicTab().initializeFrom(wc);
+ }
+
+ updateLaunchConfigurationDialog();
+ }
+
+ protected void loadDebuggerComboBox(ILaunchConfiguration config) {
+ ICDebuggerInfo[] debuggerInfo = null;
+ if ( fDinfo != null ) {
+ fDinfo.clear();
+ }
+ fDlist.removeAll();
+ try {
+ debuggerInfo = CDebugCorePlugin.getDefault().getDebuggerManager().queryDebuggers(getPlatform(config));
+ }
+ catch (CoreException e) {
+ return;
+ }
+ fDinfo = new ArrayList(debuggerInfo.length);
+ for( int i = 0; i < debuggerInfo.length; i++ ) {
+ fDinfo.add(debuggerInfo[i]);
+ fDlist.add(debuggerInfo[i].getName());
+ }
+ }
+
+ protected void setSelection(String id) {
+ for (int i = 0; i < fDinfo.size(); i++ ) {
+ ICDebuggerInfo dinfo = (ICDebuggerInfo) fDinfo.get(i);
+ if ( dinfo != null && dinfo.getID().equals(id) ) {
+ fDlist.select(i);
+ return;
+ }
+ }
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ setLaunchConfigurationWorkingCopy(config);
+ loadDebuggerComboBox(config);
+ if ( fDinfo.size() > 0 ) {
+ ICDebuggerInfo info = (ICDebuggerInfo) fDinfo.get(0);
+ if ( info != null ) {
+ setSelection(info.getID());
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, info.getID());
+ }
+ }
+ ILaunchConfigurationTab dynamicTab = getDynamicTab();
+ if (dynamicTab != null) {
+ dynamicTab.setDefaults(config);
+ }
+ }
+
+ public void initializeFrom(ILaunchConfiguration config) {
+ String id;
+ setLaunchConfiguration(config);
+ loadDebuggerComboBox(config);
+ try {
+ id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, "");
+ }
+ catch (CoreException e) {
+ return;
+ }
+ setSelection(id);
+ ILaunchConfigurationTab dynamicTab = getDynamicTab();
+ if (dynamicTab != null) {
+ dynamicTab.initializeFrom(config);
+ }
+
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ if ( isValid(config) ) {
+ ICDebuggerInfo dinfo = (ICDebuggerInfo)fDinfo.get(fDlist.getSelectionIndex());
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, dinfo.getID() );
+ ILaunchConfigurationTab dynamicTab = getDynamicTab();
+ if (dynamicTab == null) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
+ } else {
+ dynamicTab.performApply(config);
+ }
+ }
+ }
+
+ public boolean isValid(ILaunchConfiguration config) {
+ setErrorMessage(null);
+ setMessage(null);
+
+ if ( fDlist.getSelectionIndex() == -1 ) {
+ setErrorMessage("No debugger avalible");
+ return false;
+ }
+
+ ILaunchConfigurationTab dynamicTab = getDynamicTab();
+ if (dynamicTab != null) {
+ return dynamicTab.isValid(config);
+ }
+ return true;
+ }
+
+ /**
+ * Return the class that implements <code>ILaunchConfigurationTab</code>
+ * that is registered against the install type of the currently selected VM.
+ */
+ protected ILaunchConfigurationTab getTabForCurrentDebugger() {
+ int selectedIndex = fDlist.getSelectionIndex();
+ if (selectedIndex > 0) {
+ }
+ return null;
+ }
+
+ /**
+ * Show the contributed piece of UI that was registered for the install type
+ * of the currently selected VM.
+ */
+ protected void loadDynamicDebugArea() {
+ // Dispose of any current child widgets in the tab holder area
+ Control[] children = getDynamicTabHolder().getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].dispose();
+ }
+
+ // Retrieve the dynamic UI for the current JRE
+ setDynamicTab(getTabForCurrentDebugger());
+ if (getDynamicTab() == null) {
+ return;
+ }
+
+ // Ask the dynamic UI to create its Control
+ getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
+ getDynamicTab().createControl(getDynamicTabHolder());
+ getDynamicTabHolder().layout();
+ }
+
+ /**
+ * Overridden here so that any error message in the dynamic UI gets returned.
+ *
+ * @see ILaunchConfigurationTab#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ ILaunchConfigurationTab tab = getDynamicTab();
+ if ((super.getErrorMessage() != null) || (tab == null)) {
+ return super.getErrorMessage();
+ } else {
+ return tab.getErrorMessage();
+ }
+ }
+
+ protected void setLaunchConfigurationWorkingCopy(ILaunchConfigurationWorkingCopy workingCopy) {
+ fWorkingCopy = workingCopy;
+ }
+
+ protected ILaunchConfiguration getLaunchConfiguration() {
+ return fLaunchConfiguration;
+ }
+
+ protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
+ fLaunchConfiguration = launchConfiguration;
+ }
+
+ protected ILaunchConfigurationWorkingCopy getLaunchConfigurationWorkingCopy() {
+ return fWorkingCopy;
+ }
+
+ public String getName() {
+ return "Debugger";
+ }
+
+ public Image getImage() {
+ return LaunchImages.get(LaunchImages.IMG_VIEW_DEBUGGER_TAB);
+ }
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java
new file mode 100644
index 00000000000..ac5a5f6bd05
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java
@@ -0,0 +1,394 @@
+package org.eclipse.cdt.launch.ui;
+
+/*
+ * (c) Copyright QNX Software System 2002.
+ * All Rights Reserved.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
+import org.eclipse.cdt.launch.internal.ui.LaunchImages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+public class CEnvironmentTab extends CLaunchConfigurationTab {
+
+ protected Properties fElements;
+
+ private Composite fControl;
+ protected TableViewer fVariableList;
+ protected Button fBtnNew;
+ protected Button fBtnEdit;
+ protected Button fBtnRemove;
+
+ class SimpleSorter extends ViewerSorter {
+ public boolean isSorterProperty(Object element, Object property) {
+ return true;
+ }
+ }
+
+ class ElementsContentProvider implements IStructuredContentProvider {
+ Object input = null;
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object parent) {
+ return fElements.entrySet().toArray();
+ }
+ }
+
+ class ElementsLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element != null && element instanceof Map.Entry) {
+ return (columnIndex == 0) ? ((Map.Entry) element).getKey().toString() : ((Map.Entry) element).getValue().toString();
+ }
+ return null;
+ }
+ }
+
+ class EntryDialog extends Dialog {
+ private String fName;
+ private String fValue;
+ private boolean fEdit = false;
+
+ private Button fBtnOk = null;
+ private Button fBtnCancel = null;
+ private Text fTextName = null;
+ private Text fTextValue = null;
+
+ public EntryDialog(String name, String value, boolean edit) {
+ super(CEnvironmentTab.this.getControl().getShell());
+ fName = name;
+ fValue = value;
+ fEdit = edit;
+ }
+
+ protected Control createContents(Composite parent) {
+ Control result = super.createContents(parent);
+ updateButtonsState();
+ return result;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ String title = (fEdit) ? "Edit Variable" : "New Variable";
+ shell.setText(title);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth= 5;
+ layout.numColumns= 2;
+ composite.setLayout(layout);
+
+ GC gc = new GC(composite);
+ gc.setFont(composite.getFont());
+ FontMetrics metrics= gc.getFontMetrics();
+ gc.dispose();
+ int fieldWidthHint= convertWidthInCharsToPixels(metrics, 50);
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Name:");
+ fTextName = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.widthHint = fieldWidthHint;
+ fTextName.setLayoutData(gd);
+ label = new Label(composite, SWT.NONE);
+ label.setText("Value:");
+ fTextValue = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.widthHint = fieldWidthHint;
+ fTextValue.setLayoutData(gd);
+ fTextName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateButtonsState();
+ }
+ });
+ fTextValue.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateButtonsState();
+ }
+ });
+ fTextName.setText(fName);
+ fTextValue.setText(fValue);
+
+ return composite;
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ fBtnOk = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ fBtnCancel = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ private void updateButtonsState() {
+ if (fBtnOk != null)
+ fBtnOk.setEnabled(fTextName.getText().trim().length() > 0);
+ }
+
+ protected String getName() {
+ return fName;
+ }
+
+ protected String getValue() {
+ return fValue;
+ }
+
+ protected void okPressed() {
+ fName = fTextName.getText().trim();
+ fValue = fTextValue.getText().trim();
+ setReturnCode(OK);
+ close();
+ }
+ }
+
+ public void createControl(Composite parent) {
+ fElements = new Properties();
+ Composite control = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(2, false);
+
+ createVerticalSpacer(control, 2);
+
+ control.setLayout(gl);
+ createVariableList(control);
+ createButtons(control);
+ setControl(control);
+ fVariableList.setInput(fElements);
+ fVariableList.getTable().setFocus();
+ updateButtons();
+ }
+
+ public void set(String env) {
+ fElements.clear();
+ ByteArrayInputStream input = new ByteArrayInputStream(env.getBytes());
+ try {
+ fElements.load(input);
+ }
+ catch (IOException e) {
+ }
+
+ fVariableList.refresh();
+ fVariableList.getTable().setFocus();
+ if (fVariableList.getTable().getItemCount() > 0)
+ fVariableList.getTable().setSelection(0);
+ }
+
+ public String get() {
+ String result = new String();
+ Object[] entries = fElements.entrySet().toArray();
+ for (int i = 0; i < entries.length; ++i)
+ result += entries[i].toString() + '\n';
+ return result;
+ }
+
+ public Properties getProperties() {
+ return fElements;
+ }
+
+ public Object[] toArray() {
+ return fElements.entrySet().toArray();
+ }
+
+ private void createVariableList(Composite parent) {
+ fVariableList = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ fVariableList.setContentProvider(new ElementsContentProvider());
+ fVariableList.setLabelProvider(new ElementsLabelProvider());
+ fVariableList.setSorter(new SimpleSorter());
+
+ Table table = fVariableList.getTable();
+
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
+ gd.grabExcessVerticalSpace = true;
+ gd.grabExcessHorizontalSpace = true;
+ table.setLayoutData(gd);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn column1 = new TableColumn(table, SWT.NULL);
+ column1.setText("Name");
+ tableLayout.addColumnData(new ColumnWeightData(30));
+
+ TableColumn column2 = new TableColumn(table, SWT.NULL);
+ column2.setText("Value");
+ tableLayout.addColumnData(new ColumnWeightData(30));
+
+ fVariableList.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ updateButtons();
+ }
+ });
+
+ fVariableList.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent e) {
+ elementDoubleClicked((IStructuredSelection) e.getSelection());
+ }
+ });
+ }
+
+ private void createButtons(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ composite.setLayout(new GridLayout(1, true));
+ fBtnNew = new Button(composite, SWT.NONE);
+ fBtnNew.setText("New...");
+ fBtnNew.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fBtnNew.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ newEntry();
+ }
+ });
+ fBtnEdit = new Button(composite, SWT.NONE);
+ fBtnEdit.setText("Edit...");
+ fBtnEdit.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fBtnEdit.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ edit();
+ }
+ });
+ fBtnRemove = new Button(composite, SWT.NONE);
+ fBtnRemove.setText("Remove");
+ fBtnRemove.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fBtnRemove.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ remove();
+ }
+ });
+ }
+
+ private void updateButtons() {
+ IStructuredSelection selection = (IStructuredSelection) fVariableList.getSelection();
+ fBtnEdit.setEnabled(selection.size() == 1);
+ fBtnRemove.setEnabled(selection.size() > 0);
+ }
+
+ private void elementDoubleClicked(IStructuredSelection selection) {
+ if (selection.size() != 1)
+ return;
+ doEdit((Map.Entry) selection.getFirstElement());
+ }
+
+ private void newEntry() {
+ EntryDialog dialog = new EntryDialog(new String(), new String(), false);
+ if (dialog.open() == dialog.OK) {
+ fElements.setProperty(dialog.getName(), dialog.getValue());
+ fVariableList.refresh();
+ }
+ updateButtons();
+ }
+
+ private void edit() {
+ IStructuredSelection selection = (IStructuredSelection) fVariableList.getSelection();
+ doEdit((Map.Entry) selection.getFirstElement());
+ }
+
+ private void doEdit(Map.Entry entry) {
+ EntryDialog dialog = new EntryDialog(entry.getKey().toString(), entry.getValue().toString(), true);
+ if (dialog.open() == dialog.OK) {
+ fElements.remove(entry.getKey());
+ fElements.setProperty(dialog.getName(), dialog.getValue());
+ fVariableList.refresh();
+ }
+ updateButtons();
+ }
+
+ private void remove() {
+ IStructuredSelection selection = (IStructuredSelection) fVariableList.getSelection();
+ Object[] elements = selection.toArray();
+ for (int i = 0; i < elements.length; ++i)
+ fElements.remove(((Map.Entry) elements[i]).getKey());
+ fVariableList.refresh();
+ updateButtons();
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_INHERIT, true);
+ }
+
+ public void initializeFrom(ILaunchConfiguration config) {
+ try {
+ Map env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
+ if ( env != null ) {
+ fElements.putAll(env);
+ fVariableList.refresh();
+ updateButtons();
+ }
+// config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_INHERIT, true);
+ } catch ( CoreException e ) {
+ }
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, fElements);
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_INHERIT, true);
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Enviroment";
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return LaunchImages.get(LaunchImages.IMG_VIEW_ENVIRONMENT_TAB);
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
new file mode 100644
index 00000000000..c7b3ad4c124
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
@@ -0,0 +1,372 @@
+package org.eclipse.cdt.launch.ui;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.FileReader;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICProjectDescriptor;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ICRoot;
+import org.eclipse.cdt.internal.ui.CElementLabelProvider;
+import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
+import org.eclipse.cdt.launch.internal.ui.LaunchImages;
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+import org.eclipse.core.resources.IProject;
+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.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.FilteredList;
+
+/**
+ * A launch configuration tab that displays and edits project and
+ * main type name launch configuration attributes.
+ * <p>
+ * This class may be instantiated. This class is not intended to be subclassed.
+ * </p>
+ * @since 2.0
+ */
+
+public class CMainTab extends CLaunchConfigurationTab {
+
+ // Project UI widgets
+ protected Label fProjLabel;
+ protected Text fProjText;
+ protected Button fProjButton;
+
+ // Main class UI widgets
+ protected Label fProgLabel;
+ protected Text fProgText;
+ protected Button fSearchButton;
+
+ protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ private String filterPlatform = EMPTY_STRING;
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ // WorkbenchHelp.setHelp(getControl(), IJavaDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
+ GridLayout topLayout = new GridLayout();
+ comp.setLayout(topLayout);
+
+ createVerticalSpacer(comp, 1);
+
+ Composite projComp = new Composite(comp, SWT.NONE);
+ GridLayout projLayout = new GridLayout();
+ projLayout.numColumns = 2;
+ projLayout.marginHeight = 0;
+ projLayout.marginWidth = 0;
+ projComp.setLayout(projLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ projComp.setLayoutData(gd);
+
+ fProjLabel = new Label(projComp, SWT.NONE);
+ fProjLabel.setText("&Project:");
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ fProjLabel.setLayoutData(gd);
+
+ fProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fProjText.setLayoutData(gd);
+ fProjText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fProjButton = createPushButton(projComp, "&Browse...", null);
+ fProjButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleProjectButtonSelected();
+ }
+ });
+
+ createVerticalSpacer(comp, 1);
+
+ Composite mainComp = new Composite(comp, SWT.NONE);
+ GridLayout mainLayout = new GridLayout();
+ mainLayout.numColumns = 2;
+ mainLayout.marginHeight = 0;
+ mainLayout.marginWidth = 0;
+ mainComp.setLayout(mainLayout);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ mainComp.setLayoutData(gd);
+ fProgLabel = new Label(mainComp, SWT.NONE);
+ fProgLabel.setText("C/C++ Application:");
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ fProgLabel.setLayoutData(gd);
+ fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fProgText.setLayoutData(gd);
+ fProgText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ fSearchButton = createPushButton(mainComp, "Searc&h...", null);
+ fSearchButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleSearchButtonSelected();
+ }
+ });
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration config) {
+ try {
+ filterPlatform = getPlatform(config);
+ }
+ catch (CoreException e) {
+ }
+ updateProjectFromConfig(config);
+ updateProgramFromConfig(config);
+ }
+
+ protected void updateProjectFromConfig(ILaunchConfiguration config) {
+ String projectName = EMPTY_STRING;
+ try {
+ projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
+ }
+ catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+ fProjText.setText(projectName);
+ }
+
+ protected void updateProgramFromConfig(ILaunchConfiguration config) {
+ String programName = EMPTY_STRING;
+ try {
+ programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
+ }
+ catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+ fProgText.setText(programName);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) fProjText.getText());
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) fProgText.getText());
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * Show a dialog that lists all main types
+ */
+ protected void handleSearchButtonSelected() {
+ }
+
+ /**
+ * Show a dialog that lets the user select a project. This in turn provides
+ * context for the main type, allowing the user to key a main type name, or
+ * constraining the search for main types to the specified project.
+ */
+ protected void handleProjectButtonSelected() {
+ ICProject project = chooseCProject();
+ if (project == null) {
+ return;
+ }
+
+ String projectName = project.getElementName();
+ fProjText.setText(projectName);
+ }
+
+ /**
+ * Realize a C Project selection dialog and return the first selected project,
+ * or null if there was none.
+ */
+ protected ICProject chooseCProject() {
+ ICProject[] projects;
+ projects = getCProjects();
+
+ ILabelProvider labelProvider = new CElementLabelProvider();
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setTitle("Project Selection");
+ dialog.setMessage("Choose a &project to constrain the search for a program");
+ dialog.setElements(projects);
+
+ ICProject cProject = getCProject();
+ if (cProject != null) {
+ dialog.setInitialSelections(new Object[] { cProject });
+ }
+ if (dialog.open() == dialog.OK) {
+ return (ICProject) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ /**
+ * Return an array a ICProject whose platform match that of the runtime env.
+ **/
+
+ protected ICProject[] getCProjects() {
+ ICProject cproject[] = CoreModel.getDefault().getCRoot().getCProjects();
+ ArrayList list = new ArrayList(cproject.length);
+ for (int i = 0; i < cproject.length; i++) {
+ ICProjectDescriptor cdesciptor = null;
+ try {
+ cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject) cproject[i].getResource());
+ if (cdesciptor.getPlatform().equals("*") || filterPlatform.equalsIgnoreCase(cdesciptor.getPlatform()) == true) {
+ list.add(cproject[i]);
+ }
+ }
+ catch (CoreException e) {
+ }
+ }
+ return (ICProject[]) list.toArray(new ICProject[list.size()]);
+ }
+ /**
+ * Return the ICProject corresponding to the project name in the project name
+ * text field, or null if the text does not match a project name.
+ */
+ protected ICProject getCProject() {
+ String projectName = fProjText.getText().trim();
+ if (projectName.length() < 1) {
+ return null;
+ }
+ return CoreModel.getDefault().getCRoot().getCProject(projectName);
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration config) {
+
+ setErrorMessage(null);
+ setMessage(null);
+
+ String name = fProjText.getText().trim();
+ if (name.length() > 0) {
+ if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
+ setErrorMessage("Project does not exist");
+ return false;
+ }
+ }
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+
+ name = fProgText.getText().trim();
+ if (name.length() == 0) {
+ setErrorMessage("Program not specified");
+ return false;
+ }
+ IPath path = Platform.getLocation().append(project.getFullPath());
+ path = path.append(name);
+
+ if (!ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path).exists()) {
+ setErrorMessage("Program does not exist");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ ICElement cElement = null;
+ try {
+ cElement = getContext(config);
+ }
+ catch (CoreException e) {
+ }
+ if (cElement != null) {
+ initializeCProject(cElement, config);
+ }
+ else {
+ // We set empty attributes for project & program so that when one config is
+ // compared to another, the existence of empty attributes doesn't cause an
+ // incorrect result (the performApply() method can result in empty values
+ // for these attributes being set on a config if there is nothing in the
+ // corresponding text boxes)
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
+ }
+ initializeProgramName(cElement, config);
+ }
+
+ /**
+ * Set the program name attributes on the working copy based on the ICElement
+ */
+ protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
+ String name = null;
+ if (cElement instanceof ICProject) {
+ IBinaryContainer bc = ((ICProject) cElement).getBinaryContainer();
+ IBinary[] bins = bc.getBinaries();
+ if (bins.length == 1) {
+ name = bins[0].getElementName();
+ }
+ }
+ if (name == null) {
+ name = EMPTY_STRING;
+ }
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, name);
+ if (name.length() > 0) {
+ int index = name.lastIndexOf('.');
+ if (index > 0) {
+ name = name.substring(index + 1);
+ }
+ name = getLaunchConfigurationDialog().generateName(name);
+ config.rename(name);
+ }
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Main";
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return LaunchImages.get(LaunchImages.IMG_VIEW_MAIN_TAB);
+ }
+
+}

Back to the top