diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml
index d75946bb66d..ef9b975912a 100644
--- a/build/org.eclipse.cdt.make.core/plugin.xml
+++ b/build/org.eclipse.cdt.make.core/plugin.xml
@@ -14,9 +14,9 @@
-
-
+
+
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java
index f6f1501d45a..d34c7b9c925 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java
@@ -10,57 +10,53 @@
*******************************************************************************/
package org.eclipse.cdt.make.core;
-import java.util.Map;
-
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-public interface IMakeBuilderInfo {
- IPath getBuildLocation();
- void setBuildLocation(IPath location) throws CoreException;
+public interface IMakeBuilderInfo extends IMakeCommonBuildInfo {
- boolean isStopOnError();
- void setStopOnError(boolean on) throws CoreException;
-
- boolean isDefaultBuildCmd();
- void setUseDefaultBuildCmd(boolean on) throws CoreException;
-
- IPath getBuildCommand();
- void setBuildCommand(IPath command) throws CoreException;
-
- String getBuildArguments();
- void setBuildArguments(String args) throws CoreException;
+ public final static String BUILD_TARGET_FULL = ARGS_PREFIX + ".build.target.full"; //$NON-NLS-1$
+ public final static String BUILD_TARGET_INCREAMENTAL = ARGS_PREFIX + ".build.target.inc"; //$NON-NLS-1$
+ public final static String BUILD_TARGET_AUTO = ARGS_PREFIX + ".build.target.auto"; //$NON-NLS-1$
+ public final static String BUILD_TARGET_CLEAN = ARGS_PREFIX + ".build.target.clean"; //$NON-NLS-1$
boolean isAutoBuildEnable();
void setAutoBuildEnable(boolean enabled) throws CoreException;
String getAutoBuildTarget();
+
+ /**
+ * @deprecated
+ */
void setAutoBuildTarget(String target) throws CoreException;
boolean isIncrementalBuildEnabled();
void setIncrementalBuildEnable(boolean enabled) throws CoreException;
String getIncrementalBuildTarget();
+
+ /**
+ * @deprecated
+ */
void setIncrementalBuildTarget(String target) throws CoreException;
boolean isFullBuildEnabled();
void setFullBuildEnable(boolean enabled) throws CoreException;
String getFullBuildTarget();
+
+ /**
+ * @deprecated
+ */
void setFullBuildTarget(String target) throws CoreException;
String getCleanBuildTarget();
+
+ /**
+ * @deprecated
+ */
void setCleanBuildTarget(String target) throws CoreException;
boolean isCleanBuildEnabled();
void setCleanBuildEnable(boolean enabled) throws CoreException;
-
- String[] getErrorParsers();
- void setErrorParsers(String[] parsers) throws CoreException;
- Map getEnvironment();
- void setEnvironment(Map env) throws CoreException;
-
- boolean appendEnvironment();
- void setAppendEnvironment(boolean append) throws CoreException;
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeCommonBuildInfo.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeCommonBuildInfo.java
new file mode 100644
index 00000000000..395f3c3819e
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeCommonBuildInfo.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors: QNX Software Systems - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.make.core;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+
+public interface IMakeCommonBuildInfo {
+ public final static String ARGS_PREFIX = MakeCorePlugin.getUniqueIdentifier();
+
+ public final static String BUILD_LOCATION = ARGS_PREFIX + ".build.location"; //$NON-NLS-1$
+ public final static String BUILD_COMMAND = ARGS_PREFIX + ".build.command"; //$NON-NLS-1$
+ public final static String BUILD_ARGUMENTS = ARGS_PREFIX + ".build.arguments"; //$NON-NLS-1$
+
+ void setBuildAttribute(String name, String value) throws CoreException;
+ String getBuildAttribute(String name, String defaultValue);
+
+ IPath getBuildLocation();
+
+ /**
+ * @deprecated - use setBuildString(BUILD_LOCATION...)
+ */
+ void setBuildLocation(IPath location) throws CoreException;
+
+ boolean isStopOnError();
+ void setStopOnError(boolean on) throws CoreException;
+
+ boolean isDefaultBuildCmd();
+ void setUseDefaultBuildCmd(boolean on) throws CoreException;
+
+ IPath getBuildCommand();
+
+ /**
+ * @deprecated - use setBuildString(BUILD_COMMAND...)
+ */
+ void setBuildCommand(IPath command) throws CoreException;
+
+ String getBuildArguments();
+
+ /**
+ * @deprecated - use setBuildString(BUILD_ARGUMENTS...)
+ */
+ void setBuildArguments(String args) throws CoreException;
+
+ String[] getErrorParsers();
+ void setErrorParsers(String[] parsers) throws CoreException;
+
+ Map getExpandedEnvironment();
+
+ Map getEnvironment();
+ void setEnvironment(Map env) throws CoreException;
+
+ boolean appendEnvironment();
+ void setAppendEnvironment(boolean append) throws CoreException;
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java
index cbf333d674a..35e3cd39f98 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java
@@ -10,42 +10,32 @@
*******************************************************************************/
package org.eclipse.cdt.make.core;
-import java.util.Map;
-
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-public interface IMakeTarget extends IAdaptable {
+public interface IMakeTarget extends IAdaptable, IMakeCommonBuildInfo {
+
+ public final static String BUILD_TARGET = ARGS_PREFIX + ".build.target"; //$NON-NLS-1$
+
String getName();
String getTargetBuilderID();
- boolean isStopOnError();
- void setStopOnError(boolean stopOnError) throws CoreException;
-
- boolean isDefaultBuildCmd();
- void setUseDefaultBuildCmd(boolean useDefault) throws CoreException;
-
+ /**
+ * @deprecated
+ */
void setBuildTarget(String target) throws CoreException;
+
+
+ /**
+ * @deprecated
+ */
String getBuildTarget() ;
- IPath getBuildCommand();
- void setBuildCommand(IPath command) throws CoreException;
-
- String getBuildArguments();
- void setBuildArguments(String arguments) throws CoreException;
-
- void setRunAllBuilders(boolean runAllBuilders);
+ void setRunAllBuilders(boolean runAllBuilders) throws CoreException;
boolean runAllBuilders();
- void setBuildEnvironment(Map env) throws CoreException;
- Map getBuildEnvironment();
-
- void setAppendEnvironment(boolean append) throws CoreException;
- boolean isAppendEnvironment();
-
/**
* Get the target build container.
*
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
index 677875180ea..ac288e08301 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java
@@ -33,21 +33,22 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+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.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.osgi.service.environment.Constants;
public class MakeBuilder extends ACBuilder {
@@ -90,12 +91,23 @@ public class MakeBuilder extends ACBuilder {
protected void clean(IProgressMonitor monitor) throws CoreException {
final IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(getProject(), BUILDER_ID);
if (shouldBuild(CLEAN_BUILD, info)) {
+ IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
+ final ISchedulingRule rule = ruleFactory.modifyRule(getProject());
Job backgroundJob = new Job("Standard Make Builder"){ //$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
protected IStatus run(IProgressMonitor monitor) {
- invokeMake(CLEAN_BUILD, info, monitor);
+ try {
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) {
+ invokeMake(CLEAN_BUILD, info, monitor);
+ }
+ }, rule, IWorkspace.AVOID_UPDATE, monitor);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
IStatus returnStatus = Status.OK_STATUS;
return returnStatus;
}
@@ -103,7 +115,7 @@ public class MakeBuilder extends ACBuilder {
};
- backgroundJob.setRule(getProject());
+ backgroundJob.setRule(rule);
backgroundJob.schedule();
}
}
@@ -138,6 +150,7 @@ public class MakeBuilder extends ACBuilder {
if (workingDirectory == null) {
workingDirectory = currProject.getLocation();
}
+
String[] targets = getTargets(kind, info);
if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget())) //$NON-NLS-1$
isClean = true;
@@ -155,24 +168,8 @@ public class MakeBuilder extends ACBuilder {
envMap.put("CWD", workingDirectory.toOSString()); //$NON-NLS-1$
envMap.put("PWD", workingDirectory.toOSString()); //$NON-NLS-1$
// Add variables from build info
- Map userEnv = info.getEnvironment();
- Iterator iter= userEnv.entrySet().iterator();
- boolean win32= Platform.getOS().equals(Constants.OS_WIN32);
- while (iter.hasNext()) {
- Map.Entry entry= (Map.Entry) iter.next();
- String key= (String) entry.getKey();
- if (win32) {
- // Win32 vars are case insensitive. Uppercase everything so
- // that (for example) "pAtH" will correctly replace "PATH"
- key= key.toUpperCase();
- }
- String value = (String) entry.getValue();
- // translate any string substitution variables
- String translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value);
- envMap.put(key, translated);
- }
-
- iter= envMap.entrySet().iterator();
+ envMap.putAll(info.getExpandedEnvironment());
+ Iterator iter = envMap.entrySet().iterator();
List strings= new ArrayList(envMap.size());
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
@@ -191,8 +188,7 @@ public class MakeBuilder extends ACBuilder {
} else {
String args = info.getBuildArguments();
if (args != null && !args.equals("")) { //$NON-NLS-1$
- String translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(args);
- String[] newArgs = makeArray(translated);
+ String[] newArgs = makeArray(args);
buildArguments = new String[targets.length + newArgs.length];
System.arraycopy(newArgs, 0, buildArguments, 0, newArgs.length);
System.arraycopy(targets, 0, buildArguments, newArgs.length, targets.length);
@@ -297,7 +293,7 @@ public class MakeBuilder extends ACBuilder {
return true;
}
- protected String[] getTargets(int kind, IMakeBuilderInfo info) throws CoreException {
+ protected String[] getTargets(int kind, IMakeBuilderInfo info) {
String targets = ""; //$NON-NLS-1$
switch (kind) {
case IncrementalProjectBuilder.AUTO_BUILD :
@@ -313,8 +309,7 @@ public class MakeBuilder extends ACBuilder {
targets = info.getCleanBuildTarget();
break;
}
- String translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(targets);
- return makeArray(translated);
+ return makeArray(targets);
}
// Turn the string into an array.
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java
index 62b9679c129..b24684f7465 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java
@@ -130,23 +130,24 @@ public class MakeProjectNature implements IProjectNature {
addBuildSpec();
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, false);
IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(getProject(), MakeBuilder.BUILDER_ID);
- projectInfo.setBuildLocation(info.getBuildLocation());
-
+ projectInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
+ projectInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
projectInfo.setUseDefaultBuildCmd(info.isDefaultBuildCmd());
projectInfo.setStopOnError(info.isStopOnError());
- projectInfo.setBuildCommand(info.getBuildCommand());
projectInfo.setAutoBuildEnable(info.isAutoBuildEnable());
- projectInfo.setAutoBuildTarget(info.getAutoBuildTarget());
-
+ projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); //$NON-NLS-1$
+
projectInfo.setIncrementalBuildEnable(info.isIncrementalBuildEnabled());
- projectInfo.setIncrementalBuildTarget(info.getIncrementalBuildTarget());
+ projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL, "")); //$NON-NLS-1$
projectInfo.setFullBuildEnable(info.isFullBuildEnabled());
- projectInfo.setFullBuildTarget(info.getFullBuildTarget());
+ projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, "")); //$NON-NLS-1$
+
projectInfo.setCleanBuildEnable(info.isCleanBuildEnabled());
- projectInfo.setCleanBuildTarget(info.getCleanBuildTarget());
+ projectInfo.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, info.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "")); //$NON-NLS-1$
+
projectInfo.setErrorParsers(info.getErrorParsers());
projectInfo.setAppendEnvironment(info.appendEnvironment());
projectInfo.setEnvironment(info.getEnvironment());
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
index dab59d8edde..6d0432370e2 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
@@ -19,6 +19,7 @@ import java.util.StringTokenizer;
import java.util.Map.Entry;
import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
@@ -36,6 +37,8 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.osgi.service.environment.*;
public class BuildInfoFactory {
@@ -55,24 +58,77 @@ public class BuildInfoFactory {
static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild"; //$NON-NLS-1$
static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments"; //$NON-NLS-1$
static final String ENVIRONMENT = PREFIX + ".environment"; //$NON-NLS-1$
- static final String BUILD_APPEND_ENVIRONMENT = ".append_environment"; //$NON-NLS-1$
+ static final String BUILD_APPEND_ENVIRONMENT = PREFIX + ".append_environment"; //$NON-NLS-1$
private abstract static class AbstractBuildInfo implements IMakeBuilderInfo {
-
public void setUseDefaultBuildCmd(boolean on) throws CoreException {
putString(USE_DEFAULT_BUILD_CMD, new Boolean(on).toString());
}
public boolean isDefaultBuildCmd() {
- if (getString(USE_DEFAULT_BUILD_CMD) == null) { // if no property then default to true
+ if (getString(USE_DEFAULT_BUILD_CMD) == null) { // if no property
+ // then default to
+ // true
return true;
}
return getBoolean(USE_DEFAULT_BUILD_CMD);
}
+ public String getBuildAttribute(String name, String defaultValue) {
+ String value = getString(name);
+ if (value == null ) {
+ if (IMakeCommonBuildInfo.BUILD_COMMAND.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_COMMAND);
+ } else if (IMakeCommonBuildInfo.BUILD_ARGUMENTS.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_ARGUMENTS);
+ } else if (IMakeCommonBuildInfo.BUILD_LOCATION.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_LOCATION);
+ } else if (IMakeBuilderInfo.BUILD_TARGET_AUTO.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_TARGET_AUTO);
+ } else if (IMakeBuilderInfo.BUILD_TARGET_CLEAN.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_TARGET_CLEAN);
+ } else if (IMakeBuilderInfo.BUILD_TARGET_FULL.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_TARGET_FULL);
+ } else if (IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL.equals(name)) {
+ value = getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL);
+ }
+ }
+ return value != null ? value : defaultValue != null ? defaultValue : ""; //$NON-NLS-1$
+ }
+
+ public void setBuildAttribute(String name, String value) throws CoreException {
+ putString(name, value);
+ }
+
+ public Map getExpandedEnvironment() {
+ Map env = getEnvironment();
+ HashMap envMap = new HashMap(env.entrySet().size());
+ Iterator iter = env.entrySet().iterator();
+ boolean win32 = Platform.getOS().equals(Constants.OS_WIN32);
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ if (win32) {
+ // Win32 vars are case insensitive. Uppercase everything so
+ // that (for example) "pAtH" will correctly replace "PATH"
+ key = key.toUpperCase();
+ }
+ String value = (String)entry.getValue();
+ // translate any string substitution variables
+ String translated = value;
+ try {
+ translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, false);
+ } catch (CoreException e) {
+ }
+ envMap.put(key, translated);
+ }
+ return envMap;
+ }
+
public void setBuildCommand(IPath location) throws CoreException {
- putString(BUILD_COMMAND, location.toString());
+ putString(IMakeCommonBuildInfo.BUILD_COMMAND, null);
+ putString(BuildInfoFactory.BUILD_COMMAND, location.toString());
}
public IPath getBuildCommand() {
@@ -83,21 +139,23 @@ public class BuildInfoFactory {
}
return new Path(command);
}
- return new Path(getString(BUILD_COMMAND));
+ String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getString(BuildInfoFactory.BUILD_COMMAND));
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return new Path(result);
}
protected String getBuildParameter(String name) {
- IExtension extension =
- Platform.getExtensionRegistry().getExtension(
- ResourcesPlugin.PI_RESOURCES,
- ResourcesPlugin.PT_BUILDERS,
- getBuilderID());
+ IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES,
+ ResourcesPlugin.PT_BUILDERS, getBuilderID());
if (extension == null)
return null;
IConfigurationElement[] configs = extension.getConfigurationElements();
if (configs.length == 0)
return null;
- //The nature exists, or this builder doesn't specify a nature
+ // The nature exists, or this builder doesn't specify a nature
IConfigurationElement[] runElement = configs[0].getChildren("run"); //$NON-NLS-1$
IConfigurationElement[] paramElement = runElement[0].getChildren("parameter"); //$NON-NLS-1$
for (int i = 0; i < paramElement.length; i++) {
@@ -111,14 +169,36 @@ public class BuildInfoFactory {
protected abstract String getBuilderID();
public void setBuildLocation(IPath location) throws CoreException {
- putString(BUILD_LOCATION, location.toString());
+ putString(IMakeCommonBuildInfo.BUILD_LOCATION, null);
+ putString(BuildInfoFactory.BUILD_LOCATION, location.toString());
}
public IPath getBuildLocation() {
- String location = getString(BUILD_LOCATION);
- return new Path(location == null ? "" : location); //$NON-NLS-1$
+ String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, getString(BuildInfoFactory.BUILD_LOCATION));
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return new Path(result);
}
+ public String getBuildArguments() {
+ String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, getString(BuildInfoFactory.BUILD_ARGUMENTS));
+ if (result == null) {
+ return ""; //$NON-NLS-1$
+ }
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
+ }
+
+ public void setBuildArguments(String args) throws CoreException {
+ putString(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
+ putString(BuildInfoFactory.BUILD_ARGUMENTS, args);
+ }
+
public void setStopOnError(boolean enabled) throws CoreException {
putString(STOP_ON_ERROR, new Boolean(enabled).toString());
}
@@ -128,44 +208,62 @@ public class BuildInfoFactory {
}
public void setAutoBuildTarget(String target) throws CoreException {
- putString(BUILD_TARGET_AUTO, target);
+ putString(IMakeBuilderInfo.BUILD_TARGET_AUTO, null);
+ putString(BuildInfoFactory.BUILD_TARGET_AUTO, target);
}
public String getAutoBuildTarget() {
- return getString(BUILD_TARGET_AUTO);
+ String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, getString(BuildInfoFactory.BUILD_TARGET_AUTO));
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
}
public void setIncrementalBuildTarget(String target) throws CoreException {
- putString(BUILD_TARGET_INCREMENTAL, target);
+ putString(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL, null);
+ putString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL, target);
}
public String getIncrementalBuildTarget() {
- return getString(BUILD_TARGET_INCREMENTAL);
+ String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL,
+ getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL));
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
}
public void setFullBuildTarget(String target) throws CoreException {
- putString(BUILD_TARGET_FULL, target);
+ putString(IMakeBuilderInfo.BUILD_TARGET_FULL, null);
+ putString(BuildInfoFactory.BUILD_TARGET_FULL, target);
}
public String getFullBuildTarget() {
- return getString(BUILD_TARGET_FULL);
+ String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, getString(BuildInfoFactory.BUILD_TARGET_FULL));
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
}
public void setCleanBuildTarget(String target) throws CoreException {
- putString(BUILD_TARGET_CLEAN, target);
+ putString(IMakeBuilderInfo.BUILD_TARGET_CLEAN, null);
+ putString(BuildInfoFactory.BUILD_TARGET_CLEAN, target);
}
public String getCleanBuildTarget() {
- return getString(BUILD_TARGET_CLEAN);
+ String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, getString(BuildInfoFactory.BUILD_TARGET_CLEAN));
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
}
- public boolean getBoolean(String property) {
- return Boolean.valueOf(getString(property)).booleanValue();
- }
-
- protected abstract void putString(String name, String value) throws CoreException;
- protected abstract String getString(String property);
-
public void setAutoBuildEnable(boolean enabled) throws CoreException {
putString(BUILD_AUTO_ENABLED, new Boolean(enabled).toString());
}
@@ -198,14 +296,6 @@ public class BuildInfoFactory {
return getBoolean(BUILD_CLEAN_ENABLED);
}
- public String getBuildArguments() {
- return getString(BUILD_ARGUMENTS);
- }
-
- public void setBuildArguments(String args) throws CoreException {
- putString(BUILD_ARGUMENTS, args);
- }
-
public String[] getErrorParsers() {
String parsers = getString(ErrorParserManager.PREF_ERROR_PARSER);
if (parsers != null && parsers.length() > 0) {
@@ -214,7 +304,7 @@ public class BuildInfoFactory {
while (tok.hasMoreElements()) {
list.add(tok.nextToken());
}
- return (String[]) list.toArray(new String[list.size()]);
+ return (String[])list.toArray(new String[list.size()]);
}
return new String[0];
}
@@ -236,53 +326,61 @@ public class BuildInfoFactory {
}
public boolean appendEnvironment() {
- if (getString(BUILD_APPEND_ENVIRONMENT).length() > 0) {
+ if (getString(BUILD_APPEND_ENVIRONMENT) != null) {
return getBoolean(BUILD_APPEND_ENVIRONMENT);
}
return true;
}
-
+
public void setAppendEnvironment(boolean append) throws CoreException {
putString(BUILD_APPEND_ENVIRONMENT, new Boolean(append).toString());
}
-
+
+ public boolean getBoolean(String property) {
+ return Boolean.valueOf(getString(property)).booleanValue();
+ }
+
protected Map decodeMap(String value) {
Map map = new HashMap();
- StringBuffer envStr = new StringBuffer(value);
- String escapeChars = "|\\"; //$NON-NLS-1$
- char escapeChar = '\\';
- try {
- while (envStr.length() > 0) {
- int ndx = 0;
- while (ndx < envStr.length() ) {
- if (escapeChars.indexOf(envStr.charAt(ndx)) != -1) {
- if (envStr.charAt(ndx - 1) == escapeChar) { // escaped '|' - remove '\' and continue on.
- envStr.deleteCharAt(ndx - 1);
- if (ndx == envStr.length()) {
+ if (value != null) {
+ StringBuffer envStr = new StringBuffer(value);
+ String escapeChars = "|\\"; //$NON-NLS-1$
+ char escapeChar = '\\';
+ try {
+ while (envStr.length() > 0) {
+ int ndx = 0;
+ while (ndx < envStr.length()) {
+ if (escapeChars.indexOf(envStr.charAt(ndx)) != -1) {
+ if (envStr.charAt(ndx - 1) == escapeChar) {
+ // escaped '|' - remove '\' and continue on.
+ envStr.deleteCharAt(ndx - 1);
+ if (ndx == envStr.length()) {
+ break;
+ }
+ }
+ if (envStr.charAt(ndx) == '|')
+ break;
+ }
+ ndx++;
+ }
+ StringBuffer line = new StringBuffer(envStr.substring(0, ndx));
+ int lndx = 0;
+ while (lndx < line.length()) {
+ if (line.charAt(lndx) == '=') {
+ if (line.charAt(lndx - 1) == escapeChar) {
+ // escaped '=' - remove '\' and continue on.
+ line.deleteCharAt(lndx - 1);
+ } else {
break;
}
}
- if (envStr.charAt(ndx) == '|')
- break;
+ lndx++;
}
- ndx++;
+ map.put(line.substring(0, lndx), line.substring(lndx + 1));
+ envStr.delete(0, ndx + 1);
}
- StringBuffer line = new StringBuffer(envStr.substring(0, ndx));
- int lndx = 0;
- while (lndx < line.length() ) {
- if (line.charAt(lndx) == '=') {
- if (line.charAt(lndx - 1) == escapeChar) { // escaped '=' - remove '\' and continue on.
- line.deleteCharAt(lndx - 1);
- } else {
- break;
- }
- }
- lndx++;
- }
- map.put(line.substring(0, lndx), line.substring(lndx + 1));
- envStr.delete(0, ndx+1);
+ } catch (StringIndexOutOfBoundsException e) {
}
- } catch (StringIndexOutOfBoundsException e) {
}
return map;
}
@@ -291,10 +389,10 @@ public class BuildInfoFactory {
StringBuffer str = new StringBuffer();
Iterator entries = values.entrySet().iterator();
while (entries.hasNext()) {
- Entry entry = (Entry) entries.next();
- str.append(escapeChars((String) entry.getKey(), "=|\\", '\\')); //$NON-NLS-1$
+ Entry entry = (Entry)entries.next();
+ str.append(escapeChars((String)entry.getKey(), "=|\\", '\\')); //$NON-NLS-1$
str.append("="); //$NON-NLS-1$
- str.append(escapeChars((String) entry.getValue(), "|\\", '\\')); //$NON-NLS-1$
+ str.append(escapeChars((String)entry.getValue(), "|\\", '\\')); //$NON-NLS-1$
str.append("|"); //$NON-NLS-1$
}
return str.toString();
@@ -302,17 +400,21 @@ public class BuildInfoFactory {
protected String escapeChars(String string, String escapeChars, char escapeChar) {
StringBuffer str = new StringBuffer(string);
- for(int i = 0; i < str.length(); i++) {
- if ( escapeChars.indexOf(str.charAt(i)) != -1) {
+ for (int i = 0; i < str.length(); i++) {
+ if (escapeChars.indexOf(str.charAt(i)) != -1) {
str.insert(i, escapeChar);
i++;
}
}
return str.toString();
}
- }
+
+ protected abstract void putString(String name, String value) throws CoreException;
+ protected abstract String getString(String property);
+ }
private static class BuildInfoPreference extends AbstractBuildInfo {
+
private Preferences prefs;
private String builderID;
private boolean useDefaults;
@@ -325,13 +427,22 @@ public class BuildInfoFactory {
protected void putString(String name, String value) {
if (useDefaults) {
- prefs.setDefault(name, value);
+ if (value != null) {
+ prefs.setDefault(name, value);
+ }
} else {
+ if (value == null) {
+ prefs.setValue(name, prefs.getDefaultString(name));
+ return;
+ }
prefs.setValue(name, value);
}
}
protected String getString(String property) {
+ if (!prefs.contains(property)) {
+ return null;
+ }
if (useDefaults) {
return prefs.getDefaultString(property);
}
@@ -344,6 +455,7 @@ public class BuildInfoFactory {
}
private static class BuildInfoProject extends AbstractBuildInfo {
+
private IProject project;
private String builderID;
private Map args;
@@ -354,19 +466,24 @@ public class BuildInfoFactory {
ICommand builder;
builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID);
if (builder == null) {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$
}
args = builder.getArguments();
}
protected void putString(String name, String value) throws CoreException {
- String curValue = (String) args.get(name);
+ String curValue = (String)args.get(name);
if (curValue != null && curValue.equals(value)) {
return;
}
+ if (value == null) {
+ args.remove(name);
+ } else {
+ args.put(name, value);
+ }
IProjectDescription description = project.getDescription();
ICommand builder = MakeProjectNature.getBuildSpec(description, builderID);
- args.put(name, value);
builder.setArguments(args);
builder.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, isAutoBuildEnable());
builder.setBuilding(IncrementalProjectBuilder.FULL_BUILD, isFullBuildEnabled());
@@ -377,8 +494,7 @@ public class BuildInfoFactory {
}
protected String getString(String name) {
- String value = (String) args.get(name);
- return value == null ? "" : value; //$NON-NLS-1$
+ return (String)args.get(name);
}
protected String getBuilderID() {
@@ -387,6 +503,7 @@ public class BuildInfoFactory {
}
private static class BuildInfoMap extends AbstractBuildInfo {
+
private Map args;
private String builderID;
@@ -396,11 +513,15 @@ public class BuildInfoFactory {
}
protected void putString(String name, String value) {
- args.put(name, value);
+ if (value == null) {
+ args.remove(name);
+ } else {
+ args.put(name, value);
+ }
}
protected String getString(String name) {
- return args.get(name) != null ? (String)args.get(name) : ""; //$NON-NLS-1$
+ return (String)args.get(name);
}
protected String getBuilderID() {
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
index d4fe9f1abc5..68519830932 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
@@ -11,9 +11,11 @@
package org.eclipse.cdt.make.internal.core;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.core.resources.ICommand;
@@ -27,16 +29,16 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.osgi.service.environment.Constants;
public class MakeTarget extends PlatformObject implements IMakeTarget {
private final MakeTargetManager manager;
private String name;
- private String target;
- private String buildArguments;
- private IPath buildCommand;
private boolean isDefaultBuildCmd;
private boolean isStopOnError;
boolean runAllBuidlers = true;
@@ -44,14 +46,15 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
private IContainer container;
private boolean appendEnvironment;
private Map buildEnvironment;
+ private Map targetAttributes = new HashMap();
MakeTarget(MakeTargetManager manager, IProject project, String targetBuilderID, String name) throws CoreException {
this.manager = manager;
this.targetBuilderID = targetBuilderID;
this.name = name;
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(project, manager.getBuilderID(targetBuilderID));
- buildCommand = info.getBuildCommand();
- buildArguments = info.getBuildArguments();
+ setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
+ setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
isDefaultBuildCmd = info.isDefaultBuildCmd();
isStopOnError = info.isStopOnError();
appendEnvironment = info.appendEnvironment();
@@ -65,6 +68,10 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
void setName(String name) {
this.name = name;
}
+
+ Map getAttributeMap() {
+ return targetAttributes;
+ }
public String getName() {
return name;
@@ -93,40 +100,135 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
public IPath getBuildCommand() {
- return buildCommand != null ? buildCommand : new Path(""); //$NON-NLS-1$
+ if (isDefaultBuildCmd()) {
+ IMakeBuilderInfo info;
+ try {
+ info = MakeCorePlugin.createBuildInfo(container.getProject(), manager.getBuilderID(targetBuilderID));
+ return info.getBuildCommand();
+ } catch (CoreException e) {
+ }
+ }
+ String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"); //$NON-NLS-1$
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return new Path(result);
}
public void setBuildCommand(IPath command) throws CoreException {
- buildCommand = command;
- manager.updateTarget(this);
+ setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, command.toString());
}
public String getBuildArguments() {
- return buildArguments != null ? buildArguments : ""; //$NON-NLS-1$
+ String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, ""); //$NON-NLS-1$
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
}
public void setBuildArguments(String arguments) throws CoreException {
- buildArguments = arguments;
+ setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, arguments);
+ }
+
+ public void setBuildTarget(String target) throws CoreException {
+ setBuildAttribute(IMakeTarget.BUILD_TARGET, target);
+ }
+
+ public String getBuildTarget() {
+ String result = getBuildAttribute(IMakeTarget.BUILD_TARGET, ""); //$NON-NLS-1$
+ try {
+ result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
+ } catch (CoreException e) {
+ }
+ return result;
+ }
+
+ public void setRunAllBuilders(boolean runAllBuilders) throws CoreException {
+ this.runAllBuidlers = runAllBuilders;
manager.updateTarget(this);
}
- public Map getBuildEnvironment() {
+ public boolean runAllBuilders() {
+ return runAllBuidlers;
+ }
+
+ public void setBuildAttribute(String name, String value) throws CoreException {
+ targetAttributes.put(name, value);
+ manager.updateTarget(this);
+ }
+
+ public String getBuildAttribute(String name, String defaultValue) {
+ String value = (String)targetAttributes.get(name);
+ return value != null ? value : defaultValue;
+ }
+
+ public IPath getBuildLocation() {
+ return container.getLocation();
+ }
+
+ public void setBuildLocation(IPath location) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String[] getErrorParsers() {
+ IMakeBuilderInfo projectInfo;
+ try {
+ projectInfo = MakeCorePlugin.createBuildInfo(container.getProject(), manager.getBuilderID(targetBuilderID));
+ return projectInfo.getErrorParsers();
+ } catch (CoreException e) {
+ }
+ return new String[0];
+ }
+
+ public void setErrorParsers(String[] parsers) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map getExpandedEnvironment() {
+ Map env = getEnvironment();
+ HashMap envMap = new HashMap(env.entrySet().size());
+ Iterator iter = env.entrySet().iterator();
+ boolean win32 = Platform.getOS().equals(Constants.OS_WIN32);
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ if (win32) {
+ // Win32 vars are case insensitive. Uppercase everything so
+ // that (for example) "pAtH" will correctly replace "PATH"
+ key = key.toUpperCase();
+ }
+ String value = (String)entry.getValue();
+ // translate any string substitution variables
+ String translated = value;
+ try {
+ translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, false);
+ } catch (CoreException e) {
+ }
+ envMap.put(key, translated);
+ }
+ return envMap;
+ }
+
+ public Map getEnvironment() {
return buildEnvironment;
}
-
- public void setBuildEnvironment(Map env) throws CoreException {
+
+ public void setEnvironment(Map env) throws CoreException {
buildEnvironment = new HashMap(env);
manager.updateTarget(this);
- }
-
- public boolean isAppendEnvironment() {
- return appendEnvironment;
}
-
+
public void setAppendEnvironment(boolean append) throws CoreException {
appendEnvironment = append;
manager.updateTarget(this);
}
+
+ public boolean appendEnvironment() {
+ return appendEnvironment;
+ }
public IContainer getContainer() {
return container;
@@ -152,20 +254,16 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
final HashMap infoMap = new HashMap();
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(infoMap, builderID);
- if (buildArguments != null) {
- info.setBuildArguments(buildArguments);
- }
- if (buildCommand != null) {
- info.setBuildCommand(buildCommand);
- }
+ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$
info.setUseDefaultBuildCmd(isDefaultBuildCmd);
info.setStopOnError(isStopOnError);
info.setFullBuildEnable(true);
- info.setFullBuildTarget(target);
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, getBuildAttribute(IMakeTarget.BUILD_TARGET, "")); //$NON-NLS-1$
info.setEnvironment(buildEnvironment);
info.setAppendEnvironment(appendEnvironment);
if (container != null) {
- info.setBuildLocation(container.getFullPath());
+ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, container.getFullPath().toString());
}
IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(project, builderID);
info.setErrorParsers(projectInfo.getErrorParsers());
@@ -201,38 +299,6 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
}
- public void setBuildTarget(String target) throws CoreException {
- this.target = target;
- manager.updateTarget(this);
- }
-
- public String getBuildTarget() {
- return target != null ? target : ""; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.make.core.IMakeTarget#setRunAllBuilders(boolean)
- */
- public void setRunAllBuilders(boolean runAllBuilders) {
- this.runAllBuidlers = runAllBuilders;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.make.core.IMakeTarget#runAllBuilders()
- */
- public boolean runAllBuilders() {
- return runAllBuidlers;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
public Object getAdapter(Class adapter) {
if (adapter.equals(IProject.class)) {
return container.getProject();
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java
index 8a036bfb8d4..2c25c68f331 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java
@@ -9,6 +9,7 @@
package org.eclipse.cdt.make.internal.core;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin;
@@ -29,18 +30,18 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
try {
- info.setBuildCommand(new Path("make")); //$NON-NLS-1$
- info.setBuildLocation(new Path("")); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, ""); //$NON-NLS-1$
info.setStopOnError(false);
info.setUseDefaultBuildCmd(true);
info.setAutoBuildEnable(false);
- info.setAutoBuildTarget("all"); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "all"); //$NON-NLS-1$
info.setIncrementalBuildEnable(true);
- info.setIncrementalBuildTarget("all"); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL, "all"); //$NON-NLS-1$
info.setFullBuildEnable(true);
- info.setFullBuildTarget("clean all"); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, "clean all"); //$NON-NLS-1$
info.setCleanBuildEnable(true);
- info.setCleanBuildTarget("clean"); //$NON-NLS-1$
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "clean"); //$NON-NLS-1$
info.setAppendEnvironment(true);
info.setErrorParsers(CCorePlugin.getDefault().getAllErrorParsersIDs());
} catch (CoreException e) {
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java
index 0a6c58653fc..1e36b71e0e9 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java
@@ -32,6 +32,7 @@ import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.core.resources.IContainer;
@@ -39,7 +40,6 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -209,17 +209,19 @@ public class ProjectTargets {
targetElem.setAttribute(TARGET_ATTR_PATH, target.getContainer().getProjectRelativePath().toString());
Element elem = doc.createElement(TARGET_COMMAND);
targetElem.appendChild(elem);
- elem.appendChild(doc.createTextNode(target.getBuildCommand().toString()));
+ elem.appendChild(doc.createTextNode(target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"))); //$NON-NLS-1$
- if (target.getBuildArguments().length() > 0) {
+ String targetAttr = target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
+ if ( targetAttr != null) {
elem = doc.createElement(TARGET_ARGUMENTS);
- elem.appendChild(doc.createTextNode(target.getBuildArguments()));
+ elem.appendChild(doc.createTextNode(targetAttr));
targetElem.appendChild(elem);
}
- if (target.getBuildTarget().length() > 0) {
+ targetAttr = target.getBuildAttribute(IMakeTarget.BUILD_TARGET, null);
+ if (targetAttr != null) {
elem = doc.createElement(TARGET);
- elem.appendChild(doc.createTextNode(target.getBuildTarget()));
+ elem.appendChild(doc.createTextNode(targetAttr));
targetElem.appendChild(elem);
}
@@ -363,19 +365,19 @@ public class ProjectTargets {
}
option = getString(node, TARGET_COMMAND);
if (option != null) {
- target.setBuildCommand(new Path(option));
+ target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, option);
}
option = getString(node, TARGET_ARGUMENTS);
if (option != null) {
- target.setBuildArguments(option);
+ target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, option);
}
option = getString(node, BAD_TARGET);
if (option != null) {
- target.setBuildTarget(option);
+ target.setBuildAttribute(IMakeTarget.BUILD_TARGET, option);
}
option = getString(node, TARGET);
if (option != null) {
- target.setBuildTarget(option);
+ target.setBuildAttribute(IMakeTarget.BUILD_TARGET, option);
}
add(target);
} catch (CoreException e) {
diff --git a/build/org.eclipse.cdt.make.ui/icons/obj16/environment_obj.gif b/build/org.eclipse.cdt.make.ui/icons/obj16/environment_obj.gif
new file mode 100644
index 00000000000..3150162350f
Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/obj16/environment_obj.gif differ
diff --git a/build/org.eclipse.cdt.make.ui/icons/obj16/envvar_obj.gif b/build/org.eclipse.cdt.make.ui/icons/obj16/envvar_obj.gif
new file mode 100644
index 00000000000..0f076926979
Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/obj16/envvar_obj.gif differ
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/DialogSettingsHelper.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/DialogSettingsHelper.java
new file mode 100644
index 00000000000..14b7da7bbf7
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/DialogSettingsHelper.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.make.internal.ui;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Helper class for dealing with setting and restoring dialog settings.
+ */
+public class DialogSettingsHelper {
+
+ /**
+ * Persists the location and dimensions of the shell in the
+ * Debug UI Plugin dialog settings under the provided dialog settings section name
+ *
+ * @param shell The shell whose geometry is to be stored
+ * @param dialogSettingsSectionName The name of the dialog settings section
+ */
+ public static void persistShellGeometry(Shell shell, String dialogSettingsSectionName) {
+ Point shellLocation = shell.getLocation();
+ Point shellSize = shell.getSize();
+ IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
+ settings.put(IMakeUIPreferenceConstants.DIALOG_ORIGIN_X, shellLocation.x);
+ settings.put(IMakeUIPreferenceConstants.DIALOG_ORIGIN_Y, shellLocation.y);
+ settings.put(IMakeUIPreferenceConstants.DIALOG_WIDTH, shellSize.x);
+ settings.put(IMakeUIPreferenceConstants.DIALOG_HEIGHT, shellSize.y);
+ }
+
+ private static IDialogSettings getDialogSettings(String dialogSettingsSectionName) {
+ IDialogSettings settings = MakeUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(dialogSettingsSectionName);
+ if (section == null) {
+ section = settings.addNewSection(dialogSettingsSectionName);
+ }
+ return section;
+ }
+
+ /**
+ * Returns the initial size which is the larger of the initialSize
or
+ * the size persisted in the Debug UI Plugin dialog settings under the provided dialog setttings section name.
+ * If no size is persisted in the settings, the initialSize
is returned.
+ *
+ * @param initialSize The initialSize to compare against
+ * @param dialogSettingsSectionName The name of the dialog settings section
+ * @return the initial size
+ */
+ public static Point getInitialSize(String dialogSettingsSectionName, Point initialSize) {
+ IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
+ try {
+ int x, y;
+ x = settings.getInt(IMakeUIPreferenceConstants.DIALOG_WIDTH);
+ y = settings.getInt(IMakeUIPreferenceConstants.DIALOG_HEIGHT);
+ return new Point(Math.max(x, initialSize.x), Math.max(y, initialSize.y));
+ } catch (NumberFormatException e) {
+ }
+ return initialSize;
+ }
+
+ /**
+ * Returns the initial location which is persisted in the Debug UI Plugin dialog settings
+ * under the provided dialog setttings section name.
+ * If location is not persisted in the settings, the null
is returned.
+ *
+ * @param dialogSettingsSectionName The name of the dialog settings section
+ * @return The initial location or null
+ */
+ public static Point getInitialLocation(String dialogSettingsSectionName) {
+ IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
+ try {
+ int x= settings.getInt(IMakeUIPreferenceConstants.DIALOG_ORIGIN_X);
+ int y= settings.getInt(IMakeUIPreferenceConstants.DIALOG_ORIGIN_Y);
+ return new Point(x,y);
+ } catch (NumberFormatException e) {
+ }
+ return null;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/IMakeUIPreferenceConstants.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/IMakeUIPreferenceConstants.java
new file mode 100644
index 00000000000..083d51c870c
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/IMakeUIPreferenceConstants.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors: QNX Software Systems - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.make.internal.ui;
+
+public interface IMakeUIPreferenceConstants {
+
+ /**
+ * Common dialog settings
+ */
+ public static final String DIALOG_ORIGIN_X = MakeUIPlugin.getPluginId() + ".DIALOG_ORIGIN_X"; //$NON-NLS-1$
+ public static final String DIALOG_ORIGIN_Y = MakeUIPlugin.getPluginId() + ".DIALOG_ORIGIN_Y"; //$NON-NLS-1$
+ public static final String DIALOG_WIDTH = MakeUIPlugin.getPluginId() + ".DIALOG_WIDTH"; //$NON-NLS-1$
+ public static final String DIALOG_HEIGHT = MakeUIPlugin.getPluginId() + ".DIALOG_HEIGHT"; //$NON-NLS-1$
+ public static final String DIALOG_SASH_WEIGHTS_1 = MakeUIPlugin.getPluginId() + ".DIALOG_SASH_WEIGHTS_1"; //$NON-NLS-1$
+ public static final String DIALOG_SASH_WEIGHTS_2 = MakeUIPlugin.getPluginId() + ".DIALOG_SASH_WEIGHTS_2"; //$NON-NLS-1$
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java
new file mode 100644
index 00000000000..9f9ea0574d4
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java
@@ -0,0 +1,808 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors: QNX Software Systems - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.make.internal.ui;
+
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.spawner.EnvironmentReader;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+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.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+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.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+
+public class MakeEnvironmentBlock extends AbstractCOptionPage {
+
+ Preferences fPrefs;
+ String fBuilderID;
+ IMakeBuilderInfo fBuildInfo;
+ protected TableViewer environmentTable;
+ protected String[] envTableColumnHeaders = {MakeUIPlugin.getResourceString("MakeEnvironmentBlock.0"), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.1")}; //$NON-NLS-1$ //$NON-NLS-2$
+ protected ColumnLayoutData[] envTableColumnLayouts = {new ColumnWeightData(50), new ColumnWeightData(50)};
+
+ private static final String NAME_LABEL = MakeUIPlugin.getResourceString("MakeEnvironmentBlock.2"); //$NON-NLS-1$
+ private static final String VALUE_LABEL = MakeUIPlugin.getResourceString("MakeEnvironmentBlock.3"); //$NON-NLS-1$
+
+ protected static final String P_VARIABLE = "variable"; //$NON-NLS-1$
+ protected static final String P_VALUE = "value"; //$NON-NLS-1$
+ protected static String[] envTableColumnProperties = {P_VARIABLE, P_VALUE};
+ protected Button envAddButton;
+ protected Button envEditButton;
+ protected Button envRemoveButton;
+ protected Button appendEnvironment;
+ protected Button replaceEnvironment;
+ protected Button envSelectButton;
+
+ class EnvironmentVariable {
+
+ // The name of the environment variable
+ private String name;
+
+ // The value of the environment variable
+ private String value;
+
+ EnvironmentVariable(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Returns this variable's name, which serves as the key in the
+ * key/value pair this variable represents
+ *
+ * @return this variable's name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns this variables value.
+ *
+ * @return this variable's value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets this variable's value
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof EnvironmentVariable) {
+ EnvironmentVariable var = (EnvironmentVariable)obj;
+ equal = var.getName().equals(name);
+ }
+ return equal;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return name.hashCode();
+ }
+ }
+
+ /**
+ * Content provider for the environment table
+ */
+ protected class EnvironmentVariableContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ EnvironmentVariable[] elements = new EnvironmentVariable[0];
+ IMakeBuilderInfo info = (IMakeBuilderInfo)inputElement;
+ Map m = info.getEnvironment();
+ if (m != null && !m.isEmpty()) {
+ elements = new EnvironmentVariable[m.size()];
+ String[] varNames = new String[m.size()];
+ m.keySet().toArray(varNames);
+ for (int i = 0; i < m.size(); i++) {
+ elements[i] = new EnvironmentVariable(varNames[i], (String)m.get(varNames[i]));
+ }
+ }
+ return elements;
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput == null) {
+ return;
+ }
+ if (viewer instanceof TableViewer) {
+ TableViewer tableViewer = (TableViewer)viewer;
+ if (tableViewer.getTable().isDisposed()) {
+ return;
+ }
+ tableViewer.setSorter(new ViewerSorter() {
+
+ public int compare(Viewer iviewer, Object e1, Object e2) {
+ if (e1 == null) {
+ return -1;
+ } else if (e2 == null) {
+ return 1;
+ } else {
+ return ((EnvironmentVariable)e1).getName().compareToIgnoreCase( ((EnvironmentVariable)e2).getName());
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Label provider for the environment table
+ */
+ public class EnvironmentVariableLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ public String getColumnText(Object element, int columnIndex) {
+ String result = null;
+ if (element != null) {
+ EnvironmentVariable var = (EnvironmentVariable)element;
+ switch (columnIndex) {
+ case 0 : // variable
+ result = var.getName();
+ break;
+ case 1 : // value
+ result = var.getValue();
+ break;
+ }
+ }
+ return result;
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENV_VAR);
+ }
+ return null;
+ }
+ }
+
+ public MakeEnvironmentBlock(Preferences prefs, String builderID) {
+ super(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.4")); //$NON-NLS-1$
+ setDescription(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.5")); //$NON-NLS-1$
+ fPrefs = prefs;
+ fBuilderID = builderID;
+ }
+
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+ if (getContainer().getProject() != null) {
+ try {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
+ } catch (CoreException e) {
+ }
+ } else {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
+ }
+ }
+
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ // Missing builder info
+ if (fBuildInfo == null) {
+ return;
+ }
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ IWorkspace workspace = MakeUIPlugin.getWorkspace();
+ // To avoid multi-build
+ IWorkspaceRunnable operation = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(MakeUIPlugin.getResourceString("SettingsBlock.monitor.applyingSettings"), 1); //$NON-NLS-1$
+ IMakeBuilderInfo info = null;
+ if (getContainer().getProject() != null) {
+ try {
+ info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
+ } catch (CoreException e) {
+ // disabled builder... just log it
+ MakeCorePlugin.log(e);
+ return;
+ }
+ } else {
+ info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
+ }
+ // Convert the table's items into a Map so that this can be saved in the
+ // configuration's attributes.
+ TableItem[] items = environmentTable.getTable().getItems();
+ Map map = new HashMap(items.length);
+ for (int i = 0; i < items.length; i++)
+ {
+ EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
+ map.put(var.getName(), var.getValue());
+ }
+ info.setEnvironment(map);
+ info.setAppendEnvironment(appendEnvironment.getSelection());
+ }
+ };
+ if (getContainer().getProject() != null) {
+ workspace.run(operation, monitor);
+ } else {
+ operation.run(monitor);
+ }
+ }
+
+ /**
+ * Updates the environment table for the given launch configuration
+ *
+ * @param configuration
+ */
+ protected void updateEnvironment(IMakeBuilderInfo info) {
+ environmentTable.setInput(info);
+ }
+
+ public void performDefaults() {
+ // Missing builder info
+ if (fBuildInfo == null) {
+ return;
+ }
+
+ IMakeBuilderInfo info;
+ if (getContainer().getProject() != null) {
+ info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
+ } else {
+ info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, true);
+ }
+ boolean append = info.appendEnvironment();
+ if (append) {
+ appendEnvironment.setSelection(true);
+ replaceEnvironment.setSelection(false);
+ } else {
+ replaceEnvironment.setSelection(true);
+ appendEnvironment.setSelection(false);
+ }
+ updateEnvironment(info);
+ updateAppendReplace();
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ setControl(composite);
+
+ MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_BUILDER_SETTINGS);
+
+ if (fBuildInfo == null) {
+ ControlFactory.createEmptySpace(composite);
+ ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("SettingsBlock.label.missingBuilderInformation")); //$NON-NLS-1$
+ return;
+ }
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ composite.setLayout(layout);
+ composite.setLayoutData(gridData);
+ composite.setFont(parent.getFont());
+
+ createBuildEnvironmentControls(composite);
+ createTableButtons(composite);
+ createAppendReplace(composite);
+
+ boolean append = fBuildInfo.appendEnvironment();
+ if (append) {
+ appendEnvironment.setSelection(true);
+ replaceEnvironment.setSelection(false);
+ } else {
+ replaceEnvironment.setSelection(true);
+ appendEnvironment.setSelection(false);
+ }
+ updateEnvironment(fBuildInfo);
+ updateAppendReplace();
+
+ }
+
+ private void createBuildEnvironmentControls(Composite parent) {
+ Font font = parent.getFont();
+ // Create table composite
+ Composite tableComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 1;
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint = 150;
+ tableComposite.setLayout(layout);
+ tableComposite.setLayoutData(gridData);
+ tableComposite.setFont(font);
+ // Create label
+ Label label = new Label(tableComposite, SWT.NONE);
+ label.setFont(font);
+ label.setText(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.6")); //$NON-NLS-1$
+ // Create table
+ environmentTable = new TableViewer(tableComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
+ | SWT.FULL_SELECTION);
+ Table table = environmentTable.getTable();
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setFont(font);
+ gridData = new GridData(GridData.FILL_BOTH);
+ environmentTable.getControl().setLayoutData(gridData);
+ environmentTable.setContentProvider(new EnvironmentVariableContentProvider());
+ environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider());
+ environmentTable.setColumnProperties(envTableColumnProperties);
+ environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTableSelectionChanged(event);
+ }
+ });
+ environmentTable.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ if (!environmentTable.getSelection().isEmpty()) {
+ handleEnvEditButtonSelected();
+ }
+ }
+ });
+ // Create columns
+ for (int i = 0; i < envTableColumnHeaders.length; i++) {
+ tableLayout.addColumnData(envTableColumnLayouts[i]);
+ TableColumn tc = new TableColumn(table, SWT.NONE, i);
+ tc.setResizable(envTableColumnLayouts[i].resizable);
+ tc.setText(envTableColumnHeaders[i]);
+ }
+ }
+
+ /**
+ * Responds to a selection changed event in the environment table
+ *
+ * @param event
+ * the selection change event
+ */
+ protected void handleTableSelectionChanged(SelectionChangedEvent event) {
+ int size = ((IStructuredSelection)event.getSelection()).size();
+ envEditButton.setEnabled(size == 1);
+ envRemoveButton.setEnabled(size > 0);
+ }
+
+ /**
+ * Create some empty space.
+ */
+ protected void createVerticalSpacer(Composite comp, int colSpan) {
+ Label label = new Label(comp, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = colSpan;
+ label.setLayoutData(gd);
+ label.setFont(comp.getFont());
+ }
+
+ /**
+ * Creates the add/edit/remove buttons for the environment table
+ *
+ * @param parent
+ * the composite in which the buttons should be created
+ */
+ protected void createTableButtons(Composite parent) {
+ // Create button composite
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ GridLayout glayout = new GridLayout();
+ glayout.marginHeight = 0;
+ glayout.marginWidth = 0;
+ glayout.numColumns = 1;
+ GridData gdata = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
+ buttonComposite.setLayout(glayout);
+ buttonComposite.setLayoutData(gdata);
+ buttonComposite.setFont(parent.getFont());
+
+ createVerticalSpacer(buttonComposite, 1);
+ // Create buttons
+ envAddButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.7"), null); //$NON-NLS-1$
+ envAddButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvAddButtonSelected();
+ }
+ });
+ envSelectButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.8"), null); //$NON-NLS-1$
+ envSelectButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvSelectButtonSelected();
+ }
+ });
+ envEditButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.9"), null); //$NON-NLS-1$
+ envEditButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvEditButtonSelected();
+ }
+ });
+ envEditButton.setEnabled(false);
+ envRemoveButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.10"), null); //$NON-NLS-1$
+ envRemoveButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvRemoveButtonSelected();
+ }
+ });
+ envRemoveButton.setEnabled(false);
+ }
+
+ /**
+ * Adds a new environment variable to the table.
+ */
+ protected void handleEnvAddButtonSelected() {
+ MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.11")); //$NON-NLS-1$
+ dialog.addTextField(NAME_LABEL, null, false);
+ dialog.addVariablesField(VALUE_LABEL, null, true);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+
+ String name = dialog.getStringValue(NAME_LABEL);
+ String value = dialog.getStringValue(VALUE_LABEL);
+
+ if (name != null && value != null && name.length() > 0 && value.length() > 0) {
+ addVariable(new EnvironmentVariable(name.trim(), value.trim()));
+ updateAppendReplace();
+ }
+ }
+
+ /**
+ * Updates the enablement of the append/replace widgets. The widgets should
+ * disable when there are no environment variables specified.
+ */
+ protected void updateAppendReplace() {
+ boolean enable = environmentTable.getTable().getItemCount() > 0;
+ appendEnvironment.setEnabled(enable);
+ replaceEnvironment.setEnabled(enable);
+ }
+
+ /**
+ * Attempts to add the given variable. Returns whether the variable was
+ * added or not (as when the user answers not to overwrite an existing
+ * variable).
+ *
+ * @param variable
+ * the variable to add
+ * @return whether the variable was added
+ */
+ protected boolean addVariable(EnvironmentVariable variable) {
+ String name = variable.getName();
+ TableItem[] items = environmentTable.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ EnvironmentVariable existingVariable = (EnvironmentVariable)items[i].getData();
+ if (existingVariable.getName().equals(name)) {
+ boolean overWrite = MessageDialog.openQuestion(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.12"), MessageFormat.format( //$NON-NLS-1$
+ MakeUIPlugin.getResourceString("MakeEnvironmentBlock.13"), new String[]{name})); //$NON-NLS-1$
+ if (!overWrite) {
+ return false;
+ }
+ environmentTable.remove(existingVariable);
+ break;
+ }
+ }
+ environmentTable.add(variable);
+ getContainer().updateContainer();
+ return true;
+ }
+
+ /**
+ * Gets native environment variable. Creates EnvironmentVariable objects.
+ *
+ * @return Map of name - EnvironmentVariable pairs based on native
+ * environment.
+ */
+ private Map getNativeEnvironment() {
+ Map stringVars = EnvironmentReader.getEnvVars();
+ HashMap vars = new HashMap();
+ for (Iterator i = stringVars.keySet().iterator(); i.hasNext();) {
+ String key = (String)i.next();
+ String value = (String)stringVars.get(key);
+ vars.put(key, new EnvironmentVariable(key, value));
+ }
+ return vars;
+ }
+
+ /**
+ * Displays a dialog that allows user to select native environment variables
+ * to add to the table.
+ */
+ protected void handleEnvSelectButtonSelected() {
+ // get Environment Variables from the OS
+ Map envVariables = getNativeEnvironment();
+
+ // get Environment Variables from the table
+ TableItem[] items = environmentTable.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ EnvironmentVariable var = (EnvironmentVariable)items[i].getData();
+ envVariables.remove(var.getName());
+ }
+
+ ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(),
+ createSelectionDialogLabelProvider(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.14")); //$NON-NLS-1$
+ dialog.setTitle(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.15")); //$NON-NLS-1$
+
+ int button = dialog.open();
+ if (button == Window.OK) {
+ Object[] selected = dialog.getResult();
+ for (int i = 0; i < selected.length; i++) {
+ environmentTable.add(selected[i]);
+ }
+ }
+
+ updateAppendReplace();
+ getContainer().updateContainer();
+ }
+
+ /**
+ * Creates a label provider for the native native environment variable
+ * selection dialog.
+ *
+ * @return A label provider for the native native environment variable
+ * selection dialog.
+ */
+ private ILabelProvider createSelectionDialogLabelProvider() {
+ return new ILabelProvider() {
+
+ public Image getImage(Object element) {
+ return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENVIRONMNET);
+ }
+ public String getText(Object element) {
+ EnvironmentVariable var = (EnvironmentVariable)element;
+ return var.getName() + " [" + var.getValue() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ public void addListener(ILabelProviderListener listener) {
+ }
+ public void dispose() {
+ }
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ };
+ }
+
+ /**
+ * Creates a content provider for the native native environment variable
+ * selection dialog.
+ *
+ * @return A content provider for the native native environment variable
+ * selection dialog.
+ */
+ private IStructuredContentProvider createSelectionDialogContentProvider() {
+ return new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ EnvironmentVariable[] elements = null;
+ if (inputElement instanceof Map) {
+ Comparator comparator = new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ String s1 = (String)o1;
+ String s2 = (String)o2;
+ return s1.compareTo(s2);
+ }
+
+ };
+ TreeMap envVars = new TreeMap(comparator);
+ envVars.putAll((Map)inputElement);
+ elements = new EnvironmentVariable[envVars.size()];
+ int index = 0;
+ for (Iterator iterator = envVars.keySet().iterator(); iterator.hasNext(); index++) {
+ Object key = iterator.next();
+ elements[index] = (EnvironmentVariable)envVars.get(key);
+ }
+ }
+ return elements;
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ };
+ }
+ /**
+ * Creates an editor for the value of the selected environment variable.
+ */
+ protected void handleEnvEditButtonSelected() {
+ IStructuredSelection sel = (IStructuredSelection)environmentTable.getSelection();
+ EnvironmentVariable var = (EnvironmentVariable)sel.getFirstElement();
+ if (var == null) {
+ return;
+ }
+ String originalName = var.getName();
+ String value = var.getValue();
+ MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.16")); //$NON-NLS-1$
+ dialog.addTextField(NAME_LABEL, originalName, false);
+ dialog.addVariablesField(VALUE_LABEL, value, true);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ String name = dialog.getStringValue(NAME_LABEL);
+ value = dialog.getStringValue(VALUE_LABEL);
+ if (!originalName.equals(name)) {
+ if (addVariable(new EnvironmentVariable(name, value))) {
+ environmentTable.remove(var);
+ }
+ } else {
+ var.setValue(value);
+ environmentTable.update(var, null);
+ getContainer().updateContainer();
+ }
+ }
+
+ /**
+ * Removes the selected environment variable from the table.
+ */
+ protected void handleEnvRemoveButtonSelected() {
+ IStructuredSelection sel = (IStructuredSelection)environmentTable.getSelection();
+ environmentTable.getControl().setRedraw(false);
+ for (Iterator i = sel.iterator(); i.hasNext();) {
+ EnvironmentVariable var = (EnvironmentVariable)i.next();
+ environmentTable.remove(var);
+ }
+ environmentTable.getControl().setRedraw(true);
+ updateAppendReplace();
+ getContainer().updateContainer();
+ }
+
+ private class NativeEnvironmentDialog extends ListSelectionDialog {
+
+ public NativeEnvironmentDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider,
+ ILabelProvider labelProvider, String message) {
+ super(parentShell, input, contentProvider, labelProvider, message);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ protected IDialogSettings getDialogSettings() {
+ IDialogSettings settings = MakeUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
+ if (section == null) {
+ section = settings.addNewSection(getDialogSettingsSectionName());
+ }
+ return section;
+ }
+
+ /**
+ * Returns the name of the section that this dialog stores its settings
+ * in
+ *
+ * @return String
+ */
+ protected String getDialogSettingsSectionName() {
+ return MakeUIPlugin.getPluginId() + ".ENVIRONMENT_TAB.NATIVE_ENVIROMENT_DIALOG"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
+ */
+ protected Point getInitialLocation(Point initialSize) {
+ Point initialLocation = DialogSettingsHelper.getInitialLocation(getDialogSettingsSectionName());
+ if (initialLocation != null) {
+ return initialLocation;
+ }
+ return super.getInitialLocation(initialSize);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ Point size = super.getInitialSize();
+ return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#close()
+ */
+ public boolean close() {
+ DialogSettingsHelper.persistShellGeometry(getShell(), getDialogSettingsSectionName());
+ return super.close();
+ }
+ }
+
+ /**
+ * Creates and configures the widgets which allow the user to choose whether
+ * the specified environment should be appended to the native environment or
+ * if it should completely replace it.
+ *
+ * @param parent
+ * the composite in which the widgets should be created
+ */
+ protected void createAppendReplace(Composite parent) {
+ Composite appendReplaceComposite = new Composite(parent, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ GridLayout layout = new GridLayout();
+ appendReplaceComposite.setLayoutData(gridData);
+ appendReplaceComposite.setLayout(layout);
+ appendReplaceComposite.setFont(parent.getFont());
+
+ appendEnvironment = createRadioButton(appendReplaceComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.17")); //$NON-NLS-1$
+ appendEnvironment.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ getContainer().updateContainer();
+ }
+ });
+ replaceEnvironment = createRadioButton(appendReplaceComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.18")); //$NON-NLS-1$
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
index eec5f290b3c..774fae03ac1 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
@@ -40,6 +40,7 @@ public class MakeProjectOptionBlock extends TabFolderOptionBlock {
protected void addTabs() {
addTab(new SettingsBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
+ addTab(new MakeEnvironmentBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
addTab(new ErrorParserBlock(MakeCorePlugin.getDefault().getPluginPreferences()));
addTab(new BinaryParserBlock());
addTab(new DiscoveryOptionsBlock());
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
index 5f7b7c7f504..b3a44855f61 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties
@@ -11,11 +11,49 @@
MakeCWizard.title=C/Make Project
MakeCWizard.description=Create a New C Project using 'make' to build it
+MakeEnvironmentBlock.10=&Remove
+MakeEnvironmentBlock.10=&Remove
+MakeEnvironmentBlock.11=New Environment Variable
+MakeEnvironmentBlock.11=New Environment Variable
+MakeEnvironmentBlock.12=Overwrite variable?
+MakeEnvironmentBlock.12=Overwrite variable?
+MakeEnvironmentBlock.13=A variable named {0} already exists. Overwrite?
+MakeEnvironmentBlock.13=A variable named {0} already exists. Overwrite?
+MakeEnvironmentBlock.14=Select &environment variables to add:
+MakeEnvironmentBlock.14=Select &environment variables to add:
+MakeEnvironmentBlock.15=Select Environment Variables
+MakeEnvironmentBlock.15=Select Environment Variables
+MakeEnvironmentBlock.16=Edit Environment Variable
+MakeEnvironmentBlock.16=Edit Environment Variable
+MakeEnvironmentBlock.17=&Append environment to native environment
+MakeEnvironmentBlock.17=&Append environment to native environment
+MakeEnvironmentBlock.18=Re&place native environment with specified environment
+MakeEnvironmentBlock.18=Re&place native environment with specified environment
MakeCWizard.task_name=Creating C project with Make builder...
MakeCCWizard.title=C++/Make Project
MakeCCWizard.description=Create a New C++ Project using 'make' to build it
MakeCCWizard.task_name=Creating C++ project with Make builder...
+MakeEnvironmentBlock.0=Variable
+MakeEnvironmentBlock.0=Variable
+MakeEnvironmentBlock.1=Value
+MakeEnvironmentBlock.1=Value
+MakeEnvironmentBlock.2=&Name:
+MakeEnvironmentBlock.2=&Name:
+MakeEnvironmentBlock.3=&Value:
+MakeEnvironmentBlock.3=&Value:
+MakeEnvironmentBlock.4=Environment
+MakeEnvironmentBlock.4=Environment
+MakeEnvironmentBlock.5=Environment used for make builder
+MakeEnvironmentBlock.5=Environment used for make builder
+MakeEnvironmentBlock.6=Environment variables to set
+MakeEnvironmentBlock.6=Environment variables to set
+MakeEnvironmentBlock.7=N&ew...
+MakeEnvironmentBlock.7=N&ew...
+MakeEnvironmentBlock.8=Se&lect...
+MakeEnvironmentBlock.8=Se&lect...
+MakeEnvironmentBlock.9=E&dit...
+MakeEnvironmentBlock.9=E&dit...
MakeCWizardSettings.title=C/Make Project Settings
MakeCWizardSettings.description=Define the project and 'make' builder settings
@@ -250,3 +288,6 @@ DiscoveredScannerConfigurationContainerPage.list.title=Discovered include paths
CopyDiscoveredPathAction.title=Copy
CopyDiscoveredPathAction.description=Copy as text
CopyDiscoveredPathAction.tooltip=Copy as text
+MultipleInputDialog.0=&Browse...
+MultipleInputDialog.1=Select a file:
+MultipleInputDialog.2=Varia&bles...
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java
index 4b3ac3e7b30..803f6e94d02 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java
@@ -73,13 +73,15 @@ public class MakeUIImages {
public static final String IMG_OBJS_MAKEFILE_INCLUDE = NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_INCLUDE = createManaged(OBJ, IMG_OBJS_MAKEFILE_INCLUDE);
- public static final String IMG_TOOLS_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ENVIRONMNET = NAME_PREFIX + "environment_obj.gif"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ENVIRONMENT = createManaged(OBJ, IMG_OBJS_ENVIRONMNET);
- public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJS_ENV_VAR = NAME_PREFIX + "environment_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_ENV_VAR = NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_ENV_VAR = createManaged(OBJ, IMG_OBJS_ENV_VAR);
+ public static final String IMG_TOOLS_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
+ public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
+
private static ImageDescriptor createManaged(String prefix, String name) {
return createManaged(imageRegistry, prefix, name);
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MultipleInputDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MultipleInputDialog.java
new file mode 100644
index 00000000000..b046d178416
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MultipleInputDialog.java
@@ -0,0 +1,372 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.debug.ui.StringVariableSelectionDialog;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+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.Point;
+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.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class MultipleInputDialog extends Dialog {
+ protected static final String FIELD_NAME = "FIELD_NAME"; //$NON-NLS-1$
+ protected static final int TEXT = 100;
+ protected static final int BROWSE = 101;
+ protected static final int VARIABLE = 102;
+
+ protected Composite panel;
+
+ protected List fieldList = new ArrayList();
+ protected List controlList = new ArrayList();
+ protected List validators = new ArrayList();
+ protected Map valueMap = new HashMap();
+
+ private String title;
+
+
+
+ public MultipleInputDialog(Shell shell, String title) {
+ super(shell);
+ this.title = title;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null) {
+ shell.setText(title);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createButtonBar(Composite parent) {
+ Control bar = super.createButtonBar(parent);
+ validateFields();
+ return bar;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite)super.createDialogArea(parent);
+ container.setLayout(new GridLayout(2, false));
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ panel = new Composite(container, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ for (Iterator i = fieldList.iterator(); i.hasNext();) {
+ FieldSummary field = (FieldSummary)i.next();
+ switch(field.type) {
+ case TEXT:
+ createTextField(field.name, field.initialValue, field.allowsEmpty);
+ break;
+ case BROWSE:
+ createBrowseField(field.name, field.initialValue, field.allowsEmpty);
+ break;
+ case VARIABLE:
+ createVariablesField(field.name, field.initialValue, field.allowsEmpty);
+ break;
+ }
+ }
+
+ fieldList = null; // allow it to be gc'd
+ Dialog.applyDialogFont(container);
+ return container;
+ }
+
+ public void addBrowseField(String labelText, String initialValue, boolean allowsEmpty) {
+ fieldList.add(new FieldSummary(BROWSE, labelText, initialValue, allowsEmpty));
+ }
+ public void addTextField(String labelText, String initialValue, boolean allowsEmpty) {
+ fieldList.add(new FieldSummary(TEXT, labelText, initialValue, allowsEmpty));
+ }
+ public void addVariablesField(String labelText, String initialValue, boolean allowsEmpty) {
+ fieldList.add(new FieldSummary(VARIABLE, labelText, initialValue, allowsEmpty));
+ }
+
+ protected void createTextField(String labelText, String initialValue, boolean allowEmpty) {
+ Label label = new Label(panel, SWT.NONE);
+ label.setText(labelText);
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ final Text text = new Text(panel, SWT.SINGLE | SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ text.setData(FIELD_NAME, labelText);
+
+ // make sure rows are the same height on both panels.
+ label.setSize(label.getSize().x, text.getSize().y);
+
+ if (initialValue != null) {
+ text.setText(initialValue);
+ }
+
+ if (!allowEmpty) {
+ validators.add(new Validator() {
+ public boolean validate() {
+ return !text.getText().equals(""); //$NON-NLS-1$
+ }
+ });
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateFields();
+ }
+ });
+ }
+
+ controlList.add(text);
+ }
+
+ protected void createBrowseField(String labelText, String initialValue, boolean allowEmpty) {
+ Label label = new Label(panel, SWT.NONE);
+ label.setText(labelText);
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ Composite comp = new Composite(panel, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight=0;
+ layout.marginWidth=0;
+ comp.setLayout(layout);
+ comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ final Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 200;
+ text.setLayoutData(data);
+ text.setData(FIELD_NAME, labelText);
+
+ // make sure rows are the same height on both panels.
+ label.setSize(label.getSize().x, text.getSize().y);
+
+ if (initialValue != null) {
+ text.setText(initialValue);
+ }
+
+ if (!allowEmpty) {
+ validators.add(new Validator() {
+ public boolean validate() {
+ return !text.getText().equals(""); //$NON-NLS-1$
+ }
+ });
+
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateFields();
+ }
+ });
+ }
+
+ Button button = createButton(comp, IDialogConstants.IGNORE_ID, MakeUIPlugin.getResourceString("MultipleInputDialog.0"), false); //$NON-NLS-1$
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ dialog.setMessage(MakeUIPlugin.getResourceString("MultipleInputDialog.1")); //$NON-NLS-1$
+ String currentWorkingDir = text.getText();
+ 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) {
+ text.setText(selectedDirectory);
+ }
+ }
+ });
+
+ controlList.add(text);
+
+ }
+
+
+ public void createVariablesField(String labelText, String initialValue, boolean allowEmpty) {
+ Label label = new Label(panel, SWT.NONE);
+ label.setText(labelText);
+ label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ Composite comp = new Composite(panel, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight=0;
+ layout.marginWidth=0;
+ comp.setLayout(layout);
+ comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ final Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 200;
+ text.setLayoutData(data);
+ text.setData(FIELD_NAME, labelText);
+
+ // make sure rows are the same height on both panels.
+ label.setSize(label.getSize().x, text.getSize().y);
+
+ if (initialValue != null) {
+ text.setText(initialValue);
+ }
+
+ if (!allowEmpty) {
+ validators.add(new Validator() {
+ public boolean validate() {
+ return !text.getText().equals(""); //$NON-NLS-1$
+ }
+ });
+
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateFields();
+ }
+ });
+ }
+
+ Button button = createButton(comp, IDialogConstants.IGNORE_ID, MakeUIPlugin.getResourceString("MultipleInputDialog.2"), false); //$NON-NLS-1$
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
+ int code = dialog.open();
+ if (code == IDialogConstants.OK_ID) {
+ String variable = dialog.getVariableExpression();
+ if (variable != null) {
+ text.insert(variable);
+ }
+ }
+ }
+ });
+
+ controlList.add(text);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ for (Iterator i = controlList.iterator(); i.hasNext(); ) {
+ Control control = (Control)i.next();
+ if (control instanceof Text) {
+ valueMap.put(control.getData(FIELD_NAME), ((Text)control).getText());
+ }
+ }
+ controlList = null;
+ super.okPressed();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ public int open() {
+ applyDialogFont(panel);
+ return super.open();
+ }
+
+ public Object getValue(String key) {
+ return valueMap.get(key);
+ }
+
+ public String getStringValue(String key) {
+ return (String) getValue(key);
+ }
+
+ public void validateFields() {
+ for(Iterator i = validators.iterator(); i.hasNext(); ) {
+ Validator validator = (Validator) i.next();
+ if (!validator.validate()) {
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ return;
+ }
+ }
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
+ */
+ protected Point getInitialLocation(Point initialSize) {
+ Point initialLocation= DialogSettingsHelper.getInitialLocation(getDialogSettingsSectionName());
+ if (initialLocation != null) {
+ return initialLocation;
+ }
+ return super.getInitialLocation(initialSize);
+ }
+
+
+ protected String getDialogSettingsSectionName() {
+ return MakeUIPlugin.getPluginId() + ".MULTIPLE_INPUT_DIALOG_2"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ Point size = super.getInitialSize();
+ return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#close()
+ */
+ public boolean close() {
+ DialogSettingsHelper.persistShellGeometry(getShell(), getDialogSettingsSectionName());
+ return super.close();
+ }
+
+ protected class FieldSummary {
+ int type;
+ String name;
+ String initialValue;
+ boolean allowsEmpty;
+
+ public FieldSummary(int type, String name, String initialValue, boolean allowsEmpty) {
+ this.type = type;
+ this.name = name;
+ this.initialValue = initialValue;
+ this.allowsEmpty = allowsEmpty;
+ }
+ }
+
+ protected class Validator {
+ boolean validate() {
+ return true;
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java
index e07c608f8a4..68251ee6473 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java
@@ -9,6 +9,7 @@
package org.eclipse.cdt.make.ui.dialogs;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
@@ -21,8 +22,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -78,21 +79,28 @@ public class SettingsBlock extends AbstractCOptionPage {
private static final String MAKE_BUILD_CLEAN_TARGET = PREFIX + ".makeWorkbench.cleanTarget"; //$NON-NLS-1$
Button stopOnErrorButton;
-
Button defButton;
Text buildCommand;
+ Button argumentVariablesButton;
Text buildLocation;
+ Button locationVariablesButton;
Text targetFull;
Text targetIncr;
Text targetAuto;
Text targetClean;
+
Button fullButton;
Button incrButton;
Button autoButton;
Button cleanButton;
+ Button fullVariableButton;
+ Button incrVariableButton;
+ Button autoVariableButton;
+ Button cleanVariableButton;
+
IMakeBuilderInfo fBuildInfo;
Preferences fPrefs;
String fBuilderID;
@@ -117,9 +125,8 @@ public class SettingsBlock extends AbstractCOptionPage {
protected void createBuildCmdControls(Composite parent) {
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1);
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 3;
layout.makeColumnsEqualWidth = false;
- layout.horizontalSpacing = 0;
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT));
@@ -128,17 +135,19 @@ public class SettingsBlock extends AbstractCOptionPage {
public void widgetSelected(SelectionEvent e) {
if (defButton.getSelection() == true) {
buildCommand.setEnabled(false);
+ argumentVariablesButton.setEnabled(false);
stopOnErrorButton.setEnabled(true);
getContainer().updateContainer();
} else {
buildCommand.setEnabled(true);
+ argumentVariablesButton.setEnabled(true);
stopOnErrorButton.setEnabled(false);
getContainer().updateContainer();
}
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
defButton.setLayoutData(gd);
Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL));
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
@@ -153,10 +162,10 @@ public class SettingsBlock extends AbstractCOptionPage {
getContainer().updateContainer();
}
});
- if (fBuildInfo.getBuildCommand() != null) {
- StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildCommand().toOSString());
+ if (fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, null) != null) {
+ StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "")); //$NON-NLS-1$
if (!fBuildInfo.isDefaultBuildCmd()) {
- String args = fBuildInfo.getBuildArguments();
+ String args = fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "");
if (args != null && !args.equals("")) { //$NON-NLS-1$
cmd.append(" "); //$NON-NLS-1$
cmd.append(args);
@@ -164,8 +173,10 @@ public class SettingsBlock extends AbstractCOptionPage {
}
buildCommand.setText(cmd.toString());
}
+ argumentVariablesButton = addVariablesButton(group, buildCommand);
if (fBuildInfo.isDefaultBuildCmd()) {
buildCommand.setEnabled(false);
+ argumentVariablesButton.setEnabled(false);
}
defButton.setSelection(fBuildInfo.isDefaultBuildCmd());
}
@@ -175,16 +186,20 @@ public class SettingsBlock extends AbstractCOptionPage {
public void widgetSelected(SelectionEvent e) {
targetAuto.setEnabled(autoButton.getSelection());
+ autoVariableButton.setEnabled(autoButton.getSelection());
targetFull.setEnabled(fullButton.getSelection());
+ fullVariableButton.setEnabled(fullButton.getSelection());
targetIncr.setEnabled(incrButton.getSelection());
+ incrVariableButton.setEnabled(incrButton.getSelection());
targetClean.setEnabled(cleanButton.getSelection());
+ cleanVariableButton.setEnabled(cleanButton.getSelection());
getContainer().updateContainer();
}
};
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_GROUP), 1);
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 3;
layout.makeColumnsEqualWidth = false;
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -192,49 +207,70 @@ public class SettingsBlock extends AbstractCOptionPage {
label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TYPE));
label = new Label(group, SWT.NONE);
label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TARGET));
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ label.setLayoutData(gd);
autoButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO));
autoButton.addSelectionListener(selectionAdapter);
autoButton.setSelection(fBuildInfo.isAutoBuildEnable());
- // if (!MakeUIPlugin.getWorkspace().isAutoBuilding()) {
- // autoButton.setEnabled(false);
- // }
targetAuto = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetAuto.setText(fBuildInfo.getAutoBuildTarget());
+ targetAuto.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); //$NON-NLS-1$
((GridData) (targetAuto.getLayoutData())).horizontalAlignment = GridData.FILL;
((GridData) (targetAuto.getLayoutData())).grabExcessHorizontalSpace = true;
addControlAccessibleListener(targetAuto, MakeUIPlugin.getResourceString(MAKE_BUILD_AUTO_TARGET));
+ autoVariableButton = addVariablesButton(group, targetAuto);
String noteTitle = MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.note"); //$NON-NLS-1$
String noteMessage = MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.autobuildMessage"); //$NON-NLS-1$
Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), group, noteTitle, noteMessage);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
noteControl.setLayoutData(gd);
incrButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR));
incrButton.addSelectionListener(selectionAdapter);
incrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled());
targetIncr = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetIncr.setText(fBuildInfo.getIncrementalBuildTarget());
+ targetIncr.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL, "")); //$NON-NLS-1$
((GridData) (targetIncr.getLayoutData())).horizontalAlignment = GridData.FILL;
((GridData) (targetIncr.getLayoutData())).grabExcessHorizontalSpace = true;
addControlAccessibleListener(targetIncr, MakeUIPlugin.getResourceString(MAKE_BUILD_INCREMENTAL_TARGET));
+ incrVariableButton = addVariablesButton(group, targetIncr);
fullButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_FULL));
fullButton.addSelectionListener(selectionAdapter);
fullButton.setSelection(fBuildInfo.isFullBuildEnabled());
targetFull = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetFull.setText(fBuildInfo.getFullBuildTarget());
+ targetFull.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, "")); //$NON-NLS-1$
((GridData) (targetFull.getLayoutData())).horizontalAlignment = GridData.FILL;
((GridData) (targetFull.getLayoutData())).grabExcessHorizontalSpace = true;
addControlAccessibleListener(targetFull, MakeUIPlugin.getResourceString(MAKE_BUILD_FULL_TARGET));
+ fullVariableButton = addVariablesButton(group, targetFull);
cleanButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_CLEAN));
cleanButton.addSelectionListener(selectionAdapter);
cleanButton.setSelection(fBuildInfo.isCleanBuildEnabled());
targetClean = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
- targetClean.setText(fBuildInfo.getCleanBuildTarget());
+ targetClean.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, ""));
((GridData) (targetClean.getLayoutData())).horizontalAlignment = GridData.FILL;
((GridData) (targetClean.getLayoutData())).grabExcessHorizontalSpace = true;
addControlAccessibleListener(targetClean, MakeUIPlugin.getResourceString(MAKE_BUILD_CLEAN_TARGET));
+ cleanVariableButton = addVariablesButton(group, targetClean);
selectionAdapter.widgetSelected(null);
+ }
+ private Button addVariablesButton(Composite parent, final Text control) {
+ Button variablesButton = createPushButton(parent, "Variables...", null);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ variablesButton.setLayoutData(gd);
+ variablesButton.addSelectionListener(new SelectionAdapter() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent arg0) {
+ handleVariablesButtonSelected(control);
+ }
+ });
+ return variablesButton;
}
protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
@@ -289,7 +325,7 @@ public class SettingsBlock extends AbstractCOptionPage {
protected void createBuilderWorkingDirControls(Composite parent) {
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_GROUP), 1);
GridLayout layout = new GridLayout();
- layout.numColumns = 3;
+ layout.numColumns = 4;
layout.makeColumnsEqualWidth = false;
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -320,9 +356,30 @@ public class SettingsBlock extends AbstractCOptionPage {
}
}
});
- buildLocation.setText(fBuildInfo.getBuildLocation().toOSString());
+ buildLocation.setText(fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, ""));
+ locationVariablesButton = addVariablesButton(group, buildLocation);
}
+ /**
+ * 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 createControl(Composite parent) {
Composite composite = ControlFactory.createComposite(parent, 1);
setControl(composite);
@@ -373,7 +430,7 @@ public class SettingsBlock extends AbstractCOptionPage {
try {
info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
} catch (CoreException e) {
- // disabled builder... just log it
+ // disabled builder... just log it
MakeCorePlugin.log(e);
return;
}
@@ -392,29 +449,29 @@ public class SettingsBlock extends AbstractCOptionPage {
start = 1;
end = bldLine.indexOf('"', 1);
}
- IPath path;
+ String path;
if (end == -1) {
- path = new Path(bldLine);
+ path = bldLine;
} else {
- path = new Path(bldLine.substring(start, end));
+ path = bldLine.substring(start, end);
}
- info.setBuildCommand(path);
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_COMMAND, path);
String args = ""; //$NON-NLS-1$
if (end != -1) {
args = bldLine.substring(end + 1);
}
- info.setBuildArguments(args);
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_ARGUMENTS, args);
}
info.setAutoBuildEnable(autoButton.getSelection());
- info.setAutoBuildTarget(targetAuto.getText().trim());
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, targetAuto.getText().trim());
info.setIncrementalBuildEnable(incrButton.getSelection());
- info.setIncrementalBuildTarget(targetIncr.getText().trim());
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREAMENTAL, targetIncr.getText().trim());
info.setFullBuildEnable(fullButton.getSelection());
- info.setFullBuildTarget(targetFull.getText().trim());
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_FULL, targetFull.getText().trim());
info.setCleanBuildEnable(cleanButton.getSelection());
- info.setCleanBuildTarget(targetClean.getText().trim());
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, targetClean.getText().trim());
if (buildLocation != null) {
- info.setBuildLocation(new Path(buildLocation.getText().trim()));
+ info.setBuildAttribute(IMakeBuilderInfo.BUILD_LOCATION, buildLocation.getText().trim());
}
}
};
@@ -453,9 +510,11 @@ public class SettingsBlock extends AbstractCOptionPage {
}
if (info.isDefaultBuildCmd()) {
buildCommand.setEnabled(false);
+ argumentVariablesButton.setEnabled(false);
stopOnErrorButton.setEnabled(true);
} else {
buildCommand.setEnabled(true);
+ argumentVariablesButton.setEnabled(true);
stopOnErrorButton.setEnabled(false);
}
defButton.setSelection(info.isDefaultBuildCmd());