diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog
index 7b62c72d096..b8fcc69524b 100644
--- a/launch/org.eclipse.cdt.launch/ChangeLog
+++ b/launch/org.eclipse.cdt.launch/ChangeLog
@@ -1,3 +1,16 @@
+2004-10-22 David Inglis
+ Added variables support to arguments, environment and working directory.
+
+ * plugin.xml
+ * src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
+ * src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
+ * src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
+ * src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java
+ * src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java
+ * src/org/eclipse/cdt/launch/ui/CArgumentsTab.java
+ * src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
+ * src/org/eclipse/cdt/launch/internal/ui/MigratingCEnvironmentTab.java
+
2004-10-18 Alain Magloire
Adjust to changes in CDI
* src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml
index 2972e8c4e8c..3f27e525229 100644
--- a/launch/org.eclipse.cdt.launch/plugin.xml
+++ b/launch/org.eclipse.cdt.launch/plugin.xml
@@ -25,6 +25,7 @@
+
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
index 6fdeb7787d8..bcb7c9d68fa 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
@@ -16,13 +16,11 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser;
@@ -36,7 +34,6 @@ import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -52,9 +49,13 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
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.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
@@ -77,149 +78,21 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
* Return the save environment variables in the configuration. The array
* does not include the default environment of the target. array[n] :
* name=value
+ * @throws CoreException
*/
- protected String[] getEnvironmentArray(ILaunchConfiguration config) {
- Map env = null;
+ protected String[] getEnvironmentArray(ILaunchConfiguration config) throws CoreException {
try {
- env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
+ // Migrate old env settings to new.
+ Map map = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
+ if (map != null) {
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
+ wc.doSave();
+ }
} catch (CoreException e) {
- }
- if (env == null) {
- return new String[0];
- }
- String[] array = new String[env.size()];
- Iterator entries = env.entrySet().iterator();
- Entry entry;
- for (int i = 0; entries.hasNext() && i < array.length; i++) {
- entry = (Entry)entries.next();
- array[i] = ((String)entry.getKey()) + "=" + ((String)entry.getValue()); //$NON-NLS-1$
- }
- return array;
- }
-
- /**
- * Return the save environment variables of this configuration. The array
- * does not include the default environment of the target.
- */
- protected Properties getEnvironmentProperty(ILaunchConfiguration config) {
- Properties prop = new Properties();
- Map env = null;
- try {
- env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
- } catch (CoreException e) {
- }
- if (env == null)
- return prop;
- Iterator entries = env.entrySet().iterator();
- Entry entry;
- while (entries.hasNext()) {
- entry = (Entry)entries.next();
- prop.setProperty((String)entry.getKey(), (String)entry.getValue());
- }
- return prop;
- }
-
- /**
- * Return the default Environment of the target.
- */
- protected Properties getDefaultEnvironment() {
- return EnvironmentReader.getEnvVars();
- }
-
- /**
- * Expand the variable with the format ${key}. example: HOME=/foobar NEWHOME =
- * ${HOME}/project The environement NEWHOME will be /foobar/project.
- */
- protected Properties expandEnvironment(ILaunchConfiguration config) {
- return expandEnvironment(getEnvironmentProperty(config));
- }
-
- /**
- * Expand the variable with the format ${key}. example: HOME=/foobar NEWHOME =
- * ${HOME}/project The environement NEWHOME will be /foobar/project.
- */
- protected Properties expandEnvironment(Properties props) {
- Enumeration names = props.propertyNames();
- if (names != null) {
- while (names.hasMoreElements()) {
- String key = (String)names.nextElement();
- String value = props.getProperty(key);
- if (value != null && value.indexOf('$') != -1) {
- StringBuffer sb = new StringBuffer();
- StringBuffer param = new StringBuffer();
- char prev = '\n';
- char ch = prev;
- boolean inMacro = false;
- boolean inSingleQuote = false;
-
- for (int i = 0; i < value.length(); i++) {
- ch = value.charAt(i);
- switch (ch) {
- case '\'' :
- if (prev != '\\') {
- inSingleQuote = !inSingleQuote;
- }
- break;
-
- case '$' :
- if (!inSingleQuote && prev != '\\') {
- if (i < value.length() && value.indexOf('}', i) > 0) {
- char c = value.charAt(i + 1);
- if (c == '{') {
- param.setLength(0);
- inMacro = true;
- prev = ch;
- continue;
- }
- }
- }
- break;
-
- case '}' :
- if (inMacro) {
- inMacro = false;
- String v = null;
- String p = param.toString();
- /*
- * Search in the current property only if it
- * is not the same name.
- */
- if (!p.equals(key)) {
- v = props.getProperty(p);
- }
- /* Fallback to the default Environemnt. */
- if (v == null) {
- Properties def = getDefaultEnvironment();
- if (def != null) {
- v = def.getProperty(p);
- }
- }
- if (v != null) {
- sb.append(v);
- }
- param.setLength(0);
- /* Skip the trailing } */
- prev = ch;
- continue;
- }
- break;
- } /* switch */
-
- if (!inMacro) {
- sb.append(ch);
- } else {
- /* Do not had the '{' */
- if (! (ch == '{' && prev == '$')) {
- param.append(ch);
- }
- }
- prev = (ch == '\\' && prev == '\\') ? '\n' : ch;
- } /* for */
- props.setProperty(key, sb.toString());
- } /* !if (value ..) */
- } /* while() */
- } /* if (names != null) */
- return props;
+ }
+ return DebugPlugin.getDefault().getLaunchManager().getEnvironment(config);
}
/**
@@ -253,10 +126,27 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
return verifyWorkingDirectory(configuration);
}
+ /**
+ * Expands and returns the working directory attribute of the given launch
+ * configuration. Returns null
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
+ * null
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
+ */
protected IPath getWorkingDirectoryPath(ILaunchConfiguration config) throws CoreException {
- String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
- if (path != null) {
- return new Path(path);
+ String location = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ if (location != null) {
+ String expandedLocation = getStringVariableManager().performStringSubstitution(location);
+ if (expandedLocation.length() > 0) {
+ return new Path(expandedLocation);
+ }
}
return null;
}
@@ -316,6 +206,10 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
}
return new Path(path);
}
+
+ private static IStringVariableManager getStringVariableManager() {
+ return VariablesPlugin.getDefault().getStringVariableManager();
+ }
/**
* @param launch
@@ -371,7 +265,11 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
* @return the program arguments as a String
*/
public String getProgramArguments(ILaunchConfiguration config) throws CoreException {
- return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
+ String args = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
+ if (args != null) {
+ args = getStringVariableManager().performStringSubstitution(args);
+ }
+ return args;
}
/**
@@ -545,7 +443,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(
LaunchMessages.getFormattedString(
- "AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
+ "AbstractCLaunchDelegate.WORKINGDIRECTORY_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} else {
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
@@ -556,7 +454,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(
LaunchMessages.getFormattedString(
- "AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
+ "AbstractCLaunchDelegate.WORKINGDIRECTORY_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}
@@ -869,4 +767,25 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
return null;
}
+ /**
+ * @param config
+ * @return
+ * @throws CoreException
+ */
+ protected Properties getEnvironmentProperty(ILaunchConfiguration config) throws CoreException {
+ String[] envp = getEnvironmentArray(config);
+ Properties p = new Properties( );
+ for( int i = 0; i < envp.length; i++ ) {
+ int idx = envp[i].indexOf('=');
+ if (idx != -1) {
+ String key = envp[i].substring(0, idx);
+ String value = envp[i].substring(idx + 1);
+ p.setProperty(key, value);
+ } else {
+ p.setProperty(envp[i], ""); //$NON-NLS-1$
+ }
+ }
+ return p;
+ }
+
}
\ No newline at end of file
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
index 5f1e18d8884..37f0ddde588 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
@@ -12,8 +12,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Properties;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.model.ICProject;
@@ -67,32 +65,31 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8));
+ dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
+ new SubProgressMonitor(monitor, 8));
try {
- ICDITarget[] dtargets = dsession.getTargets();
- for (int i = 0; i < dtargets.length; ++i) {
- ICDIRuntimeOptions opt = dtargets[i].getRuntimeOptions();
- opt.setArguments(arguments);
- File wd = getWorkingDirectory(config);
- if (wd != null) {
- opt.setWorkingDirectory(wd.getAbsolutePath());
- }
- opt.setEnvironment(expandEnvironment(config));
- }
- } catch (CDIException e) {
try {
- dsession.terminate();
- } catch (CDIException ex) {
- // ignore
+ ICDITarget[] dtargets = dsession.getTargets();
+ for (int i = 0; i < dtargets.length; ++i) {
+ ICDIRuntimeOptions opt = dtargets[i].getRuntimeOptions();
+ opt.setArguments(arguments);
+ File wd = getWorkingDirectory(config);
+ if (wd != null) {
+ opt.setWorkingDirectory(wd.getAbsolutePath());
+ }
+ opt.setEnvironment(getEnvironmentProperty(config));
+ }
+ } catch (CDIException e) {
+ abort(
+ LaunchMessages
+ .getString("LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger"), e, //$NON-NLS-1$
+ ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
- abort(LaunchMessages.getString("LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger"), e, //$NON-NLS-1$
- ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
- }
- monitor.worked(1);
- try {
- boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+ monitor.worked(1);
+ boolean stopInMain = config
+ .getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
ICDITarget[] targets = dsession.getTargets();
for (int i = 0; i < targets.length; i++) {
@@ -102,7 +99,7 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
}
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig),
- iprocess, exeFile, true, false, stopInMain, true);
+ iprocess, exeFile, true, false, stopInMain, true);
}
} catch (CoreException e) {
try {
@@ -121,9 +118,9 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
ArrayList command = new ArrayList(1 + arguments.length);
command.add(exePath.toOSString());
command.addAll(Arrays.asList(arguments));
- String[] commandArray = (String[])command.toArray(new String[command.size()]);
+ String[] commandArray = (String[]) command.toArray(new String[command.size()]);
monitor.worked(5);
- Process process = exec(commandArray, getEnvironmentProperty(config), wd);
+ Process process = exec(commandArray, getEnvironmentArray(config), wd);
monitor.worked(3);
DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
}
@@ -148,26 +145,14 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
* cancelled
* @see Runtime
*/
- protected Process exec(String[] cmdLine, Properties environ, File workingDirectory) throws CoreException {
+ protected Process exec(String[] cmdLine, String[] environ, File workingDirectory) throws CoreException {
Process p = null;
- Properties props = getDefaultEnvironment();
- props.putAll(expandEnvironment(environ));
- String[] envp = null;
- ArrayList envList = new ArrayList();
- Enumeration names = props.propertyNames();
- if (names != null) {
- while (names.hasMoreElements()) {
- String key = (String)names.nextElement();
- envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
- }
- envp = (String[])envList.toArray(new String[envList.size()]);
- }
try {
if (workingDirectory == null) {
- p = ProcessFactory.getFactory().exec(cmdLine, envp);
+ p = ProcessFactory.getFactory().exec(cmdLine, environ);
} else {
- p = ProcessFactory.getFactory().exec(cmdLine, envp, workingDirectory);
+ p = ProcessFactory.getFactory().exec(cmdLine, environ, workingDirectory);
}
} catch (IOException e) {
if (p != null) {
@@ -180,14 +165,14 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
// directory
IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
- ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED,
- LaunchMessages.getString("LocalRunLaunchDelegate.Does_not_support_working_dir"), //$NON-NLS-1$
+ ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED, LaunchMessages
+ .getString("LocalRunLaunchDelegate.Does_not_support_working_dir"), //$NON-NLS-1$
e);
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
if (handler != null) {
Object result = handler.handleStatus(status, this);
- if (result instanceof Boolean && ((Boolean)result).booleanValue()) {
+ if (result instanceof Boolean && ((Boolean) result).booleanValue()) {
p = exec(cmdLine, environ, null);
}
}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
index ee804842102..72b6ca40b49 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
@@ -14,11 +14,11 @@ AbstractCLaunchDelegate.C_Project_not_specified=C Project not specified
AbstractCLaunchDelegate.Not_a_C_CPP_project=Project is not a C/C++ project
AbstractCLaunchDelegate.Program_file_not_specified=Program file not specified
AbstractCLaunchDelegate.Program_file_does_not_exist=Program file does not exist
+AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found
AbstractCLaunchDelegate.Working_directory_does_not_exist=Working directory does not exist
+AbstractCLaunchDelegate.WORKINGDIRECTORY_PATH_not_found=The working directory {0} does not exist.
AbstractCLaunchDelegate.Project_NAME_does_not_exist=Project {0} does not exist
AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed
-AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found
-AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist.
AbstractCLaunchDelegate.Debugger_Process=Debugger Process
AbstractCLaunchDelegate.building_projects=Building prerequisite project list
AbstractCLaunchDelegate.building=Building
@@ -121,16 +121,15 @@ CEnvironmentTab.Environment_variable_NAME_exists=Environment variable \" {0} \"
CArgumentsTab.C/C++_Program_Arguments=C/C++ Program Arguments:
CArgumentsTab.Arguments=Arguments
-WorkingDirectoryBlock.Wor&king_directory=Wor&king directory:
-WorkingDirectoryBlock.Use_de&fault_working_directory=Use de&fault working directory
-WorkingDirectoryBlock.&Local_directory=&Local directory
-WorkingDirectoryBlock.Works&pace=Works&pace
-WorkingDirectoryBlock.Select_&working_directory_for_launch_configuration=Select a &working directory for the launch configuration
-WorkingDirectoryBlock.Select_&workspace_relative_working_directory=Select a &workspace relative working directory
-WorkingDirectoryBlock.Working_directory_does_not_exist=Working directory does not exist
-WorkingDirectoryBlock.Working_directory_is_not_a_directory=Working directory is not a directory
-WorkingDirectoryBlock.Project_or_folder_does_not_exist=Specified project or folder does not exist.
-WorkingDirectoryBlock.Working_Directory=Working Directory
+WorkingDirectoryBlock.4=Select a &workspace relative working directory:
+WorkingDirectoryBlock.7=Select a working directory for the launch configuration:
+WorkingDirectoryBlock.0=W&orkspace...
+WorkingDirectoryBlock.Working_Directory_8=Working Directory
+WorkingDirectoryBlock.10=Working directory does not exist
+WorkingDirectoryBlock.Use_de&fault_working_directory_4=Use default wor&king directory
+WorkingDirectoryBlock.17=Variabl&es...
+WorkingDirectoryBlock.1=File S&ystem...
+WorkingDirectoryBlock.Exception_occurred_reading_configuration___15=Exception occurred reading configuration:
Launch.common.Exception_occurred_reading_configuration_EXCEPTION=Exception occurred reading configuration {0}
Launch.common.DebuggerColon=Debugger:
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java
index 154aa25287d..ea687389af8 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java
@@ -12,7 +12,6 @@ package org.eclipse.cdt.launch.internal.ui;
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.cdt.launch.ui.CSourceLookupTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
@@ -29,7 +28,7 @@ public class LocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigura
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(),
new CArgumentsTab(),
- new CEnvironmentTab(),
+ new MigratingCEnvironmentTab(),
new CDebuggerTab(false),
new CSourceLookupTab(),
new CommonTab()
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MigratingCEnvironmentTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MigratingCEnvironmentTab.java
new file mode 100644
index 00000000000..cadbe75a28a
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MigratingCEnvironmentTab.java
@@ -0,0 +1,45 @@
+/*
+ * Created on Oct 21, 2004
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.launch.internal.ui;
+
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.EnvironmentTab;
+
+
+/**
+ * @author DInglis
+ * @deprecated - temporary class for while configs are migrated to new EnvironmentTab
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class MigratingCEnvironmentTab extends EnvironmentTab {
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.ui.CEnvironmentTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration config) {
+ if (config instanceof ILaunchConfigurationWorkingCopy) {
+ ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) config;
+ try {
+ Map map = wc.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
+ if (map != null) {
+ wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map)null);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ super.initializeFrom(config);
+ }
+}
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
index 3eaf00c44ff..5a141f42e47 100644
--- 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
@@ -1,41 +1,41 @@
-/**********************************************************************
- * Copyright (c) 2002 - 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Common Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/cpl-v10.html
*
- * Contributors:
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
package org.eclipse.cdt.launch.internal.ui;
+
import java.io.File;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
+import org.eclipse.cdt.launch.ui.CLaunchConfigurationTab;
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.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.internal.ui.stringsubstitution.StringVariableSelectionDialog;
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.Font;
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;
@@ -43,328 +43,288 @@ 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;
-
+public class WorkingDirectoryBlock extends CLaunchConfigurationTab {
+
// Local directory
- protected Button fLocalDirButton;
protected Text fWorkingDirText;
- protected Button fWorkingDirBrowseButton;
-
-
- // Workspace directory
- protected Button fWorkspaceDirButton;
- protected Text fWorkspaceDirText;
- protected Button fWorkspaceDirBrowseButton;
-
+ protected Button fWorkspaceButton;
+ protected Button fFileSystemButton;
+ protected Button fVariablesButton;
+
// 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)
+ * A listener to update for text changes and widget selection
+ */
+ private class WidgetListener extends SelectionAdapter implements ModifyListener {
+
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ Object source = e.getSource();
+ if (source == fWorkspaceButton) {
+ handleWorkspaceDirBrowseButtonSelected();
+ } else if (source == fFileSystemButton) {
+ handleWorkingDirBrowseButtonSelected();
+ } else if (source == fUseDefaultWorkingDirButton) {
+ handleUseDefaultWorkingDirButtonSelected();
+ } else if (source == fVariablesButton) {
+ handleWorkingDirVariablesButtonSelected();
+ }
+ }
+ }
+
+ private WidgetListener fListener = new WidgetListener();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.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(LaunchMessages.getString("WorkingDirectoryBlock.Wor&king_directory")); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalSpan = 3;
- fWorkingDirLabel.setLayoutData(gd);
+ Font font = parent.getFont();
- fUseDefaultWorkingDirButton = new Button(workingDirComp,SWT.CHECK);
- fUseDefaultWorkingDirButton.setText(LaunchMessages.getString("WorkingDirectoryBlock.Use_de&fault_working_directory")); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalSpan = 3;
- fUseDefaultWorkingDirButton.setLayoutData(gd);
- fUseDefaultWorkingDirButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- handleUseDefaultWorkingDirButtonSelected();
- }
- });
-
- fLocalDirButton = createRadioButton(workingDirComp, LaunchMessages.getString("WorkingDirectoryBlock.&Local_directory")); //$NON-NLS-1$
- fLocalDirButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- handleLocationButtonSelected();
- }
- });
-
- fWorkingDirText = new Text(workingDirComp, SWT.SINGLE | SWT.BORDER);
+ Composite comp = new Composite(parent, SWT.NONE);
+ // WorkbenchHelp.setHelp(group,
+ // IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK);
+ GridLayout workingDirLayout = new GridLayout();
+ workingDirLayout.numColumns = 2;
+ workingDirLayout.makeColumnsEqualWidth = false;
+ comp.setLayout(workingDirLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ comp.setLayoutData(gd);
+ comp.setFont(font);
+ setControl(comp);
+
+ fWorkingDirText = new Text(comp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
fWorkingDirText.setLayoutData(gd);
- fWorkingDirText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- updateLaunchConfigurationDialog();
- }
- });
-
- fWorkingDirBrowseButton = createPushButton(workingDirComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$
- fWorkingDirBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- handleWorkingDirBrowseButtonSelected();
- }
- });
-
- fWorkspaceDirButton = createRadioButton(workingDirComp, LaunchMessages.getString("WorkingDirectoryBlock.Works&pace")); //$NON-NLS-1$
- fWorkspaceDirButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- handleLocationButtonSelected();
- }
- });
-
- fWorkspaceDirText = new Text(workingDirComp, SWT.SINGLE | SWT.BORDER);
+ fWorkingDirText.setFont(font);
+ fWorkingDirText.addModifyListener(fListener);
+
+ fUseDefaultWorkingDirButton = new Button(comp, SWT.CHECK);
+ fUseDefaultWorkingDirButton.setText(LaunchMessages.getString("WorkingDirectoryBlock.Use_de&fault_working_directory_4")); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
- fWorkspaceDirText.setLayoutData(gd);
- fWorkspaceDirText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- updateLaunchConfigurationDialog();
- }
- });
-
- fWorkspaceDirBrowseButton = createPushButton(workingDirComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
- fWorkspaceDirBrowseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent evt) {
- handleWorkspaceDirBrowseButtonSelected();
- }
- });
-
+ fUseDefaultWorkingDirButton.setLayoutData(gd);
+ fUseDefaultWorkingDirButton.setFont(font);
+ fUseDefaultWorkingDirButton.addSelectionListener(fListener);
+
+ Composite buttonComp = new Composite(comp, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ buttonComp.setLayout(layout);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ buttonComp.setLayoutData(gd);
+ buttonComp.setFont(font);
+ fWorkspaceButton = createPushButton(buttonComp, LaunchMessages.getString("WorkingDirectoryBlock.0"), null); //$NON-NLS-1$
+ fWorkspaceButton.addSelectionListener(fListener);
+
+ fFileSystemButton = createPushButton(buttonComp, LaunchMessages.getString("WorkingDirectoryBlock.1"), null); //$NON-NLS-1$
+ fFileSystemButton.addSelectionListener(fListener);
+
+ fVariablesButton = createPushButton(buttonComp, LaunchMessages.getString("WorkingDirectoryBlock.17"), null); //$NON-NLS-1$
+ fVariablesButton.addSelectionListener(fListener);
}
-
- /**
- * @see ILaunchConfigurationTab#dispose()
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.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(LaunchMessages.getString("WorkingDirectoryBlock.Select_&working_directory_for_launch_configuration")); //$NON-NLS-1$
+ dialog.setMessage(LaunchMessages.getString("WorkingDirectoryBlock.7")); //$NON-NLS-1$
String currentWorkingDir = fWorkingDirText.getText();
- if (!currentWorkingDir.trim().equals(EMPTY_STRING)) {
+ if (!currentWorkingDir.trim().equals("")) { //$NON-NLS-1$
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
+ * 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,
- LaunchMessages.getString("WorkingDirectoryBlock.Select_&workspace_relative_working_directory")); //$NON-NLS-1$
-
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ LaunchMessages.getString("WorkingDirectoryBlock.4")); //$NON-NLS-1$
+
IContainer currentContainer = getContainer();
if (currentContainer != null) {
IPath path = currentContainer.getFullPath();
- dialog.setInitialSelections(new Object[] {path});
+ dialog.setInitialSelections(new Object[] { path});
}
-
+
dialog.showClosedProjects(false);
dialog.open();
- Object[] results = dialog.getResult();
+ Object[] results = dialog.getResult();
if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
- IPath path = (IPath)results[0];
+ IPath path = (IPath) results[0];
String containerName = path.makeRelative().toString();
- fWorkspaceDirText.setText(containerName);
- }
+ fWorkingDirText.setText("${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
-
+
/**
* Returns the selected workspace container,or null
*/
protected IContainer getContainer() {
- IResource res = getResource();
- if (res instanceof IContainer) {
- return (IContainer)res;
+ String path = fWorkingDirText.getText().trim();
+ if (path.length() > 0) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource res = root.findMember(path);
+ if (res instanceof IContainer) {
+ return (IContainer) res;
+ }
}
return null;
}
-
- /**
- * Returns the selected workspace resource, or null
- */
- 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()) {
+ boolean def = isDefaultWorkingDirectory();
+ if (def) {
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();
+ }
+ fWorkingDirText.setEnabled(!def);
+ fWorkspaceButton.setEnabled(!def);
+ fVariablesButton.setEnabled(!def);
+ fFileSystemButton.setEnabled(!def);
+ }
+
+ protected void handleWorkingDirVariablesButtonSelected() {
+ String variableText = getVariable();
+ if (variableText != null) {
+ fWorkingDirText.append(variableText);
}
}
-
+
+ private String getVariable() {
+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
+ dialog.open();
+ return dialog.getVariableExpression();
+ }
+
/**
* Sets the default working directory
*/
protected void setDefaultWorkingDir() {
- ILaunchConfiguration config = getLaunchConfiguration();
- if (config != null) {
- ICProject cProject = null;
- try {
- cProject = AbstractCLaunchDelegate.getCProject(config);
- } catch (CoreException e) {
- }
- if (cProject != null) {
- fWorkspaceDirText.setText(cProject.getPath().makeRelative().toOSString());
- fLocalDirButton.setSelection(false);
- fWorkspaceDirButton.setSelection(true);
- return;
+ try {
+ ILaunchConfiguration config = getLaunchConfiguration();
+ if (config != null) {
+ ICProject cProject = AbstractCLaunchDelegate.getCProject(config);
+ if (cProject != null) {
+ fWorkingDirText.setText("${workspace_loc:" + cProject.getPath().makeRelative().toOSString() + "}"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
}
+ } catch (CoreException ce) {
}
-
fWorkingDirText.setText(System.getProperty("user.dir")); //$NON-NLS-1$
- fLocalDirButton.setSelection(true);
- fWorkspaceDirButton.setSelection(false);
}
- /**
- * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.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(LaunchMessages.getString("WorkingDirectoryBlock.Working_directory_does_not_exist")); //$NON-NLS-1$
- return false;
- }
- if (!dir.isDirectory()) {
- setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Working_directory_is_not_a_directory")); //$NON-NLS-1$
- return false;
- }
+
+ // if variables are present, we cannot resolve the directory
+ String workingDirPath = fWorkingDirText.getText().trim();
+ if (workingDirPath.indexOf("${") >= 0) { //$NON-NLS-1$
+ IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
+ try {
+ manager.validateStringVariables(workingDirPath);
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ return false;
}
- } else {
- if (getContainer() == null) {
- setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Project_or_folder_does_not_exist")); //$NON-NLS-1$
+ } else if (workingDirPath.length() > 0) {
+ IContainer container = getContainer();
+ if (container == null) {
+ File dir = new File(workingDirPath);
+ if (dir.isDirectory()) {
+ return true;
+ }
+ setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.10")); //$NON-NLS-1$
return false;
}
}
-
return true;
}
/**
* Defaults are empty.
*
- * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ // config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+ // (String)null);
}
- /**
- * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.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);
+ try {
+ String wd = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); //$NON-NLS-1$
+ fWorkingDirText.setText(""); //$NON-NLS-1$
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);
- }
+ fWorkingDirText.setText(wd);
fUseDefaultWorkingDirButton.setSelection(false);
}
handleUseDefaultWorkingDirButtonSelected();
} catch (CoreException e) {
- setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$
+ setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Exception_occurred_reading_configuration___15") + e.getStatus().getMessage()); //$NON-NLS-1$
LaunchUIPlugin.log(e);
}
}
- /**
- * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.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();
- }
- }
+ wd = getAttributeValueFrom(fWorkingDirText);
+ }
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd);
}
@@ -380,49 +340,37 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab {
}
return null;
}
-
- /**
- * @see ILaunchConfigurationTab#getName()
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
public String getName() {
- return LaunchMessages.getString("WorkingDirectoryBlock.Working_Directory"); //$NON-NLS-1$
- }
-
+ return LaunchMessages.getString("WorkingDirectoryBlock.Working_Directory_8"); //$NON-NLS-1$
+ }
+
/**
* 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.
+ * Sets the c project currently specified by the given launch config, if
+ * any.
*/
protected void setLaunchConfiguration(ILaunchConfiguration config) {
fLaunchConfiguration = config;
- }
-
+ }
+
/**
- * Returns the current java project context
+ * Returns the current c project context
*/
protected ILaunchConfiguration getLaunchConfiguration() {
return fLaunchConfiguration;
}
-
- /**
- * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
- */
- protected void updateLaunchConfigurationDialog() {
- super.updateLaunchConfigurationDialog();
- }
}
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
index c489ed2dd7d..3f4d0ced87d 100644
--- 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
@@ -18,15 +18,22 @@ 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.internal.ui.stringsubstitution.StringVariableSelectionDialog;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
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.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -44,7 +51,8 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
// Program arguments UI widgets
protected Label fPrgmArgumentsLabel;
protected Text fPrgmArgumentsText;
-
+ protected Button fArgumentVariablesButton;
+
// Working directory
protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock();
@@ -60,13 +68,28 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
GridLayout topLayout = new GridLayout();
comp.setLayout(topLayout);
- GridData gd;
+ createVerticalSpacer(comp, 1);
+ createArgumentComponent(comp, 1);
createVerticalSpacer(comp, 1);
- fPrgmArgumentsLabel = new Label(comp, SWT.NONE);
+ fWorkingDirectoryBlock.createControl(comp);
+ }
+
+ protected void createArgumentComponent(Composite comp, int i) {
+ Composite argsComp = new Composite(comp, SWT.NONE);
+ GridLayout projLayout = new GridLayout();
+ projLayout.numColumns = 1;
+ projLayout.marginHeight = 0;
+ projLayout.marginWidth = 0;
+ argsComp.setLayout(projLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = i;
+ argsComp.setLayoutData(gd);
+
+ fPrgmArgumentsLabel = new Label(argsComp, SWT.NONE);
fPrgmArgumentsLabel.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$
- fPrgmArgumentsText = new Text(comp, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
+ fPrgmArgumentsText = new Text(argsComp, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 40;
fPrgmArgumentsText.setLayoutData(gd);
@@ -75,12 +98,64 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
updateLaunchConfigurationDialog();
}
});
-
- createVerticalSpacer(comp, 1);
-
- fWorkingDirectoryBlock.createControl(comp);
+ fArgumentVariablesButton= createPushButton(argsComp, "Varianbles...", null); //$NON-NLS-1$
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ fArgumentVariablesButton.setLayoutData(gd);
+ fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent arg0) {
+ handleVariablesButtonSelected(fPrgmArgumentsText);
+ }
+
+ });
+// addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
}
+ /**
+ * A variable entry button has been pressed for the given text
+ * field. Prompt the user for a variable and enter the result
+ * in the given field.
+ */
+ private void handleVariablesButtonSelected(Text textField) {
+ String variable = getVariable();
+ if (variable != null) {
+ textField.append(variable);
+ }
+ }
+
+ /**
+ * Prompts the user to choose and configure a variable and returns
+ * the resulting string, suitable to be used as an attribute.
+ */
+ private String getVariable() {
+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
+ dialog.open();
+ return dialog.getVariableExpression();
+ }
+ public void addControlAccessibleListener(Control control, String controlName) {
+ //strip mnemonic (&)
+ String[] strs = controlName.split("&"); //$NON-NLS-1$
+ StringBuffer stripped = new StringBuffer();
+ for (int i = 0; i < strs.length; i++) {
+ stripped.append(strs[i]);
+ }
+ control.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString()));
+ }
+
+ private class ControlAccessibleListener extends AccessibleAdapter {
+ private String controlName;
+ ControlAccessibleListener(String name) {
+ controlName = name;
+ }
+ public void getName(AccessibleEvent e) {
+ e.result = controlName;
+ }
+
+ }
+
/**
* @see ILaunchConfigurationTab#dispose()
*/
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
index 3e91ff215bd..59630a62bac 100644
--- 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
@@ -275,14 +275,19 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected void createOptionsComposite( Composite parent ) {
Composite optionsComp = new Composite( parent, SWT.NONE );
- GridLayout layout = new GridLayout( 2, true );
- optionsComp.setLayout( layout );
- optionsComp.setLayoutData( new GridData( GridData.FILL, GridData.CENTER, true, false, 1, 1 ) );
if (fAttachMode == true) {
- createVerticalSpacer(optionsComp, 1);
+ GridLayout layout = new GridLayout( 1, false );
+ optionsComp.setLayout( layout );
+ optionsComp.setLayoutData( new GridData( GridData.END, GridData.CENTER, true, false, 1, 1 ) );
} else {
+ GridLayout layout = new GridLayout( 2, false );
+ optionsComp.setLayout( layout );
+ optionsComp.setLayoutData( new GridData( GridData.END, GridData.CENTER, true, false, 1, 1 ) );
fStopInMain = createCheckButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.BEGINNING;
+ fStopInMain.setLayoutData( data );
fStopInMain.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {