Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-06-09 19:22:21 +0000
committerDoug Schaefer2003-06-09 19:22:21 +0000
commitda0c569bffa17674195771eb1bea9bb14c2386ef (patch)
tree27b91d12488fb7d8dad09e116a023b09f29c5e7e
parente9adc8cbbbdaf99f2b679bbe01db9867da668cfb (diff)
downloadorg.eclipse.cdt-da0c569bffa17674195771eb1bea9bb14c2386ef.tar.gz
org.eclipse.cdt-da0c569bffa17674195771eb1bea9bb14c2386ef.tar.xz
org.eclipse.cdt-da0c569bffa17674195771eb1bea9bb14c2386ef.zip
Patch for Sean Evoy:
- Initial contribution of Managed Build UI.
-rw-r--r--core/org.eclipse.cdt.core/ChangeLog41
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IResourceBuildInfo.java124
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java83
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java54
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java36
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java2
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java18
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java225
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java70
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java144
-rw-r--r--core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java78
-rw-r--r--core/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd49
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/GeneratedMakefileBuilder.java86
-rw-r--r--core/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java272
-rw-r--r--core/org.eclipse.cdt.ui.tests/plugin.xml74
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog44
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BrowseEntryDialog.java179
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java105
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java61
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java556
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java131
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java425
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ManageConfigDialog.java233
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/NewConfigurationDialog.java208
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java114
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListContentProvider.java98
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java65
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/CProjectPlatformPage.java218
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationBlock.java181
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationContentProvider.java35
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationLabelProvider.java36
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCCWizard.java66
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCWizard.java61
-rw-r--r--core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedProjectWizard.java201
-rw-r--r--core/org.eclipse.cdt.ui/plugin.properties17
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml363
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties65
38 files changed, 4621 insertions, 214 deletions
diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog
index 5b20ac0e3f9..12dea6c2a44 100644
--- a/core/org.eclipse.cdt.core/ChangeLog
+++ b/core/org.eclipse.cdt.core/ChangeLog
@@ -1,3 +1,44 @@
+2003-06-06 Sean Evoy
+
+ Added new interface, IResourceBuildInfo, so clients could
+ be shielded from future implementation changes.
+
+ ManagedBuildManager class has been updated to return an
+ interface, IResourceBuildInfo, instead of the implementing
+ class.
+
+ For ITool, I added a method to determine if the tool produces
+ an output based on a file extension, and one to determine if
+ it builds an input based on a file extension. I added a method
+ to determine what the output file extension of a build will
+ be based on an input extension. Finally, I added a method to
+ extract a tool command and one to extract its flags.
+
+ For ITarget, I added more information about the build artifact.
+ I have added artifact name and default extension attributes to
+ the target schema. The artifact name is intended to hold the
+ name the user has selected as the final build object
+ (i.e. test.exe, foo.so, etc). The default extension will be
+ used by the toolchain provider to specify a default extension
+ for the final build object (i.e. .dll.a for Cygwin shared libs
+ vs .so for Linux shared libs). There are getter and setter
+ methods for the name of the final build artifact. There is also a
+ method to extract the default extension that is built for targets
+ of this type.
+
+ The build model schema was updated to reflect these new bit of
+ information.
+
+ The GeneratedMakefileBuilder was updated to extract this information
+ and to create a new rule for each input to the build artifact.
+
+ The resource build information store now remembers the top
+ configuration for a target as selected by the user in the UI.
+ This is needed by the makefile generator and in persisted in the
+ project build file.
+
+ The test has been updated to reflect these changes.
+
2003-06-05 Alain Magloire
PR #38380, partially fix; would need more detail form
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IResourceBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IResourceBuildInfo.java
new file mode 100644
index 00000000000..c42170e900d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/IResourceBuildInfo.java
@@ -0,0 +1,124 @@
+package org.eclipse.cdt.core.build.managed;
+
+import java.util.List;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+public interface IResourceBuildInfo {
+
+ /**
+ * Add a new target to the build information for the receiver
+ *
+ * @param target
+ */
+ public void addTarget(ITarget target);
+
+ /**
+ * Returns the name of the artifact to build for the receiver.
+ *
+ * @return
+ */
+ public String getBuildArtifactName();
+
+ /**
+ * Get the default configuration associated with the receiver
+ *
+ * @return
+ */
+ public IConfiguration getDefaultConfiguration(ITarget target);
+
+
+ /**
+ * Returns the default target in the receiver.
+ *
+ * @return
+ */
+ public ITarget getDefaultTarget();
+
+ /**
+ * Answers the extension that will be built by the current configuration
+ * for the extension passed in the argument or <code>null</code>.
+ *
+ * @param resourceName
+ * @return
+ */
+ public String getOutputExtension(String resourceExtension);
+
+ /**
+ * Get the target specified in the argument.
+ *
+ * @param id
+ * @return
+ */
+ public ITarget getTarget(String id);
+
+ /**
+ * Get all of the targets associated with the receiver.
+ *
+ * @return
+ */
+ public List getTargets();
+
+ /**
+ * Returns a <code>String</code> containing the flags, including
+ * those overridden by the user, for the tool that handles the
+ * type of source file defined by the argument.
+ *
+ * @param extension
+ * @return
+ */
+ public String getFlagsForSource(String extension);
+
+ /**
+ * Returns a <code>String</code> containing the flags, including
+ * those overridden by the user, for the tool that handles the
+ * type of target defined by the argument.
+ *
+ * @param extension
+ * @return
+ */
+ public String getFlagsForTarget(String extension);
+
+ /**
+ * Returns a <code>String</code> containing the command-line invocation
+ * for the tool associated with the source extension.
+ *
+ * @param extension
+ * @return
+ */
+ public String getToolForSource(String extension);
+
+ /**
+ * Returns a <code>String</code> containing the command-line invocation
+ * for the tool associated with the target extension.
+ *
+ * @param extension
+ * @return
+ */
+ public String getToolForTarget(String extension);
+
+ /**
+ * Set the primary configuration for the receiver.
+ *
+ * @param configuration The <code>IConfiguration</code> that will be used as the default
+ * for all building.
+ */
+ public void setDefaultConfiguration(IConfiguration configuration);
+
+ /**
+ * Set the primary target for the receiver.
+ *
+ * @param target
+ */
+ public void setDefaultTarget(ITarget target);
+
+}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
index 3a44a11fa40..2eefd1c879f 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITarget.java
@@ -19,36 +19,46 @@ import org.eclipse.core.resources.IResource;
public interface ITarget extends IBuildObject {
/**
- * Returns whether this target is abstract
+ * Creates a configuration for the target populated with the tools and
+ * options settings from the parent configuration. As options and tools
+ * change in the parent, unoverridden values are updated in the child
+ * config as well.
+ *
+ * @param parent
+ * @param id
* @return
*/
- public boolean isAbstract();
-
+ public IConfiguration createConfiguration(IConfiguration parent, String id);
+
/**
- * Gets the resource that this target is applied to.
+ * Creates a new configuration for the target. It is populated with
+ * the tools defined for that target and options set at their defaults.
*
+ * @param id id for this configuration.
* @return
*/
- public IResource getOwner();
-
+ public IConfiguration createConfiguration(String id);
+
/**
- * @return the <code>ITarget</code> that is the parent of the receiver.
+ * Get the name of the final build artifact.
+ *
+ * @return
*/
- public ITarget getParent();
+ public String getArtifactName();
/**
- * Returns the list of platform specific tools associated with this
- * platform.
- *
+ * Returns all of the configurations defined by this target.
* @return
*/
- public ITool[] getTools();
+ public IConfiguration[] getConfigurations();
/**
- * Returns all of the configurations defined by this target.
+ * Get the default extension that should be applied to build artifacts
+ * created by this target.
+ *
* @return
*/
- public IConfiguration[] getConfigurations();
+ public String getDefaultExtension();
/**
* Returns the configuration with the given id, or null if not found.
@@ -59,23 +69,46 @@ public interface ITarget extends IBuildObject {
public IConfiguration getConfiguration(String id);
/**
- * Creates a new configuration for the target. It is populated with
- * the tools defined for that target and options set at their defaults.
+ * Gets the resource that this target is applied to.
*
- * @param id id for this configuration.
* @return
*/
- public IConfiguration createConfiguration(String id);
+ public IResource getOwner();
+
+ /**
+ * @return the <code>ITarget</code> that is the parent of the receiver.
+ */
+ public ITarget getParent();
/**
- * Creates a configuration for the target populated with the tools and
- * options settings from the parent configuration. As options and tools
- * change in the parent, unoverridden values are updated in the child
- * config as well.
+ * Returns the list of platform specific tools associated with this
+ * platform.
*
- * @param parent
- * @param id
* @return
*/
- public IConfiguration createConfiguration(IConfiguration parent, String id);
+ public ITool[] getTools();
+
+ /**
+ * Returns whether this target is abstract.
+ * @return
+ */
+ public boolean isAbstract();
+
+ /**
+ * Answers <code>true</code> if the receiver is a target that is defined
+ * for testing purposes only, else <code>false</code>. A test target will
+ * not be shown in the UI but can still be manipulated programmatically.
+ *
+ * @return
+ */
+ public boolean isTestTarget();
+
+ /**
+ * Set the name of the artifact that will be produced when the receiver
+ * is built.
+ *
+ * @param name The name of the build artifact.
+ */
+ public void setBuildArtifact(String name);
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
index 5878ce765b2..89751c5d8ef 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ITool.java
@@ -14,12 +14,24 @@ package org.eclipse.cdt.core.build.managed;
*
*/
public interface ITool extends IBuildObject {
+ public static final String WHITE_SPACE = " ";
/**
- * Return the target that defines this tool, if applicable
+ * Return <code>true</code> if the receiver builds files with the
+ * specified extension, else <code>false</code>.
+ *
+ * @param extension
* @return
*/
- public ITarget getTarget();
+ public boolean buildsFileType(String extension);
+
+ /**
+ * Get a particular option.
+ *
+ * @param id
+ * @return
+ */
+ public IOption getOption(String id);
/**
* Returns the options that may be customized for this tool.
@@ -27,12 +39,34 @@ public interface ITool extends IBuildObject {
public IOption[] getOptions();
/**
- * Get a particular option.
+ * Answer the output extension the receiver will create from the input,
+ * or <code>null</code> if the tool does not understand that extension.
*
- * @param id
+ * @param inputExtension The extension of the source file.
* @return
*/
- public IOption getOption(String id);
+ public String getOutputExtension(String inputExtension);
+
+ /**
+ * Return the target that defines this tool, if applicable
+ * @return
+ */
+ public ITarget getTarget();
+
+ /**
+ * Answers the command-line invocation defined for the receiver.
+ *
+ * @return
+ */
+ public String getToolCommand();
+
+ /**
+ * Answers the additional command line arguments the user has specified for
+ * the tool.
+ *
+ * @return
+ */
+ public String getToolFlags() throws BuildException ;
/**
* Options are organized into categories for UI purposes.
@@ -42,4 +76,14 @@ public interface ITool extends IBuildObject {
* @return
*/
public IOptionCategory getTopOptionCategory();
+
+ /**
+ * Answers <code>true</code> if the receiver builds a file with the extension specified
+ * in the argument, else <code>false</code>.
+ *
+ * @param outputExtension
+ * @return
+ */
+ public boolean producesFileType(String outputExtension);
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
index 149affb08b7..7adb6cd1471 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/core/build/managed/ManagedBuildManager.java
@@ -108,7 +108,7 @@ public class ManagedBuildManager {
* @return
*/
public static ITarget[] getTargets(IResource resource) {
- ResourceBuildInfo buildInfo = getBuildInfo(resource);
+ IResourceBuildInfo buildInfo = getBuildInfo(resource);
if (buildInfo != null) {
List targets = buildInfo.getTargets();
@@ -121,7 +121,7 @@ public class ManagedBuildManager {
public static ITarget getTarget(IResource resource, String id) {
if (resource != null) {
- ResourceBuildInfo buildInfo = getBuildInfo(resource);
+ IResourceBuildInfo buildInfo = getBuildInfo(resource);
if (buildInfo != null)
return buildInfo.getTarget(id);
}
@@ -138,7 +138,7 @@ public class ManagedBuildManager {
*
* @param resource
* @param parentTarget
- * @return
+ * @return new <code>ITarget</code> with settings based on the parent passed in the arguments
* @throws BuildException
*/
public static ITarget createTarget(IResource resource, ITarget parentTarget)
@@ -167,6 +167,24 @@ public class ManagedBuildManager {
}
/**
+ * Sets the default configuration for the project. Note that this will also
+ * update the default target if needed.
+ *
+ * @param project
+ * @param newDefault
+ */
+ public static void setDefaultConfiguration(IProject project, IConfiguration newDefault) {
+ if (project == null || newDefault == null) {
+ return;
+ }
+ // Set the default in build information for the project
+ IResourceBuildInfo info = getBuildInfo(project);
+ if (info != null) {
+ info.setDefaultConfiguration(newDefault);
+ }
+ }
+
+ /**
* Set the string value for an option for a given config.
*
* @param config The configuration the option belongs to.
@@ -223,9 +241,8 @@ public class ManagedBuildManager {
Element rootElement = doc.createElement("buildInfo");
doc.appendChild(rootElement);
- // Populate from buildInfo
- // To do - find other resources also
- ResourceBuildInfo buildInfo = getBuildInfo(project);
+ // Save the build info
+ ResourceBuildInfo buildInfo = (ResourceBuildInfo) getBuildInfo(project);
if (buildInfo != null)
buildInfo.serialize(doc, rootElement);
@@ -276,8 +293,7 @@ public class ManagedBuildManager {
return;
extensionTargetsLoaded = true;
- IExtensionPoint extensionPoint
- = CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ManagedBuildInfo");
+ IExtensionPoint extensionPoint = CCorePlugin.getDefault().getDescriptor().getExtensionPoint("ManagedBuildInfo");
IExtension[] extensions = extensionPoint.getExtensions();
for (int i = 0; i < extensions.length; ++i) {
IExtension extension = extensions[i];
@@ -313,7 +329,7 @@ public class ManagedBuildManager {
return buildInfo;
}
- public static ResourceBuildInfo getBuildInfo(IResource resource, boolean create) {
+ public static IResourceBuildInfo getBuildInfo(IResource resource, boolean create) {
// Make sure the extension information is loaded first
loadExtensions();
ResourceBuildInfo buildInfo = null;
@@ -338,7 +354,7 @@ public class ManagedBuildManager {
return buildInfo;
}
- public static ResourceBuildInfo getBuildInfo(IResource resource) {
+ public static IResourceBuildInfo getBuildInfo(IResource resource) {
return getBuildInfo(resource, false);
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
index 0a11759af69..1369bb6a944 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
@@ -258,7 +258,7 @@ public class Configuration extends BuildObject implements IConfiguration {
String oldValue;
// Check whether this is an enumerated option
if (option.getValueType() == IOption.ENUMERATED) {
- oldValue = option.getEnumCommand(option.getSelectedEnum());
+ oldValue = option.getSelectedEnum();
}
else {
oldValue = option.getStringValue();
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
index 6961ac68dc5..66abdfc2df1 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/OptionReference.java
@@ -30,10 +30,14 @@ import org.w3c.dom.NodeList;
*/
public class OptionReference implements IOption {
+ // Used for all option references that override the command
+ private String command;
+ // The option this reference overrides
private IOption option;
+ // The owner of the reference
private ToolReference owner;
+ // The actual value of the reference
private Object value;
- private String command;
/**
* Created internally.
@@ -69,7 +73,7 @@ public class OptionReference implements IOption {
value = element.getAttribute("defaultValue");
break;
case IOption.ENUMERATED:
- value = option.getEnumCommand(option.getSelectedEnum());
+ value = option.getSelectedEnum();
break;
case IOption.STRING_LIST:
List valueList = new ArrayList();
@@ -97,11 +101,11 @@ public class OptionReference implements IOption {
// value
switch (option.getValueType()) {
case IOption.BOOLEAN:
- value = new Boolean(element.getAttribute("value"));
+ value = new Boolean(element.getAttribute("defaultValue"));
break;
case IOption.STRING:
case IOption.ENUMERATED:
- value = (String) element.getAttribute("value");
+ value = (String) element.getAttribute("defaultValue");
break;
case IOption.STRING_LIST:
List valueList = new ArrayList();
@@ -130,11 +134,11 @@ public class OptionReference implements IOption {
// value
switch (option.getValueType()) {
case IOption.BOOLEAN:
- element.setAttribute("value", ((Boolean)value).toString());
+ element.setAttribute("defaultValue", ((Boolean)value).toString());
break;
case IOption.STRING:
case IOption.ENUMERATED:
- element.setAttribute("value", (String)value);
+ element.setAttribute("defaultValue", (String)value);
break;
case IOption.STRING_LIST:
ArrayList stringList = (ArrayList)value;
@@ -213,7 +217,7 @@ public class OptionReference implements IOption {
// Return the default defined for the enumeration in the manifest.
return option.getSelectedEnum();
} else {
- // Value will contain the selection of the user
+ // Value will contain the human-readable name of the enum
return (String) value;
}
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
index a1a36e5f0ef..82e3627c505 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ResourceBuildInfo.java
@@ -14,58 +14,263 @@ package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
+import org.eclipse.cdt.core.build.managed.BuildException;
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IResourceBuildInfo;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.core.resources.IResource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-public class ResourceBuildInfo {
+public class ResourceBuildInfo implements IResourceBuildInfo {
private IResource owner;
private Map targetMap;
private List targets;
-
+ private Map defaultConfigurations;
+ private ITarget defaultTarget;
+
public ResourceBuildInfo() {
targetMap = new HashMap();
targets = new ArrayList();
+ defaultConfigurations = new HashMap();
}
public ResourceBuildInfo(IResource owner, Element element) {
this();
-
+ // The id of the default configuration
+ String defaultTargetId = null;
+ List configIds = new ArrayList();
Node child = element.getFirstChild();
while (child != null) {
if (child.getNodeName().equals("target")) {
new Target(this, (Element)child);
+ } else if (child.getNodeName().equals("defaultConfig")) {
+ // We may not have read the config in yet, so just cache it
+ configIds.add(((Element)child).getAttribute("id"));
+ } else if (child.getNodeName().equals("defaultTarget")) {
+ defaultTargetId = ((Element)child).getAttribute("id");
}
child = child.getNextSibling();
}
+ // All the available targets have been read in
+ defaultTarget = (ITarget) targetMap.get(defaultTargetId);
+ // Now we have a misserable O(N^2) operation (oh well, the data sets are small)
+ ListIterator stringIter = configIds.listIterator();
+ while (stringIter.hasNext()){
+ String confId = (String) stringIter.next();
+ ListIterator targIter = targets.listIterator();
+ while (targIter.hasNext()) {
+ Target targ = (Target) targIter.next();
+ IConfiguration conf = targ.getConfiguration(confId);
+ if (conf != null) {
+ defaultConfigurations.put(targ.getId(), conf);
+ break;
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
+ */
+ public void addTarget(ITarget target) {
+ targetMap.put(target.getId(), target);
+ targets.add(target);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getBuildArtifactName()
+ */
+ public String getBuildArtifactName() {
+ // Get the default target and use its value
+ String name = getDefaultTarget().getArtifactName();
+ return name == null ? new String() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getDefaultConfiguration()
+ */
+ public IConfiguration getDefaultConfiguration(ITarget target) {
+ // Get the default config associated with the defalt target
+ IConfiguration config = (IConfiguration) defaultConfigurations.get(target.getId());
+
+ // If null, look up the first configuration associated with the target
+ if (config == null) {
+ IConfiguration[] configs = getDefaultTarget().getConfigurations();
+ if (configs.length > 0) {
+ config = configs[0];
+ }
+ }
+ return config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getDefaultTarget()
+ */
+ public ITarget getDefaultTarget() {
+ if (defaultTarget == null) {
+ defaultTarget = (ITarget) targets.get(0);
+ }
+ return defaultTarget;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getFlagsForSource(java.lang.String)
+ */
+ public String getFlagsForSource(String extension) {
+ // Get all the tools for the current config
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(extension)) {
+ String flags = new String();
+ try {
+ flags = tool.getToolFlags();
+ } catch (BuildException e) {
+ // Give it your best shot with the next tool
+ continue;
+ }
+ return flags;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getToolFlags(java.lang.String)
+ */
+ public String getFlagsForTarget(String extension) {
+ // Get all the tools for the current config
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(extension)) {
+ String flags = new String();
+ try {
+ flags = tool.getToolFlags();
+ } catch (BuildException e) {
+ // TODO: handle exception
+ }
+ return flags;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getOutputExtension(java.lang.String)
+ */
+ public String getOutputExtension(String resourceExtension) {
+ // Get all the tools for the current config
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ String output = tool.getOutputExtension(resourceExtension);
+ if (output != null) {
+ return output;
+ }
+ }
+ return null;
}
public IResource getOwner() {
return owner;
}
-
- public Target getTarget(String id) {
- return (Target)targetMap.get(id);
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public ITarget getTarget(String id) {
+ return (ITarget) targetMap.get(id);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
public List getTargets() {
return targets;
}
- public void addTarget(Target target) {
- targetMap.put(target.getId(), target);
- targets.add(target);
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getToolForSource(java.lang.String)
+ */
+ public String getToolForSource(String extension) {
+ // Get all the tools for the current config
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.buildsFileType(extension)) {
+ return tool.getToolCommand();
+ }
+ }
+ return null;
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#getToolInvocation(java.lang.String)
+ */
+ public String getToolForTarget(String extension) {
+ // Get all the tools for the current config
+ IConfiguration config = getDefaultConfiguration(getDefaultTarget());
+ ITool[] tools = config.getTools();
+ for (int index = 0; index < tools.length; index++) {
+ ITool tool = tools[index];
+ if (tool.producesFileType(extension)) {
+ return tool.getToolCommand();
+ }
+ }
+ return null;
+ }
+
public void serialize(Document doc, Element element) {
+ // Write out each target and their default config
for (int i = 0; i < targets.size(); ++i) {
Element targetElement = doc.createElement("target");
element.appendChild(targetElement);
((Target)targets.get(i)).serialize(doc, targetElement);
+ IConfiguration config = getDefaultConfiguration((ITarget)targets.get(i));
+ if (config != null) {
+ Element configEl = doc.createElement("defaultConfig");
+ element.appendChild(configEl);
+ configEl.setAttribute("id", config.getId());
+ }
+ }
+ // Persist the default target
+ if (getDefaultTarget() != null){
+ Element targEl = doc.createElement("defaultTarget");
+ element.appendChild(targEl);
+ targEl.setAttribute("id", getDefaultTarget().getId());
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public void setDefaultConfiguration(IConfiguration configuration) {
+ // Get the target associated with the argument
+ ITarget target = configuration.getTarget();
+ // Make sure it is the default
+ setDefaultTarget(target);
+ defaultConfigurations.put(target.getId(), configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IResourceBuildInfo#setDefaultTarget(org.eclipse.cdt.core.build.managed.ITarget)
+ */
+ public void setDefaultTarget(ITarget target) {
+ if (defaultTarget != null && defaultTarget.getId().equals(target.getId())) {
+ return;
+ }
+ defaultTarget = target;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
index b9aec823e43..406972b5674 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Target.java
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IResourceBuildInfo;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
@@ -37,8 +38,12 @@ public class Target extends BuildObject implements ITarget {
private List configurations;
private Map configMap;
private boolean isAbstract = false;
+ private boolean isTest = false;
+ private String artifactName;
+ private String defaultExtension;
private static final IConfiguration[] emptyConfigs = new IConfiguration[0];
+ private static final String EMPTY_STRING = new String();
public Target(IResource owner) {
this.owner = owner;
@@ -58,9 +63,12 @@ public class Target extends BuildObject implements ITarget {
this.parent = parent;
setId(parent.getId() + ".1");
setName(parent.getName());
+ this.artifactName = parent.getArtifactName();
+ this.defaultExtension = parent.getDefaultExtension();
+ this.isTest = parent.isTestTarget();
// Hook me up
- ResourceBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner, true);
+ IResourceBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner, true);
buildInfo.addTarget(this);
}
@@ -76,9 +84,16 @@ public class Target extends BuildObject implements ITarget {
// hook me up
ManagedBuildManager.addExtensionTarget(this);
- // name
+ // Get the target name
setName(element.getAttribute("name"));
+ // Get the name of the build artifact associated with target (usually
+ // in the plugin specification).
+ artifactName = element.getAttribute("artifactName");
+
+ // Get the default extension
+ defaultExtension = element.getAttribute("defaultExtension");
+
// parent
String parentId = element.getAttribute("parent");
if (parentId != null) {
@@ -93,6 +108,9 @@ public class Target extends BuildObject implements ITarget {
if ("true".equals(element.getAttribute("isAbstract")))
isAbstract = true;
+ // Is this a test target
+ isTest = ("true".equals(element.getAttribute("isTest")));
+
IConfigurationElement[] targetElements = element.getChildren();
for (int k = 0; k < targetElements.length; ++k) {
IConfigurationElement targetElement = targetElements[k];
@@ -123,6 +141,13 @@ public class Target extends BuildObject implements ITarget {
// name
setName(element.getAttribute("name"));
+ // Get the name of the build artifact associated with target (should
+ // contain what the user entered in the UI).
+ artifactName = element.getAttribute("artifactName");
+
+ // Get the default extension
+ defaultExtension = element.getAttribute("defaultExtension");
+
// parent
String parentId = element.getAttribute("parent");
if (parentId != null)
@@ -131,6 +156,9 @@ public class Target extends BuildObject implements ITarget {
// isAbstract
if ("true".equals(element.getAttribute("isAbstract")))
isAbstract = true;
+
+ // Is this a test target
+ isTest = ("true".equals(element.getAttribute("isTest")));
Node child = element.getFirstChild();
while (child != null) {
@@ -139,8 +167,6 @@ public class Target extends BuildObject implements ITarget {
}
child = child.getNextSibling();
}
-
-
}
/**
@@ -155,7 +181,10 @@ public class Target extends BuildObject implements ITarget {
if (parent != null)
element.setAttribute("parent", parent.getId());
element.setAttribute("isAbstract", isAbstract ? "true" : "false");
-
+ element.setAttribute("artifactName", getArtifactName());
+ element.setAttribute("defaultExtension", getDefaultExtension());
+ element.setAttribute("isTest", isTest ? "true" : "false");
+
if (configurations != null)
for (int i = 0; i < configurations.size(); ++i) {
Configuration config = (Configuration)configurations.get(i);
@@ -231,6 +260,24 @@ public class Target extends BuildObject implements ITarget {
return emptyConfigs;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getDefaultExtension()
+ */
+ public String getDefaultExtension() {
+ return defaultExtension == null ? EMPTY_STRING : defaultExtension;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getArtifactName()
+ */
+ public String getArtifactName() {
+ // Return name or an empty string
+ return artifactName == null ? EMPTY_STRING : artifactName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
+ */
public IConfiguration getConfiguration(String id) {
return (IConfiguration)configMap.get(id);
}
@@ -252,6 +299,13 @@ public class Target extends BuildObject implements ITarget {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
+ */
+ public boolean isTestTarget() {
+ return isTest;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
*/
public IConfiguration createConfiguration(String id) {
@@ -265,4 +319,10 @@ public class Target extends BuildObject implements ITarget {
return new Configuration(this, parent, id);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#setBuildArtifact(java.lang.String)
+ */
+ public void setBuildArtifact(String name) {
+ artifactName = name;
+ }
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
index 320f6b5061a..713663b02e8 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Tool.java
@@ -13,8 +13,11 @@ package org.eclipse.cdt.internal.core.build.managed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
+import java.util.StringTokenizer;
+import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
@@ -29,19 +32,30 @@ import org.eclipse.core.runtime.IConfigurationElement;
*/
public class Tool extends BuildObject implements ITool, IOptionCategory {
+ private static final String DEFAULT_SEPARATOR = ",";
+ private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
+ private static final IOption[] EMPTY_OPTIONS = new IOption[0];
+
private ITarget target;
private List options;
private Map optionMap;
private List childOptionCategories;
private Map categoryMap;
-
- private static IOption[] emptyOptions = new IOption[0];
- private static IOptionCategory[] emptyCategories = new IOptionCategory[0];
+ private String command;
+ private List inputExtensions;
+ private String outputExtension;
public Tool(Target target) {
this.target = target;
}
+ /**
+ * Constructor to create a new tool in the build model based on the information
+ * defined in the plugin.xml manifest.
+ *
+ * @param target The target the receiver will belong to.
+ * @param element The element containing the information.
+ */
public Tool(Target target, IConfigurationElement element) {
this(target);
@@ -53,6 +67,25 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
// name
setName(element.getAttribute("name"));
+
+ // Get the supported input file extension
+ String inputs = element.getAttribute("sources") == null ?
+ new String() :
+ element.getAttribute("sources");
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensions().add(tokenizer.nextElement());
+ }
+
+ // Get the output extension
+ outputExtension = element.getAttribute("outputs") == null ?
+ new String() :
+ element.getAttribute("outputs");
+
+ // Get the tool invocation
+ command = element.getAttribute("command") == null ?
+ new String() :
+ element.getAttribute("command");
// set up the category map
categoryMap = new HashMap();
@@ -70,10 +103,6 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
}
- public ITarget getTarget() {
- return target;
- }
-
public IOptionCategory getOptionCategory(String id) {
return (IOptionCategory)categoryMap.get(id);
}
@@ -82,6 +111,13 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
categoryMap.put(category.getId(), category);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#handlesFileType(java.lang.String)
+ */
+ public boolean buildsFileType(String extension) {
+ return getInputExtensions().contains(extension);
+ }
+
void addChildCategory(IOptionCategory category) {
if (childOptionCategories == null)
childOptionCategories = new ArrayList();
@@ -92,7 +128,7 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
if (options != null)
return (IOption[])options.toArray(new IOption[options.size()]);
else
- return emptyOptions;
+ return EMPTY_OPTIONS;
}
public void addOption(Option option) {
@@ -115,7 +151,17 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
if (childOptionCategories != null)
return (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
else
- return emptyCategories;
+ return EMPTY_CATEGORIES;
+ }
+
+ /* (non-Javadoc)
+ * @return
+ */
+ private List getInputExtensions() {
+ if (inputExtensions == null) {
+ inputExtensions = new ArrayList();
+ }
+ return inputExtensions;
}
/* (non-Javadoc)
@@ -138,6 +184,10 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
return null;
}
+ public ITarget getTarget() {
+ return target;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getTool()
*/
@@ -146,6 +196,61 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
+ */
+ public String getToolCommand() {
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getToolFlags()
+ */
+ public String getToolFlags() throws BuildException {
+ // Get all of the options
+ StringBuffer buf = new StringBuffer();
+ IOption[] opts = getOptions();
+ for (int index = 0; index < opts.length; index++) {
+ IOption option = opts[index];
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ if (option.getBooleanValue()) {
+ buf.append(option.getCommand() + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.ENUMERATED :
+ String enum = option.getEnumCommand(option.getSelectedEnum());
+ if (enum.length() > 0) {
+ buf.append(enum + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.STRING :
+ String val = option.getStringValue();
+ if (val.length() > 0) {
+ buf.append(val + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.STRING_LIST :
+ String cmd = option.getCommand();
+ String[] list = option.getStringListValue();
+ for (int j = 0; j < list.length; j++) {
+ String temp = list[j];
+ buf.append(cmd + temp + WHITE_SPACE);
+ }
+ break;
+
+ default :
+ break;
+ }
+
+ }
+
+ return buf.toString();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOptionCategory#getOptions(org.eclipse.cdt.core.build.managed.ITool)
*/
public IOption[] getOptions(IConfiguration configuration) {
@@ -183,4 +288,25 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
return (IOption)optionMap.get(id);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutput(java.lang.String)
+ */
+ public String getOutputExtension(String inputExtension) {
+ // Examine the list of input extensions
+ ListIterator iter = getInputExtensions().listIterator();
+ while (iter.hasNext()) {
+ if (((String)iter.next()).equals(inputExtension)) {
+ return outputExtension;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
+ */
+ public boolean producesFileType(String outputExtension) {
+ return outputExtension.equals(this.outputExtension);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
index f1bb01997b9..57bbfb48082 100644
--- a/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
+++ b/core/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/ToolReference.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
@@ -122,6 +123,61 @@ public class ToolReference implements ITool {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
+ */
+ public String getToolCommand() {
+ return parent.getToolCommand();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getToolFlags()
+ */
+ public String getToolFlags() throws BuildException {
+ // Get all of the options
+ StringBuffer buf = new StringBuffer();
+ IOption[] opts = getOptions();
+ for (int index = 0; index < opts.length; index++) {
+ IOption option = opts[index];
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ if (option.getBooleanValue()) {
+ buf.append(option.getCommand() + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.ENUMERATED :
+ String enum = option.getEnumCommand(option.getSelectedEnum());
+ if (enum.length() > 0) {
+ buf.append(enum + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.STRING :
+ String val = option.getStringValue();
+ if (val.length() > 0) {
+ buf.append(val + WHITE_SPACE);
+ }
+ break;
+
+ case IOption.STRING_LIST :
+ String cmd = option.getCommand();
+ String[] list = option.getStringListValue();
+ for (int j = 0; j < list.length; j++) {
+ String temp = list[j];
+ buf.append(cmd + temp + WHITE_SPACE);
+ }
+ break;
+
+ default :
+ break;
+ }
+
+ }
+
+ return buf.toString().trim();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#createOption()
*/
public IOption createOption() {
@@ -160,6 +216,13 @@ public class ToolReference implements ITool {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#producesFileType(java.lang.String)
+ */
+ public boolean producesFileType(String outputExtension) {
+ return parent.producesFileType(outputExtension);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
*/
public String getId() {
@@ -220,6 +283,13 @@ public class ToolReference implements ITool {
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#handlesFileType(java.lang.String)
+ */
+ public boolean buildsFileType(String extension) {
+ return parent.buildsFileType(extension);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
*/
public IOption getOption(String id) {
@@ -227,4 +297,12 @@ public class ToolReference implements ITool {
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOutput(java.lang.String)
+ */
+ public String getOutputExtension(String inputExtension) {
+ return parent.getOutputExtension(inputExtension);
+ }
+
+
}
diff --git a/core/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd b/core/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd
index d45c972dde2..fce56ce8345 100644
--- a/core/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd
+++ b/core/org.eclipse.cdt.core/schema/ManagedBuildTools.exsd
@@ -50,41 +50,48 @@
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
-
+ A unique identifier for the tool that will be used by the build model.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
-
+ Human-readable name for the tool to be used in the UI.
</documentation>
</annotation>
</attribute>
<attribute name="sources" type="string">
<annotation>
<documentation>
-
+ A comma-separated list of file extensions that the tool will produce output for.
</documentation>
</annotation>
</attribute>
<attribute name="outputs" type="string">
<annotation>
<documentation>
-
+ The extension that the tool will produce from a given input.
</documentation>
</annotation>
</attribute>
<attribute name="dependencyCalculator" type="string">
<annotation>
<documentation>
-
+ A reference to the class that will calculate the dependencies for a given file. For example, a compiler might require a dependency calculator for source files that discovers the dependenncies on header files.
</documentation>
<appInfo>
<meta.attribute kind="java"/>
</appInfo>
</annotation>
</attribute>
+ <attribute name="command" type="string">
+ <annotation>
+ <documentation>
+ The command that invokes the tool. For example, gcc for the Gnu C compiler, or g++ for the Gnu C++ compiler.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -234,6 +241,11 @@
</element>
<element name="optionRef">
+ <annotation>
+ <documentation>
+ Option references hold onto information the user has changed through the UI. Not all fields will be populated, depending on the option type the reference overrides. For example, the &apos;name&apos; field is used by enumerated options only.
+ </documentation>
+ </annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
@@ -273,14 +285,14 @@
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
-
+ Used by the build model to uniquely identify the target.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
-
+ A human-readable target name, such as &apos;Linux Executable&apos;. This will be the name the user sees displayed in the UI.
</documentation>
</annotation>
</attribute>
@@ -298,6 +310,27 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="artifactName" type="string">
+ <annotation>
+ <documentation>
+ This is the name of the final build artifact associated with the target. The user will specify this is the UI, so there is no need to supply a default value.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="defaultExtension" type="string">
+ <annotation>
+ <documentation>
+ This is the extensionthat will be applied to any build artifact created by the target.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="isTest" type="boolean">
+ <annotation>
+ <documentation>
+ A an optional field that flags a target as a test-only target. If true, the target will not appear in the UI.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -394,4 +427,4 @@
</documentation>
</annotation>
-</schema> \ No newline at end of file
+</schema>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/GeneratedMakefileBuilder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/GeneratedMakefileBuilder.java
index c8810be3449..69aef8c99ef 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/GeneratedMakefileBuilder.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/GeneratedMakefileBuilder.java
@@ -14,10 +14,10 @@ package org.eclipse.cdt.internal.core;
import java.io.ByteArrayInputStream;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.build.managed.IResourceBuildInfo;
import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.resources.MakeUtil;
-import org.eclipse.cdt.internal.core.build.managed.ResourceBuildInfo;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -41,6 +41,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
private static final String INCREMENTAL = MESSAGE + ".incremental"; //$NON-NLS-1$
private static final String FILENAME = "makefile"; //$NON-NLS-1$
private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$
+ private static final String COLON = ":";
private static final String TAB = "\t"; //$NON-NLS-1$
public class MyResourceDeltaVisitor implements IResourceDeltaVisitor {
@@ -67,34 +68,88 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
/**
+ * Add whatever macros we can figure out to the makefile.
+ *
* @param buffer
*/
- private void addMacros(StringBuffer buffer, ResourceBuildInfo info) {
+ private void addMacros(StringBuffer buffer, IResourceBuildInfo info) {
// TODO this should come from the build model
- buffer.append("CC = " + NEWLINE);
- buffer.append("CFLAGS = " + NEWLINE);
- buffer.append("LD = " + NEWLINE);
- buffer.append("LDFLAGS = " + NEWLINE);
buffer.append("RM = rm -f" + NEWLINE);
buffer.append("MAKE = make" + NEWLINE);
+ buffer.append(NEWLINE);
+ }
+
+ private void addRule(StringBuffer buffer, IPath sourcePath, String outputName, IResourceBuildInfo info) {
+ // Add the rule to the makefile
+ buffer.append(outputName + COLON + " " + sourcePath.toString());
+ // Add all of the dependencies on the source file
buffer.append(NEWLINE);
+ String ext = sourcePath.getFileExtension();
+ String cmd = info.getToolForSource(ext);
+ String flags = info.getFlagsForSource(ext);
+ buffer.append(TAB + cmd + " " + flags + " " + "$?" + NEWLINE + NEWLINE);
+ }
+
+ /**
+ * Creates a list of dependencies on project resources.
+ *
+ * @param buffer
+ */
+ private void addSources(StringBuffer buffer, IResourceBuildInfo info) throws CoreException {
+ // Add the list of project files to be built
+ buffer.append("OBJS = \\" + NEWLINE);
+
+ //Get a list of files from the project
+ IResource[] members = getProject().members();
+ for (int i = 0; i < members.length; i++) {
+ IResource resource = members[i];
+ IPath sourcePath = resource.getProjectRelativePath().removeFileExtension();
+ String srcExt = resource.getFileExtension();
+ String outExt = info.getOutputExtension(srcExt);
+ if (outExt != null) {
+ // Add the extension back to path
+ IPath outputPath = sourcePath.addFileExtension(outExt);
+ // Add the file to the list of dependencies for the base target
+ buffer.append(outputPath.toString() + " \\" + NEWLINE);
+ }
+ }
+ buffer.append(NEWLINE);
+
+ // Add a rule for building each resource to the makefile
+ for (int j = 0; j < members.length; j++) {
+ IResource resource = members[j];
+ IPath sourcePath = resource.getProjectRelativePath().removeFileExtension();
+ String srcExt = resource.getFileExtension();
+ String outExt = info.getOutputExtension(srcExt);
+ if (outExt != null) {
+ // Add the extension back to path
+ IPath outputPath = sourcePath.addFileExtension(outExt);
+ addRule(buffer, resource.getProjectRelativePath(), outputPath.toString(), info);
+ }
+ }
}
/**
* @param buffer
*/
- private void addTargets(StringBuffer buffer) {
- // TODO Targets should come from build model
+ private void addTargets(StringBuffer buffer, IResourceBuildInfo info) {
+ // Generate a rule per source
- // TODO Generate 'all' for now
- buffer.append("all:" + NEWLINE);
+ // This is the top build rule
+ String flags = info.getFlagsForTarget("exe") + " ";
+ String cmd = info.getToolForTarget("exe") + " ";
+ buffer.append(info.getBuildArtifactName() + COLON + " ${OBJS}" + NEWLINE);
+ buffer.append(TAB + cmd + flags + "$@ ${OBJS}" + NEWLINE);
+ buffer.append(NEWLINE);
+
+ // TODO Generate 'all' for now but determine the real rules from UI
+ buffer.append("all: " + info.getBuildArtifactName() + NEWLINE);
buffer.append(NEWLINE);
-
// Always add a clean target
buffer.append("clean:" + NEWLINE);
- buffer.append(TAB + "$(RM) *.o" + NEWLINE);
+ buffer.append(TAB + "$(RM) *.o " + info.getBuildArtifactName() + NEWLINE);
buffer.append(NEWLINE);
}
@@ -234,13 +289,16 @@ public class GeneratedMakefileBuilder extends ACBuilder {
private void populateMakefile(IFile fileHandle, IProgressMonitor monitor) throws CoreException {
// Write out the contents of the build model
StringBuffer buffer = new StringBuffer();
- ResourceBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
+ IResourceBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
// Add the macro definitions
addMacros(buffer, info);
+ // Add a list of source files
+ addSources(buffer, info);
+
// Add targets
- addTargets(buffer);
+ addTargets(buffer, info);
// Save the file
Util.save(buffer, fileHandle);
diff --git a/core/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java b/core/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java
index b40938eb9d2..3a81a4f9a35 100644
--- a/core/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java
+++ b/core/org.eclipse.cdt.ui.tests/build/org/eclipse/cdt/core/build/managed/tests/AllBuildTests.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.core.build.managed.tests;
import java.util.Arrays;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -20,6 +21,7 @@ import org.eclipse.cdt.core.build.managed.BuildException;
import org.eclipse.cdt.core.build.managed.IConfiguration;
import org.eclipse.cdt.core.build.managed.IOption;
import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.IResourceBuildInfo;
import org.eclipse.cdt.core.build.managed.ITarget;
import org.eclipse.cdt.core.build.managed.ITool;
import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
@@ -35,11 +37,13 @@ import org.eclipse.core.runtime.CoreException;
*/
public class AllBuildTests extends TestCase {
private static final boolean boolVal = true;
- private static final String newConfigName = "test.config.override";
+ private static final String testConfigName = "test.config.override";
private static final String enumVal = "Another Enum";
private static final String[] listVal = {"_DEBUG", "/usr/include", "libglade.a"};
private static final String projectName = "BuildTest";
- private static final String stringVal = "-c -wall";
+ private static final String rootExt = "toor";
+ private static final String stringVal = "-c -Wall";
+ private static final String subExt = "bus";
public AllBuildTests(String name) {
super(name);
@@ -51,14 +55,12 @@ public class AllBuildTests extends TestCase {
suite.addTest(new AllBuildTests("testExtensions"));
suite.addTest(new AllBuildTests("testProject"));
suite.addTest(new AllBuildTests("testConfigurations"));
+ suite.addTest(new AllBuildTests("testTargetArtifacts"));
+ suite.addTest(new AllBuildTests("cleanup"));
return suite;
}
- public void testThatAlwaysFails() {
- assertTrue(false);
- }
-
/**
* Navigates through the build info as defined in the extensions
* defined in this plugin
@@ -75,30 +77,11 @@ public class AllBuildTests extends TestCase {
if (target.getName().equals("Test Root")) {
testRoot = target;
-
checkRootTarget(testRoot, "x");
} else if (target.getName().equals("Test Sub")) {
testSub = target;
-
- // Tools
- ITool[] tools = testSub.getTools();
- // Root Tool
- ITool rootTool = tools[0];
- assertEquals("Root Tool", rootTool.getName());
- // Sub Tool
- ITool subTool = tools[1];
- assertEquals("Sub Tool", subTool.getName());
-
- // Configs
- IConfiguration[] configs = testSub.getConfigurations();
- // Root Config
- IConfiguration rootConfig = configs[0];
- assertEquals("Root Config", rootConfig.getName());
- assertEquals("Root Override Config", configs[1].getName());
- // Sub Config
- IConfiguration subConfig = configs[2];
- assertEquals("Sub Config", subConfig.getName());
+ checkSubTarget(testSub);
}
}
@@ -106,6 +89,16 @@ public class AllBuildTests extends TestCase {
assertNotNull(testSub);
}
+ /**
+ * Create a new configuration based on one defined in the plugin file.
+ * Overrides all of the configuration settings. Saves, closes, and reopens
+ * the project. Then calls a method to check the overridden options.
+ *
+ * Tests creating a new configuration.
+ * Tests setting options.
+ * Tests persisting overridden options between project sessions.
+ *
+ */
public void testConfigurations() throws CoreException, BuildException {
// Open the test project
IProject project = createProject(projectName);
@@ -119,7 +112,7 @@ public class AllBuildTests extends TestCase {
IConfiguration baseConfig = definedConfigs[0];
// Create a new configuration
- IConfiguration newConfig = rootTarget.createConfiguration(baseConfig, newConfigName);
+ IConfiguration newConfig = rootTarget.createConfiguration(baseConfig, testConfigName);
assertEquals(3, rootTarget.getConfigurations().length);
// There is only one tool
@@ -155,29 +148,38 @@ public class AllBuildTests extends TestCase {
public void testProject() throws CoreException, BuildException {
// Create new project
IProject project = createProject(projectName);
-
+ // There should not be any targets defined for this project yet
assertEquals(0, ManagedBuildManager.getTargets(project).length);
// Find the base target definition
ITarget targetDef = ManagedBuildManager.getTarget(project, "test.root");
assertNotNull(targetDef);
- // Create the target for our project
+ // Create the target for our project that builds a dummy executable
ITarget newTarget = ManagedBuildManager.createTarget(project, targetDef);
assertEquals(newTarget.getName(), targetDef.getName());
assertFalse(newTarget.equals(targetDef));
+ String buildArtifactName = projectName + "." + newTarget.getDefaultExtension();
+ newTarget.setBuildArtifact(buildArtifactName);
ITarget[] targets = ManagedBuildManager.getTargets(project);
assertEquals(1, targets.length);
ITarget target = targets[0];
assertEquals(target, newTarget);
assertFalse(target.equals(targetDef));
-
+
// Copy over the configs
+ IConfiguration defaultConfig = null;
IConfiguration[] configs = targetDef.getConfigurations();
- for (int i = 0; i < configs.length; ++i)
- target.createConfiguration(configs[i], target.getId() + "." + i);
-
+ for (int i = 0; i < configs.length; ++i) {
+ // Make the first configuration the default
+ if (i == 0) {
+ defaultConfig = target.createConfiguration(configs[i], target.getId() + "." + i);
+ } else {
+ target.createConfiguration(configs[i], target.getId() + "." + i);
+ }
+ }
+ ManagedBuildManager.setDefaultConfiguration(project, defaultConfig);
checkRootTarget(target, "x");
// Override the "String Option in Category" option value
@@ -198,29 +200,86 @@ public class AllBuildTests extends TestCase {
ManagedBuildManager.removeBuildInfo(project);
project.open(null);
+ // Test that the default config was remembered
+ IResourceBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ assertEquals(defaultConfig.getId(), info.getDefaultConfiguration(target).getId());
+
+ // Get the targets
targets = ManagedBuildManager.getTargets(project);
assertEquals(1, targets.length);
+ // See if the artifact name is remembered
+ assertEquals(targets[0].getArtifactName(), buildArtifactName);
+ // Check the rest of the default information
checkRootTarget(targets[0], "z");
+
+ // Now test the information the makefile builder needs
+ checkBuildSettings(project);
}
- IProject createProject(String name) throws CoreException {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = root.getProject(name);
- if (!project.exists()) {
- project.create(null);
- } else {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- if (!project.isOpen()) {
- project.open(null);
- }
+ /**
+ * Tests the tool settings through the interface the makefile generator
+ * uses.
+ *
+ * @param project
+ */
+ private void checkBuildSettings(IProject project) {
+ String ext1 = "foo";
+ String ext2 = "bar";
+ String badExt = "cpp";
+ String expectedOutput = "toor";
+ String expectedCmd = "doIt";
+
+ // Get that interface, Rover. Go get it. That's a good doggie! Good boy.
+ IResourceBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ assertNotNull(info);
+ assertEquals(info.getBuildArtifactName(), "BuildTest.toor");
+
+ // There should be a default configuration defined for the project
+ ITarget buildTarget = info.getDefaultTarget();
+ assertNotNull(buildTarget);
+ assertEquals(buildTarget.getId(), "test.root.1");
+ IConfiguration buildConfig = info.getDefaultConfiguration(buildTarget);
+ assertNotNull(buildConfig);
+ assertEquals(buildConfig.getId(), "test.root.1.0");
+
+ // The default target should be the same as the one-and-only target in the project
+ List targets = info.getTargets();
+ assertEquals(targets.size(), 1);
+ ITarget target = (ITarget) targets.get(0);
+ assertEquals(target, buildTarget);
+
+ // Check that tool handles resources with extensions foo and bar by building a baz
+ assertEquals(info.getOutputExtension(ext1), expectedOutput);
+ assertEquals(info.getOutputExtension(ext2), expectedOutput);
+
+ // Check that it ignores others based on filename extensions
+ assertNull(info.getOutputExtension(badExt));
+
+ // Now see what the tool command line invocation is for foo and bar
+ assertEquals(info.getToolForSource(ext1), expectedCmd);
+ assertEquals(info.getToolForSource(ext2), expectedCmd);
+ // Make sure that there is no tool to build files of type foo and bar
+ assertNull(info.getToolForTarget(ext1));
+ assertNull(info.getToolForTarget(ext2));
+
+ // There is no target that builds toor
+ assertNull(info.getToolForSource(expectedOutput));
+ // but there is one that produces it
+ assertEquals(info.getToolForTarget(expectedOutput), expectedCmd);
+
+ // Now check the build flags
+ assertEquals(info.getFlagsForSource(ext1), "-La -Lb z -e1");
+ assertEquals(info.getFlagsForSource(ext1), info.getFlagsForSource(ext2));
- //CCorePlugin.getDefault().convertProjectToC(project, null, CCorePlugin.PLUGIN_ID + ".make", true);
-
- return project;
}
+ /**
+ * Tests that overridden options are properly read into build model.
+ * Test that option values that are not overridden remain the same.
+ *
+ * @param project The project to get build model information for.
+ * @throws BuildException
+ */
private void checkOptionReferences(IProject project) throws BuildException {
// Get the targets out of the project
ITarget[] definedTargets = ManagedBuildManager.getTargets(project);
@@ -230,7 +289,7 @@ public class AllBuildTests extends TestCase {
// Now get the configs
IConfiguration[] definedConfigs = rootTarget.getConfigurations();
assertEquals(3, definedConfigs.length);
- IConfiguration newConfig = rootTarget.getConfiguration(newConfigName);
+ IConfiguration newConfig = rootTarget.getConfiguration(testConfigName);
assertNotNull(newConfig);
// Now get the tool options and make sure the values are correct
@@ -273,6 +332,10 @@ public class AllBuildTests extends TestCase {
private void checkRootTarget(ITarget target, String oicValue) throws BuildException {
+ // Target stuff
+ assertTrue(target.isTestTarget());
+ assertEquals(target.getDefaultExtension(), rootExt);
+
// Tools
ITool[] tools = target.getTools();
// Root Tool
@@ -376,4 +439,115 @@ public class AllBuildTests extends TestCase {
assertEquals("-e2", options[1].getEnumCommand(valueList[1]));
}
+ private void checkSubTarget(ITarget target) {
+ // Make sure this is a test target
+ assertTrue(target.isTestTarget());
+ // Make sure the build artifact extension is there
+ assertEquals(target.getDefaultExtension(), subExt);
+
+ // Tools
+ ITool[] tools = target.getTools();
+ // Root Tool
+ ITool rootTool = tools[0];
+ assertEquals("Root Tool", rootTool.getName());
+ // Sub Tool
+ ITool subTool = tools[1];
+ assertEquals("Sub Tool", subTool.getName());
+
+ // Configs
+ IConfiguration[] configs = target.getConfigurations();
+ // Root Config
+ IConfiguration rootConfig = configs[0];
+ assertEquals("Root Config", rootConfig.getName());
+ assertEquals("Root Override Config", configs[1].getName());
+ // Sub Config
+ IConfiguration subConfig = configs[2];
+ assertEquals("Sub Config", subConfig.getName());
+ }
+
+ /**
+ * Remove all the project information associated with the project used during test.
+ */
+ public void cleanup() {
+ removeProject(projectName);
+ }
+
+ /**
+ * Create a new project named <code>name</code> or return the project in
+ * the workspace of the same name if it exists.
+ *
+ * @param name The name of the project to create or retrieve.
+ * @return
+ * @throws CoreException
+ */
+ private IProject createProject(String name) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+
+ //CCorePlugin.getDefault().convertProjectToC(project, null, CCorePlugin.PLUGIN_ID + ".make", true);
+
+ return project;
+ }
+
+ /**
+ * Remove the <code>IProject</code> with the name specified in the argument from the
+ * receiver's workspace.
+ *
+ * @param name
+ */
+ private void removeProject(String name) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ if (project.exists()) {
+ try {
+ project.delete(true, false, null);
+ } catch (CoreException e) {
+ assertTrue(false);
+ }
+ }
+ }
+
+ /**
+ * Test that the build artifact of a <code>ITarget</code> can be modified
+ * programmatically.
+ */
+ public void testTargetArtifacts () throws CoreException {
+ // Open the test project
+ IProject project = createProject(projectName);
+
+ // Make sure there is one and only one target
+ ITarget[] definedTargets = ManagedBuildManager.getTargets(project);
+ assertEquals(1, definedTargets.length);
+ ITarget rootTarget = definedTargets[0];
+
+ // Set the build artifact of the target
+ String ext = rootTarget.getDefaultExtension();
+ String name = project.getName() + "." + ext;
+ rootTarget.setBuildArtifact(name);
+
+ // Save, close, reopen and test again
+ ManagedBuildManager.saveBuildInfo(project);
+ project.close(null);
+ ManagedBuildManager.removeBuildInfo(project);
+ project.open(null);
+
+ // Make sure there is one and only one target
+ definedTargets = ManagedBuildManager.getTargets(project);
+ assertEquals(1, definedTargets.length);
+ rootTarget = definedTargets[0];
+ assertEquals(name, rootTarget.getArtifactName());
+ }
+
+ public void testThatAlwaysFails() {
+ assertTrue(false);
+ }
}
diff --git a/core/org.eclipse.cdt.ui.tests/plugin.xml b/core/org.eclipse.cdt.ui.tests/plugin.xml
index 51084931cb2..bc7e3259c98 100644
--- a/core/org.eclipse.cdt.ui.tests/plugin.xml
+++ b/core/org.eclipse.cdt.ui.tests/plugin.xml
@@ -29,75 +29,16 @@
name="Tools for Build Test"
point="org.eclipse.cdt.core.ManagedBuildInfo">
<target
- name="Linux"
- isAbstract="true"
- id="linux">
- <tool
- name="Compiler"
- id="linux.compiler">
- <optionCategory
- owner="linux.compiler"
- name="Optimization Options"
- id="linux.compiler.optimization">
- </optionCategory>
- <option
- name="Compiler Flags"
- valueType="string"
- id="linux.compiler.flags">
- </option>
- <option
- name="Optimization Flags"
- category="linux.compiler.optimization"
- value="-O"
- valueType="string"
- id="linux.compiler.optimizationFlags">
- </option>
- </tool>
- </target>
- <target
- name="Linux Executable"
- parent="linux"
- isAbstract="false"
- id="linux.exec">
- <tool
- name="Linker"
- id="org.eclipse.cdt.ui.tests.tool.linux.link">
- </tool>
- <configuration
- name="Release"
- id="linux.exec.release">
- </configuration>
- <configuration
- name="Debug"
- id="linux.exec.debug">
- </configuration>
- </target>
- <target
- name="Linux Shared Library"
- parent="linux"
- isAbstract="false"
- id="linux.so">
- <tool
- name="Linker"
- id="org.eclipse.cdt.ui.tests.tool.linux.solink">
- </tool>
- </target>
- <target
- name="Linux Static Library"
- parent="linux"
- isAbstract="false"
- id="linux.lib">
- <tool
- name="Archiver"
- id="org.eclipse.cdt.ui.tests.tool.linux.ar">
- </tool>
- </target>
- <target
+ isTest="true"
name="Test Root"
+ defaultExtension="toor"
isAbstract="false"
id="test.root">
<tool
+ sources="foo,bar"
name="Root Tool"
+ outputs="toor"
+ command="doIt"
id="root.tool">
<optionCategory
owner="root.tool"
@@ -137,14 +78,12 @@
id="enumerated.option">
<optionEnum
name="Default Enum"
- value="s"
isDefault="true"
command="-e1"
id="default.enum.option">
</optionEnum>
<optionEnum
name="Another Enum"
- value="t"
command="-e2"
id="another.enum.option">
</optionEnum>
@@ -161,7 +100,6 @@
id="root.tool">
<optionRef
defaultValue="y"
- value="y"
id="string.option">
</optionRef>
<optionRef
@@ -172,8 +110,10 @@
</configuration>
</target>
<target
+ isTest="true"
name="Test Sub"
parent="test.root"
+ defaultExtension="bus"
isAbstract="false"
id="test.sub">
<configuration
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 9f274b02952..b2758f4e127 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,46 @@
+<<<<<<< ChangeLog
+2003-06-06
+ I have added toolchain definitions for Cygnus and Linux to the plugin.xml file
+ for the new build model. There are two new wizards for adding a C and C++ project
+ for use with managed build systems. The files to implement that are:
+
+ * build/org/eclipse/cdt/build/ui/wizards/ConfigurationBlock.java
+ * build/org/eclipse/cdt/build/ui/wizards/ConfigurationContentProvider.java
+ * build/org/eclipse/cdt/build/ui/wizards/ConfigurationLabelProvider.java
+ * build/org/eclipse/cdt/build/ui/wizards/CProjectPlatformPage.java
+ * build/org/eclipse/cdt/build/ui/wizards/ManagedCCWizard.java
+ * build/org/eclipse/cdt/build/ui/wizards/ManagedCWizard.java
+ * build/org/eclipse/cdt/build/ui/wizards/ManagedProjectWizard.java
+
+ There is a new property page specifically for projects with this managed nature.
+ The code to implement it has been added to:
+
+ * build/org/eclipse/cdt/build/ui/properties/BrowseEntryDialog.java
+ * build/org/eclipse/cdt/build/ui/properties/BuildOptionComboFieldEditor.java
+ * build/org/eclipse/cdt/build/ui/properties/BuildOptionListFieldEditor.java
+ * build/org/eclipse/cdt/build/ui/properties/BuildPropertyPage.java
+ * build/org/eclipse/cdt/build/ui/properties/BuildToolSettingsPage.java
+ * build/org/eclipse/cdt/build/ui/properties/BuildToolsSettingsStore.java
+ * build/org/eclipse/cdt/build/ui/properties/ManageConfigDialog.java
+ * build/org/eclipse/cdt/build/ui/properties/NewConfigurationDialog.java
+ * build/org/eclipse/cdt/build/ui/properties/SummaryFieldEditor.java
+ * build/org/eclipse/cdt/build/ui/properties/ToolListContentProvider.java
+ * build/org/eclipse/cdt/build/ui/properties/ToolListLabelProvider.java
+
+ New string resources have been added to the plugin.properties file and to the
+ src/org/eclipse/cdt/internal/ui/CPluginResources.properties file.
+
+ New icons have been added:
+ * icons/full/build16/config-command.gif
+ * icons/full/build16/config-librarian.gif
+ * icons/full/build16/config-tool.gif
+ * icons/full/ctool16/newmngc_app.gif
+ * icons/full/ctool16/newmngcc_app.gif
+
+ and the path src/org/eclipse/cdt/internal/ui/CPluginImages.java class
+ has been modified to manage them.
+
+=======
2003-06-05 Alain Magloire
Patch from Christophe Juniet, this patch adds #ifdef guards
@@ -11,6 +54,7 @@
* src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java
* src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties.
+>>>>>>> 1.101
2003-05-23 Alain Magloire
Patch from Victor Mozgin to deal with PR 38405
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BrowseEntryDialog.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BrowseEntryDialog.java
new file mode 100644
index 00000000000..ffab7c71d6d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BrowseEntryDialog.java
@@ -0,0 +1,179 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+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.layout.GridData;
+import org.eclipse.swt.widgets.*;
+
+public class BrowseEntryDialog extends Dialog {
+ // String constants
+ private static final String PREFIX = "BuildPropertyCommon"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String BROWSE = LABEL + ".browse"; //$NON-NLS-1$
+
+ /**
+ * The title of the dialog.
+ */
+ private String title = "";
+
+ /**
+ * The message to display, or <code>null</code> if none.
+ */
+ private String message = "";
+
+ /**
+ * The input value; the empty string by default.
+ */
+ private String value = "";
+
+ /**
+ * Error message label widget.
+ */
+ private Label errorMessageLabel;
+
+ // Widgets
+ private Button btnBrowse = null;
+ private Button btnOK = null;
+ private Text text = null;
+
+ /**
+ * Creates an input dialog with OK, Cancel, and a Browse button.
+ *
+ * @param shell the parent shell
+ * @param dialogTitle the title of the dialog or <code>null</code> if none
+ * @param dialogMessage the dialog message, or <code>null</code> if none
+ * @param initialValue the initial input value, or <code>null</code> if none
+ * (equivalent to the empty string)
+ */
+ public BrowseEntryDialog(Shell shell, String dialogTitle, String dialogMessage, String initialValue) {
+ super(shell);
+ // We are editing the value argument if it is not an empty string
+ if (dialogTitle != null) {
+ title = dialogTitle;
+ }
+ // Cache the message to be shown in the label
+ if (dialogMessage != null) {
+ message = dialogMessage;
+ }
+ // Value for the text widget
+ if (initialValue != null) {
+ value = initialValue;
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ value = text.getText().trim();
+ } else {
+ value = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /* (non-Javadoc)
+ * Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null)
+ shell.setText(title);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = ControlFactory.createComposite(parent, 4);
+
+ // Create the label
+ if (message != null) {
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText(message);
+ GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ gd.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+ gd.horizontalSpan = 4;
+ label.setLayoutData(gd);
+ label.setFont(parent.getFont());
+ }
+
+ text = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 3;
+ text.setLayoutData(gd);
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateButtonState();
+ }
+ });
+
+ // Instantiate the browse button
+ btnBrowse = ControlFactory.createPushButton(composite, CUIPlugin.getResourceString(BROWSE));
+ setButtonLayoutData(btnBrowse);
+ btnBrowse.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowsePressed();
+ }
+ });
+
+ return composite;
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ // create OK and Cancel buttons by default
+ btnOK = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+
+ text.setFocus();
+ if (value != null) {
+ text.setText(value);
+ }
+ updateButtonState();
+ }
+
+ protected String getValue() {
+ return value;
+ }
+
+ protected void handleBrowsePressed() {
+ // Popup a file browser widget
+ DirectoryDialog dialog = new DirectoryDialog(getShell());
+ // Create a hint if text widget contains value
+ String widgetText;
+ if ((widgetText = text.getText().trim()).length() > 0) {
+ dialog.setFilterPath(widgetText);
+ }
+ // Open the selection dialog and populate the widget
+ String directory;
+ if ((directory = dialog.open()) != null) {
+ /*
+ * TODO: Convert the dialog to the proper format for platform (i.e.
+ * if platform.pathStyle == Platform.POSIX then swap \\ to / )
+ */
+ text.setText(directory.trim());
+ updateButtonState();
+ }
+ }
+
+ protected void updateButtonState() {
+ if (btnOK != null)
+ btnOK.setEnabled(text.getText().trim().length() > 0);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java
new file mode 100644
index 00000000000..08b2ade7029
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java
@@ -0,0 +1,105 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+public class BuildOptionComboFieldEditor extends FieldEditor {
+
+ // Widgets and bookeeping variables
+ private Combo optionSelector;
+ private String [] options = new String[0];
+ private String selected;
+
+ /**
+ * @param name
+ * @param label
+ * @param opts
+ * @param sel
+ * @param parent
+ */
+ public BuildOptionComboFieldEditor (String name, String label, String [] opts, String sel, Composite parent) {
+ init(name, label);
+ options = opts;
+ selected = sel;
+ createControl(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
+ */
+ protected void adjustForNumColumns(int numColumns) {
+ // For now grab the excess space
+ GridData gd = (GridData)optionSelector.getLayoutData();
+ gd.horizontalSpan = numColumns - 1;
+ gd.grabExcessHorizontalSpace = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
+ */
+ protected void doFillIntoGrid(Composite parent, int numColumns) {
+ // Add the label
+ getLabelControl(parent);
+
+ // Now add the combo selector
+ optionSelector = ControlFactory.createSelectCombo(parent, options, selected);
+ GridData gd = (GridData) optionSelector.getLayoutData();
+ gd.horizontalSpan = numColumns - 1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doLoad()
+ */
+ protected void doLoad() {
+ // Retrieve the option string from the store
+ String values = getPreferenceStore().getString(getPreferenceName());
+
+ // Convert it to a string array
+ options = BuildToolsSettingsStore.parseString(values);
+ optionSelector.removeAll();
+ optionSelector.setItems(options);
+
+ // Set the index of selection in the combo box
+ int index = optionSelector.indexOf(selected);
+ optionSelector.select(index >= 0 ? index : 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
+ */
+ protected void doLoadDefault() {
+ doLoad();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doStore()
+ */
+ protected void doStore() {
+ // Save the selected item in the store
+ int index = optionSelector.getSelectionIndex();
+ String selected = index == -1 ? new String() : optionSelector.getItem(index);
+ getPreferenceStore().setValue(getPreferenceName(), selected);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
+ */
+ public int getNumberOfControls() {
+ // There is just the label from the parent and the combo
+ return 2;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java
new file mode 100644
index 00000000000..34300a4a479
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java
@@ -0,0 +1,61 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.preference.ListEditor;
+import org.eclipse.swt.widgets.Composite;
+
+public class BuildOptionListFieldEditor extends ListEditor {
+ private static final String TITLE = "BuildPropertyCommon.label.title"; //$NON-NLS-1$
+
+ private boolean browse;
+ private String fieldName;
+
+ /**
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param parent the parent of the field editor's control
+ */
+ public BuildOptionListFieldEditor (String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ this.fieldName = labelText;
+ createControl(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
+ */
+ protected String createList(String[] items) {
+ return BuildToolsSettingsStore.createList(items);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.ListEditor#getNewInputObject()
+ */
+ protected String getNewInputObject() {
+ // Create a dialog to prompt for a new symbol or path
+ InputDialog dialog = new InputDialog(getShell(), CUIPlugin.getResourceString(TITLE), fieldName, new String(), null);
+ if (dialog.open() == InputDialog.OK) {
+ return dialog.getValue();
+ }
+ return new String();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
+ */
+ protected String[] parseString(String stringList) {
+ return BuildToolsSettingsStore.parseString(stringList);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java
new file mode 100644
index 00000000000..7eca47b27b7
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java
@@ -0,0 +1,556 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, IPreferencePageContainer {
+ /*
+ * String constants
+ */
+ private static final String PREFIX = "BuildPropertyPage"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String NAME_LABEL = LABEL + ".NameText"; //$NON-NLS-1$
+ private static final String BUILD_TOOLS_LABEL = LABEL + ".BuildToolTree"; //$NON-NLS-1$
+ private static final String PLATFORM_LABEL = LABEL + ".Platform"; //$NON-NLS-1$
+ private static final String CONFIG_LABEL = LABEL + ".Configuration"; //$NON-NLS-1$
+ private static final String ACTIVE_LABEL = LABEL + ".Active"; //$NON-NLS-1$
+ private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
+ private static final String TREE_LABEL = LABEL + ".ToolTree"; //$NON-NLS-1$
+ private static final String OPTIONS_LABEL = LABEL + ".ToolOptions"; //$NON-NLS-1$
+ private static final String ADD_CONF = LABEL + ".AddConfButton"; //$NON-NLS-1$
+ private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
+ private static final String PLAT_TIP = TIP + ".platform"; //$NON-NLS-1$
+ private static final String CONF_TIP = TIP + ".config"; //$NON-NLS-1$
+ private static final String ADD_TIP = TIP + ".addconf"; //$NON-NLS-1$
+ private static final String MANAGE_TITLE = PREFIX + ".manage.title"; //$NON-NLS-1$
+ private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 20, 30 };
+
+ /*
+ * Dialog widgets
+ */
+ private Combo targetSelector;
+ private Combo configSelector;
+ private Button manageConfigs;
+ private TreeViewer optionList;
+ private SashForm sashForm;
+ private Group sashGroup;
+ private Composite settingsPageContainer;
+
+ /*
+ * Bookeeping variables
+ */
+ private ITarget [] targets;
+ private ITarget selectedTarget;
+ private IConfiguration [] configurations;
+ private IConfiguration selectedConfiguration;
+ private BuildToolSettingsPage currentSettingsPage;
+ private Map configToPageListMap;
+ private BuildToolsSettingsStore settingsStore;
+ private IOptionCategory selectedCategory;
+ private Point lastShellSize;
+
+ /**
+ * The minimum page size; 200 by 200 by default.
+ *
+ * @see #setMinimumPageSize
+ */
+ private Point minimumPageSize = new Point(200, 200);
+
+ /**
+ * Layout for the page container.
+ *
+ */
+ private class PageLayout extends Layout {
+ public void layout(Composite composite, boolean force) {
+ Rectangle rect = composite.getClientArea();
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ children[i].setSize(rect.width, rect.height);
+ }
+ }
+ public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
+ if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+ return new Point(wHint, hHint);
+ }
+ int x = minimumPageSize.x;
+ int y = minimumPageSize.y;
+
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+ x = Math.max(x, size.x);
+ y = Math.max(y, size.y);
+ }
+ if (wHint != SWT.DEFAULT) {
+ x = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ y = hHint;
+ }
+ return new Point(x, y);
+ }
+ }
+
+ /**
+ * Default constructor
+ */
+ public BuildPropertyPage() {
+ configToPageListMap = new HashMap();
+ }
+
+ protected void constrainShellSize() {
+ // limit the shell size to the display size
+ Shell shell = getShell();
+ Point size = shell.getSize();
+ Rectangle bounds = shell.getDisplay().getClientArea();
+ int newX = Math.min(size.x, bounds.width);
+ int newY = Math.min(size.y, bounds.height);
+ if (size.x != newX || size.y != newY)
+ shell.setSize(newX, newY);
+
+ // move the shell origin as required
+ Point loc = shell.getLocation();
+
+ //Choose the position between the origin of the client area and
+ //the bottom right hand corner
+ int x =
+ Math.max(
+ bounds.x,
+ Math.min(loc.x, bounds.x + bounds.width - size.x));
+ int y =
+ Math.max(
+ bounds.y,
+ Math.min(loc.y, bounds.y + bounds.height - size.y));
+ shell.setLocation(x, y);
+
+ // record opening shell size
+ if (lastShellSize == null)
+ lastShellSize = getShell().getSize();
+ }
+
+ protected Control createContents(Composite parent) {
+ // Initialize the key data
+ targets = ManagedBuildManager.getTargets(getProject());
+
+ // Create the container we return to the property page editor
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ GridData gd;
+
+ // Add a config selection area
+ Group configGroup = ControlFactory.createGroup(composite, CUIPlugin.getResourceString(ACTIVE_LABEL), 1);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.grabExcessHorizontalSpace = true;
+ configGroup.setLayoutData(gd);
+ // Use the form layout inside the group composite
+ FormLayout form = new FormLayout();
+ form.marginHeight = 5;
+ form.marginWidth = 5;
+ configGroup.setLayout(form);
+
+ Label platformLabel = ControlFactory.createLabel(configGroup, CUIPlugin.getResourceString(PLATFORM_LABEL));
+ targetSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), null);
+ targetSelector.addListener(SWT.Selection, new Listener () {
+ public void handleEvent(Event e) {
+ handleTargetSelection();
+ }
+ });
+ targetSelector.setToolTipText(CUIPlugin.getResourceString(PLAT_TIP));
+ Label configLabel = ControlFactory.createLabel(configGroup, CUIPlugin.getResourceString(CONFIG_LABEL));
+ configSelector = new Combo(configGroup, SWT.READ_ONLY|SWT.DROP_DOWN);
+ configSelector.addListener(SWT.Selection, new Listener () {
+ public void handleEvent(Event e) {
+ handleConfigSelection();
+ }
+ });
+ configSelector.setToolTipText(CUIPlugin.getResourceString(CONF_TIP));
+ manageConfigs = ControlFactory.createPushButton(configGroup, CUIPlugin.getResourceString(ADD_CONF));
+ manageConfigs.setToolTipText(CUIPlugin.getResourceString(ADD_TIP));
+ manageConfigs.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleManageConfig();
+ }
+ });
+ // Now do the form layout for the widgets
+ FormData fd = new FormData();
+ // Anchor the labels in the centre of their respective combos
+ fd.top = new FormAttachment(targetSelector, 0, SWT.CENTER);
+ platformLabel.setLayoutData(fd);
+ fd = new FormData();
+ fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
+ configLabel.setLayoutData(fd);
+ // Anchor platform combo left to the config selector
+ fd = new FormData();
+ fd.left = new FormAttachment(configSelector, 0, SWT.LEFT);
+ fd.right = new FormAttachment(100, 0);
+ targetSelector.setLayoutData(fd);
+ // Anchor button right to combo and left to group
+ fd = new FormData();
+ fd.top = new FormAttachment(configSelector, 0, SWT.CENTER);
+ fd.right = new FormAttachment(100,0);
+ manageConfigs.setLayoutData(fd);
+ // Anchor config combo left 5 pixels from label, top 5% below the centre, and right to the button
+ fd = new FormData();
+ fd.left = new FormAttachment(configLabel, 5);
+ fd.top = new FormAttachment(55,0);
+ fd.right = new FormAttachment(manageConfigs, -5 , SWT.LEFT);
+ configSelector.setLayoutData(fd);
+
+ // Create the sash form
+ sashGroup = ControlFactory.createGroup(composite, CUIPlugin.getResourceString(SETTINGS_LABEL), 1);
+ sashGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+ sashForm = new SashForm(sashGroup, SWT.NONE);
+ sashForm.setOrientation(SWT.HORIZONTAL);
+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 5;
+ layout.marginWidth = 5;
+ sashForm.setLayout(layout);
+
+ createSelectionArea(sashForm);
+ createEditArea(sashForm);
+ initializeSashForm();
+
+ // Do not call this until the widgets are constructed
+ handleTargetSelection();
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * Add the tabs relevant to the project to edit area tab folder.
+ */
+ protected void createEditArea(Composite parent) {
+ // Add a container for the build settings page
+ settingsPageContainer = new Composite(parent, SWT.NULL);
+ settingsPageContainer.setLayout(new PageLayout());
+ }
+
+ protected void createSelectionArea (Composite parent) {
+ // Create a label and list viewer
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ optionList = new TreeViewer(composite, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
+ optionList.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleOptionSelection();
+ }
+ });
+ optionList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ optionList.setLabelProvider(new ToolListLabelProvider());
+ }
+
+ /**
+ * Method displayOptionsForTool.
+ * @param toolReference
+ */
+ private void displayOptionsForCategory(IOptionCategory category) {
+ // Do nothing if the selected category is is unchanged
+ if (selectedCategory == category) {
+ return;
+ }
+ selectedCategory = category;
+
+ // Cache the current build setting page
+ BuildToolSettingsPage oldPage = currentSettingsPage;
+ currentSettingsPage = null;
+
+ // Create a new settings page if necessary
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildToolSettingsPage page = (BuildToolSettingsPage) iter.next();
+ if (page.getCategory().equals(category)) {
+ currentSettingsPage = page;
+ break;
+ }
+ }
+ if (currentSettingsPage == null) {
+ currentSettingsPage = new BuildToolSettingsPage(selectedConfiguration, category);
+ pages.add(currentSettingsPage);
+ currentSettingsPage.setContainer(this);
+ if (currentSettingsPage.getControl() == null) {
+ currentSettingsPage.createControl(settingsPageContainer);
+ }
+ }
+
+ // Force calculation of the page's description label because
+ // label can be wrapped.
+ Point contentSize = currentSettingsPage.computeSize();
+ // Do we need resizing. Computation not needed if the
+ // first page is inserted since computing the dialog's
+ // size is done by calling dialog.open().
+ // Also prevent auto resize if the user has manually resized
+ Shell shell = getShell();
+ Point shellSize = shell.getSize();
+ if (oldPage != null) {
+ Rectangle rect = settingsPageContainer.getClientArea();
+ Point containerSize = new Point(rect.width, rect.height);
+ int hdiff = contentSize.x - containerSize.x;
+ int vdiff = contentSize.y - containerSize.y;
+
+ if (hdiff > 0 || vdiff > 0) {
+ if (shellSize.equals(lastShellSize)) {
+ hdiff = Math.max(0, hdiff);
+ vdiff = Math.max(0, vdiff);
+ setShellSize(shellSize.x + hdiff, shellSize.y + vdiff);
+ lastShellSize = shell.getSize();
+ } else {
+ currentSettingsPage.setSize(containerSize);
+ }
+ } else if (hdiff < 0 || vdiff < 0) {
+ currentSettingsPage.setSize(containerSize);
+ }
+
+ }
+
+ // Make all the other pages invisible
+ Control[] children = settingsPageContainer.getChildren();
+ Control currentControl = currentSettingsPage.getControl();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != currentControl)
+ children[i].setVisible(false);
+ }
+ currentSettingsPage.setVisible(true);
+ if (oldPage != null)
+ oldPage.setVisible(false);
+ }
+
+ /* (non-Javadoc)
+ * @return an array of names for the configurations defined for the chosen target
+ */
+ private String [] getConfigurationNames () {
+ String [] names = new String[configurations.length];
+ for (int index = 0; index < configurations.length; ++index) {
+ names[index] = configurations[index].getName();
+ }
+ return names;
+ }
+
+ private List getPagesForConfig() {
+ List pages = (List) configToPageListMap.get(selectedConfiguration.getId());
+ if (pages == null) {
+ pages = new ArrayList();
+ configToPageListMap.put(selectedConfiguration.getId(), pages);
+ }
+ return pages;
+ }
+
+ private String [] getPlatformNames() {
+ String [] names = new String[targets.length];
+ for (int index = 0; index < targets.length; ++index) {
+ names[index] = targets[index].getName();
+ }
+ return names;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
+ */
+ public IPreferenceStore getPreferenceStore()
+ {
+ return settingsStore;
+ }
+
+ private IProject getProject() {
+ Object element= getElement();
+ if (element != null && element instanceof IProject) {
+ return (IProject)element;
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfiguration;
+ }
+
+ /*
+ * Event Handlers
+ */
+ private void handleConfigSelection () {
+ // If there is nothing in config selection widget just bail
+ if (configSelector.getItemCount() == 0) return;
+
+ // Cache the selected config
+ selectedConfiguration = configurations[configSelector.getSelectionIndex()];
+
+ // Set the content provider for the list viewer
+ ToolListContentProvider provider = new ToolListContentProvider();
+ optionList.setContentProvider(provider);
+ optionList.setInput(selectedConfiguration);
+ optionList.expandAll();
+
+ // Recreate the settings store for the configuration
+ settingsStore = new BuildToolsSettingsStore(selectedConfiguration);
+
+ // Select the first option in the list
+ Object[] elements = provider.getElements(selectedConfiguration);
+ Object primary = elements.length > 0 ? elements[0] : null;
+ if (primary != null) {
+ optionList.setSelection(new StructuredSelection(primary));
+ }
+ }
+
+ // Event handler for the manage configuration button event
+ private void handleManageConfig () {
+ ManageConfigDialog manageDialog = new ManageConfigDialog(getShell(), CUIPlugin.getResourceString(MANAGE_TITLE), selectedTarget);
+ if (manageDialog.open() == ManageConfigDialog.OK) {
+ // Check to see if any configurations have to be deleted
+ ArrayList deleteMe = manageDialog.getDeletedConfigs();
+ ListIterator iter = deleteMe.listIterator();
+ while (iter.hasNext()) {
+ }
+ return;
+ }
+ }
+
+ private void handleOptionSelection() {
+ // Get the selection from the tree list
+ IStructuredSelection selection = (IStructuredSelection) optionList.getSelection();
+
+ // Set the option page based on the selection
+ Object element = selection.getFirstElement();
+ if (element instanceof IOptionCategory) {
+ displayOptionsForCategory((IOptionCategory)element);
+ }
+ }
+
+ private void handleTargetSelection() {
+ // Is there anything in the selector widget
+ if (targetSelector.getItemCount() == 0) {
+ manageConfigs.setEnabled(false);
+ return;
+ }
+
+ // Enable the manage button
+ manageConfigs.setEnabled(true);
+
+ // Cache the platform at the selection index
+ selectedTarget = targets[targetSelector.getSelectionIndex()];
+
+ // Update the contents of the configuration widget
+ populateConfigurations();
+ }
+
+ /**
+ * Initialize the relative weights (widths) of the 2 sides of the sash.
+ */
+ protected void initializeSashForm() {
+ sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
+ }
+
+ public boolean performOk() {
+ // Force each settings page to update
+ List pages = getPagesForConfig();
+ ListIterator iter = pages.listIterator();
+ while (iter.hasNext()) {
+ BuildToolSettingsPage page = (BuildToolSettingsPage) iter.next();
+ page.performOk();
+ }
+
+ // Write out the build model info
+ ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
+ ManagedBuildManager.saveBuildInfo(getProject());
+ return true;
+ }
+
+ private void populateConfigurations() {
+ // If the config select widget is not there yet, just stop
+ if (configSelector == null) return;
+
+ // Find the configurations defined for the platform
+ configurations = selectedTarget.getConfigurations();
+
+ // Clear and replace the contents of the selector widget
+ configSelector.removeAll();
+ configSelector.setItems(getConfigurationNames());
+
+ // Make sure the active configuration is selected
+ configSelector.select(0);
+ handleConfigSelection();
+ }
+
+ /**
+ * Changes the shell size to the given size, ensuring that
+ * it is no larger than the display bounds.
+ *
+ * @param width the shell width
+ * @param height the shell height
+ */
+ private void setShellSize(int width, int height) {
+ getShell().setSize(width, height);
+ constrainShellSize();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
+ */
+ public void updateButtons() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
+ */
+ public void updateMessage() {
+ }
+ /**
+ * @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
+ */
+ public void updateTitle() {
+ }
+
+
+
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java
new file mode 100644
index 00000000000..0e6a61a10ef
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java
@@ -0,0 +1,131 @@
+package org.eclipse.cdt.ui.build.properties;
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOption;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * @author sevoy
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class BuildToolSettingsPage extends FieldEditorPreferencePage {
+
+ // Variables to help map this page back to an option category and tool
+ private IConfiguration configuration;
+ private IOptionCategory category;
+
+ BuildToolSettingsPage(IConfiguration configuration, IOptionCategory category) {
+ // Must be a grid layout and we don't want another set of buttons
+ super(GRID);
+ noDefaultAndApplyButton();
+
+ // Cache the option category this page is created for
+ this.configuration = configuration;
+ this.category = category;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#computeSize()
+ */
+ public Point computeSize() {
+ // TODO Auto-generated method stub
+ return super.computeSize();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ protected void createFieldEditors() {
+ // Get the preference store for the build settings
+ IPreferenceStore settings = getPreferenceStore();
+ setPreferenceStore(settings);
+
+ // Iterate over the options in the category and create a field editor for each
+ IOption[] options = category.getOptions(configuration);
+ for (int index = 0; index < options.length; ++index) {
+ // Get the option
+ IOption opt = options[index];
+ // Figure out which type the option is and add a proper field editor for it
+ switch (opt.getValueType()) {
+ case IOption.STRING :
+ StringFieldEditor stringField = new StringFieldEditor(opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(stringField);
+ break;
+ case IOption.BOOLEAN :
+ BooleanFieldEditor booleanField = new BooleanFieldEditor(opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(booleanField);
+ break;
+ case IOption.ENUMERATED :
+ BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(opt.getId(), opt.getName(), opt.getApplicableValues(), opt.getSelectedEnum(), getFieldEditorParent());
+ addField(comboField);
+ break;
+ case IOption.STRING_LIST :
+ BuildOptionListFieldEditor listField = new BuildOptionListFieldEditor(opt.getId(), opt.getName(), getFieldEditorParent());
+ addField(listField);
+ break;
+// case IOption.SUMMARY :
+// SummaryFieldEditor summaryField = new SummaryFieldEditor(opt.getId(), opt.getName(), category.getTool(), getFieldEditorParent());
+// addField(summaryField);
+// break;
+ default :
+ break;
+ }
+ }
+ }
+
+ /**
+ * @return the option category the page was created for
+ */
+ public IOptionCategory getCategory() {
+ return category;
+ }
+
+ /**
+ * @see IPreferencePage#performOk()
+ */
+ public boolean performOk() {
+ // Write the field editor contents out to the preference store
+ boolean ok = super.performOk();
+
+ // Write the preference store values back to the build model
+ IOption[] options = category.getOptions(configuration);
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+
+ // Transfer value from preference store to options
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = getPreferenceStore().getBoolean(option.getId());
+ ManagedBuildManager.setOption(configuration, option, boolVal);
+ break;
+ case IOption.ENUMERATED :
+ String enumVal = getPreferenceStore().getString(option.getId());
+ ManagedBuildManager.setOption(configuration, option, enumVal);
+ break;
+ case IOption.STRING :
+ String strVal = getPreferenceStore().getString(option.getId());
+ ManagedBuildManager.setOption(configuration, option, strVal);
+ break;
+ case IOption.STRING_LIST :
+ String listStr = getPreferenceStore().getString(option.getId());
+ String[] listVal = BuildToolsSettingsStore.parseString(listStr);
+ ManagedBuildManager.setOption(configuration, option, listVal);
+ break;
+ default :
+ break;
+ }
+ }
+
+ return ok;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java
new file mode 100644
index 00000000000..31aa7e609a0
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolsSettingsStore.java
@@ -0,0 +1,425 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.build.managed.BuildException;
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOption;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.jface.util.ListenerList;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+
+public class BuildToolsSettingsStore implements IPreferenceStore {
+ public static final String DEFAULT_SEPERATOR = ";";
+
+ // List of listeners on the property store
+ private ListenerList listenerList;
+ private HashMap optionMap;
+ private boolean dirtyFlag;
+ private IConfiguration owner;
+
+ public BuildToolsSettingsStore (IConfiguration config) {
+ listenerList = new ListenerList();
+ dirtyFlag = false;
+ owner = config;
+
+ // Now populate the options map
+ populateOptionMap();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ listenerList.add(listener);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
+ */
+ public boolean contains(String name) {
+ return optionMap.containsKey(name);
+ }
+
+ /**
+ * @param items An array of strings
+ * @return a String containing the strings passed in the argument separated by the
+ * DEFAULT_SEPERATOR
+ */
+ public static String createList(String[] items) {
+ StringBuffer path = new StringBuffer(""); //$NON-NLS-1$
+
+ for (int i = 0; i < items.length; i++) {
+ path.append(items[i]);
+ if (i < (items.length - 1)) {
+ path.append(DEFAULT_SEPERATOR);
+ }
+ }
+ return path.toString();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, java.lang.Object, java.lang.Object)
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+ Object[] listeners = listenerList.getListeners();
+ if (listeners.length > 0 && (oldValue == null || !oldValue.equals(newValue)))
+ {
+ PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue);
+ for (int i = 0; i < listeners.length; ++i)
+ {
+ IPropertyChangeListener l = (IPropertyChangeListener)listeners[i];
+ l.propertyChange( pe );
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
+ */
+ public boolean getBoolean(String name) {
+ Object b = optionMap.get(name);
+ if (b instanceof Boolean)
+ {
+ return ((Boolean)b).booleanValue();
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String)
+ */
+ public boolean getDefaultBoolean(String name) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String)
+ */
+ public double getDefaultDouble(String name) {
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String)
+ */
+ public float getDefaultFloat(String name) {
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String)
+ */
+ public int getDefaultInt(String name) {
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String)
+ */
+ public long getDefaultLong(String name) {
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String)
+ */
+ public String getDefaultString(String name) {
+ return new String();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String)
+ */
+ public double getDouble(String name) {
+ return getDefaultDouble(name);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String)
+ */
+ public float getFloat(String name) {
+ return getDefaultFloat(name);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String)
+ */
+ public int getInt(String name) {
+ return getDefaultInt(name);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String)
+ */
+ public long getLong(String name) {
+ return getDefaultLong(name);
+ }
+
+ private void getOptionsForCategory(IOptionCategory cat) {
+ IOptionCategory [] children = cat.getChildCategories();
+ // If there are child categories, add their options
+ for (int i = 0; i < children.length; ++i) {
+ getOptionsForCategory(children[i]);
+ }
+ // Else get the options for this category and add them to the map
+ if (optionMap == null) {
+ optionMap = new HashMap();
+ }
+ IOption [] options = cat.getOptions(owner);
+ for (int j = 0; j < options.length; ++j) {
+ IOption opt = options[j];
+ String name = opt.getId();
+ Object value;
+ // Switch on the type of option
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN :
+ try {
+ value = new Boolean(opt.getBooleanValue());
+ } catch (BuildException e) {
+ break;
+ }
+ optionMap.put(name, value);
+ break;
+
+ case IOption.ENUMERATED :
+ value = createList(opt.getApplicableValues());
+ optionMap.put(name, value);
+ break;
+
+ case IOption.STRING :
+ try {
+ value = opt.getStringValue();
+ } catch (BuildException e1) {
+ break;
+ }
+ optionMap.put(name, value);
+ break;
+
+ case IOption.STRING_LIST :
+ try {
+ value = createList(opt.getStringListValue());
+ } catch (BuildException e2) {
+ break;
+ }
+ optionMap.put(name, value);
+ break;
+
+ default :
+ break;
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
+ */
+ public String getString(String name) {
+ Object s = optionMap.get(name);
+
+ if ( s instanceof String )
+ {
+ return (String)s;
+ }
+ return getDefaultString(name);
+
+// Object s = optionMap.get(name);
+// if (s instanceof IOption) {
+// IOption option = (IOption) s;
+// String [] values = null;
+// String list = null;
+// try {
+// switch (option.getValueType()) {
+// // Return the enumerated options in a semicolon-separated list
+// case IOption.ENUMERATED :
+// values = option.getApplicableValues();
+// list = createList(values);
+// break;
+// // Just return the string
+// case IOption.STRING :
+// list = option.getStringValue();
+// break;
+// // Return the list values in a semicolon-spearated string
+// case IOption.STRING_LIST :
+// values = option.getStringListValue();
+// list = createList(values);
+// default:
+// break;
+// }
+// } catch (BuildException e) {
+// return getDefaultString(name);
+// }
+// return list == null ? getDefaultString(name) : list;
+// }
+// return getDefaultString(name);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String)
+ */
+ public boolean isDefault(String name) {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
+ */
+ public boolean needsSaving() {
+ return dirtyFlag;
+ }
+
+ public static String[] parseString(String stringList) {
+ StringTokenizer tokenizer = new StringTokenizer(stringList, BuildToolsSettingsStore.DEFAULT_SEPERATOR);
+ ArrayList list = new ArrayList();
+ while (tokenizer.hasMoreElements()) {
+ list.add(tokenizer.nextElement());
+ }
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+
+ /**
+ *
+ */
+ private void populateOptionMap() {
+ // Each configuration has a list of tools
+ ITool [] tools = owner.getTools();
+ for (int index = 0; index < tools.length; ++index) {
+ ITool tool = tools[index];
+ IOptionCategory cat = tool.getTopOptionCategory();
+ getOptionsForCategory(cat);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String)
+ */
+ public void putValue(String name, String value) {
+ Object oldValue = optionMap.get(name);
+ if (oldValue == null || !oldValue.equals(value))
+ {
+ optionMap.put(name, value);
+ setDirty(true);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, double)
+ */
+ public void setDefault(String name, double value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, float)
+ */
+ public void setDefault(String name, float value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, int)
+ */
+ public void setDefault(String name, int value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, long)
+ */
+ public void setDefault(String name, long value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, java.lang.String)
+ */
+ public void setDefault(String name, String defaultObject) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, boolean)
+ */
+ public void setDefault(String name, boolean value) {
+ }
+
+ protected void setDirty( boolean isDirty )
+ {
+ dirtyFlag = isDirty;
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String)
+ */
+ public void setToDefault(String name) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, double)
+ */
+ public void setValue(String name, double value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, float)
+ */
+ public void setValue(String name, float value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, int)
+ */
+ public void setValue(String name, int value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, long)
+ */
+ public void setValue(String name, long value) {
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, java.lang.String)
+ */
+ public void setValue(String name, String value) {
+ Object oldValue = getString(name);
+ if (oldValue == null || !oldValue.equals(value))
+ {
+ optionMap.put(name, value);
+ setDirty(true);
+ firePropertyChangeEvent(name, oldValue, value);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, boolean)
+ */
+ public void setValue(String name, boolean value) {
+ boolean oldValue = getBoolean(name);
+ if (oldValue != value)
+ {
+ optionMap.put(name, new Boolean(value));
+ setDirty(true);
+ firePropertyChangeEvent(name, new Boolean(oldValue), new Boolean(value));
+ }
+
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ManageConfigDialog.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ManageConfigDialog.java
new file mode 100644
index 00000000000..412fb529c8b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ManageConfigDialog.java
@@ -0,0 +1,233 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+import java.util.ArrayList;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+public class ManageConfigDialog extends Dialog {
+ // String constants
+ private static final String PREFIX = "BuildPropertyCommon"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String NEW = LABEL + ".new"; //$NON-NLS-1$
+ private static final String REMOVE = LABEL + ".remove"; //$NON-NLS-1$
+ private static final String CONFIGS = LABEL + ".configs"; //$NON-NLS-1$
+
+ // Default return values
+ private static final ArrayList EMPTY_LIST = new ArrayList(0);
+ private static final SortedMap EMPTY_MAP = new TreeMap();
+
+ // The title of the dialog.
+ private String title = "";
+ // The target the configs belong to
+ private ITarget managedTarget;
+ // The list of configurations to delete
+ private ArrayList deletedConfigIds;
+ // Map of configuration names and ids
+ private SortedMap configIds;
+ // Map of new configurations chosen by the user
+ private SortedMap newConfigs;
+
+ // Widgets
+ private List configurationList;
+ private Button newBtn;
+ private Button okBtn;
+ private Button removeBtn;
+
+ /**
+ * @param parentShell
+ */
+ protected ManageConfigDialog(Shell parentShell, String title, ITarget target) {
+ super(parentShell);
+ this.title = title;
+ this.managedTarget = target;
+
+ // Get the defined configurations from the target
+ IConfiguration [] configs = this.managedTarget.getConfigurations();
+ configIds = new TreeMap();
+ for (int i = 0; i < configs.length; i++) {
+ IConfiguration configuration = configs[i];
+ configIds.put(configuration.getName(), configuration.getId());
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null)
+ shell.setText(title);
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ // create OK and Cancel buttons by default
+ okBtn = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+
+ updateButtons();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ // Create the main composite with a 2-column grid layout
+ Composite composite = ControlFactory.createComposite(parent, 3);
+
+ // Create a list
+ Composite listComp = ControlFactory.createComposite(composite, 1);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ listComp.setLayoutData(gd);
+ Label label = ControlFactory.createLabel(listComp, CUIPlugin.getResourceString(CONFIGS));
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ configurationList = new List(listComp, SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 15;
+ configurationList.setLayoutData(gd);
+
+ // Create a composite for the buttons
+ Composite buttonBar = ControlFactory.createComposite(composite, 1);
+ newBtn = ControlFactory.createPushButton(buttonBar, CUIPlugin.getResourceString(NEW));
+ setButtonLayoutData(newBtn);
+ newBtn.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ handleNewPressed();
+ }
+ });
+ removeBtn = ControlFactory.createPushButton(buttonBar, CUIPlugin.getResourceString(REMOVE));
+ setButtonLayoutData(removeBtn);
+ removeBtn.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ handleRemovePressed();
+ }
+ });
+
+ // Do the final widget prep
+ configurationList.setItems(getConfigurationNames());
+ configurationList.select(0);
+ newBtn.setFocus();
+ return composite;
+ }
+
+ private String [] getConfigurationNames() {
+ return (String[]) configIds.keySet().toArray(new String[configIds.size()]);
+ }
+
+ /**
+ * @return <code>ArrayList</code> of <code>IConfiguration</code> ids
+ * the user has decided to remove from the target.
+ */
+ public ArrayList getDeletedConfigs() {
+ if (deletedConfigIds == null) {
+ deletedConfigIds = EMPTY_LIST;
+ }
+ return deletedConfigIds;
+ }
+
+ /**
+ * @return Map of configuration names to <code>IConfiguration</code>.
+ * The name is selected by the user and should be unique for the target
+ * it will be added to. The configuration is the what the new
+ * configuration will be based on.
+ */
+ public SortedMap getNewConfigs() {
+ if (newConfigs == null) {
+ newConfigs = EMPTY_MAP;
+ }
+ return newConfigs;
+ }
+
+ /*
+ * @return the <code>IProject</code> associated with the target
+ */
+ private IProject getProject() {
+ return managedTarget.getOwner().getProject();
+ }
+
+ /*
+ * Event handler for the add button
+ */
+ protected void handleNewPressed() {
+ // Find the defined target
+ ITarget parentTarget = null;
+ ITarget [] targets = ManagedBuildManager.getDefinedTargets(getProject());
+ for (int i = 0; i < targets.length; i++) {
+ ITarget target = targets[i];
+ if (target.getId().equals(managedTarget.getId())) {
+ parentTarget = target;
+ break;
+ }
+ }
+ // Get all the predefined configs
+ IConfiguration [] allDefinedConfigs = null;
+ if (parentTarget != null) {
+ allDefinedConfigs = parentTarget.getConfigurations();
+ }
+
+ // There should be predefined configurations ....
+ if (allDefinedConfigs != null && allDefinedConfigs.length != 0) {
+ NewConfigurationDialog dialog = new NewConfigurationDialog(getShell(), allDefinedConfigs, managedTarget);
+ if (dialog.open() == NewConfigurationDialog.OK) {
+ // Get the new name and configuration to base the new config on
+ getNewConfigs().put(dialog.getNewName(), dialog.getParentConfiguration());
+ }
+ }
+
+ // Update the buttons based on the choices
+ updateButtons();
+ }
+
+ /*
+ * Event handler for the remove button
+ */
+ protected void handleRemovePressed() {
+ // TODO Request a remove configuration function through the ITarget interface
+ // Determine which configuration was selected
+ int selectionIndex = configurationList.getSelectionIndex();
+ if (selectionIndex != -1){
+ String selectedConfig = configurationList.getItem(selectionIndex);
+ getDeletedConfigs().add(configIds.get(selectedConfig));
+ configurationList.remove(selectionIndex);
+ updateButtons();
+ }
+ }
+
+ private void updateButtons() {
+ // Disable the remove button if there is only 1 configuration
+// removeBtn.setEnabled(configurationList.getItemCount() > 1);
+ removeBtn.setEnabled(false);
+
+ // Enable the OK button if there are any configs to delete or add
+ okBtn.setEnabled(!(getDeletedConfigs().isEmpty() && getNewConfigs().isEmpty()));
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/NewConfigurationDialog.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/NewConfigurationDialog.java
new file mode 100644
index 00000000000..6fcb6b5e85a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/NewConfigurationDialog.java
@@ -0,0 +1,208 @@
+package org.eclipse.cdt.ui.build.properties;
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+public class NewConfigurationDialog extends Dialog {
+ // String constants
+ private static final String PREFIX = "NewConfiguration"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String ERROR = PREFIX + ".error"; //$NON-NLS-1$
+ private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
+ private static final String COPY = LABEL + ".copy"; //$NON-NLS-1$
+ private static final String TITLE = ERROR + ".title"; //$NON-NLS-1$
+ private static final String DUPLICATE = ERROR + ".duplicateName"; //$NON-NLS-1$
+
+ // Widgets
+ private Combo configSelector;
+ private Button btnOk;
+ private Text configName;
+
+ // Bookeeping
+ private IConfiguration[] definedConfigurations;
+ private IConfiguration parentConfig;
+ private ITarget target;
+ private String newName;
+ private String [] allNames;
+
+
+ /**
+ * @param parentShell
+ */
+ protected NewConfigurationDialog(Shell parentShell, IConfiguration[] configs, ITarget managedTarget) {
+ super(parentShell);
+ setShellStyle(getShellStyle()|SWT.RESIZE);
+ newName = new String();
+ parentConfig = null;
+ definedConfigurations = configs == null ? new IConfiguration[0] : configs;
+ allNames = getConfigurationNames();
+ this.target = managedTarget;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog. Cache the name and base config selections.
+ * We don't have to worry that the index or name is wrong because we
+ * enable the OK button IFF those conditions are met.
+ */
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ newName = configName.getText().trim();
+ String baseConfigName = configSelector.getItem(configSelector.getSelectionIndex());
+ for (int i = 0; i < definedConfigurations.length; i++) {
+ IConfiguration config = definedConfigurations[i];
+ if (config.getName().equals(baseConfigName)) {
+ parentConfig = config;
+ break;
+ }
+ }
+ } else {
+ newName = null;
+ parentConfig = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog. Create OK and Cancel buttons and hold onto the OK button handle.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ btnOk = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ configName.setFocus();
+ if (configName != null) {
+ configName.setText(newName);
+ }
+ updateButtonState();
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = ControlFactory.createComposite(parent, 3);
+ GridData gd;
+
+ // Add a label and a text widget
+ Label nameLabel = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(NAME));
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ nameLabel.setLayoutData(gd);
+ configName = ControlFactory.createTextField(composite);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ configName.setLayoutData(gd);
+ configName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateButtonState();
+ }
+ });
+
+ // Add a label and combo box to select the base config
+ Label configLabel = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(COPY));
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ configLabel.setLayoutData(gd);
+ configSelector = ControlFactory.createSelectCombo(composite, allNames, newName);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ configSelector.setLayoutData(gd);
+ configSelector.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateButtonState();
+ }
+ });
+
+ return composite;
+ }
+
+ /**
+ * @return the <code>IConfiguration</code> the user selected as
+ * the parent of the new configuration.
+ */
+ public IConfiguration getParentConfiguration() {
+ return parentConfig;
+ }
+
+ /*
+ * Returns an array of configuration names
+ */
+ private String [] getConfigurationNames() {
+ String [] names = new String[definedConfigurations.length];
+ for (int index = 0; index < definedConfigurations.length; ++index) {
+ IConfiguration config = definedConfigurations[index];
+ names[index] = config.getName();
+ }
+ return names;
+ }
+
+ /**
+ * @return <code>String</code> containing the name chosen by the user for the
+ * new configuration.
+ */
+ public String getNewName() {
+ return newName;
+ }
+
+ protected boolean isDuplicateName(String newName) {
+ // Return true if there is already a config of that name defined on the target
+ IConfiguration [] configs = target.getConfigurations();
+ for (int index = 0; index < configs.length; index++) {
+ IConfiguration configuration = configs[index];
+ if (configuration.getName() == newName) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * Enable the OK button if there is a valid name in the text widget
+ * and there is a valid selection in the base configuration combo
+ */
+ private void updateButtonState() {
+ if (btnOk != null) {
+ int selectionIndex = configSelector.getSelectionIndex();
+ btnOk.setEnabled(validateName() && selectionIndex != -1);
+ }
+ }
+
+ private boolean validateName() {
+ String currentName = configName.getText().trim();
+ int nameLength = currentName.length();
+ // Make sure the name is not a duplicate
+ if (isDuplicateName(currentName)) {
+ MessageDialog.openError(getShell(),
+ CUIPlugin.getResourceString(TITLE),
+ CUIPlugin.getFormattedString(DUPLICATE, currentName)); //$NON-NLS-1$
+ return false;
+ }
+ // TODO make sure there are no invalid chars in name
+ return (nameLength > 0);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java
new file mode 100644
index 00000000000..5d0872f6838
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java
@@ -0,0 +1,114 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.core.build.managed.IOption;
+import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class SummaryFieldEditor extends FieldEditor {
+
+ // The tool this category belongs to
+ ITool tool;
+ // The text widget to hold summary of all commands for the tool
+ Text summary;
+ // Whitespace character
+ private static final String WHITESPACE = " ";
+
+ /**
+ * @param name
+ * @param labelText
+ * @param parent
+ */
+ public SummaryFieldEditor(String name, String labelText, ITool tool, Composite parent) {
+ super(name, labelText, parent);
+ this.tool = tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
+ */
+ protected void adjustForNumColumns(int numColumns) {
+ // For now grab the excess space
+ GridData gd = (GridData) summary.getLayoutData();
+ gd.horizontalSpan = numColumns - 1;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
+ */
+ protected void doFillIntoGrid(Composite parent, int numColumns) {
+ // Add the label
+ getLabelControl(parent);
+
+ // Create the multi-line, read-only field
+ summary = new Text(parent, SWT.MULTI|SWT.READ_ONLY|SWT.WRAP);
+ GridData data = new GridData();
+ data.horizontalSpan = numColumns - 1;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.verticalAlignment = GridData.CENTER;
+ data.grabExcessVerticalSpace = true;
+ summary.setLayoutData(data);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doLoad()
+ */
+ protected void doLoad() {
+ // Look at the data store for every option defined for the tool
+ IOption[] options = tool.getOptions();
+ for (int index = 0; index < options.length; ++index) {
+ IOption option = options[index];
+ String command = option.getCommand();
+ if (command == null) {
+ command = "";
+ }
+ String id = option.getId();
+ String values = getPreferenceStore().getString(id);
+ String[] valuesList = BuildToolsSettingsStore.parseString(values);
+ for (int j = 0; j < valuesList.length; ++j) {
+ String entry = valuesList[j];
+ summary.append(command + entry + WHITESPACE);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
+ */
+ protected void doLoadDefault() {
+ doLoad();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#doStore()
+ */
+ protected void doStore() {
+ // This is a read-only summary field, so don't store data
+ return;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
+ */
+ public int getNumberOfControls() {
+ // There is just the label from the parent and the text field
+ return 2;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListContentProvider.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListContentProvider.java
new file mode 100644
index 00000000000..d2f04f63c72
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListContentProvider.java
@@ -0,0 +1,98 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Timesys - Initial API and implementation
+ * IBM Rational Software
+ * *********************************************************************/
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.core.build.managed.ITool;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class ToolListContentProvider implements ITreeContentProvider{
+ private static Object[] EMPTY_ARRAY = new Object[0];
+ private IConfiguration root;
+
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ // If parent is configuration, return a list of its option categories
+ if (parentElement instanceof IConfiguration) {
+ IConfiguration config = (IConfiguration)parentElement;
+ ITool [] tools = config.getTools();
+ IOptionCategory [] categories = new IOptionCategory[tools.length];
+ // The categories are accessed through the tool
+ for (int index = 0; index < tools.length; ++index) {
+ categories[index] = tools[index].getTopOptionCategory();
+ }
+ return categories;
+ } else if (parentElement instanceof IOptionCategory) {
+ // Categories can have child categories
+ IOptionCategory cat = (IOptionCategory)parentElement;
+ IOptionCategory [] children = cat.getChildCategories();
+ if (children == null) {
+ return EMPTY_ARRAY;
+ } else {
+ return children;
+ }
+ } else {
+ return EMPTY_ARRAY;
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ public Object getParent(Object element) {
+ if (element instanceof IOptionCategory) {
+ // Find the parent category
+ IOptionCategory cat = (IOptionCategory)element;
+ IOptionCategory parent = cat.getOwner();
+ // Then we need to get the configuration we belong to
+ if (parent == null) {
+ ITool tool = cat.getTool();
+ return root;
+ }
+ return parent;
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ root = (IConfiguration) newInput;
+ }
+}
+
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java
new file mode 100644
index 00000000000..b93e7dc0f01
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java
@@ -0,0 +1,65 @@
+package org.eclipse.cdt.ui.build.properties;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * **********************************************************************/
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.IOptionCategory;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+
+class ToolListLabelProvider extends LabelProvider {
+ private final Image IMG_FOLDER = CUIPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ private final Image IMG_TOOL = CPluginImages.get(CPluginImages.IMG_BUILD_TOOL);
+ private static final String TREE_LABEL = "BuildPropertyPage.label.ToolTree"; //$NON-NLS-1$
+
+ public Image getImage(Object element) {
+ // If the element is a configuration, return the folder image
+ if (element instanceof IConfiguration) {
+ return IMG_FOLDER;
+ } else if (element instanceof IOptionCategory) {
+ IOptionCategory cat = (IOptionCategory)element;
+ IOptionCategory [] children = cat.getChildCategories();
+ if (children.length > 0){
+ return IMG_FOLDER;
+ } else {
+ return IMG_TOOL;
+ }
+ } else {
+ throw unknownElement(element);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
+ */
+ public String getText(Object element) {
+ if (element instanceof IConfiguration) {
+ IConfiguration config = (IConfiguration)element;
+ return CUIPlugin.getResourceString(TREE_LABEL);
+ }
+ else if (element instanceof IOptionCategory) {
+ IOptionCategory cat = (IOptionCategory)element;
+ return cat.getName();
+ }
+ else {
+ throw unknownElement(element);
+ }
+ }
+
+ protected RuntimeException unknownElement(Object element) {
+ return new RuntimeException("Unknown type of element in tree of type " + element.getClass().getName());
+ }
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/CProjectPlatformPage.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/CProjectPlatformPage.java
new file mode 100644
index 00000000000..120811bc905
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/CProjectPlatformPage.java
@@ -0,0 +1,218 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.ListIterator;
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.CProjectWizard;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+
+public class CProjectPlatformPage extends WizardPage {
+ /*
+ * Bookeeping variables
+ */
+ private CProjectWizard wizard;
+ private ArrayList selectedConfigurations;
+ protected ITarget selectedTarget;
+ protected String[] targetNames;
+ protected ArrayList targets;
+
+ /*
+ * Dialog variables and string constants
+ */
+ protected Combo platformSelection;
+ protected CheckboxTableViewer tableViewer;
+ private static final String PREFIX = "PlatformBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String TIP = PREFIX + ".tip"; //$NON-NLS-1$
+ private static final String PLATFORM_TIP = TIP + ".platform"; //$NON-NLS-1$
+ private static final String PLATFORM_LABEL = LABEL + ".platform"; //$NON-NLS-1$
+ private static final String CONFIG_LABEL = LABEL + ".configs"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ * @param wizard
+ * @param pageName
+ */
+ public CProjectPlatformPage(CProjectWizard wizard, String pageName) {
+ super(pageName);
+ setPageComplete(false);
+ this.wizard = wizard;
+ populateTargets();
+ selectedTarget = null;
+ selectedConfigurations = new ArrayList(0);
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
+ */
+ public boolean canFlipToNextPage() {
+ return validatePage();
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ // Create the composite control for the tab
+ Composite composite = ControlFactory.createComposite(parent, 6);
+
+ // Create the platform selection label and combo widgets
+ Label platformLabel = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(PLATFORM_LABEL));
+ platformLabel.setLayoutData(new GridData());
+
+ platformSelection = ControlFactory.createSelectCombo(composite, targetNames, null);
+ platformSelection.setToolTipText(CUIPlugin.getResourceString(PLATFORM_TIP));
+ platformSelection.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleTargetSelection();
+ }
+ });
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 5;
+ platformSelection.setLayoutData(gd);
+
+ // Create a check box table of valid configurations
+ Label configLabel = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(CONFIG_LABEL));
+ configLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI
+ | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 6;
+ table.setLayoutData(gd);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(false);
+
+ // Add a table layout to the table
+ TableLayout tableLayout = new TableLayout();
+ table.setHeaderVisible(false);
+ table.setLayout(tableLayout);
+
+ // Add the viewer
+ tableViewer = new CheckboxTableViewer(table);
+ tableViewer.setLabelProvider(new ConfigurationLabelProvider());
+ tableViewer.setContentProvider(new ConfigurationContentProvider());
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ // will default to false until a selection is made
+ handleConfigurationSelectionChange();
+ }
+ });
+
+ // Do the nasty
+ setErrorMessage(null);
+ setMessage(null);
+ setControl(composite);
+ }
+
+ public IConfiguration[] getSelectedConfigurations() {
+ return (IConfiguration[]) selectedConfigurations.toArray(new IConfiguration[selectedConfigurations.size()]);
+ }
+
+ /**
+ * Returns the name of the selected platform.
+ *
+ * @return String containing platform name or <code>null</code> if an invalid selection
+ * has been made.
+ */
+ public ITarget getSelectedTarget() {
+ return selectedTarget;
+ }
+
+ private void handleConfigurationSelectionChange() {
+ // Get the selections from the table viewer
+ selectedConfigurations.clear();
+ selectedConfigurations.addAll(Arrays.asList(tableViewer.getCheckedElements()));
+ }
+
+ /**
+ * Returns whether this page's controls currently all contain valid
+ * values.
+ *
+ * @return <code>true</code> if all controls are valid, and
+ * <code>false</code> if at least one is invalid
+ */
+ protected void handleTargetSelection() {
+ /*
+ * The index in the combo is the offset into the target list
+ */
+ int index;
+ if (platformSelection != null
+ && (index = platformSelection.getSelectionIndex()) != -1) {
+ selectedTarget = (ITarget) targets.get(index);
+ }
+ populateConfigurations();
+ setPageComplete(validatePage());
+ }
+
+ /**
+ * Populate the table viewer with the known configurations.
+ * By default, all the configurations are selected.
+ */
+ private void populateConfigurations() {
+ // Make the root of the content provider the new target
+ tableViewer.setInput(selectedTarget);
+ tableViewer.setAllChecked(true);
+ handleConfigurationSelectionChange();
+ }
+
+ private void populateTargetNames() {
+ targetNames = new String[targets.size()];
+ ListIterator iter = targets.listIterator();
+ int index = 0;
+ while (iter.hasNext()) {
+ targetNames[index++] = ((ITarget) iter.next()).getName();
+ }
+ }
+
+ private void populateTargets() {
+ // Get a list of platforms defined by plugins
+ ITarget[] allTargets = ManagedBuildManager.getDefinedTargets(null);
+ targets = new ArrayList();
+ // Add all of the concrete targets to the target list
+ for (int index = 0; index < allTargets.length; ++index) {
+ ITarget target = allTargets[index];
+ if (!target.isAbstract() && !target.isTestTarget()) {
+ targets.add(target);
+ }
+ }
+ targets.trimToSize();
+ populateTargetNames();
+ }
+
+ /**
+ * @return
+ */
+ private boolean validatePage() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationBlock.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationBlock.java
new file mode 100644
index 00000000000..48a3910cafb
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationBlock.java
@@ -0,0 +1,181 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.IWizardTab;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea;
+import org.eclipse.cdt.utils.ui.swt.IValidation;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+public class ConfigurationBlock implements IWizardTab {
+ /* (non-Javadoc)
+ * String constants
+ */
+ private static final String PREFIX = "ConfigurationBlock"; //$NON-NLS-1$
+ private static final String TYPE = PREFIX + ".type"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String APP = TYPE + ".app"; //$NON-NLS-1$
+ private static final String DLL = TYPE + ".shared"; //$NON-NLS-1$
+ private static final String LIB = TYPE + ".static"; //$NON-NLS-1$
+ private static final String BUILD = PREFIX + ".build"; //$NON-NLS-1$
+ private static final String BUILD_LABEL = BUILD + ".label"; //$NON-NLS-1$
+ private static final String CONT = BUILD + ".continue"; //$NON-NLS-1$
+ private static final String STOP = BUILD + ".stop"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * Bookeeping variables
+ */
+ private IValidation page;
+ private ManagedProjectWizard fWizard;
+
+ /* (non-Javadoc)
+ * Widgets used on the tab
+ */
+ protected Composite composite;
+ protected GridData gd;
+ protected RadioButtonsArea typeRadioButtons;
+ private String [][] types;
+ private static final String APP_ARG = "exe"; //$NON-NLS-1$
+ private static final String DLL_ARG = "dll"; //$NON-NLS-1$
+ private static final String LIB_ARG = "lib"; //$NON-NLS-1$
+ protected RadioButtonsArea optRadioButtons;
+ private String [][] opts;
+ private static final String CONT_ARG = "cont"; //$NON-NLS-1$
+ private static final String STOP_ARG = "stop"; //$NON-NLS-1$
+
+ public ConfigurationBlock(IValidation valid, ManagedProjectWizard wizard) {
+ page = valid;
+ fWizard = wizard;
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#getLabel()
+ */
+ public String getLabel() {
+ return CUIPlugin.getResourceString(LABEL);
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#getImage()
+ */
+ public Image getImage() {
+// return CPluginImages.get(CPluginImages.IMG_BUILD_CONFIG);
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#getControl(org.eclipse.swt.widgets.Composite)
+ */
+ public Composite getControl(Composite parent) {
+ // Create the composite control for the tab
+ composite = ControlFactory.createComposite(parent, 2);
+
+ // Create the application type selection area and select the application option
+ types = new String [][] {
+ {CUIPlugin.getResourceString(APP), APP_ARG},
+ {CUIPlugin.getResourceString(DLL), DLL_ARG},
+ {CUIPlugin.getResourceString(LIB), LIB_ARG}
+ };
+ typeRadioButtons = new RadioButtonsArea(composite, CUIPlugin.getResourceString(TYPE), 1, types);
+ typeRadioButtons.addListener(SWT.Selection, new Listener () {
+ public void handleEvent(Event e) {
+ page.setComplete(isValid());
+ }
+ });
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ typeRadioButtons.setLayoutData(gd);
+
+ // Create the build option buttons
+ opts = new String [][] {
+ {CUIPlugin.getResourceString(CONT), CONT_ARG},
+ {CUIPlugin.getResourceString(STOP), STOP_ARG}
+ };
+ optRadioButtons = new RadioButtonsArea(composite, CUIPlugin.getResourceString(BUILD_LABEL), 1, opts);
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ optRadioButtons.setLayoutData(gd);
+
+ // Return the widget
+ return composite;
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#isValid()
+ */
+ public boolean isValid() {
+ return true;
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+
+ // Set the executable radio button by default
+ typeRadioButtons.setSelectedButton(0);
+
+ // Set the build option radio button based on the platform default
+ optRadioButtons.setSelectedButton(0);
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#doRun(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doRun(IProject project, IProgressMonitor monitor) {
+ try {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("Configuration", 1);
+
+ // Get the project nature;
+ CProjectNature nature = (CProjectNature) project.getNature(CProjectNature.C_NATURE_ID);
+
+ // Set the build options on the project nature
+ if (nature != null) {
+ nature.setStopOnError(isStopOnError());
+ }
+ }
+ catch (CoreException e) {
+ }
+ }
+
+ /**
+ * Method isStopOnError.
+ * @return boolean
+ */
+ private boolean isStopOnError() {
+ if (optRadioButtons != null) {
+ return (optRadioButtons.getSelectedValue() == STOP_ARG);
+ }
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationContentProvider.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationContentProvider.java
new file mode 100644
index 00000000000..ab4a6f6e670
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationContentProvider.java
@@ -0,0 +1,35 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class ConfigurationContentProvider implements IStructuredContentProvider {
+ // The contents of the parent of the table is a list of configurations
+ public Object[] getElements(Object parent) {
+ // The content is a list of configurations
+ IConfiguration[] configs = ((ITarget) parent).getConfigurations();
+ return (configs.length == 0) ? new Object[0] : configs;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(
+ Viewer viewer,
+ Object oldInput,
+ Object newInput) {
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationLabelProvider.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationLabelProvider.java
new file mode 100644
index 00000000000..9d727ee6c88
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ConfigurationLabelProvider.java
@@ -0,0 +1,36 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class ConfigurationLabelProvider extends LabelProvider implements ITableLabelProvider {
+ private final Image IMG_CFG =
+ CPluginImages.get(CPluginImages.IMG_BUILD_CONFIG);
+
+ //
+ public String getColumnText(Object obj, int index) {
+ if (obj instanceof IConfiguration) {
+ return ((IConfiguration) obj).getName();
+ }
+ return new String();
+ }
+
+ public Image getColumnImage(Object obj, int index) {
+ return IMG_CFG;
+ }
+}
+
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCCWizard.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCCWizard.java
new file mode 100644
index 00000000000..76b9e27c41f
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCCWizard.java
@@ -0,0 +1,66 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.TabFolder;
+
+/**
+ * Wizard that creates a new C++ project that uses the managed make system
+ */
+public class ManagedCCWizard extends ManagedProjectWizard {
+
+ private static final String WZ_TITLE = "MngCCWizard.title";
+ private static final String WZ_DESC = "MngCCWizard.description";
+ private static final String SETTINGS_TITLE= "MngCCWizardSettings.title"; //$NON-NLS-1$
+ private static final String SETTINGS_DESC= "MngCCWizardSettings.description"; //$NON-NLS-1$
+
+ public ManagedCCWizard() {
+ this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC));
+ }
+
+ public ManagedCCWizard(String title, String desc) {
+ super(title, desc);
+ }
+
+ public void addTabItems(TabFolder folder) {
+ super.addTabItems(folder);
+ fTabFolderPage.setTitle(CUIPlugin.getResourceString(SETTINGS_TITLE));
+ fTabFolderPage.setDescription(CUIPlugin.getResourceString(SETTINGS_DESC));
+ }
+
+ protected void doRun(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask("Creating Generated C++ Make Project", 4);
+ super.doRun(monitor);
+ // Add C++ and managed build natures
+ if (newProject != null) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ // Add C++ Nature to the newly created project.
+ monitor.subTask("Adding C++ Nature");
+ CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
+ monitor.worked(1);
+
+ // Add the managed build nature to the project
+ monitor.subTask("Adding makefile generator");
+ addManagedBuildNature(newProject, monitor);
+ monitor.worked(1);
+
+ monitor.done();
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCWizard.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCWizard.java
new file mode 100644
index 00000000000..550c9585a0e
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedCWizard.java
@@ -0,0 +1,61 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.TabFolder;
+
+/**
+ * Wizard to create a new C project that uses the managed make system.
+ */
+public class ManagedCWizard extends ManagedProjectWizard {
+
+ private static final String WZ_TITLE = "MngCWizard.title";
+ private static final String WZ_DESC = "MngCWizard.description";
+ private static final String SETTINGS_TITLE= "MngCWizardSettings.title"; //$NON-NLS-1$
+ private static final String SETTINGS_DESC= "MngCWizardSettings.description"; //$NON-NLS-1$
+
+ public ManagedCWizard() {
+ this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC));
+ }
+
+ public ManagedCWizard(String title, String desc) {
+ super(title, desc);
+ }
+
+ public void addTabItems(TabFolder folder) {
+ super.addTabItems(folder);
+ fTabFolderPage.setTitle(CUIPlugin.getResourceString(SETTINGS_TITLE));
+ fTabFolderPage.setDescription(CUIPlugin.getResourceString(SETTINGS_DESC));
+ }
+
+ protected void doRun(IProgressMonitor monitor) throws CoreException {
+ // Let the super class create and populate the standard project
+ super.doRun(monitor);
+ // Add the managed build nature
+ if (newProject != null) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("Creating Generated C Make Project", 3);
+
+ // Add the managed build nature to the project
+ addManagedBuildNature(newProject, monitor);
+
+ monitor.done();
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedProjectWizard.java b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedProjectWizard.java
new file mode 100644
index 00000000000..664be138613
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/wizards/ManagedProjectWizard.java
@@ -0,0 +1,201 @@
+package org.eclipse.cdt.ui.build.wizards;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ManagedCProjectNature;
+import org.eclipse.cdt.core.build.managed.BuildException;
+import org.eclipse.cdt.core.build.managed.IConfiguration;
+import org.eclipse.cdt.core.build.managed.ITarget;
+import org.eclipse.cdt.core.build.managed.ManagedBuildManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.BinaryParserBlock;
+import org.eclipse.cdt.ui.wizards.CProjectWizard;
+import org.eclipse.cdt.ui.wizards.CProjectWizardPage;
+import org.eclipse.cdt.ui.wizards.ReferenceBlock;
+import org.eclipse.cdt.ui.wizards.TabFolderPage;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+public abstract class ManagedProjectWizard extends CProjectWizard {
+
+ /* (non-Javadoc)
+ * String constants
+ */
+ protected static final String PREFIX = "MngMakeProjectWizard"; //$NON-NLS-1$
+ protected static final String OP_ERROR= PREFIX + ".op_error"; //$NON-NLS-1$
+ protected static final String WZ_TITLE= PREFIX + ".title"; //$NON-NLS-1$
+ protected static final String WZ_DESC= PREFIX + ".description"; //$NON-NLS-1$
+ protected static final String SETTINGS_TITLE= "MngMakeWizardSettings.title"; //$NON-NLS-1$
+ protected static final String SETTINGS_DESC= "MngMakeWizardSettings.description"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * Wizard has a page inherited from super class for setting project
+ * location, one for choosing the platform and a tabbed page to set
+ * configuration options
+ */
+ protected CProjectPlatformPage targetConfigurationPage;
+ protected ConfigurationBlock configBlock;
+ protected ReferenceBlock referenceBlock;
+ protected BinaryParserBlock binaryParserBlock;
+
+ /**
+ * Default Constructor
+ */
+ public ManagedProjectWizard() {
+ this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC));
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.CProjectWizard#CProjectWizard(java.lang.String, java.lang.String)
+ */
+ public ManagedProjectWizard(String title, String desc) {
+ super(title,desc);
+ }
+
+ public void addManagedBuildNature (IProject project, IProgressMonitor monitor) {
+ // Add the managed build nature
+ try {
+ monitor.subTask("Adding Managed Nature");
+ ManagedCProjectNature.addManagedNature(project, monitor);
+ monitor.worked(1);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ // Add the builder
+ try {
+ monitor.subTask("Adding Makefile Generator");
+ ManagedCProjectNature.addManagedBuilder(project, monitor);
+ monitor.worked(1);
+ } catch (CoreException e) {
+ // TODO: handle exception
+ }
+
+ // Add the target to the project
+ try {
+ ITarget parent = targetConfigurationPage.getSelectedTarget();
+ ITarget newTarget = ManagedBuildManager.createTarget(project, parent);
+ if (newTarget != null) {
+ // TODO add name entry field to project
+ newTarget.setBuildArtifact(project.getName() + "." + parent.getDefaultExtension());
+ IConfiguration [] selectedConfigs = targetConfigurationPage.getSelectedConfigurations();
+ for (int i = 0; i < selectedConfigs.length; i++) {
+ IConfiguration config = selectedConfigs[i];
+ newTarget.createConfiguration(config, config.getId() + "." + i);
+ }
+ // Now add the first config in the list as the default
+ IConfiguration[] newConfigs = newTarget.getConfigurations();
+ if (newConfigs.length > 0) {
+ ManagedBuildManager.setDefaultConfiguration(project, newConfigs[0]);
+ }
+ }
+ } catch (BuildException e) {
+ e.printStackTrace();
+ }
+ // Save the build options
+ monitor.subTask("Saving new build options.");
+ ManagedBuildManager.saveBuildInfo(project);
+ monitor.worked(1);
+ }
+
+ /**
+ * @see Wizard#createPages
+ */
+ public void addPages() {
+ // Add the page to name the project and set the location
+ fMainPage= new CProjectWizardPage(this, new String());
+ fMainPage.setTitle(CUIPlugin.getResourceString(WZ_TITLE));
+ fMainPage.setDescription(CUIPlugin.getResourceString(WZ_DESC));
+ addPage(fMainPage);
+
+ // Add a page to chose the build platform
+ targetConfigurationPage = new CProjectPlatformPage(this, new String());
+ targetConfigurationPage.setTitle(CUIPlugin.getResourceString(WZ_TITLE));
+ targetConfigurationPage.setDescription(CUIPlugin.getResourceString(WZ_DESC));
+ addPage(targetConfigurationPage);
+
+ // Add the tab container
+ fTabFolderPage = new TabFolderPage(this);
+ addPage(fTabFolderPage);
+ }
+
+ /**
+ * @see org.eclipse.cdt.ui.wizards.CProjectWizard#addTabItems(org.eclipse.swt.widgets.TabFolder)
+ */
+ public void addTabItems(TabFolder folder) {
+ fTabFolderPage.setTitle(CUIPlugin.getResourceString(SETTINGS_TITLE));
+ fTabFolderPage.setDescription(CUIPlugin.getResourceString(SETTINGS_DESC));
+
+ // Add the tab to set the project dependencies
+ referenceBlock = new ReferenceBlock(getValidation());
+ TabItem item2 = new TabItem(folder, SWT.NONE);
+ item2.setText(referenceBlock.getLabel());
+ Image img2 = referenceBlock.getImage();
+ if (img2 != null)
+ item2.setImage(img2);
+ item2.setData(referenceBlock);
+ item2.setControl(referenceBlock.getControl(folder));
+ addTabItem(referenceBlock);
+
+ // add the tab to select which parser to use for binaries
+ binaryParserBlock = new BinaryParserBlock(getValidation());
+ TabItem item3 = new TabItem(folder, SWT.NONE);
+ item3.setText(binaryParserBlock.getLabel());
+ Image img3 = binaryParserBlock.getImage();
+ if (img3 != null)
+ item3.setImage(img3);
+ item3.setData(binaryParserBlock);
+ item3.setControl(binaryParserBlock.getControl(folder));
+ addTabItem(binaryParserBlock);
+ }
+
+ protected void doRunPrologue(IProgressMonitor monitor) {
+ }
+
+ protected void doRunEpilogue(IProgressMonitor monitor) {
+ }
+
+ protected void doRun(IProgressMonitor monitor) throws CoreException {
+ // super.doRun() just creates the project and does not assign a builder to it.
+ super.doRun(monitor);
+
+ // Modify the project based on what the user has selected
+ if (newProject != null) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ // Update the referenced project if provided.
+ monitor.subTask("Adding project references");
+ if (referenceBlock != null) {
+ referenceBlock.doRun(newProject, new SubProgressMonitor(monitor, 1));
+ }
+ monitor.worked(1);
+ // Update the binary parser
+ monitor.subTask("Setting binary parser");
+ if (binaryParserBlock != null) {
+ binaryParserBlock.doRun(newProject, new SubProgressMonitor(monitor, 1));
+ }
+ monitor.worked(1);
+ }
+ }
+
+ public String getProjectID() {
+ return CCorePlugin.PLUGIN_ID + ".make";
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 16c75cdb029..645c0ae8e20 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -13,16 +13,20 @@ BuildConsoleView.name=C-Build
CView.name=C/C++ Projects
MakeView.name=Make Targets
-# The Wizard
+# The Wizards
# C
newCWizardsCategory.name=C
StdCWizard.name=Standard Make C Project
-StdCWizard.description=Create a new C project
+StdCWizard.description=Create a new C project and let me create and manage the makefile
+MngCWizard.name=Managed Make C Project
+MngCWizard.description=Create a new C project and let Eclipse create and manage the makefile
# C++
newCCWizardsCategory.name=C++
StdCCWizard.name=Standard Make C++ Project
-StdCCWizard.description=Create a new C++ project
+StdCCWizard.description=Create a new C++ project and let me create and manage the makefile
+MngCCWizard.name=Managed Make C++ Project
+MngCCWizard.description=Create a new C++ project and let Eclipse create and manage the makefile
#Project Conversion
ConversionWizard.name=Convert a project's nature
@@ -64,3 +68,10 @@ AsmEditor.name = Assembly Editor
# Task Action
DeleteTaskAction.label=Delete C/C++ Markers
+
+# Build Model Names
+ToolName.preprocessor = Preprocessor
+ToolName.compiler = Compiler
+ToolName.archiver = Archiver
+ToolName.linker = Linker
+ToolName.command = Command Line
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 318911b386a..a60a60ea923 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -227,6 +227,31 @@
class="org.eclipse.core.resources.IResource">
</selection>
</wizard>
+<!-- Managed Make Builder Projects -->
+ <wizard
+ name="%MngCCWizard.name"
+ icon="icons/full/ctool16/newmngcc_app.gif"
+ category="org.eclipse.cdt.ui.newCCWizards"
+ class="org.eclipse.cdt.ui.build.wizards.ManagedCCWizard"
+ project="true"
+ finalPerspective="org.eclipse.cdt.ui.CPerspective"
+ id="org.eclipse.cdt.ui.wizards.StdCCWizard">
+ <description>
+ %MngCCWizard.description
+ </description>
+ </wizard>
+ <wizard
+ name="%MngCWizard.name"
+ icon="icons/full/ctool16/newmngcc_app.gif"
+ category="org.eclipse.cdt.ui.newCWizards"
+ class="org.eclipse.cdt.ui.build.wizards.ManagedCWizard"
+ project="true"
+ finalPerspective="org.eclipse.cdt.ui.CPerspective"
+ id="org.eclipse.cdt.ui.wizards.StdCWizard">
+ <description>
+ %MngCWizard.description
+ </description>
+ </wizard>
<wizard
name="%NewWizards.class"
icon="icons/full/ctool16/newclass_wiz.gif"
@@ -305,6 +330,16 @@
value="org.eclipse.cdt.core.cnature">
</filter>
</page>
+ <page
+ objectClass="org.eclipse.core.resources.IProject"
+ name="C/C++ Build"
+ class="org.eclipse.cdt.ui.build.properties.BuildPropertyPage"
+ id="org.eclipse.cdt.ui.build.properties">
+ <filter
+ name="nature"
+ value="org.eclipse.cdt.core.managedBuildNature">
+ </filter>
+ </page>
</extension>
<extension
point="org.eclipse.ui.editorActions">
@@ -440,6 +475,7 @@
class="org.eclipse.cdt.internal.ui.BuildConsole">
</CBuildConsole>
</extension>
+<!--
<extension
point="org.eclipse.ui.views">
<view
@@ -525,5 +561,332 @@
id="org.eclipse.cdt.gnu.tools.tabGroupLD">
</toolTabGroup>
</extension>
+ -->
+ <extension
+ id="cdt.managed.build.info"
+ name="Managed Build Tools Description"
+ point="org.eclipse.cdt.core.ManagedBuildInfo">
+ <target
+ isTest="false"
+ name="Cygwin"
+ isAbstract="true"
+ id="cygwin">
+ <tool
+ sources="c,cc,cpp,cxx,C"
+ name="%ToolName.compiler"
+ outputs="o"
+ command="g++"
+ id="org.eclipse.cdt.build.tool.cygwin.compiler">
+ <optionCategory
+ owner="org.eclipse.cdt.build.tool.cygwin.compiler"
+ name="Preprocessor"
+ id="cygwin.compiler.category.preprocessor">
+ </optionCategory>
+ <option
+ name="Defined Symbols"
+ category="cygwin.compiler.category.preprocessor"
+ command="-D"
+ valueType="stringList"
+ id="cygwin.preprocessor.def.symbols">
+ </option>
+ <option
+ name="Undefined Symbols"
+ category="cygwin.compiler.category.preprocessor"
+ command="-U"
+ valueType="stringList"
+ id="cygwin.preprocessor.undef.symbol">
+ </option>
+ <optionCategory
+ owner="org.eclipse.cdt.build.tool.cygwin.compiler"
+ name="General"
+ id="cygwin.compiler.category.general">
+ </optionCategory>
+ <option
+ defaultValue="-c"
+ name="Compiler Flags"
+ category="cygwin.compiler.category.general"
+ valueType="string"
+ id="cygwin.compiler.general.ccflags">
+ </option>
+ <option
+ name="Optimization Level"
+ category="cygwin.compiler.category.general"
+ valueType="enumerated"
+ id="cygwin.compiler.general.optimization.level">
+ <optionEnum
+ name="None (-O0)"
+ command="-O0"
+ id="cygwin.optimization.level.none">
+ </optionEnum>
+ <optionEnum
+ name="Optimize (-O1)"
+ command="-O1"
+ id="cygwin.optimization.level.optimize">
+ </optionEnum>
+ <optionEnum
+ name="Optimize more (-O2)"
+ isDefault="true"
+ command="-O2"
+ id="cygwin.optimization.level.more">
+ </optionEnum>
+ <optionEnum
+ name="Optimize most (-O3)"
+ command="-O3"
+ id="cygwin.optimization.level.most">
+ </optionEnum>
+ </option>
+ <option
+ name="Debug Level"
+ category="cygwin.compiler.category.general"
+ valueType="enumerated"
+ id="cygwin.compiler.debugging.level">
+ <optionEnum
+ name="None"
+ isDefault="false"
+ id="cygwin.debugging.level.none">
+ </optionEnum>
+ <optionEnum
+ name="Minimal (-g1)"
+ command="-g1"
+ id="cygwin.debugging.level.minimal">
+ </optionEnum>
+ <optionEnum
+ name="Default (-g)"
+ isDefault="true"
+ command="-g"
+ id="cygwin.debugging.level.default">
+ </optionEnum>
+ <optionEnum
+ name="Maximum (-g3)"
+ isDefault="false"
+ command="-g3"
+ id="cygwin.debugging.level.max">
+ </optionEnum>
+ </option>
+ <option
+ name="Include Paths"
+ category="cygwin.compiler.category.general"
+ command="-I"
+ valueType="stringList"
+ id="cygwin.compiler.general.include.paths">
+ </option>
+ <option
+ defaultValue="false"
+ name="Verbose"
+ category="cygwin.compiler.category.general"
+ command="-v"
+ valueType="boolean"
+ id="cygwin.compiler.general.verbose">
+ </option>
+ <optionCategory
+ owner="org.eclipse.cdt.build.tool.cygwin.compiler"
+ name="Command Line"
+ id="cygwin.compiler.category.commandline">
+ </optionCategory>
+ <option
+ name="Compiler Command Line"
+ category="cygwin.compiler.category.commandline"
+ id="cygwin.compiler.commandline.args">
+ </option>
+ </tool>
+ </target>
+ <target
+ isTest="false"
+ name="Cygwin Executable"
+ parent="cygwin"
+ defaultExtension="exe"
+ isAbstract="false"
+ id="cygwin.exec">
+ <configuration
+ name="Release"
+ id="cygwin.exec.release">
+ </configuration>
+ <configuration
+ name="Debug"
+ id="cygwin.exec.debug">
+ </configuration>
+ <tool
+ name="%ToolName.linker"
+ outputs="exe"
+ command="g++"
+ id="org.eclipse.cdt.build.tool.cygwin.link">
+ <optionCategory
+ owner="org.eclipse.cdt.build.tool.cygwin.link"
+ name="General"
+ id="cygwin.linker.category.general">
+ </optionCategory>
+ <option
+ defaultValue="-o"
+ name="Linker Flags"
+ category="cygwin.linker.category.general"
+ valueType="string"
+ id="cygwin.link.ld.flags">
+ </option>
+ <option
+ name="Library Paths"
+ category="cygwin.linker.category.general"
+ command="-L"
+ valueType="stringList"
+ id="cygwin.link.ld.paths">
+ </option>
+ <option
+ name="Libraries"
+ category="cygwin.linker.category.general"
+ command="-l"
+ valueType="stringList"
+ id="cygwin.link.libs">
+ </option>
+ <optionCategory
+ owner="org.eclipse.cdt.build.tool.cygwin.link"
+ name="Command Line"
+ id="cygwin.linker.category.commandline">
+ </optionCategory>
+ <option
+ name="Linker Command Line"
+ category="cygwin.linker.category.commandline"
+ id="cygwin.linker.commandline.args">
+ </option>
+ </tool>
+ </target>
+ <target
+ isTest="true"
+ name="Cygwin Shared Library"
+ parent="cygwin"
+ defaultExtension="dll.a"
+ isAbstract="false"
+ id="cygwin.so">
+ <configuration
+ name="Release"
+ id="cygwin.so.release">
+ </configuration>
+ <configuration
+ name="Debug"
+ id="cygwin.so.debug">
+ </configuration>
+ <tool
+ name="%ToolName.linker"
+ outputs="dll.a"
+ id="org.eclipse.cdt.build.tool.cygwin.solink">
+ <optionCategory
+ owner="org.eclipse.cdt.build.tool.cygwin.solink"
+ name="General"
+ id="cygwin.solink.category.general">
+ </optionCategory>
+ <option
+ defaultValue="-shared"
+ name="Linker Flags"
+ category="cygwin.solink.category.general"
+ valueType="string"
+ id="cygwin.solink.ld.flags">
+ </option>
+ <option
+ name="Library Paths"
+ category="cygwin.solink.category.general"
+ command="-L"
+ valueType="stringList"
+ id="cygwin.solink.ld.paths">
+ </option>
+ <option
+ name="Libraries"
+ category="cygwin.solink.category.general"
+ command="-l"
+ valueType="stringList"
+ id="cygwin.solink.libs">
+ </option>
+ </tool>
+ </target>
+ <target
+ isTest="false"
+ name="Cygwin Static Library"
+ parent="cygwin"
+ defaultExtension="a"
+ isAbstract="false"
+ id="cygwin.lib">
+ <configuration
+ name="Release"
+ id="cygwin.lib.release">
+ </configuration>
+ <configuration
+ name="Debug"
+ id="cygwin.lib.debug">
+ </configuration>
+ <tool
+ name="%ToolName.archiver"
+ outputs="a"
+ command="ar"
+ id="org.eclipse.cdt.build.tool.cygwin.ar">
+ </tool>
+ </target>
+ <target
+ isTest="true"
+ name="Linux"
+ isAbstract="true"
+ id="linux">
+ <tool
+ name="Compiler"
+ id="linux.compiler">
+ <optionCategory
+ owner="linux.compiler"
+ name="Optimization Options"
+ id="linux.compiler.optimization">
+ </optionCategory>
+ <option
+ name="Compiler Flags"
+ valueType="string"
+ id="linux.compiler.flags">
+ </option>
+ <option
+ name="Optimization Flags"
+ category="linux.compiler.optimization"
+ value="-O"
+ valueType="string"
+ id="linux.compiler.optimizationFlags">
+ </option>
+ </tool>
+ </target>
+ <target
+ isTest="true"
+ name="Linux Executable"
+ parent="linux"
+ isAbstract="false"
+ id="linux.exec">
+ <tool
+ name="Linker"
+ id="org.eclipse.cdt.ui.tests.tool.linux.link">
+ </tool>
+ <configuration
+ name="Release"
+ id="linux.exec.release">
+ </configuration>
+ <configuration
+ name="Debug"
+ id="linux.exec.debug">
+ </configuration>
+ </target>
+ <target
+ isTest="true"
+ name="Linux Shared Library"
+ parent="linux"
+ defaultExtension=".so"
+ isAbstract="false"
+ id="linux.so">
+ <tool
+ name="Linker"
+ id="org.eclipse.cdt.ui.tests.tool.linux.solink">
+ </tool>
+ </target>
+ <target
+ isTest="true"
+ name="Linux Static Library"
+ parent="linux"
+ defaultExtension=".a"
+ isAbstract="false"
+ id="linux.lib">
+ <tool
+ name="Archiver"
+ id="org.eclipse.cdt.ui.tests.tool.linux.ar">
+ </tool>
+ </target>
+ </extension>
</plugin>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
index bf099831071..84e82d37077 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
@@ -35,6 +35,7 @@ public class CPluginImages {
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
private static final String T= "full/";
+ public static final String T_BUILD= T + "build16/";
public static final String T_OBJ= T + "obj16/";
public static final String T_WIZBAN= T + "wizban/";
public static final String T_LCL= "lcl16/";
@@ -147,6 +148,22 @@ public class CPluginImages {
public static final String IMG_OBJS_BUILD= NAME_PREFIX + "build_menu.gif";
public static final ImageDescriptor DESC_BUILD_MENU = createManaged(T_OBJ, IMG_OBJS_BUILD);
+ // For the managed build images
+ public static final String IMG_BUILD_CONFIG = NAME_PREFIX + "build_configs.gif";
+ public static final ImageDescriptor DESC_BUILD_CONFIG = createManaged(T_BUILD, IMG_BUILD_CONFIG);
+ public static final String IMG_BUILD_COMPILER = NAME_PREFIX + "config-compiler.gif";
+ public static final ImageDescriptor DESC_BUILD_COMPILER = createManaged(T_BUILD, IMG_BUILD_COMPILER);
+ public static final String IMG_BUILD_LINKER = NAME_PREFIX + "config-linker.gif";
+ public static final ImageDescriptor DESC_BUILD_LINKER = createManaged(T_BUILD, IMG_BUILD_LINKER);
+ public static final String IMG_BUILD_LIBRARIAN = NAME_PREFIX + "config-librarian.gif";
+ public static final ImageDescriptor DESC_BUILD_LIBRARIAN = createManaged(T_BUILD, IMG_BUILD_LIBRARIAN);
+ public static final String IMG_BUILD_COMMAND = NAME_PREFIX + "config-command.gif";
+ public static final ImageDescriptor DESC_BUILD_COMMAND = createManaged(T_BUILD, IMG_BUILD_COMMAND);
+ public static final String IMG_BUILD_PREPROCESSOR = NAME_PREFIX + "config-preprocessor.gif";
+ public static final ImageDescriptor DESC_BUILD_PREPROCESSOR = createManaged(T_BUILD, IMG_BUILD_PREPROCESSOR);
+ public static final String IMG_BUILD_TOOL = NAME_PREFIX + "config-tool.gif";
+ public static final ImageDescriptor DESC_BUILD_TOOL = createManaged(T_BUILD, IMG_BUILD_TOOL);
+
public static void initialize() {
//createManaged(registry, T_OBJ, IMG_OBJS_TUNIT);
//createManaged(registry, T_OBJ, IMG_OBJS_FIELD);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
index d9ea175de43..81afbbb966a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
@@ -64,6 +64,21 @@ SettingsBlock.makeOption.label=Build Command
SettingsBlock.makeOption.use_default=Use Default
SettingsBlock.makeOption.build_cmd=Build Command:
+#Strings for the platform selection tab
+PlatformBlock.label.platform=Platform:
+PlatformBlock.tip.platform=Select the platform you wish to deploy on
+PlatformBlock.label.configs=Configurations:
+
+# String constants for the build configuration tab
+ConfigurationBlock.label=Build Information
+ConfigurationBlock.type=Project Type
+ConfigurationBlock.type.app=Application
+ConfigurationBlock.type.shared=Shared Library/DLL
+ConfigurationBlock.type.static=Static Library
+ConfigurationBlock.build.label=Build Settings
+ConfigurationBlock.build.continue=Continue On Error
+ConfigurationBlock.build.stop=Stop On Error
+
StdMakeProjectWizard.op_error=Standard Make Error
StdMakeProjectWizard.title=Standard Make Project
StdMakeProjectWizard.description=Create a new Standard Make project.
@@ -80,6 +95,22 @@ StdCCWizard.description=Create a new Standard Make C++ Project.
StdCCWizardSettings.title=Standard Make C++ Settings
StdCCWizardSettings.description=Define the Standard Make C++ build settings.
+MngMakeProjectWizard.op_error=Managed Make Error
+MngMakeProjectWizard.title=Managed Make Project
+MngMakeProjectWizard.description=Create a new Managed Make project.
+MngMakeProjectWizardSettings.title=Managed Make Settings
+MngMakeProjectWizardSettings.description=Define the Managed Make build settings.
+
+MngCWizard.title=Managed Make C Project
+MngCWizard.description=Create a new Managed Make C project.
+MngCWizardSettings.title=Managed Make C Settings
+MngCWizardSettings.description=Define the Managed Make C build settings.
+
+MngCCWizard.title=Managed Make C++ Project
+MngCCWizard.description=Create a new Managed Make C++ Project.
+MngCCWizardSettings.title=Managed Make C++ Settings
+MngCCWizardSettings.description=Define the Managed Make C++ build settings.
+
NewClassWizard.title=New Class
NewClassWizard.description=Create a new C++ Class.
NewClassWizard.page.title=Class
@@ -262,4 +293,36 @@ CreateFileAction.text = &File
CreateFolderAction.text = F&older
# ------- Drag and Drop Message Text -----------
-CViewDragNDrop.txt = already exists. Would you like to overwrite it? \ No newline at end of file
+CViewDragNDrop.txt = already exists. Would you like to overwrite it?
+
+# ----------- Build Property Page -----------
+BuildPropertyPage.label.Platform=Platform:
+BuildPropertyPage.label.Configuration=Configuration:
+BuildPropertyPage.label.Active=Active configuration
+BuildPropertyPage.label.Settings=Configuration settings
+BuildPropertyPage.label.AddConfButton=Manage...
+BuildPropertyPage.label.ToolTree=Tools
+BuildPropertyPage.label.ToolOptions=Options
+BuildPropertyPage.tip.platform=Select a platform for the project
+BuildPropertyPage.tip.config=Select the configuration to edit
+BuildPropertyPage.tip.addconf=Add configurations for the platform
+BuildPropertyPage.tip.remconf=Remove configurations for the platform
+BuildPropertyPage.manage.title=Manage Configurations
+
+# ----------- Build Property Common -----------
+BuildPropertyCommon.label.title=Enter Value
+BuildPropertyCommon.label.new=New...
+BuildPropertyCommon.label.remove=Remove
+BuildPropertyCommon.label.up=Move Up
+BuildPropertyCommon.label.down=Move Down
+BuildPropertyCommon.label.editVar=Edit
+BuildPropertyCommon.label.addVar=Add
+BuildPropertyCommon.label.message=Value:
+BuildPropertyCommon.label.browse=Browse...
+BuildPropertyCommon.label.configs=Defined configurations:
+
+# ----------- New Configuration -----------
+NewConfiguration.label.name=Configuration name:
+NewConfiguration.label.copy=Copy settings from:
+NewConfiguration.error.title=Error
+NewConfiguration.error.duplicateName=A configuration named "{0}" already exists.

Back to the top