1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Changes for bugzilla 54202 - Changing the active configuration forces a save in the cdtbuildfile.

This commit is contained in:
Sean Evoy 2004-03-16 22:12:27 +00:00
parent 4fdafaa433
commit 1661bb8022
13 changed files with 1151 additions and 962 deletions

View file

@ -45,6 +45,19 @@ public interface IConfiguration extends IBuildObject {
*/
public ITool[] getTools();
/**
* Answers <code>true</code> the receiver has changes that need to be saved
* in the project file, else <code>false</code>.
*
* @return boolean
*/
public boolean isDirty();
/**
* @param isDirty
*/
public void setDirty(boolean isDirty);
/**
* Sets the name of the receiver to the value specified in the argument
*
@ -57,6 +70,7 @@ public interface IConfiguration extends IBuildObject {
*
* @param option The option to change.
* @param value The value to apply to the option.
*
* @throws BuildException
*/
public void setOption(IOption option, boolean value)
@ -67,6 +81,8 @@ public interface IConfiguration extends IBuildObject {
*
* @param option The option that will be effected by change.
* @param value The value to apply to the option.
*
* @throws BuildException
*/
public void setOption(IOption option, String value)
throws BuildException;
@ -76,6 +92,8 @@ public interface IConfiguration extends IBuildObject {
*
* @param option The option to change.
* @param value The values to apply to the option.
*
* @throws BuildException
*/
public void setOption(IOption option, String[] value)
throws BuildException;
@ -83,8 +101,8 @@ public interface IConfiguration extends IBuildObject {
/**
* Overrides the tool command for a tool defined in the receiver.
*
* @param tool
* @param command
* @param tool The tool that will have its command modified
* @param command The command
*/
public void setToolCommand(ITool tool, String command);

View file

@ -66,6 +66,11 @@ public interface ITarget extends IBuildObject {
*/
public String getArtifactName();
/**
* @param isDirty
*/
public void setDirty(boolean isDirty);
/**
* Answers the unique ID of the binary parser associated with the target.
*
@ -171,6 +176,14 @@ public interface ITarget extends IBuildObject {
* @return boolean
*/
public boolean isAbstract();
/**
* Answers <code>true</code> the receiver has changes that need to be saved
* in the project file, else <code>false</code>.
*
* @return boolean
*/
public boolean isDirty();
/**
* Answers <code>true</code> if the receiver is a target that is defined
@ -232,5 +245,4 @@ public interface ITarget extends IBuildObject {
* @param resource
*/
public void updateOwner(IResource resource);
}

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Target;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
@ -206,18 +207,14 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @param config
* @param option
*/
private static void setDirty(IConfiguration config, IOption option) {
// Set the build info dirty so builder will rebuild
IResource resource = config.getOwner();
IManagedBuildInfo info = getBuildInfo(resource);
info.setDirty(true);
private static void notifyListeners(IConfiguration config, IOption option) {
// Continue if change is something that effect the scanner
if (!(option.getValueType() == IOption.INCLUDE_PATH
|| option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
return;
}
// Figure out if there is a listener for this change
IResource resource = config.getOwner();
List listeners = (List) getBuildModelListeners().get(resource);
if (listeners == null) {
return;
@ -237,8 +234,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*/
public static void setOption(IConfiguration config, IOption option, boolean value) {
try {
// Request a value change and set dirty if real change results
config.setOption(option, value);
setDirty(config, option);
notifyListeners(config, option);
} catch (BuildException e) {
return;
}
@ -254,7 +252,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static void setOption(IConfiguration config, IOption option, String value) {
try {
config.setOption(option, value);
setDirty(config, option);
notifyListeners(config, option);
} catch (BuildException e) {
return;
}
@ -270,19 +268,35 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static void setOption(IConfiguration config, IOption option, String[] value) {
try {
config.setOption(option, value);
setDirty(config, option);
notifyListeners(config, option);
} catch (BuildException e) {
return;
}
}
/**
* @param config
* @param tool
* @param command
*/
public static void setToolCommand(IConfiguration config, ITool tool, String command) {
// The tool may be a reference.
if (tool instanceof ToolReference) {
// If so, just set the command in the reference
((ToolReference)tool).setToolCommand(command);
} else {
config.setToolCommand(tool, command);
}
}
/**
* Saves the build information associated with a project and all resources
* in the project to the build info file.
*
* @param project
* @param force
*/
public static void saveBuildInfo(IProject project) {
public static void saveBuildInfo(IProject project, boolean force) {
// Create document
Document doc = new DocumentImpl();
Element rootElement = doc.createElement(ROOT_ELEM_NAME);
@ -290,30 +304,31 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Save the build info
ManagedBuildInfo buildInfo = (ManagedBuildInfo) getBuildInfo(project);
if (buildInfo != null)
if (buildInfo != null && (force == true || buildInfo.isDirty())) {
buildInfo.serialize(doc, rootElement);
// Save the document
ByteArrayOutputStream s = new ByteArrayOutputStream();
OutputFormat format = new OutputFormat();
format.setIndenting(true);
format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
String xml = null;
try {
Serializer serializer
// Save the document
ByteArrayOutputStream s = new ByteArrayOutputStream();
OutputFormat format = new OutputFormat();
format.setIndenting(true);
format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
String xml = null;
try {
Serializer serializer
= SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(new OutputStreamWriter(s, "UTF8"), format); //$NON-NLS-1$
serializer.asDOMSerializer().serialize(doc);
xml = s.toString("UTF8"); //$NON-NLS-1$
IFile rscFile = project.getFile(FILE_NAME);
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
// update the resource content
if (rscFile.exists()) {
rscFile.setContents(inputStream, IResource.FORCE, null);
} else {
rscFile.create(inputStream, IResource.FORCE, null);
serializer.asDOMSerializer().serialize(doc);
xml = s.toString("UTF8"); //$NON-NLS-1$
IFile rscFile = project.getFile(FILE_NAME);
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
// update the resource content
if (rscFile.exists()) {
rscFile.setContents(inputStream, IResource.FORCE, null);
} else {
rscFile.create(inputStream, IResource.FORCE, null);
}
} catch (Exception e) {
return;
}
} catch (Exception e) {
return;
}
}
@ -542,7 +557,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
if (buildInfo == null && create) {
try {
// Create a new build info object for the project
buildInfo = new ManagedBuildInfo(resource);
// Associate the build info with the project for the duration of the session
resource.setSessionProperty(buildInfoProperty, buildInfo);
} catch (CoreException e) {
buildInfo = null;
@ -668,5 +685,5 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static IConfigurationElement getConfigElement(IBuildObject buildObj) {
return (IConfigurationElement)getConfigElementMap().get(buildObj);
}
}

View file

@ -33,11 +33,11 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Configuration extends BuildObject implements IConfiguration {
private ITarget target;
private boolean isDirty = false;
private IConfiguration parent;
private List toolReferences;
private boolean resolved = true;
private ITarget target;
private List toolReferences;
/**
* Build a configuration from the project manifest file.
@ -307,6 +307,14 @@ public class Configuration extends BuildObject implements IConfiguration {
return tools;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
*/
public boolean isDirty() {
return isDirty;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
*/
@ -418,15 +426,27 @@ public class Configuration extends BuildObject implements IConfiguration {
element.appendChild(toolRefElement);
toolRef.serialize(doc, toolRefElement);
}
// I am clean now
isDirty = false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
*/
public void setDirty(boolean isDirty) {
this.isDirty = isDirty;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
*/
public void setOption(IOption option, boolean value) throws BuildException {
// Is there a delta
if (option.getBooleanValue() != value)
if (option.getBooleanValue() != value) {
createOptionReference(option).setValue(value);
isDirty = true;
}
}
/* (non-Javadoc)
@ -441,8 +461,10 @@ public class Configuration extends BuildObject implements IConfiguration {
else {
oldValue = option.getStringValue();
}
if (oldValue != null && !oldValue.equals(value))
if (oldValue != null && !oldValue.equals(value)) {
createOptionReference(option).setValue(value);
isDirty = true;
}
}
/* (non-Javadoc)
@ -471,8 +493,10 @@ public class Configuration extends BuildObject implements IConfiguration {
oldValue = new String[0];
break;
}
if(!Arrays.equals(value, oldValue))
if(!Arrays.equals(value, oldValue)) {
createOptionReference(option).setValue(value);
isDirty = true;
}
}
/* (non-Javadoc)
@ -489,8 +513,9 @@ public class Configuration extends BuildObject implements IConfiguration {
}
// Set the ref's command
if (ref != null) {
ref.setToolCommand(command);
isDirty = ref.setToolCommand(command);
}
}
}
}

View file

@ -45,8 +45,10 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultConfig"); //$NON-NLS-1$
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
private String defaultConfigIds;
private Map defaultConfigMap;
private ITarget defaultTarget;
private String defaultTargetId;
private boolean isDirty;
private IResource owner;
private Map targetMap;
@ -58,8 +60,28 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param owner
*/
public ManagedBuildInfo(IResource owner) {
targetList = new ArrayList();
this.owner = owner;
isDirty = false;
// The id of the default target from the project persistent settings store
IProject project = (IProject)owner;
defaultTargetId = null;
try {
defaultTargetId = project.getPersistentProperty(defaultTargetProperty);
} catch (CoreException e) {
// We have all the build elements so we can stop if this occurs
return;
}
// Get the default configs for every target out of the same store
defaultConfigIds = null;
try {
defaultConfigIds = project.getPersistentProperty(defaultConfigProperty);
} catch (CoreException e) {
// Again, hitting this error just means the default config is not set
return;
}
}
/**
@ -70,7 +92,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param element
*/
public ManagedBuildInfo(IResource owner, Element element) {
// Store the IProject the info is for
this(owner);
// Read in the top-level info objects
@ -81,70 +102,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
child = child.getNextSibling();
}
// The id of the default configuration from the persistent store
IProject project = (IProject)getOwner();
String defaultTargetId = null;
try {
defaultTargetId = project.getPersistentProperty(defaultTargetProperty);
} catch (CoreException e) {
// We have all the build elements so we can stop if this occurs
return;
}
// All targets have been read in so set the default from the persisted ID
if (defaultTargetId != null) {
defaultTarget = (ITarget) getTargetMap().get(defaultTargetId);
}
// Get the string of all default config IDs from the store
String defaultIds = null;
try {
defaultIds = project.getPersistentProperty(defaultConfigProperty);
} catch (CoreException e1) {
// Again, hitting this error just means the default config is not set
return;
}
if (defaultIds != null) {
String[] majorTokens = defaultIds.split(MAJOR_SEPERATOR);
for (int index = majorTokens.length - 1; index >= 0; --index) {
// Now split each token into the target and config id component
String idToken = majorTokens[index];
if (idToken != null) {
String[] minorTokens = idToken.split(MINOR_SEPERATOR);
// The first token is the target ID
ITarget target = getTarget(minorTokens[0]);
// The second is the configuration ID
IConfiguration config = target.getConfiguration(minorTokens[1]);
if (config != null) {
getDefaultConfigMap().put(target.getId(), config);
}
}
}
}
/* // Now we have a miserable 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 = targetList.listIterator();
while (targIter.hasNext()) {
Target targ = (Target) targIter.next();
IConfiguration conf = targ.getConfiguration(confId);
if (conf != null) {
defaultConfigMap.put(targ.getId(), conf);
break;
}
}
}
*/ }
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
*/
public void addTarget(ITarget target) {
getTargetMap().put(target.getId(), target);
targetList.add(target);
getTargets().add(target);
}
/* (non-Javadoc)
@ -250,6 +215,25 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private Map getDefaultConfigMap() {
if (defaultConfigMap == null) {
defaultConfigMap = new HashMap();
// We read this as part of the constructor
if (defaultConfigIds != null) {
String[] majorTokens = defaultConfigIds.split(MAJOR_SEPERATOR);
for (int index = majorTokens.length - 1; index >= 0; --index) {
// Now split each token into the target and config id component
String idToken = majorTokens[index];
if (idToken != null) {
String[] minorTokens = idToken.split(MINOR_SEPERATOR);
// The first token is the target ID
ITarget target = getTarget(minorTokens[0]);
if (target == null) continue;
// The second is the configuration ID
IConfiguration config = target.getConfiguration(minorTokens[1]);
if (config != null) {
defaultConfigMap.put(target.getId(), config);
}
}
}
}
}
return defaultConfigMap;
}
@ -276,7 +260,14 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
public ITarget getDefaultTarget() {
if (defaultTarget == null) {
defaultTarget = (ITarget) targetList.get(0);
// See if there is a target that was persisted
if (defaultTargetId != null) {
defaultTarget = (ITarget) getTargetMap().get(defaultTargetId);
}
// If that failed, look for anything
if (defaultTarget == null) {
defaultTarget = (ITarget) getTargets().get(0);
}
}
return defaultTarget;
}
@ -709,6 +700,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public List getTargets() {
if (targetList == null) {
targetList = new ArrayList();
}
return targetList;
}
@ -840,7 +834,20 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isDirty()
*/
public boolean isDirty() {
return isDirty;
// If the info has been flagged dirty, answer true
if (isDirty) {
return true;
}
// Check if any of the defined targets are dirty
Iterator iter = getTargets().listIterator();
while (iter.hasNext()) {
if (((ITarget)iter.next()).isDirty()) {
return true;
}
}
return false;
}
/* (non-Javadoc)
@ -877,27 +884,17 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return false;
}
/**
* Write the contents of the build model to the persistent store specified in the
* argument.
/* (non-Javadoc)
*
* @param doc
* @param element
*/
public void serialize(Document doc, Element element) {
private void persistDefaultConfigurations() {
// Create a buffer of the default configuration IDs
StringBuffer defaultConfigs = new StringBuffer();
// Write out each target and their default config
Iterator iter = targetList.listIterator();
Iterator iter = getTargets().listIterator();
while (iter.hasNext()) {
// Get the target
Target targ = (Target)iter.next();
// Create an XML element to hold the target settings
Element targetElement = doc.createElement(ITarget.TARGET_ELEMENT_NAME);
element.appendChild(targetElement);
targ.serialize(doc, targetElement);
// Persist the default target configuration pair as <targ_ID>::<conf_ID>
ITarget targ = (ITarget)iter.next();
IConfiguration config = getDefaultConfiguration((ITarget)targ);
if (config != null) {
defaultConfigs.append(targ.getId());
@ -906,65 +903,105 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
defaultConfigs.append(MAJOR_SEPERATOR);
}
}
/* for (int i = 0; i < targets.size(); ++i) {
Element targetElement = doc.createElement(ITarget.TARGET_ELEMENT_NAME);
element.appendChild(targetElement);
((Target)targets.get(i)).serialize(doc, targetElement);
IConfiguration config = getDefaultConfiguration((ITarget)targets.get(i));
if (config != null) {
Element configEl = doc.createElement(DEFAULT_CONFIGURATION);
element.appendChild(configEl);
configEl.setAttribute(IConfiguration.ID, config.getId());
}
// Persist the default configurations
IProject project = (IProject) getOwner();
try {
project.setPersistentProperty(defaultConfigProperty, defaultConfigs.toString().trim());
} catch (CoreException e) {
// Too bad
}
*/ // Persist the default target as a project setting
}
/* (non-Javadoc)
*
*/
private void persistDefaultTarget() {
// Persist the default target as a project setting
IProject project = (IProject) getOwner();
ITarget defTarget = getDefaultTarget();
if (defTarget != null){
try {
project.setPersistentProperty(defaultTargetProperty, defTarget.getId());
} catch (CoreException e) {
// There is no point in storing the default configurations
return;
// Tough
}
}
try {
// Persist the default configurations
project.setPersistentProperty(defaultConfigProperty, defaultConfigs.toString().trim());
} catch (CoreException e) {
// Too bad
}
/**
* Write the contents of the build model to the persistent store
* specified in the argument.
*
* @param doc
* @param element
*/
public void serialize(Document doc, Element element) {
// Write out each target
Iterator iter = getTargets().listIterator();
while (iter.hasNext()) {
// Get the target
Target targ = (Target)iter.next();
// Create an XML element to hold the target settings
Element targetElement = doc.createElement(ITarget.TARGET_ELEMENT_NAME);
element.appendChild(targetElement);
targ.serialize(doc, targetElement);
}
// Remember the default target and configurations
persistDefaultTarget();
persistDefaultConfigurations();
// I'm clean now
setDirty(false);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public void setDefaultConfiguration(IConfiguration configuration) {
// Sanity
if (configuration== null) return;
// Get the target associated with the argument
ITarget target = configuration.getTarget();
// Make sure it is the default
setDefaultTarget(target);
getDefaultConfigMap().put(target.getId(), configuration);
// See if there is anything to be done
IConfiguration oldDefault = getDefaultConfiguration(target);
if (!configuration.equals(oldDefault)) {
// Make sure it is the default
setDefaultTarget(target);
// Make the argument the
getDefaultConfigMap().put(target.getId(), configuration);
// Save it
persistDefaultConfigurations();
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultTarget(org.eclipse.cdt.core.build.managed.ITarget)
*/
public void setDefaultTarget(ITarget target) {
if (defaultTarget != null && defaultTarget.getId().equals(target.getId())) {
return;
// Sanity
if (target == null) return;
// Make sure there is something to change
if (!target.equals(defaultTarget)) {
defaultTarget = target;
defaultTargetId = target.getId();
persistDefaultTarget();
}
defaultTarget = target;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setDirty(boolean)
*/
public void setDirty(boolean isDirty) {
// Reset the dirty status here
this.isDirty = isDirty;
// and in the contained targets
Iterator iter = getTargets().listIterator();
while (iter.hasNext()) {
ITarget target = (ITarget)iter.next();
target.setDirty(isDirty);
}
}
/**
@ -979,7 +1016,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
if (!owner.equals(resource)) {
owner = resource;
// Do the same for the targets
Iterator iter = targetList.listIterator();
Iterator iter = getTargets().listIterator();
while(iter.hasNext()) {
ITarget target = (ITarget) iter.next();
target.updateOwner(resource);

View file

@ -37,11 +37,12 @@ public class Target extends BuildObject implements ITarget {
private String artifactName;
private String binaryParserId;
private String cleanCommand;
private List configList;
private Map configMap;
private List configurations;
private String defaultExtension;
private String extension;
private boolean isAbstract = false;
private boolean isDirty = false;
private boolean isTest = false;
private String makeArguments;
private String makeCommand;
@ -252,12 +253,10 @@ public class Target extends BuildObject implements ITarget {
ToolReference current = (ToolReference)refIter.next();
current.resolveReferences();
}
if (configurations != null) {
Iterator configIter = configurations.iterator();
while (configIter.hasNext()) {
Configuration current = (Configuration)configIter.next();
current.resolveReferences();
}
Iterator configIter = getConfigurationList().iterator();
while (configIter.hasNext()) {
Configuration current = (Configuration)configIter.next();
current.resolveReferences();
}
}
}
@ -267,12 +266,13 @@ public class Target extends BuildObject implements ITarget {
*/
public void removeConfiguration(String id) {
// Remove the specified configuration from the list and map
Iterator iter = configurations.listIterator();
Iterator iter = getConfigurationList().listIterator();
while (iter.hasNext()) {
IConfiguration config = (IConfiguration)iter.next();
if (config.getId().equals(id)) {
configurations.remove(config);
configMap.remove(id);
getConfigurationList().remove(config);
getConfigurationMap().remove(id);
isDirty = true;
break;
}
}
@ -310,14 +310,18 @@ public class Target extends BuildObject implements ITarget {
if (makeArguments != null) {
element.setAttribute(MAKE_ARGS, makeArguments);
}
if (configurations != null)
for (int i = 0; i < configurations.size(); ++i) {
Configuration config = (Configuration)configurations.get(i);
Element configElement = doc.createElement(IConfiguration.CONFIGURATION_ELEMENT_NAME);
element.appendChild(configElement);
config.serialize(doc, configElement);
}
// Serialize the configuration settings
Iterator iter = getConfigurationList().listIterator();
while (iter.hasNext()) {
Configuration config = (Configuration) iter.next();
Element configElement = doc.createElement(IConfiguration.CONFIGURATION_ELEMENT_NAME);
element.appendChild(configElement);
config.serialize(doc, configElement);
}
// I am clean now
isDirty = false;
}
/* (non-javadoc)
@ -566,14 +570,35 @@ public class Target extends BuildObject implements ITarget {
getToolMap().put(tool.getId(), tool);
}
/* (non-Javadoc)
* Safe accessor for the list of configurations.
*
* @return List containing the configurations
*/
private List getConfigurationList() {
if (configList == null) {
configList = new ArrayList();
}
return configList;
}
/* (non-Javadoc)
* Safe accessor for the map of configuration ids to configurations
*
* @return
*/
private Map getConfigurationMap() {
if (configMap == null) {
configMap = new HashMap();
}
return configMap;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
*/
public IConfiguration[] getConfigurations() {
if (configurations != null)
return (IConfiguration[])configurations.toArray(new IConfiguration[configurations.size()]);
else
return emptyConfigs;
return (IConfiguration[])getConfigurationList().toArray(new IConfiguration[getConfigurationList().size()]);
}
@ -665,19 +690,15 @@ public class Target extends BuildObject implements ITarget {
* @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
*/
public IConfiguration getConfiguration(String id) {
return (IConfiguration)configMap.get(id);
return (IConfiguration)getConfigurationMap().get(id);
}
/**
* @param configuration
*/
public void addConfiguration(IConfiguration configuration) {
if (configurations == null) {
configurations = new ArrayList();
configMap = new HashMap();
}
configurations.add(configuration);
configMap.put(configuration.getId(), configuration);
getConfigurationList().add(configuration);
getConfigurationMap().put(configuration.getId(), configuration);
}
/* (non-Javadoc)
@ -687,6 +708,25 @@ public class Target extends BuildObject implements ITarget {
return isAbstract;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#isDirty()
*/
public boolean isDirty() {
// If I need saving, just say yes
if (isDirty) {
return true;
}
// Iterate over the configurations and ask them if they need saving
Iterator iter = getConfigurationList().listIterator();
while (iter.hasNext()) {
if (((IConfiguration)iter.next()).isDirty()) {
return true;
}
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
*/
@ -705,6 +745,7 @@ public class Target extends BuildObject implements ITarget {
* @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public IConfiguration createConfiguration(IConfiguration parent, String id) {
isDirty = true;
return new Configuration(this, parent, id);
}
@ -723,6 +764,7 @@ public class Target extends BuildObject implements ITarget {
public void setArtifactExtension(String extension) {
if (extension != null) {
this.extension = extension;
isDirty = true;
}
}
@ -731,16 +773,32 @@ public class Target extends BuildObject implements ITarget {
*/
public void setArtifactName(String name) {
if (name != null) {
artifactName = name;
artifactName = name;
isDirty = true;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#setDirty(boolean)
*/
public void setDirty(boolean isDirty) {
// Override the dirty flag here
this.isDirty = isDirty;
// and in the configurations
Iterator iter = getConfigurationList().listIterator();
while (iter.hasNext()) {
IConfiguration config = (IConfiguration)iter.next();
config.setDirty(isDirty);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeArguments(java.lang.String)
*/
public void setMakeArguments(String makeArgs) {
if (makeArgs != null && !getMakeArguments().equals(makeArgs)) {
makeArguments = makeArgs;
isDirty = true;
}
}
@ -750,6 +808,7 @@ public class Target extends BuildObject implements ITarget {
public void setMakeCommand(String command) {
if (command != null && !getMakeCommand().equals(command)) {
makeCommand = command;
isDirty = true;
}
}

View file

@ -366,10 +366,14 @@ public class ToolReference extends AbstractToolReference {
* Sets the command in the receiver to be the argument.
*
* @param cmd
*/
public void setToolCommand(String cmd) {
* @return <code>true</code> if the call results in a chnaged command, else <code>false</code>
*/
public boolean setToolCommand(String cmd) {
if (cmd != null && !cmd.equals(command)) {
command = cmd;
return true;
} else {
return false;
}
}

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,7 @@ BuildPropertyPage.label.Configuration=Configuration:
BuildPropertyPage.label.Active=Active configuration
BuildPropertyPage.label.Settings=Configuration settings
BuildPropertyPage.label.AddConfButton=Manage...
BuildPropertyPage.selection.configuration.all=All configurations
BuildPropertyPage.label.ToolTree=Tools
BuildPropertyPage.label.ToolOptions=Options
BuildPropertyPage.tip.platform=Select a platform for the project

View file

@ -75,6 +75,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
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 ALL_CONFS = PREFIX + ".selection.configuration.all"; //$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$
@ -453,8 +454,15 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// If there is nothing in config selection widget just bail
if (configSelector.getItemCount() == 0) return;
// Cache the selected config
selectedConfiguration = configurations[configSelector.getSelectionIndex()];
// Check if the user has selected the "all" configuration
int selectionIndex = configSelector.getSelectionIndex();
if (selectionIndex >= configurations.length) {
// This is the all config
return;
} else {
// Cache the selected config
selectedConfiguration = configurations[selectionIndex];
}
// Set the content provider for the list viewer
ToolListContentProvider provider = new ToolListContentProvider();
@ -768,7 +776,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Write out the build model info
ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
ManagedBuildManager.saveBuildInfo(getProject());
ManagedBuildManager.saveBuildInfo(getProject(), false);
return true;
}
@ -782,6 +790,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Clear and replace the contents of the selector widget
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
configSelector.add(ManagedBuilderUIPlugin.getResourceString(ALL_CONFS));
// Make sure the active configuration is selected
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.graphics.Point;
@ -77,13 +77,9 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
return result;
}
// The tool may be a reference.
if (tool instanceof ToolReference) {
// If so, just set the command in the reference
((ToolReference)tool).setToolCommand(command);
} else {
configuration.setToolCommand(tool, command);
}
// Ask the build system manager to change the tool command
ManagedBuildManager.setToolCommand(configuration, tool, command);
return result;
}
}

View file

@ -35,11 +35,20 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
private boolean dirtyFlag;
private IConfiguration owner;
public BuildToolsSettingsStore (IConfiguration config) {
/**
*
*/
public BuildToolsSettingsStore() {
listenerList = new ListenerList();
dirtyFlag = false;
dirtyFlag = false;
}
/**
* @param config
*/
public BuildToolsSettingsStore (IConfiguration config) {
this();
owner = config;
// Now populate the options map
populateSettingsMap();
}

View file

@ -148,7 +148,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
// Save the build options
monitor.subTask(ManagedBuilderUIPlugin.getResourceString(MSG_SAVE));
ManagedBuildManager.saveBuildInfo(newProject);
ManagedBuildManager.saveBuildInfo(newProject, true);
monitor.done();
}