1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 03:05:39 +02:00

1. The “temporary configuration” concept is implemented

2.	Managed build property page is adopted to use the “clone” configuration.
3.	When the value of any option is changed by the user in UI, the values and enabled/disabled state of all the options on the current page is updated
4.	Each time the given page becomes visible, its values get updated
5.	The bug# 106036 is fixed
6.	The FileListControlFieldEditor is now disabled properly
7.	Notification mechanism for the FileListControlFieldEditor implemented.
8.	Restore defaults now works correctly for the error parsers block.
9.	Restore defaults does not sets the defaults to the real configuration immediately, so if “cancel” is pressed after “restore defaults”, no changes are made to the real configuration.
10.	Restore defaults for the tool settings page now restores the tool commands also
11.	Build macros and environment settings are copied from the source configuration to the configuration clone when the clone constructor is invoked
12.	When the resource build property page contains default values, the resource configuration is removed for the resource.
13.	The build is invoked in case the build command or builder arguments are changed. The build info is persisted also in case only the build command is changed.
14.	The new resource configuration id is now calculated in the way: <configuration_id> + “.” + <random_number> instead of <configuration_id> + “.” + <resource_path>.
15.	the calculateChildId method is added to the managed build manager, Core and UI code is updated to use the ManagedBuildManager.calculateChildId method. Some other fixes of id calculation.
16.	Some minor fixes for the managed build path entries calculation
17.	Some Build Environment persistence issues were fixed
18.	The managed build revision and version of the managed project and of all its children is now updated after the project conversion is performed. Configuration now obtains the version from the toolchain
This commit is contained in:
Mikhail Sennikovsky 2005-09-30 19:09:20 +00:00
parent ee2db04840
commit ca2e8c288e
39 changed files with 2720 additions and 1759 deletions

View file

@ -471,4 +471,10 @@ public interface IConfiguration extends IBuildObject {
*/ */
public IConfigurationBuildMacroSupplier getBuildMacroSupplier(); public IConfigurationBuildMacroSupplier getBuildMacroSupplier();
/**
* answers true if the configuration is temporary, otherwise - false
* @return boolean
*/
public boolean isTemporary();
} }

View file

@ -1529,7 +1529,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// Create the internal representation of the project's MBS information // Create the internal representation of the project's MBS information
buildInfo = new ManagedBuildInfo(project, (Element)node, fileVersion); buildInfo = new ManagedBuildInfo(project, (Element)node, fileVersion);
if (fileVersion != null) { if (fileVersion != null) {
buildInfo.setVersion(fileVersion); // buildInfo.setVersion(fileVersion);
PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion); PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion);
PluginVersionIdentifier version21 = new PluginVersionIdentifier("2.1"); //$NON-NLS-1$ PluginVersionIdentifier version21 = new PluginVersionIdentifier("2.1"); //$NON-NLS-1$
// CDT 2.1 is the first version using the new MBS model // CDT 2.1 is the first version using the new MBS model
@ -2904,6 +2904,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return false; return false;
} }
/*
* if the suffix is null, then the random number will be appended to the superId
*/
static public String calculateChildId(String superId, String suffix){
if(suffix == null)
suffix = new Integer(getRandomNumber()).toString();
String version = getVersionFromIdAndVersion(superId);
if(version != null)
return ManagedBuildManager.getIdFromIdAndVersion(superId) + "." + suffix + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
return superId + "." + suffix; //$NON-NLS-1$
}
/** /**
* Calculate a relative path given the full path to a folder and a file * Calculate a relative path given the full path to a folder and a file
*/ */

View file

@ -119,4 +119,12 @@ public class BuildObject implements IBuildObject {
public void setManagedBuildRevision(String managedBuildRevision) { public void setManagedBuildRevision(String managedBuildRevision) {
this.managedBuildRevision = managedBuildRevision; this.managedBuildRevision = managedBuildRevision;
} }
/*
* updates revision for this build object and all its children
*/
public void updateManagedBuildRevision(String revision){
setManagedBuildRevision(revision);
setVersion(getVersionFromId());
}
} }

View file

@ -23,21 +23,23 @@ import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.UserDefinedMacroSupplier;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier; import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -76,6 +78,7 @@ public class Configuration extends BuildObject implements IConfiguration {
private boolean isDirty = false; private boolean isDirty = false;
private boolean rebuildNeeded = false; private boolean rebuildNeeded = false;
private boolean resolved = true; private boolean resolved = true;
private boolean isTemporary = false;
/* /*
@ -222,11 +225,13 @@ public class Configuration extends BuildObject implements IConfiguration {
* @param id A unique ID for the new configuration. * @param id A unique ID for the new configuration.
* @param cloneChildren If <code>true</code>, the configuration's tools are cloned * @param cloneChildren If <code>true</code>, the configuration's tools are cloned
*/ */
public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren) { public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
setId(id); setId(id);
setName(cloneConfig.getName()); setName(cloneConfig.getName());
this.description = cloneConfig.getDescription();
this.managedProject = managedProject; this.managedProject = managedProject;
isExtensionConfig = false; isExtensionConfig = false;
this.isTemporary = temporary;
// set managedBuildRevision // set managedBuildRevision
setManagedBuildRevision(cloneConfig.getManagedBuildRevision()); setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
@ -264,39 +269,48 @@ public class Configuration extends BuildObject implements IConfiguration {
// Clone the configuration's children // Clone the configuration's children
// Tool Chain // Tool Chain
int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
String tmpId;
String subName; String subName;
if (cloneConfig.parent != null) { if (cloneConfig.parent != null) {
tmpId = cloneConfig.parent.getToolChain().getId(); subId = ManagedBuildManager.calculateChildId(
cloneConfig.parent.getToolChain().getId(),
null);
subName = cloneConfig.parent.getToolChain().getName(); subName = cloneConfig.parent.getToolChain().getName();
} else { } else {
tmpId = cloneConfig.getToolChain().getId(); subId = ManagedBuildManager.calculateChildId(
cloneConfig.getToolChain().getId(),
null);
subName = cloneConfig.getToolChain().getName(); subName = cloneConfig.getToolChain().getName();
} }
String version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
if ( version != null) { // If the 'tmpId' contains version information
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
} else {
subId = tmpId + "." + nnn; //$NON-NLS-1$
}
if (cloneChildren) { if (cloneChildren) {
toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain()); toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
//copy expand build macros setting
BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
macroProvider.expandMacrosInBuildfile(this,
macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
//copy user-defined build macros
UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
userMacros.setMacros(
userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
BuildMacroProvider.CONTEXT_CONFIGURATION,
this);
//copy user-defined environment
UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
userEnv.setVariables(
userEnv.getVariables(cloneConfig), this);
} else { } else {
// Add a tool-chain element that specifies as its superClass the // Add a tool-chain element that specifies as its superClass the
// tool-chain that is the child of the configuration. // tool-chain that is the child of the configuration.
ToolChain superChain = (ToolChain)cloneConfig.getToolChain(); ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
tmpId = superChain.getId(); subId = ManagedBuildManager.calculateChildId(
version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId); superChain.getId(),
if ( version != null) { // If the 'tmpId' contains version information null);
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
} else {
subId = tmpId + "." + nnn; //$NON-NLS-1$
}
IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false); IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
// For each option/option category child of the tool-chain that is // For each option/option category child of the tool-chain that is
@ -312,14 +326,7 @@ public class Configuration extends BuildObject implements IConfiguration {
ITool[] tools = superChain.getTools(); ITool[] tools = superChain.getTools();
for (int i=0; i<tools.length; i++) { for (int i=0; i<tools.length; i++) {
Tool toolChild = (Tool)tools[i]; Tool toolChild = (Tool)tools[i];
nnn = ManagedBuildManager.getRandomNumber(); subId = ManagedBuildManager.calculateChildId(toolChild.getId(),null);
tmpId = toolChild.getId();
version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
if ( version != null) { // If the 'tmpId' contains version information
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
} else {
subId = tmpId + "." + nnn; //$NON-NLS-1$
}
newChain.createTool(toolChild, subId, toolChild.getName(), false); newChain.createTool(toolChild, subId, toolChild.getName(), false);
} }
} }
@ -330,7 +337,7 @@ public class Configuration extends BuildObject implements IConfiguration {
Iterator iter = resElements.listIterator(); Iterator iter = resElements.listIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
ResourceConfiguration resConfig = (ResourceConfiguration) iter.next(); ResourceConfiguration resConfig = (ResourceConfiguration) iter.next();
subId = getId() + "." + resConfig.getResourcePath(); //$NON-NLS-1$ subId = getId() + "." + ManagedBuildManager.getRandomNumber(); //$NON-NLS-1$
ResourceConfiguration newResConfig = new ResourceConfiguration(this, resConfig, subId); ResourceConfiguration newResConfig = new ResourceConfiguration(this, resConfig, subId);
addResourceConfiguration(newResConfig); addResourceConfiguration(newResConfig);
} }
@ -409,7 +416,7 @@ public class Configuration extends BuildObject implements IConfiguration {
// description // description
if (element.hasAttribute(IConfiguration.DESCRIPTION)) if (element.hasAttribute(IConfiguration.DESCRIPTION))
setDescription(element.getAttribute(IConfiguration.DESCRIPTION)); this.description = element.getAttribute(IConfiguration.DESCRIPTION);
if (element.hasAttribute(IConfiguration.PARENT)) { if (element.hasAttribute(IConfiguration.PARENT)) {
// See if the parent belongs to the same project // See if the parent belongs to the same project
@ -849,11 +856,15 @@ public class Configuration extends BuildObject implements IConfiguration {
public void addResourceConfiguration(ResourceConfiguration resConfig) { public void addResourceConfiguration(ResourceConfiguration resConfig) {
getResourceConfigurationList().add(resConfig); getResourceConfigurationList().add(resConfig);
getResourceConfigurationMap().put(resConfig.getResourcePath(), resConfig); getResourceConfigurationMap().put(resConfig.getResourcePath(), resConfig);
isDirty = true;
rebuildNeeded = true;
} }
public void removeResourceConfiguration(IResourceConfiguration resConfig) { public void removeResourceConfiguration(IResourceConfiguration resConfig) {
getResourceConfigurationList().remove(resConfig); getResourceConfigurationList().remove(resConfig);
getResourceConfigurationMap().remove(resConfig.getResourcePath()); getResourceConfigurationMap().remove(resConfig.getResourcePath());
isDirty = true;
rebuildNeeded = true;
} }
/* /*
* M O D E L A T T R I B U T E A C C E S S O R S * M O D E L A T T R I B U T E A C C E S S O R S
@ -1154,13 +1165,20 @@ public class Configuration extends BuildObject implements IConfiguration {
public void setBuildArguments(String makeArgs) { public void setBuildArguments(String makeArgs) {
IToolChain tc = getToolChain(); IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder(); IBuilder builder = tc.getBuilder();
if(makeArgs == null){ //resetting the build arguments
if(!builder.isExtensionElement()){
builder.setArguments(makeArgs);
rebuildNeeded = true;
}
}else if(!makeArgs.equals(builder.getArguments())){
if (builder.isExtensionElement()) { if (builder.isExtensionElement()) {
int nnn = ManagedBuildManager.getRandomNumber(); String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
builder = toolChain.createBuilder(builder, subId, builderName, false); builder = toolChain.createBuilder(builder, subId, builderName, false);
} }
builder.setArguments(makeArgs); builder.setArguments(makeArgs);
rebuildNeeded = true;
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1169,13 +1187,20 @@ public class Configuration extends BuildObject implements IConfiguration {
public void setBuildCommand(String command) { public void setBuildCommand(String command) {
IToolChain tc = getToolChain(); IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder(); IBuilder builder = tc.getBuilder();
if(command == null){ //resetting the build command
if(!builder.isExtensionElement()){
builder.setCommand(command);
rebuildNeeded = true;
}
} else if(!command.equals(builder.getCommand())){
if (builder.isExtensionElement()) { if (builder.isExtensionElement()) {
int nnn = ManagedBuildManager.getRandomNumber(); String subId = ManagedBuildManager.calculateChildId(builder.getId(), null);
String subId = builder.getId() + "." + nnn; //$NON-NLS-1$
String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$ String builderName = builder.getName() + "." + getName(); //$NON-NLS-1$
builder = toolChain.createBuilder(builder, subId, builderName, false); builder = toolChain.createBuilder(builder, subId, builderName, false);
} }
builder.setCommand(command); builder.setCommand(command);
rebuildNeeded = true;
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1298,7 +1323,7 @@ public class Configuration extends BuildObject implements IConfiguration {
*/ */
public void setRebuildState(boolean rebuild) { public void setRebuildState(boolean rebuild) {
rebuildNeeded = rebuild; rebuildNeeded = rebuild;
if(rebuild) if(rebuild && !isTemporary())
((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider()).checkBuildPathVariables(this); ((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider()).checkBuildPathVariables(this);
} }
@ -1372,6 +1397,8 @@ public class Configuration extends BuildObject implements IConfiguration {
for (int j = 0; j < opts.length; j++) { for (int j = 0; j < opts.length; j++) {
toolChain.removeOption(opts[j]); toolChain.removeOption(opts[j]);
} }
rebuildNeeded = true;
} }
/* /*
@ -1381,7 +1408,7 @@ public class Configuration extends BuildObject implements IConfiguration {
{ {
String path = file.getFullPath().toString(); String path = file.getFullPath().toString();
String resourceName = file.getName(); String resourceName = file.getName();
String id = getId() + "." + path; //$NON-NLS-1$ String id = getId() + "." + ManagedBuildManager.getRandomNumber(); //$NON-NLS-1$
ResourceConfiguration resConfig = new ResourceConfiguration( (IConfiguration) this, id, resourceName, path); ResourceConfiguration resConfig = new ResourceConfiguration( (IConfiguration) this, id, resourceName, path);
// Get file extension. // Get file extension.
@ -1419,10 +1446,8 @@ public class Configuration extends BuildObject implements IConfiguration {
*/ */
public PluginVersionIdentifier getVersion() { public PluginVersionIdentifier getVersion() {
if ( version == null) { if ( version == null) {
if ( projectType != null) { if ( toolChain != null) {
projectType.getVersion(); return toolChain.getVersion();
} else if ( managedProject != null) {
return managedProject.getVersion();
} }
} }
return version; return version;
@ -1442,4 +1467,23 @@ public class Configuration extends BuildObject implements IConfiguration {
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary()
*/
public boolean isTemporary(){
return isTemporary;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
*/
public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision);
toolChain.updateManagedBuildRevision(revision);
for(Iterator iter = getResourceConfigurationList().iterator(); iter.hasNext();){
((ResourceConfiguration)iter.next()).updateManagedBuildRevision(revision);
}
}
} }

View file

@ -142,6 +142,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Switch the rebuild off since this is an existing project // Switch the rebuild off since this is an existing project
rebuildNeeded = false; rebuildNeeded = false;
version = managedBuildRevision;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1022,6 +1024,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
this.version = version; this.version = version;
//setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state //setDirty(true); - It is primarily up to the ManagedProject to maintain the dirty state
} }
updateRevision(version);
} }
/** /**
@ -1266,7 +1269,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
rescfgs[i]); rescfgs[i]);
} }
} }
// */ */
return entries; return entries;
} }
@ -1279,7 +1282,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/ */
private List readToolsOptions(int entryType, List entries, boolean builtIns, IBuildObject obj) { private List readToolsOptions(int entryType, List entries, boolean builtIns, IBuildObject obj) {
ITool[] t = null; ITool[] t = null;
Path resPath = Path.EMPTY; IPath resPath = Path.EMPTY;
// check that entryType is correct // check that entryType is correct
if (entryType != IPathEntry.CDT_INCLUDE_FILE && if (entryType != IPathEntry.CDT_INCLUDE_FILE &&
@ -1293,7 +1296,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// calculate parameters depending of object type // calculate parameters depending of object type
if (obj instanceof IResourceConfiguration) { if (obj instanceof IResourceConfiguration) {
resPath = new Path(((IResourceConfiguration)obj).getResourcePath()); resPath = new Path(((IResourceConfiguration)obj).getResourcePath()).removeFirstSegments(1);
t = ((IResourceConfiguration)obj).getToolsToInvoke(); t = ((IResourceConfiguration)obj).getToolsToInvoke();
} else if (obj instanceof IConfiguration) { } else if (obj instanceof IConfiguration) {
t = ((IConfiguration)obj).getFilteredTools(); t = ((IConfiguration)obj).getFilteredTools();
@ -1339,7 +1342,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param resPath * @param resPath
* @param ocd * @param ocd
*/ */
protected List addIncludes(List entries, String[] values, Path resPath, OptionContextData ocd) { protected List addIncludes(List entries, String[] values, IPath resPath, OptionContextData ocd) {
if (values != null) { if (values != null) {
for (int k=0; k<values.length; k++) { for (int k=0; k<values.length; k++) {
if (ocd != null) { if (ocd != null) {
@ -1359,7 +1362,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param resPath * @param resPath
* @param ocd * @param ocd
*/ */
protected List addLibraries(List entries, String[] values, Path resPath, OptionContextData ocd) { protected List addLibraries(List entries, String[] values, IPath resPath, OptionContextData ocd) {
if (values != null) { if (values != null) {
for (int k=0; k<values.length; k++) { for (int k=0; k<values.length; k++) {
if (ocd != null) { if (ocd != null) {
@ -1378,7 +1381,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param values * @param values
* @param resPath * @param resPath
*/ */
protected List addSymbols(List entries, String[] values, Path resPath) { protected List addSymbols(List entries, String[] values, IPath resPath) {
if (values == null) return entries; if (values == null) return entries;
for (int i=0; i<values.length; i++) { for (int i=0; i<values.length; i++) {
if (values[i].length() == 0) continue; if (values[i].length() == 0) continue;
@ -1403,4 +1406,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return entries; return entries;
} }
public void updateRevision(String revision){
if(managedProject != null)
((ManagedProject)managedProject).updateManagedBuildRevision(revision);
}
} }

View file

@ -17,17 +17,19 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros; import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -54,7 +56,8 @@ public class ManagedProject extends BuildObject implements IManagedProject {
private boolean resolved = true; private boolean resolved = true;
//holds the user-defined macros //holds the user-defined macros
private StorableMacros userDefinedMacros; private StorableMacros userDefinedMacros;
//holds user-defined environment
private StorableEnvironment userDefinedEnvironment;
/* /*
* C O N S T R U C T O R S * C O N S T R U C T O R S
*/ */
@ -189,6 +192,10 @@ public class ManagedProject extends BuildObject implements IManagedProject {
userDefinedMacros.serialize(doc,macrosElement); userDefinedMacros.serialize(doc,macrosElement);
} }
if(userDefinedEnvironment != null){
EnvironmentVariableProvider.fUserSupplier.storeEnvironment(this,true);
}
// I am clean now // I am clean now
isDirty = false; isDirty = false;
} }
@ -225,7 +232,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration) * @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/ */
public IConfiguration createConfiguration(IConfiguration parent, String id) { public IConfiguration createConfiguration(IConfiguration parent, String id) {
Configuration config = new Configuration(this, (Configuration)parent, id, false); Configuration config = new Configuration(this, (Configuration)parent, id, false, false);
ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN); ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
return (IConfiguration)config; return (IConfiguration)config;
} }
@ -234,7 +241,7 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfigurationClone(org.eclipse.cdt.core.build.managed.IConfiguration) * @see org.eclipse.cdt.core.build.managed.IManagedProject#createConfigurationClone(org.eclipse.cdt.core.build.managed.IConfiguration)
*/ */
public IConfiguration createConfigurationClone(IConfiguration parent, String id) { public IConfiguration createConfigurationClone(IConfiguration parent, String id) {
Configuration config = new Configuration(this, (Configuration)parent, id, true); Configuration config = new Configuration(this, (Configuration)parent, id, true, false);
// Inform all options in the configuration and all its resource configurations // Inform all options in the configuration and all its resource configurations
ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN); ManagedBuildManager.performValueHandlerEvent(config, IManagedOptionValueHandler.EVENT_OPEN);
return (IConfiguration)config; return (IConfiguration)config;
@ -266,6 +273,11 @@ public class ManagedProject extends BuildObject implements IManagedProject {
*/ */
public void removeConfiguration(String id) { public void removeConfiguration(String id) {
final String removeId = id; final String removeId = id;
//handle the case of temporary configuration
if(getConfigurationMap().get(id) == null)
return;
IWorkspaceRunnable remover = new IWorkspaceRunnable() { IWorkspaceRunnable remover = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException { public void run(IProgressMonitor monitor) throws CoreException {
// Remove the specified configuration from the list and map // Remove the specified configuration from the list and map
@ -324,9 +336,11 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @param Tool * @param Tool
*/ */
public void addConfiguration(Configuration configuration) { public void addConfiguration(Configuration configuration) {
if(!configuration.isTemporary()){
getConfigurationList().add(configuration); getConfigurationList().add(configuration);
getConfigurationMap().put(configuration.getId(), configuration); getConfigurationMap().put(configuration.getId(), configuration);
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* Safe accessor for the list of configurations. * Safe accessor for the list of configurations.
@ -408,6 +422,10 @@ public class ManagedProject extends BuildObject implements IManagedProject {
if(userDefinedMacros != null && userDefinedMacros.isDirty()) if(userDefinedMacros != null && userDefinedMacros.isDirty())
return true; return true;
//check whether the project - specific environment is dirty
if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
return true;
// Otherwise see if any configurations need saving // Otherwise see if any configurations need saving
Iterator iter = getConfigurationList().listIterator(); Iterator iter = getConfigurationList().listIterator();
@ -476,4 +494,22 @@ public class ManagedProject extends BuildObject implements IManagedProject {
return userDefinedMacros; return userDefinedMacros;
} }
public StorableEnvironment getUserDefinedEnvironmet(){
return userDefinedEnvironment;
}
public void setUserDefinedEnvironmet(StorableEnvironment env){
userDefinedEnvironment = env;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
*/
public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision);
for(Iterator iter = getConfigurationList().iterator(); iter.hasNext();){
Configuration cfg = (Configuration)iter.next();
cfg.updateManagedBuildRevision(revision);
}
}
} }

View file

@ -239,9 +239,11 @@ public class ProjectType extends BuildObject implements IProjectType {
* @param Tool * @param Tool
*/ */
public void addConfiguration(Configuration configuration) { public void addConfiguration(Configuration configuration) {
if(!configuration.isTemporary()){
getConfigurationList().add(configuration); getConfigurationList().add(configuration);
getConfigurationMap().put(configuration.getId(), configuration); getConfigurationMap().put(configuration.getId(), configuration);
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* Safe accessor for the list of configurations. * Safe accessor for the list of configurations.

View file

@ -164,25 +164,20 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
Iterator iter = cloneConfig.getToolList().listIterator(); Iterator iter = cloneConfig.getToolList().listIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Tool toolChild = (Tool) iter.next(); Tool toolChild = (Tool) iter.next();
int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
String tmpId;
String subName; String subName;
String version;
if (toolChild.getSuperClass() != null) { if (toolChild.getSuperClass() != null) {
tmpId = toolChild.getSuperClass().getId(); subId = ManagedBuildManager.calculateChildId(
toolChild.getSuperClass().getId(),
null);
subName = toolChild.getSuperClass().getName(); subName = toolChild.getSuperClass().getName();
} else { } else {
tmpId = toolChild.getId(); subId = ManagedBuildManager.calculateChildId(
toolChild.getId(),
null);
subName = toolChild.getName(); subName = toolChild.getName();
} }
version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
if ( version != null) { // If the 'tmpId' contains version information
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
} else {
subId = tmpId + "." + nnn; //$NON-NLS-1$
}
// The superclass for the cloned tool is not the same as the one from the tool being cloned. // The superclass for the cloned tool is not the same as the one from the tool being cloned.
// The superclasses reside in different configurations. // The superclasses reside in different configurations.
@ -646,6 +641,7 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
if (isExcluded == null || excluded != isExcluded.booleanValue()) { if (isExcluded == null || excluded != isExcluded.booleanValue()) {
isExcluded = new Boolean(excluded); isExcluded = new Boolean(excluded);
setDirty(true); setDirty(true);
parent.setRebuildState(true);
} }
} }
@ -926,4 +922,14 @@ public class ResourceConfiguration extends BuildObject implements IResourceConfi
// Do nothing // Do nothing
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
*/
public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision);
for(Iterator iter = getToolList().iterator(); iter.hasNext();){
((Tool)iter.next()).updateManagedBuildRevision(revision);
}
}
} }

View file

@ -31,6 +31,8 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros; import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier; import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -85,6 +87,8 @@ public class ToolChain extends HoldsOptions implements IToolChain {
private boolean resolved = resolvedDefault; private boolean resolved = resolvedDefault;
//holds the user-defined macros //holds the user-defined macros
private StorableMacros userDefinedMacros; private StorableMacros userDefinedMacros;
//holds user-defined macros
private StorableEnvironment userDefinedEnvironment;
private IConfigurationElement previousMbsVersionConversionElement = null; private IConfigurationElement previousMbsVersionConversionElement = null;
private IConfigurationElement currentMbsVersionConversionElement = null; private IConfigurationElement currentMbsVersionConversionElement = null;
@ -299,25 +303,20 @@ public class ToolChain extends HoldsOptions implements IToolChain {
super.copyChildren(toolChain); super.copyChildren(toolChain);
// Clone the children // Clone the children
if (toolChain.builder != null) { if (toolChain.builder != null) {
int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
String tmpId;
String version;
String subName; String subName;
if (toolChain.builder.getSuperClass() != null) { if (toolChain.builder.getSuperClass() != null) {
tmpId = toolChain.builder.getSuperClass().getId(); //$NON-NLS-1$ subId = ManagedBuildManager.calculateChildId(
toolChain.builder.getSuperClass().getId(),
null);
subName = toolChain.builder.getSuperClass().getName(); subName = toolChain.builder.getSuperClass().getName();
} else { } else {
tmpId = toolChain.builder.getId(); //$NON-NLS-1$ subId = ManagedBuildManager.calculateChildId(
toolChain.builder.getId(),
null);
subName = toolChain.builder.getName(); subName = toolChain.builder.getName();
} }
version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
if ( version != null) { // If the 'tmpId' contains version information
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
} else {
subId = tmpId + "." + nnn; //$NON-NLS-1$
}
builder = new Builder(this, subId, subName, toolChain.builder); builder = new Builder(this, subId, subName, toolChain.builder);
} }
@ -679,6 +678,9 @@ public class ToolChain extends HoldsOptions implements IToolChain {
userDefinedMacros.serialize(doc,macrosElement); userDefinedMacros.serialize(doc,macrosElement);
} }
if(userDefinedEnvironment != null)
EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
// I am clean now // I am clean now
isDirty = false; isDirty = false;
} catch (Exception e) { } catch (Exception e) {
@ -1214,6 +1216,12 @@ public class ToolChain extends HoldsOptions implements IToolChain {
if(userDefinedMacros != null && userDefinedMacros.isDirty()) if(userDefinedMacros != null && userDefinedMacros.isDirty())
return true; return true;
if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
return true;
if(builder != null && builder.isDirty())
return true;
// Otherwise see if any tools need saving // Otherwise see if any tools need saving
Iterator iter = getToolList().listIterator(); Iterator iter = getToolList().listIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -1435,6 +1443,19 @@ public class ToolChain extends HoldsOptions implements IToolChain {
return userDefinedMacros; return userDefinedMacros;
} }
public StorableEnvironment getUserDefinedEnvironment(){
if(isExtensionToolChain)
return null;
return userDefinedEnvironment;
}
public void setUserDefinedEnvironment(StorableEnvironment env){
if(!isExtensionToolChain)
userDefinedEnvironment = env;
}
/** /**
* Returns the plugin.xml element of the configurationMacroSupplier extension or <code>null</code> if none. * Returns the plugin.xml element of the configurationMacroSupplier extension or <code>null</code> if none.
* *
@ -1477,7 +1498,6 @@ public class ToolChain extends HoldsOptions implements IToolChain {
public void checkForMigrationSupport() { public void checkForMigrationSupport() {
String tmpId = null;
boolean isExists = false; boolean isExists = false;
if (getSuperClass() == null) { if (getSuperClass() == null) {
@ -1655,4 +1675,19 @@ public class ToolChain extends HoldsOptions implements IToolChain {
public IConfigurationElement getCurrentMbsVersionConversionElement() { public IConfigurationElement getCurrentMbsVersionConversionElement() {
return currentMbsVersionConversionElement; return currentMbsVersionConversionElement;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
*/
public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision);
for(Iterator iter = getToolList().iterator(); iter.hasNext();){
((Tool)iter.next()).updateManagedBuildRevision(revision);
}
if(builder != null)
builder.updateManagedBuildRevision(revision);
}
} }

View file

@ -90,10 +90,13 @@ public class StorableEnvironment {
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
return null; return null;
StorableEnvVar var = new StorableEnvVar(name, value, op, delimiter); IBuildEnvironmentVariable var = checkVariable(name,value,op,delimiter);
if(var == null){
var = new StorableEnvVar(name, value, op, delimiter);
addVariable(var); addVariable(var);
fIsDirty = true; fIsDirty = true;
fIsChanged = true; fIsChanged = true;
}
return var; return var;
} }
@ -109,6 +112,23 @@ public class StorableEnvironment {
return createVariable(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,delimiter); return createVariable(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,delimiter);
} }
public IBuildEnvironmentVariable checkVariable(String name, String value, int op, String delimiter){
IBuildEnvironmentVariable var = getVariable(name);
if(var != null
&& checkStrings(var.getValue(),value)
&& var.getOperation() == op
&& checkStrings(var.getDelimiter(),delimiter))
return var;
return null;
}
private boolean checkStrings(String str1, String str2){
if(str1 != null &&
str1.equals(str2))
return true;
return str1 == str2;
}
/** /**
* Returns the "dirty" state of the environment. * Returns the "dirty" state of the environment.
* If the dirty state is <code>true</code>, that means that the environment * If the dirty state is <code>true</code>, that means that the environment
@ -162,6 +182,35 @@ public class StorableEnvironment {
return (IBuildEnvironmentVariable)getMap().get(name); return (IBuildEnvironmentVariable)getMap().get(name);
} }
public void setVariales(IBuildEnvironmentVariable vars[]){
if(vars == null || vars.length == 0)
deleteAll();
else{
if (getMap().size() != 0) {
Iterator iter = getMap().values().iterator();
while(iter.hasNext()){
IBuildEnvironmentVariable v = (IBuildEnvironmentVariable)iter.next();
int i;
for(i = 0 ; i < vars.length; i++){
if(v.getName().equals(vars[i].getName()))
break;
}
if(i == vars.length)
deleteVariable(v.getName());
}
}
createVriables(vars);
}
}
public void createVriables(IBuildEnvironmentVariable vars[]){
for(int i = 0; i < vars.length; i++)
createVariable(vars[i].getName(),
vars[i].getValue(),
vars[i].getOperation(),
vars[i].getDelimiter());
}
public IBuildEnvironmentVariable[] getVariables(){ public IBuildEnvironmentVariable[] getVariables(){
Collection vars = getMap().values(); Collection vars = getMap().values();

View file

@ -17,6 +17,8 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ProjectScope;
@ -47,56 +49,35 @@ public class UserDefinedEnvironmentSupplier extends
EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$ EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
}; };
private StorableEnvironment fConfigurationVariables;
private StorableEnvironment fProjectVariables;
private StorableEnvironment fWorkspaceVariables; private StorableEnvironment fWorkspaceVariables;
private IConfiguration fCurrentCfg = null;
private IManagedProject fCurrentProj = null;
protected StorableEnvironment getEnvironment(Object context){ protected StorableEnvironment getEnvironment(Object context){
return getEnvironment(context,true);
}
protected StorableEnvironment getEnvironment(Object context, boolean forceLoad){
if(context == null) if(context == null)
return null; return null;
StorableEnvironment env = null; StorableEnvironment env = null;
if(context instanceof IConfiguration){ if(context instanceof IConfiguration){
IConfiguration newCfg = (IConfiguration)context; IConfiguration cfg = (IConfiguration)context;
if(fCurrentCfg == newCfg && fConfigurationVariables != null){ env = ((ToolChain)cfg.getToolChain()).getUserDefinedEnvironment();
env = fConfigurationVariables; if(env == null && forceLoad){
} env = loadEnvironment(cfg);
else{ ((ToolChain)cfg.getToolChain()).setUserDefinedEnvironment(env);
env = loadEnvironment(newCfg);
if(env != null){
if(fConfigurationVariables != null)
try{
storeEnvironment(fConfigurationVariables,fCurrentCfg,false);
} catch(CoreException e){
}
fConfigurationVariables = env;
fCurrentCfg = newCfg;
} }
} }
} else if(context instanceof ManagedProject){
else if(context instanceof IManagedProject){ ManagedProject proj = (ManagedProject)context;
IManagedProject newProj = (IManagedProject)context; env = proj.getUserDefinedEnvironmet();
if(fCurrentProj == newProj && fProjectVariables != null){ if(env == null && forceLoad){
env = fProjectVariables; env = loadEnvironment(proj);
} proj.setUserDefinedEnvironmet(env);
else{
env = loadEnvironment(newProj);
if(env != null){
if(fProjectVariables != null)
try{
storeEnvironment(fProjectVariables,fCurrentProj,false);
} catch(CoreException e){
}
fProjectVariables = env;
fCurrentProj = newProj;
}
} }
} }
else if(context instanceof IWorkspace){ else if(context instanceof IWorkspace){
if(fWorkspaceVariables == null) if(fWorkspaceVariables == null && forceLoad)
fWorkspaceVariables = loadEnvironment(context); fWorkspaceVariables = loadEnvironment(context);
env = fWorkspaceVariables; env = fWorkspaceVariables;
} }
@ -189,7 +170,7 @@ public class UserDefinedEnvironmentSupplier extends
return; return;
try{ try{
String ids[] = prefNode.childrenNames(); String ids[] = prefNode.keys();
boolean found = false; boolean found = false;
for( int i = 0; i < ids.length; i++){ for( int i = 0; i < ids.length; i++){
if(managedProject.getConfiguration(ids[i]) == null){ if(managedProject.getConfiguration(ids[i]) == null){
@ -206,29 +187,22 @@ public class UserDefinedEnvironmentSupplier extends
} }
public void serialize(boolean force){ public void serialize(boolean force){
if(fConfigurationVariables != null && fCurrentCfg != null ){
try{
storeEnvironment(fConfigurationVariables,fCurrentCfg,force);
} catch(CoreException e){
}
}
if(fProjectVariables != null && fCurrentProj != null ){
try{
storeEnvironment(fProjectVariables,fCurrentProj,force);
} catch(CoreException e){
}
}
if(fWorkspaceVariables != null){ if(fWorkspaceVariables != null){
try{ try{
storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force); storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force);
} catch(CoreException e){ } catch(CoreException e){
} }
}
}
public void storeEnvironment(Object context, boolean force){
StorableEnvironment env = getEnvironment(context, false);
if(env != null){
try {
storeEnvironment(env, context, force);
} catch (CoreException e) {
}
} }
} }
@ -261,6 +235,7 @@ public class UserDefinedEnvironmentSupplier extends
if(env == null) if(env == null)
return null; return null;
IBuildEnvironmentVariable var = env.createVariable(name,value,op,delimiter); IBuildEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
if(env.isChanged())
setRebuildStateForContext(context); setRebuildStateForContext(context);
return var; return var;
} }
@ -284,6 +259,16 @@ public class UserDefinedEnvironmentSupplier extends
setRebuildStateForContext(context); setRebuildStateForContext(context);
} }
public void setVariables(IBuildEnvironmentVariable vars[], Object context){
StorableEnvironment env = getEnvironment(context);
if(env == null)
return;
env.setVariales(vars);
if(env.isChanged())
setRebuildStateForContext(context);
}
protected void setRebuildStateForContext(Object context){ protected void setRebuildStateForContext(Object context){
if(context == null) if(context == null)
return; return;

View file

@ -102,13 +102,94 @@ public class StorableMacros {
if(name == null || "".equals(name = name.trim()) || MacroResolver.isStringListMacro(type)) //$NON-NLS-1$ if(name == null || "".equals(name = name.trim()) || MacroResolver.isStringListMacro(type)) //$NON-NLS-1$
return null; return null;
StorableBuildMacro macro = new StorableBuildMacro(name, type, value); IBuildMacro macro = checkMacro(name, type, value);
if(macro == null){
macro = new StorableBuildMacro(name, type, value);
addMacro(macro); addMacro(macro);
fIsDirty = true; fIsDirty = true;
fIsChanged = true; fIsChanged = true;
}
return macro; return macro;
} }
public IBuildMacro checkMacro(String name, int type, String value){
IBuildMacro macro = getMacro(name);
if(macro != null){
if(macro.getName().equals(name)
&& macro.getMacroValueType() == type){
try {
String val = macro.getStringValue();
if((val != null
&& val.equals(value))
|| val == value){
return macro;
}
} catch (BuildMacroException e) {
}
}
}
return null;
}
public IBuildMacro checkMacro(String name, int type, String value[]){
IBuildMacro macro = getMacro(name);
if(macro != null){
if(macro.getName().equals(name)
&& macro.getMacroValueType() == type){
try {
String val[] = macro.getStringListValue();
if(val != null){
if(value != null && value.length == val.length){
int i;
for(i = 0; i < val.length; i++){
if(!value[i].equals(val[i]))
break;
}
if(i == value.length)
return macro;
}
} else if (value == val){
return macro;
}
} catch (BuildMacroException e) {
}
}
}
return null;
}
/*
* sets the storable macros to hold the geven number of macros
* all macros that are present in the store but not included in the given array
* will be removed
*/
public void setMacros(IBuildMacro macros[]){
if(macros == null || macros.length == 0)
deleteAll();
else{
if (getMap().size() != 0) {
Iterator iter = getMap().values().iterator();
while(iter.hasNext()){
IBuildMacro m = (IBuildMacro)iter.next();
int i;
for(i = 0 ; i < macros.length; i++){
if(m.getName().equals(macros[i].getName()))
break;
}
if(i == macros.length)
deleteMacro(m.getName());
}
}
createMacros(macros);
}
}
public void createMacros(IBuildMacro macros[]){
for(int i = 0; i < macros.length; i++){
createMacro(macros[i]);
}
}
public IBuildMacro createMacro(IBuildMacro copy){ public IBuildMacro createMacro(IBuildMacro copy){
String name = copy.getName(); String name = copy.getName();
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
@ -116,19 +197,28 @@ public class StorableMacros {
int type = copy.getMacroValueType(); int type = copy.getMacroValueType();
StorableBuildMacro macro = null; IBuildMacro macro = null;
try{ try{
if(MacroResolver.isStringListMacro(type)){ if(MacroResolver.isStringListMacro(type)){
String value[] = copy.getStringListValue(); String value[] = copy.getStringListValue();
macro = checkMacro(name, type, value);
if(macro == null){
macro = new StorableBuildMacro(name, type, value); macro = new StorableBuildMacro(name, type, value);
}
else {
String value = copy.getStringValue();
macro = new StorableBuildMacro(name, type, value);
}
addMacro(macro); addMacro(macro);
fIsDirty = true; fIsDirty = true;
fIsChanged = true; fIsChanged = true;
}
}
else {
String value = copy.getStringValue();
macro = checkMacro(name, type, value);
if(macro == null){
macro = new StorableBuildMacro(name, type, value);
addMacro(macro);
fIsDirty = true;
fIsChanged = true;
}
}
}catch(BuildMacroException e){ }catch(BuildMacroException e){
} }
@ -139,10 +229,13 @@ public class StorableMacros {
if(name == null || "".equals(name = name.trim()) || !MacroResolver.isStringListMacro(type)) //$NON-NLS-1$ if(name == null || "".equals(name = name.trim()) || !MacroResolver.isStringListMacro(type)) //$NON-NLS-1$
return null; return null;
StorableBuildMacro macro = new StorableBuildMacro(name, type, value); IBuildMacro macro = checkMacro(name, type, value);
if(macro == null){
macro = new StorableBuildMacro(name, type, value);
addMacro(macro); addMacro(macro);
fIsDirty = true; fIsDirty = true;
fIsChanged = true; fIsChanged = true;
}
return macro; return macro;
} }
@ -215,7 +308,7 @@ public class StorableMacros {
return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]); return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]);
} }
IBuildMacro deleteMacro(String name){ public IBuildMacro deleteMacro(String name){
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$ if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
return null; return null;

View file

@ -152,7 +152,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null; return null;
IBuildMacro macro = macros.createMacro(macroName,type,value); IBuildMacro macro = macros.createMacro(macroName,type,value);
if(macro != null) if(macros.isChanged())
setRebuildStateForContext(contextType, contextData); setRebuildStateForContext(contextType, contextData);
return macro; return macro;
@ -171,7 +171,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null; return null;
IBuildMacro macro = macros.createMacro(macroName,type,value); IBuildMacro macro = macros.createMacro(macroName,type,value);
if(macro != null) if(macros.isChanged())
setRebuildStateForContext(contextType, contextData); setRebuildStateForContext(contextType, contextData);
return macro; return macro;
@ -189,7 +189,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
return null; return null;
IBuildMacro macro = macros.createMacro(copy); IBuildMacro macro = macros.createMacro(copy);
if(macro != null) if(macros.isChanged())
setRebuildStateForContext(contextType, contextData); setRebuildStateForContext(contextType, contextData);
return macro; return macro;
@ -215,6 +215,16 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier {
setRebuildStateForContext(contextType, contextData); setRebuildStateForContext(contextType, contextData);
} }
public void setMacros(IBuildMacro m[], int contextType, Object contextData){
StorableMacros macros = getStorableMacros(contextType, contextData);
if(macros == null)
return;
macros.setMacros(m);
if(macros.isChanged())
setRebuildStateForContext(contextType, contextData);
}
/* /*
* *
* methods used for loadding/storing workspace macros from properties * methods used for loadding/storing workspace macros from properties

View file

@ -746,7 +746,7 @@ class UpdateManagedProject12 {
} }
// Upgrade the version // Upgrade the version
((ManagedBuildInfo)info).setVersion("2.1.0"); ((ManagedBuildInfo)info).setVersion("2.1.0"); //$NON-NLS-1$
info.setValid(true); info.setValid(true);
} catch (CoreException e){ } catch (CoreException e){
throw e; throw e;

View file

@ -97,7 +97,7 @@ class UpdateManagedProject20 {
} }
} }
// Upgrade the version // Upgrade the version
((ManagedBuildInfo)info).setVersion("2.1.0"); ((ManagedBuildInfo)info).setVersion("2.1.0"); //$NON-NLS-1$
info.setValid(true); info.setValid(true);
}catch (CoreException e){ }catch (CoreException e){
throw e; throw e;

View file

@ -306,6 +306,7 @@ public class UpdateManagedProjectManager {
} }
),null)); ),null));
} }
} catch (CoreException e) { } catch (CoreException e) {
fIsInfoReadOnly = true; fIsInfoReadOnly = true;
throw e; throw e;

View file

@ -76,20 +76,39 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
* Bookeeping variables * Bookeeping variables
*/ */
private BuildPropertyPage parent; private BuildPropertyPage parent;
// The name of the build artifact
private String artifactExt;
private String artifactName;
// The make command associated with the target
private String makeCommand;
// State of the check box on exit
private boolean useDefaultMake;
// Has the page been changed? // Has the page been changed?
private boolean dirty = false; private boolean dirty = false;
private ModifyListener widgetModified = new ModifyListener() { private ModifyListener widgetModified = new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
IConfiguration config = parent.getSelectedConfigurationClone();
if(e.widget == buildArtifactName){
String val = buildArtifactName.getText().trim();
if(!val.equals(config.getArtifactName())){
config.setArtifactName(val);
setValues();
setDirty(true); setDirty(true);
} }
} else if(e.widget == buildArtifactExt){
String val = buildArtifactExt.getText().trim();
if(!val.equals(config.getArtifactExtension())){
config.setArtifactExtension(val);
setValues();
setDirty(true);
}
} else if(e.widget == makeCommandEntry) {
String fullCommand = makeCommandEntry.getText().trim();
String buildCommand = parseMakeCommand(fullCommand);
String buildArgs = parseMakeArgs(fullCommand);
if(!buildCommand.equals(config.getBuildCommand())
|| !buildArgs.equals(config.getBuildArguments())){
parent.getSelectedConfigurationClone().setBuildCommand(buildCommand);
parent.getSelectedConfigurationClone().setBuildArguments(buildArgs);
setValues();
setDirty(true);
}
}
}
}; };
@ -205,7 +224,6 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
makeCommandDefault.addSelectionListener(new SelectionAdapter () { makeCommandDefault.addSelectionListener(new SelectionAdapter () {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
handleUseDefaultPressed(); handleUseDefaultPressed();
setDirty(true);
} }
}); });
makeCommandDefault.addDisposeListener(new DisposeListener() { makeCommandDefault.addDisposeListener(new DisposeListener() {
@ -243,8 +261,15 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
buildMacrosExpand.setForeground(buildMacrosExpandGroup.getForeground()); buildMacrosExpand.setForeground(buildMacrosExpandGroup.getForeground());
buildMacrosExpand.addSelectionListener(new SelectionAdapter () { buildMacrosExpand.addSelectionListener(new SelectionAdapter () {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
IConfiguration config = BuildSettingsBlock.this.parent.getSelectedConfigurationClone();
if(buildMacrosExpand.getSelection() != provider.areMacrosExpandedInBuildfile(config)){
provider.expandMacrosInBuildfile(config,
buildMacrosExpand.getSelection());
setValues();
setDirty(true); setDirty(true);
} }
}
}); });
buildMacrosExpand.addDisposeListener(new DisposeListener() { buildMacrosExpand.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) { public void widgetDisposed(DisposeEvent event) {
@ -255,36 +280,39 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
protected void initializeValues() { protected void initializeValues() {
setValues(); setValues();
setDirty(false);
} }
public void updateValues() { public void updateValues() {
setValues(); setValues();
useDefaultMake = !parent.getSelectedConfiguration().hasOverriddenBuildCommand(); makeCommandDefault.setSelection(!parent.getSelectedConfigurationClone().hasOverriddenBuildCommand());
makeCommandDefault.setSelection(useDefaultMake);
makeCommandEntry.setEditable(!makeCommandDefault.getSelection()); makeCommandEntry.setEditable(!makeCommandDefault.getSelection());
} }
protected void setValues() { protected void setValues() {
artifactName = parent.getSelectedConfiguration().getArtifactName(); IConfiguration config = parent.getSelectedConfigurationClone();
buildArtifactName.setText(artifactName); if(!config.getArtifactName().equals(buildArtifactName.getText()))
artifactExt = parent.getSelectedConfiguration().getArtifactExtension(); buildArtifactName.setText(config.getArtifactName());
buildArtifactExt.setText(artifactExt);
makeCommand = parent.getSelectedConfiguration().getBuildCommand(); if(!config.getArtifactExtension().equals(buildArtifactExt.getText()))
String makeArgs = parent.getSelectedConfiguration().getBuildArguments(); buildArtifactExt.setText(config.getArtifactExtension());
String makeCommand = config.getBuildCommand();
String makeArgs = config.getBuildArguments();
if (makeArgs != null) { if (makeArgs != null) {
makeCommand += " " + makeArgs; //$NON-NLS-1$ makeCommand += " " + makeArgs; //$NON-NLS-1$
} }
if(!makeCommand.equals(makeCommandEntry.getText()))
makeCommandEntry.setText(makeCommand); makeCommandEntry.setText(makeCommand);
BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
if(!provider.canKeepMacrosInBuildfile(this.parent.getSelectedConfiguration())) if(!provider.canKeepMacrosInBuildfile(config))
buildMacrosExpandGroup.setVisible(false); buildMacrosExpandGroup.setVisible(false);
else { else {
buildMacrosExpandGroup.setVisible(true); buildMacrosExpandGroup.setVisible(true);
buildMacrosExpand.setSelection(provider.areMacrosExpandedInBuildfile(parent.getSelectedConfiguration())); buildMacrosExpand.setSelection(provider.areMacrosExpandedInBuildfile(config));
} }
setDirty(false); // setDirty(false);
} }
public void removeValues(String id) { public void removeValues(String id) {
@ -297,36 +325,24 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
*/ */
public void performDefaults() { public void performDefaults() {
// Display a "Confirm" dialog box, since: IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
// 1. The defaults are immediately applied cloneConfig.setArtifactName(cloneConfig.getManagedProject().getDefaultArtifactName());
// 2. The action cannot be undone cloneConfig.setArtifactExtension(null);
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell(); IBuilder cloneBuilder = cloneConfig.getToolChain().getBuilder();
boolean shouldDefault = MessageDialog.openConfirm(shell, if (!cloneBuilder.isExtensionElement()) {
ManagedBuilderUIMessages.getResourceString("BuildSettingsBlock.defaults.title"), //$NON-NLS-1$ cloneConfig.getToolChain().removeLocalBuilder();
ManagedBuilderUIMessages.getResourceString("BuildSettingsBlock.defaults.message")); //$NON-NLS-1$
if (!shouldDefault) return;
IConfiguration config = parent.getSelectedConfiguration();
config.setArtifactName(config.getManagedProject().getDefaultArtifactName());
config.setArtifactExtension(null);
IBuilder builder = config.getToolChain().getBuilder();
if (!builder.isExtensionElement()) {
config.getToolChain().removeLocalBuilder();
} }
// Save the information that was reset
ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration());
ManagedBuildManager.saveBuildInfo(parent.getProject(), false);
//set the expand macros state to false //set the expand macros state to false
BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
provider.expandMacrosInBuildfile(config,false); provider.expandMacrosInBuildfile(cloneConfig,false);
setValues(); setValues();
makeCommandDefault.setSelection(true); makeCommandDefault.setSelection(true);
makeCommandEntry.setEditable(false); makeCommandEntry.setEditable(false);
setDirty(false); setDirty(true);
} }
/* /*
@ -334,74 +350,33 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor) * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
*/ */
public void performApply(IProgressMonitor monitor) throws CoreException { public void performApply(IProgressMonitor monitor) throws CoreException {
useDefaultMake = makeCommandDefault.getSelection();
makeCommand = makeCommandEntry.getText().trim();
artifactName = buildArtifactName.getText().trim();
artifactExt = buildArtifactExt.getText().trim();
IConfiguration selectedConfiguration = parent.getSelectedConfiguration(); IConfiguration selectedConfiguration = parent.getSelectedConfiguration();
IBuilder builder = selectedConfiguration.getToolChain().getBuilder(); IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
boolean setBuilderValues = false;
String buildCommand = cloneConfig.getBuildCommand();
String buildArgs = cloneConfig.getBuildArguments();
String artifactName = cloneConfig.getArtifactName();
String artifactExt = cloneConfig.getArtifactExtension();
// Set the build output name // Set the build output name
if (!selectedConfiguration.getArtifactName().equals(artifactName)) { if (!selectedConfiguration.getArtifactName().equals(artifactName)) {
setBuilderValues = true; selectedConfiguration.setArtifactName(artifactName);
} }
// Set the build output extension // Set the build output extension
if (!selectedConfiguration.getArtifactExtension().equals(artifactExt)) { if (!selectedConfiguration.getArtifactExtension().equals(artifactExt)) {
setBuilderValues = true; selectedConfiguration.setArtifactExtension(artifactExt);
} }
// Set the new make command // Set the new make command
String makeCommandOnly = null; if(!selectedConfiguration.getBuildCommand().equals(buildCommand))
String makeArguments = null; selectedConfiguration.setBuildCommand(buildCommand);
if (useDefaultMake) {
if (!builder.isExtensionElement()) {
setBuilderValues = true;
}
} else {
// Parse for command and arguments
String rawCommand = makeCommand;
makeCommandOnly = parseMakeCommand(rawCommand);
if (!selectedConfiguration.getBuildCommand().equals(makeCommandOnly)) {
setBuilderValues = true;
}
makeArguments = parseMakeArgs(rawCommand);
if (!selectedConfiguration.getBuildArguments().equals(makeArguments)) {
setBuilderValues = true;
}
}
if (setBuilderValues) { if(!selectedConfiguration.getBuildArguments().equals(buildArgs))
// If the configuration does not already have a "local" builder, we selectedConfiguration.setBuildArguments(buildArgs);
// need to create it.
if (builder.isExtensionElement()) {
IToolChain tc = selectedConfiguration.getToolChain();
int nnn = ManagedBuildManager.getRandomNumber();
String subId;
String tmpId;
String version;
tmpId = builder.getId();
version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
if ( version != null) { // If the 'tmpId' contains version information
subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
} else {
subId = tmpId + "." + nnn; //$NON-NLS-1$
}
String name = builder.getName() + "." + selectedConfiguration.getName(); //$NON-NLS-1$
tc.createBuilder(builder, subId, name, false);
}
// Set the builder values
selectedConfiguration.setArtifactName(artifactName);
selectedConfiguration.setArtifactExtension(artifactExt);
selectedConfiguration.setBuildCommand(makeCommandOnly);
selectedConfiguration.setBuildArguments(makeArguments);
}
BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
if(provider.canKeepMacrosInBuildfile(this.parent.getSelectedConfiguration())) provider.expandMacrosInBuildfile(
provider.expandMacrosInBuildfile(selectedConfiguration,buildMacrosExpand.getSelection()); selectedConfiguration,
provider.areMacrosExpandedInBuildfile(cloneConfig));
setDirty(false); setDirty(false);
} }
@ -534,9 +509,7 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
*/ */
public void setVisible(boolean visible) { public void setVisible(boolean visible) {
if (visible) { if (visible) {
useDefaultMake = !parent.getSelectedConfiguration().hasOverriddenBuildCommand(); setValues();
makeCommandDefault.setSelection(useDefaultMake);
makeCommandEntry.setEditable(!makeCommandDefault.getSelection());
} }
super.setVisible(visible); super.setVisible(visible);
} }
@ -547,16 +520,16 @@ public class BuildSettingsBlock extends AbstractCOptionPage {
protected void handleUseDefaultPressed() { protected void handleUseDefaultPressed() {
// If the state of the button is unchecked, then we want to enable the edit widget // If the state of the button is unchecked, then we want to enable the edit widget
boolean checked = makeCommandDefault.getSelection(); boolean checked = makeCommandDefault.getSelection();
IConfiguration config = parent.getSelectedConfigurationClone();
if (checked == true) { if (checked == true) {
// TODO: This should NOT change the configuration immediately - config.setBuildCommand(null);
// it should set an intermediate variable and wait for OK/Apply config.setBuildArguments(null);
parent.getSelectedConfiguration().setBuildCommand(null);
parent.getSelectedConfiguration().setBuildArguments(null);
makeCommandEntry.setEditable(false); makeCommandEntry.setEditable(false);
} else { } else {
makeCommandEntry.setEditable(true); makeCommandEntry.setEditable(true);
} }
setValues(); setValues();
setDirty(true);
} }
/** /**

View file

@ -62,18 +62,44 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage {
* Bookeeping variables * Bookeeping variables
*/ */
private BuildPropertyPage parent; private BuildPropertyPage parent;
private String preBuildCommand;
private String preBuildAnnounce;
private String postBuildCommand;
private String postBuildAnnounce;
// Has the page been changed? // Has the page been changed?
private boolean dirty = false; private boolean dirty = false;
private ModifyListener widgetModified = new ModifyListener() { private ModifyListener widgetModified = new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
IConfiguration config = parent.getSelectedConfigurationClone();
if(e.widget == preBuildCmd){
String val = preBuildCmd.getText().trim();
if(!val.equals(config.getPrebuildStep())){
config.setPrebuildStep(val);
setValues();
setDirty(true); setDirty(true);
} }
} else if(e.widget == preBuildAnnc){
String val = preBuildAnnc.getText().trim();
if(!val.equals(config.getPreannouncebuildStep())){
config.setPreannouncebuildStep(val);
setValues();
setDirty(true);
}
} else if(e.widget == postBuildCmd){
String val = postBuildCmd.getText().trim();
if(!val.equals(config.getPostbuildStep())){
config.setPostbuildStep(val);
setValues();
setDirty(true);
}
} else if(e.widget == postBuildAnnc){
String val = postBuildAnnc.getText().trim();
if(!val.equals(config.getPostannouncebuildStep())){
config.setPostannouncebuildStep(val);
setValues();
setDirty(true);
}
}
}
}; };
/* /*
@ -219,6 +245,7 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage {
protected void initializeValues() { protected void initializeValues() {
setValues(); setValues();
setDirty(false);
} }
public void updateValues() { public void updateValues() {
@ -227,15 +254,18 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage {
protected void setValues() { protected void setValues() {
// Fetch values from the current configuration and set in the UI // Fetch values from the current configuration and set in the UI
preBuildCommand = parent.getSelectedConfiguration().getPrebuildStep(); IConfiguration config = parent.getSelectedConfigurationClone();
preBuildCmd.setText(preBuildCommand); if(!config.getPrebuildStep().equals(preBuildCmd.getText()))
preBuildAnnounce = parent.getSelectedConfiguration().getPreannouncebuildStep(); preBuildCmd.setText(config.getPrebuildStep());
preBuildAnnc.setText(preBuildAnnounce);
postBuildCommand = parent.getSelectedConfiguration().getPostbuildStep(); if(!config.getPreannouncebuildStep().equals(preBuildAnnc.getText()))
postBuildCmd.setText(postBuildCommand); preBuildAnnc.setText(config.getPreannouncebuildStep());
postBuildAnnounce = parent.getSelectedConfiguration().getPostannouncebuildStep();
postBuildAnnc.setText(postBuildAnnounce); if(!config.getPostbuildStep().equals(postBuildCmd.getText()))
setDirty(false); //Indicate that the UI state is consistent with internal state postBuildCmd.setText(config.getPostbuildStep());
if(!config.getPostannouncebuildStep().equals(postBuildAnnc.getText()))
postBuildAnnc.setText(config.getPostannouncebuildStep());
} }
public void removeValues(String id) { public void removeValues(String id) {
@ -247,32 +277,16 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage {
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
*/ */
public void performDefaults() { public void performDefaults() {
IConfiguration config = parent.getSelectedConfiguration(); IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
boolean mustSetValue = false;
// Display a "Confirm" dialog box, since: cloneConfig.setPrebuildStep(null);
// 1. The defaults are immediately applied cloneConfig.setPreannouncebuildStep(null);
// 2. The action cannot be undone cloneConfig.setPostbuildStep(null);
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell(); cloneConfig.setPostannouncebuildStep(null);
boolean shouldDefault = MessageDialog.openConfirm(shell,
ManagedBuilderUIMessages.getResourceString("BuildStepsSettingsBlock.defaults.title"), //$NON-NLS-1$
ManagedBuilderUIMessages.getResourceString("BuildStepsSettingsBlock.defaults.message")); //$NON-NLS-1$
if (!shouldDefault) return;
// Set the build step entries to null; this will force the next fetch of the entries to get the
// values from the parent of this configuration, which should be the values from the .xml manifest
// file
config.setPrebuildStep(null);
config.setPreannouncebuildStep(null);
config.setPostbuildStep(null);
config.setPostannouncebuildStep(null);
// Save the information that was reset
ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration());
ManagedBuildManager.saveBuildInfo(parent.getProject(), false);
// Fetch and set the default values to be displayed in the UI // Fetch and set the default values to be displayed in the UI
setValues(); setValues();
setDirty(true);
} }
@ -282,34 +296,24 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage {
*/ */
public void performApply(IProgressMonitor monitor) throws CoreException { public void performApply(IProgressMonitor monitor) throws CoreException {
// Fetch the build step values from the UI and store
preBuildCommand = preBuildCmd.getText().trim();
preBuildAnnounce = preBuildAnnc.getText().trim();
postBuildCommand = postBuildCmd.getText().trim();
postBuildAnnounce = postBuildAnnc.getText().trim();
IConfiguration selectedConfiguration = parent.getSelectedConfiguration(); IConfiguration selectedConfiguration = parent.getSelectedConfiguration();
boolean mustSetValue = false; IConfiguration cloneConfig = parent.getSelectedConfigurationClone();
if (!selectedConfiguration.getPrebuildStep().equals(preBuildCommand)) { if (!selectedConfiguration.getPrebuildStep().equals(
mustSetValue = true; cloneConfig.getPrebuildStep())) {
selectedConfiguration.setPrebuildStep(cloneConfig.getPrebuildStep());
} }
else if (!selectedConfiguration.getPreannouncebuildStep().equals(preBuildAnnounce)) { if (!selectedConfiguration.getPreannouncebuildStep().equals(
mustSetValue = true; cloneConfig.getPreannouncebuildStep())) {
selectedConfiguration.setPreannouncebuildStep(cloneConfig.getPreannouncebuildStep());
} }
else if (!selectedConfiguration.getPostbuildStep().equals(postBuildCommand)) { if (!selectedConfiguration.getPostbuildStep().equals(
mustSetValue = true; cloneConfig.getPostbuildStep())) {
selectedConfiguration.setPostbuildStep(cloneConfig.getPostbuildStep());
} }
else if (!selectedConfiguration.getPostannouncebuildStep().equals(postBuildAnnounce)) { if (!selectedConfiguration.getPostannouncebuildStep().equals(
mustSetValue = true; cloneConfig.getPostannouncebuildStep())) {
} selectedConfiguration.setPostannouncebuildStep(cloneConfig.getPostannouncebuildStep());
if (mustSetValue) {
// Set all the build step values in the current configuration
selectedConfiguration.setPrebuildStep(preBuildCommand);
selectedConfiguration.setPreannouncebuildStep(preBuildAnnounce);
selectedConfiguration.setPostbuildStep(postBuildCommand);
selectedConfiguration.setPostannouncebuildStep(postBuildAnnounce);
} }
setDirty(false); //Indicate that the UI state is consistent with internal state setDirty(false); //Indicate that the UI state is consistent with internal state
@ -334,4 +338,10 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage {
public boolean isDirty() { public boolean isDirty() {
return dirty; return dirty;
} }
public void setVisible(boolean visible){
if(visible)
setValues();
super.setVisible(visible);
}
} }

View file

@ -42,6 +42,7 @@ import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro; import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractBuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
@ -254,6 +255,9 @@ public class EnvironmentBlock extends AbstractCOptionPage {
public IEnvironmentVariableSupplier[] getSuppliers(Object context){ public IEnvironmentVariableSupplier[] getSuppliers(Object context){
IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context); IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
if(context == fContext && storeDirectly())
return suppliers;
if(suppliers == null || suppliers.length == 0) if(suppliers == null || suppliers.length == 0)
return suppliers; return suppliers;
if(!(suppliers[0] instanceof UserDefinedEnvironmentSupplier)) if(!(suppliers[0] instanceof UserDefinedEnvironmentSupplier))
@ -288,7 +292,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
if(context != fContext) if(context != fContext)
return null; return null;
return (IBuildEnvironmentVariable)getUserVariables().get(name); return getUserVariable(name);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -298,8 +302,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
if(context != fContext) if(context != fContext)
return null; return null;
Collection vars = getUserVariables().values(); return getUserVariables();
return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
} }
} }
@ -457,7 +460,7 @@ public class EnvironmentBlock extends AbstractCOptionPage {
/* /*
* returns the map containing the user-defined variables * returns the map containing the user-defined variables
*/ */
private Map getUserVariables(){ private Map getUserVariablesMap(){
Map map = new HashMap(); Map map = new HashMap();
if(fUserSupplier != null) { if(fUserSupplier != null) {
if(!fDeleteAll){ if(!fDeleteAll){
@ -489,6 +492,14 @@ public class EnvironmentBlock extends AbstractCOptionPage {
return map; return map;
} }
private IBuildEnvironmentVariable[] getUserVariables(){
if(storeDirectly() && fUserSupplier != null)
return fUserSupplier.getVariables(fContext);
Collection vars = getUserVariablesMap().values();
return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
}
/* /*
* returns the HashSet holding the names of the user-deleted variables * returns the HashSet holding the names of the user-deleted variables
*/ */
@ -515,28 +526,41 @@ public class EnvironmentBlock extends AbstractCOptionPage {
private void addUserVariable(String name, String value, int op, String delimiter){ private void addUserVariable(String name, String value, int op, String delimiter){
if(!canCreate(name)) if(!canCreate(name))
return; return;
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.createVariable(name,value, op, delimiter, fContext);
} else {
fDeleteAll = false; fDeleteAll = false;
BuildEnvVar newVar = new BuildEnvVar(name,value,op,delimiter); BuildEnvVar newVar = new BuildEnvVar(name,value,op,delimiter);
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
name = name.toUpperCase(); name = name.toUpperCase();
getDeletedUserVariableNames().remove(name); getDeletedUserVariableNames().remove(name);
getAddedUserVariables().put(name,newVar); getAddedUserVariables().put(name,newVar);
}
fModified = true; fModified = true;
} }
protected boolean storeDirectly(){
if(fContext instanceof IConfiguration)
return ((IConfiguration)fContext).isTemporary();
return false;
}
/* /*
* deletes a user variable * deletes a user variable
* the variables deleted are stored in the fDeletedUserVariableNames HashSet, and are not actually deleted from the user supplier * the variables deleted are stored in the fDeletedUserVariableNames HashSet, and are not actually deleted from the user supplier
* the applyUserVariables() should be called to delete those variabes from the user supplier * the applyUserVariables() should be called to delete those variabes from the user supplier
*/ */
private void deleteUserVariable(String name){ private void deleteUserVariable(String name){
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.deleteVariable(name, fContext);
} else {
fDeleteAll = false; fDeleteAll = false;
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
name = name.toUpperCase(); name = name.toUpperCase();
getAddedUserVariables().remove(name); getAddedUserVariables().remove(name);
getDeletedUserVariableNames().add(name); getDeletedUserVariableNames().add(name);
}
fModified = true; fModified = true;
} }
@ -545,10 +569,13 @@ public class EnvironmentBlock extends AbstractCOptionPage {
* the applyUserVariables() should be called to delete those variabes from the user supplier * the applyUserVariables() should be called to delete those variabes from the user supplier
*/ */
private void deleteAllUserVariables(){ private void deleteAllUserVariables(){
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.deleteAll(fContext);
} else {
fDeleteAll = true; fDeleteAll = true;
getDeletedUserVariableNames().clear(); getDeletedUserVariableNames().clear();
getAddedUserVariables().clear(); getAddedUserVariables().clear();
}
fModified = true; fModified = true;
} }
@ -570,13 +597,13 @@ public class EnvironmentBlock extends AbstractCOptionPage {
* returns a user variable of a given name * returns a user variable of a given name
*/ */
private IBuildEnvironmentVariable getUserVariable(String name){ private IBuildEnvironmentVariable getUserVariable(String name){
Map vars = getUserVariables();
if(vars == null)
return null;
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
name = name.toUpperCase(); name = name.toUpperCase();
return (IBuildEnvironmentVariable)vars.get(name);
if(fUserSupplier != null && storeDirectly())
return fUserSupplier.getVariable(name, fContext);
return (IBuildEnvironmentVariable)getUserVariablesMap().get(name);
} }
/* /*
@ -585,6 +612,16 @@ public class EnvironmentBlock extends AbstractCOptionPage {
*/ */
private void applyUserVariables(){ private void applyUserVariables(){
if(fUserSupplier != null){ if(fUserSupplier != null){
if(storeDirectly()){
if(getContainer() instanceof AbstractBuildPropertyPage
&& fContext instanceof IConfiguration){
AbstractBuildPropertyPage page = (AbstractBuildPropertyPage)getContainer();
IConfiguration realCfg = page.getRealConfig((IConfiguration)fContext);
IBuildEnvironmentVariable vars[] = getUserVariables();
UserDefinedEnvironmentSupplier supplier = EnvironmentVariableProvider.fUserSupplier;
supplier.setVariables(vars,realCfg);
}
} else {
if(fDeleteAll){ if(fDeleteAll){
fUserSupplier.deleteAll(fContext); fUserSupplier.deleteAll(fContext);
} }
@ -605,12 +642,14 @@ public class EnvironmentBlock extends AbstractCOptionPage {
} }
} }
} }
}
/* /*
* applies user variables and asks the user supplier to serialize * applies user variables and asks the user supplier to serialize
*/ */
private void storeUserVariables(){ private void storeUserVariables(){
applyUserVariables(); applyUserVariables();
if(fUserSupplier != null) if(fUserSupplier != null)
fUserSupplier.serialize(false); fUserSupplier.serialize(false);
} }
@ -813,12 +852,11 @@ public class EnvironmentBlock extends AbstractCOptionPage {
// handleSelectionChanged(fEditableList); // handleSelectionChanged(fEditableList);
if(fUserSupplier != null) { if(fUserSupplier != null) {
Collection vars = getUserVariables().values(); IBuildEnvironmentVariable variables[] = getUserVariables();
Iterator iter = vars.iterator();
List list = new ArrayList(vars.size()); List list = new ArrayList(variables.length);
while(iter.hasNext()){ for( int i = 0; i < variables.length; i++ ){
IBuildEnvironmentVariable userVar = (IBuildEnvironmentVariable)iter.next(); IBuildEnvironmentVariable userVar = variables[i];
if(userVar != null){ if(userVar != null){
IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true); IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true);
IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar); IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar);

View file

@ -150,10 +150,10 @@ public class EnvironmentSetBlock extends AbstractCOptionPage {
if(fParentContainer instanceof BuildPropertyPage){ if(fParentContainer instanceof BuildPropertyPage){
BuildPropertyPage page = (BuildPropertyPage)fParentContainer; BuildPropertyPage page = (BuildPropertyPage)fParentContainer;
if(page.getSelectedConfiguration() != null) if(page.getSelectedConfigurationClone() != null)
fFolderTabs[1].setContext(page.getSelectedConfiguration().getManagedProject()); fFolderTabs[1].setContext(page.getSelectedConfigurationClone().getManagedProject());
fFolderTabs[0].setContext(page.getSelectedConfiguration()); fFolderTabs[0].setContext(page.getSelectedConfigurationClone());
fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo()); fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
} }
else { else {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2004 IBM Corporation and others. * Copyright (c) 2002, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,10 +12,11 @@
package org.eclipse.cdt.managedbuilder.internal.ui; package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectOptionPage; import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectOptionPage;
import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectWizard; import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectWizard;
import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock; import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock;
@ -26,9 +27,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
public class ErrorParserBlock extends AbstractErrorParserBlock { public class ErrorParserBlock extends AbstractErrorParserBlock {
private BuildPropertyPage parent;
private String errorParsers[];
public ErrorParserBlock() { public ErrorParserBlock(BuildPropertyPage parent) {
super(); super();
this.parent = parent;
} }
protected String[] getErrorParserIDs(IConfiguration config) { protected String[] getErrorParserIDs(IConfiguration config) {
@ -45,8 +49,11 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
} }
protected String[] getErrorParserIDs(IProject project) { protected String[] getErrorParserIDs(IProject project) {
IConfiguration config = ManagedBuildManager.getSelectedConfiguration(project);
if (config == null) { IConfiguration config = null;
if(parent != null)
config = parent.getSelectedConfigurationClone();
else if ((config = ManagedBuildManager.getSelectedConfiguration(project)) == null) {
// This case occurs when modifying the properties of an existing // This case occurs when modifying the properties of an existing
// managed build project, and the user selects the error parsers // managed build project, and the user selects the error parsers
// page before the "C/C++ Build" page. // page before the "C/C++ Build" page.
@ -66,6 +73,9 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
// Get the currently selected configuration from the page's container // Get the currently selected configuration from the page's container
// This is invoked by the managed builder new project wizard before the // This is invoked by the managed builder new project wizard before the
// project is created. // project is created.
if(parent != null){
return getErrorParserIDs(parent.getSelectedConfigurationClone());
}
ICOptionContainer container = getContainer(); ICOptionContainer container = getContainer();
if (container instanceof NewManagedProjectOptionPage) { if (container instanceof NewManagedProjectOptionPage) {
NewManagedProjectOptionPage parent = (NewManagedProjectOptionPage)getContainer(); NewManagedProjectOptionPage parent = (NewManagedProjectOptionPage)getContainer();
@ -82,7 +92,11 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
} }
public void saveErrorParsers(IProject project, String[] parsers) { public void saveErrorParsers(IProject project, String[] parsers) {
IConfiguration config = ManagedBuildManager.getSelectedConfiguration(project); IConfiguration config = null;
if(parent != null)
config = parent.getSelectedConfigurationClone();
else
config = ManagedBuildManager.getSelectedConfiguration(project);
if (config != null) { if (config != null) {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
for (int i = 0; i < parsers.length; i++) { for (int i = 0; i < parsers.length; i++) {
@ -97,9 +111,31 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
return null; return null;
} }
protected boolean checkIds(String ids1[], String ids2[]){
if(ids1.length != ids2.length)
return true;
for(int i = 0; i < ids1.length; i++){
String id = ids1[i];
int j;
for(j = 0; j < ids2.length; j++){
if(id.equals(ids2[j]))
break;
}
if(j == ids2.length)
return true;
}
return false;
}
protected void setValues() { protected void setValues() {
super.setValues(); super.setValues();
if(parent != null && parent.getSelectedConfigurationClone() != null)
errorParsers = getErrorParserIDs(parent.getSelectedConfigurationClone());
// TODO: This reset belongs in AbstractErrorParserBlock.java? // TODO: This reset belongs in AbstractErrorParserBlock.java?
// Reset the "dirty" flag // Reset the "dirty" flag
listDirty = false; listDirty = false;
@ -108,6 +144,11 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
public void performApply(IProgressMonitor monitor) throws CoreException { public void performApply(IProgressMonitor monitor) throws CoreException {
super.performApply(monitor); super.performApply(monitor);
if(parent != null){
IConfiguration realConfig = ManagedBuildManager.getSelectedConfiguration(parent.getProject());
realConfig.setErrorParserIds(parent.getSelectedConfigurationClone().getErrorParserIds());
errorParsers = getErrorParserIDs(parent.getSelectedConfigurationClone());
}
// TODO: This reset belongs in AbstractErrorParserBlock.java? // TODO: This reset belongs in AbstractErrorParserBlock.java?
// Reset the "dirty" flag // Reset the "dirty" flag
listDirty = false; listDirty = false;
@ -127,4 +168,32 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
public boolean isDirty() { public boolean isDirty() {
return listDirty; return listDirty;
} }
public void setVisible(boolean visible){
if(parent != null){
if(visible){
boolean dirtyState = listDirty;
updateListControl(parent.getSelectedConfigurationClone().getErrorParserList());
if(dirtyState != listDirty)
listDirty = checkIds(parent.getSelectedConfigurationClone().getErrorParserList(),errorParsers);
} else {
try {
super.performApply(null);
} catch (CoreException e) {
}
}
}
super.setVisible(visible);
}
protected void setDefaults() {
if(parent != null){
IConfiguration cfg = parent.getSelectedConfigurationClone();
cfg.setErrorParserIds(null);
updateListControl(cfg.getErrorParserList());
listDirty = true;
} else
super.setDefaults();
}
} }

View file

@ -20,9 +20,9 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.internal.ui.util.SWTUtil; import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor; import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider; import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo; import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo;
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor; import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
@ -36,6 +36,7 @@ import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroStatus;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier;
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractBuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
@ -328,6 +329,10 @@ public class MacrosBlock extends AbstractCOptionPage {
*/ */
public IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){ public IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){
IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData); IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData);
if(contextType == fContextType && contextData == fContextData && storeDirectly())
return suppliers;
if(suppliers == null || suppliers.length == 0) if(suppliers == null || suppliers.length == 0)
return suppliers; return suppliers;
if(!(suppliers[0] instanceof UserDefinedMacroSupplier)) if(!(suppliers[0] instanceof UserDefinedMacroSupplier))
@ -362,7 +367,7 @@ public class MacrosBlock extends AbstractCOptionPage {
if(contextType != fContextType || contextData != fContextData) if(contextType != fContextType || contextData != fContextData)
return null; return null;
return (IBuildMacro)getUserMacros().get(name); return getUserMacro(name);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -372,8 +377,7 @@ public class MacrosBlock extends AbstractCOptionPage {
if(contextType != fContextType || contextData != fContextData) if(contextType != fContextType || contextData != fContextData)
return null; return null;
Collection macros = getUserMacros().values(); return getUserMacros();
return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]);
} }
} }
@ -557,10 +561,7 @@ public class MacrosBlock extends AbstractCOptionPage {
fIsEditable = editable; fIsEditable = editable;
} }
/* private Map getUserMacrosMap(){
* returns the map containing the user-defined macros
*/
private Map getUserMacros(){
Map map = new HashMap(); Map map = new HashMap();
if(fUserSupplier != null) { if(fUserSupplier != null) {
if(!fDeleteAll){ if(!fDeleteAll){
@ -588,6 +589,18 @@ public class MacrosBlock extends AbstractCOptionPage {
return map; return map;
} }
/*
* returns the map containing the user-defined macros
*/
private IBuildMacro[] getUserMacros(){
if(storeDirectly() && fUserSupplier != null)
return fUserSupplier.getMacros(fContextType,fContextData);
Collection macros = getUserMacrosMap().values();
return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]);
}
/* /*
* returns the HashSet holding the names of the user-deleted macros * returns the HashSet holding the names of the user-deleted macros
*/ */
@ -611,17 +624,20 @@ public class MacrosBlock extends AbstractCOptionPage {
* the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier * the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier
* the applyUserMacros() should be called to store those macros to the user supplier * the applyUserMacros() should be called to store those macros to the user supplier
*/ */
private void addUserMacro(String name, int type, String value){ /* private void addUserMacro(String name, int type, String value){
if(!canCreate(name)) if(!canCreate(name))
return; return;
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.createMacro(newMacro, fContextType, fContextData);
} else {
fDeleteAll = false; fDeleteAll = false;
BuildMacro newMacro = new BuildMacro(name,type,value); BuildMacro newMacro = new BuildMacro(name,type,value);
getDeletedUserMacroNames().remove(name); getDeletedUserMacroNames().remove(name);
getAddedUserMacros().put(name,newMacro); getAddedUserMacros().put(name,newMacro);
}
fModified = true; fModified = true;
} }
*/
/* /*
* creates a user macro * creates a user macro
* the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier * the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier
@ -631,9 +647,14 @@ public class MacrosBlock extends AbstractCOptionPage {
String name = newMacro.getName(); String name = newMacro.getName();
if(!canCreate(name)) if(!canCreate(name))
return; return;
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.createMacro(newMacro, fContextType, fContextData);
} else {
fDeleteAll = false; fDeleteAll = false;
getDeletedUserMacroNames().remove(name); getDeletedUserMacroNames().remove(name);
getAddedUserMacros().put(name,newMacro); getAddedUserMacros().put(name,newMacro);
}
fModified = true; fModified = true;
} }
@ -643,27 +664,34 @@ public class MacrosBlock extends AbstractCOptionPage {
* the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier * the macros created are stored in the fAddedUserMacros Map, and are not actually added to the user supplier
* the applyUserMacros() should be called to store those macros to the user supplier * the applyUserMacros() should be called to store those macros to the user supplier
*/ */
private void addUserMacro(String name, int type, String value[]){ /* private void addUserMacro(String name, int type, String value[]){
if(!canCreate(name)) if(!canCreate(name))
return; return;
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.createMacro(newMacro, fContextType, fContextData);
} else {
fDeleteAll = false; fDeleteAll = false;
BuildMacro newMacro = new BuildMacro(name,type,value); BuildMacro newMacro = new BuildMacro(name,type,value);
getDeletedUserMacroNames().remove(name); getDeletedUserMacroNames().remove(name);
getAddedUserMacros().put(name,newMacro); getAddedUserMacros().put(name,newMacro);
}
fModified = true; fModified = true;
} }
*/
/* /*
* deletes a user macro * deletes a user macro
* the macros deleted are stored in the fDeletedUserMacroNames HashSet, and are not actually deleted from the user supplier * the macros deleted are stored in the fDeletedUserMacroNames HashSet, and are not actually deleted from the user supplier
* the applyUserMacros() should be called to delete those macros from the user supplier * the applyUserMacros() should be called to delete those macros from the user supplier
*/ */
private void deleteUserMacro(String name){ private void deleteUserMacro(String name){
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.deleteMacro(name, fContextType, fContextData);
} else {
fDeleteAll = false; fDeleteAll = false;
getAddedUserMacros().remove(name); getAddedUserMacros().remove(name);
getDeletedUserMacroNames().add(name); getDeletedUserMacroNames().add(name);
}
fModified = true; fModified = true;
} }
@ -672,10 +700,13 @@ public class MacrosBlock extends AbstractCOptionPage {
* the applyUserMacros() should be called to delete those macros from the user supplier * the applyUserMacros() should be called to delete those macros from the user supplier
*/ */
private void deleteAllUserMacros(){ private void deleteAllUserMacros(){
if(storeDirectly() && fUserSupplier != null){
fUserSupplier.deleteAll(fContextType, fContextData);
} else {
fDeleteAll = true; fDeleteAll = true;
getDeletedUserMacroNames().clear(); getDeletedUserMacroNames().clear();
getAddedUserMacros().clear(); getAddedUserMacros().clear();
}
fModified = true; fModified = true;
} }
@ -697,7 +728,10 @@ public class MacrosBlock extends AbstractCOptionPage {
* returns a user macro of a given name * returns a user macro of a given name
*/ */
private IBuildMacro getUserMacro(String name){ private IBuildMacro getUserMacro(String name){
Map macros = getUserMacros(); if(storeDirectly() && fUserSupplier != null)
return fUserSupplier.getMacro(name,fContextType,fContextData);
Map macros = getUserMacrosMap();
if(macros == null) if(macros == null)
return null; return null;
@ -710,6 +744,17 @@ public class MacrosBlock extends AbstractCOptionPage {
*/ */
private void applyUserMacros(){ private void applyUserMacros(){
if(fUserSupplier != null){ if(fUserSupplier != null){
if(storeDirectly()){
if(getContainer() instanceof AbstractBuildPropertyPage
&& fContextType == IBuildMacroProvider.CONTEXT_CONFIGURATION
&& fContextData instanceof IConfiguration){
AbstractBuildPropertyPage page = (AbstractBuildPropertyPage)getContainer();
IConfiguration realCfg = page.getRealConfig((IConfiguration)fContextData);
IBuildMacro macros[] = getUserMacros();
UserDefinedMacroSupplier supplier = BuildMacroProvider.fUserDefinedMacroSupplier;
supplier.setMacros(macros, IBuildMacroProvider.CONTEXT_CONFIGURATION, realCfg);
}
} else {
if(fDeleteAll){ if(fDeleteAll){
fUserSupplier.deleteAll(fContextType,fContextData); fUserSupplier.deleteAll(fContextType,fContextData);
} }
@ -730,6 +775,7 @@ public class MacrosBlock extends AbstractCOptionPage {
} }
} }
} }
}
/* /*
* applies user macros and asks the user supplier to serialize * applies user macros and asks the user supplier to serialize
@ -906,12 +952,11 @@ public class MacrosBlock extends AbstractCOptionPage {
if(fEditableTable == null || fContextType == 0) if(fEditableTable == null || fContextType == 0)
return; return;
Collection values = getUserMacros().values(); IBuildMacro macros[] = getUserMacros();
ArrayList list = new ArrayList(values.size()); ArrayList list = new ArrayList(macros.length);
for(Iterator iter = values.iterator(); iter.hasNext();){ for(int i = 0; i < macros.length; i++){
Object next = iter.next(); if(macros[i] != null)
if(next != null) list.add(macros[i]);
list.add(next);
} }
fEditableTable.setInput(list.toArray(new IBuildMacro[list.size()])); fEditableTable.setInput(list.toArray(new IBuildMacro[list.size()]));
} }
@ -1238,4 +1283,12 @@ public class MacrosBlock extends AbstractCOptionPage {
} }
return null; return null;
} }
protected boolean storeDirectly(){
if(fContextType == IBuildMacroProvider.CONTEXT_CONFIGURATION
&& fContextData instanceof IConfiguration)
return ((IConfiguration)fContextData).isTemporary();
return false;
}
} }

View file

@ -153,10 +153,10 @@ import org.eclipse.swt.widgets.Group;
if(fParentContainer instanceof BuildPropertyPage){ if(fParentContainer instanceof BuildPropertyPage){
BuildPropertyPage page = (BuildPropertyPage)fParentContainer; BuildPropertyPage page = (BuildPropertyPage)fParentContainer;
if(page.getSelectedConfiguration() != null) if(page.getSelectedConfigurationClone() != null)
fFolderTabs[1].setContext(IBuildMacroProvider.CONTEXT_PROJECT,page.getSelectedConfiguration().getManagedProject()); fFolderTabs[1].setContext(IBuildMacroProvider.CONTEXT_PROJECT,page.getSelectedConfigurationClone().getManagedProject());
fFolderTabs[0].setContext(IBuildMacroProvider.CONTEXT_CONFIGURATION,page.getSelectedConfiguration()); fFolderTabs[0].setContext(IBuildMacroProvider.CONTEXT_CONFIGURATION,page.getSelectedConfigurationClone());
fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo()); fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
} }
/* else { /* else {

View file

@ -14,6 +14,7 @@ import java.util.Iterator;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPreferenceStore;
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
import org.eclipse.cdt.ui.dialogs.BinaryParserBlock; import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionPage; import org.eclipse.cdt.ui.dialogs.ICOptionPage;
@ -76,7 +77,7 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
addTab(toolsSettingsBlock = new ToolsSettingsBlock((BuildPropertyPage) fParent, element)); addTab(toolsSettingsBlock = new ToolsSettingsBlock((BuildPropertyPage) fParent, element));
addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent)); addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent));
addTab(buildStepSettingsBlock = new BuildStepSettingsBlock((BuildPropertyPage) fParent)); addTab(buildStepSettingsBlock = new BuildStepSettingsBlock((BuildPropertyPage) fParent));
addTab(errParserBlock = new ErrorParserBlock()); addTab(errParserBlock = new ErrorParserBlock((BuildPropertyPage) fParent));
addTab(binaryParserBlock = new BinaryParserBlock()); addTab(binaryParserBlock = new BinaryParserBlock());
addTab(environmentBlock = new EnvironmentSetBlock((BuildPropertyPage) fParent)); addTab(environmentBlock = new EnvironmentSetBlock((BuildPropertyPage) fParent));
addTab(macrosBlock = new MacrosSetBlock((BuildPropertyPage) fParent)); addTab(macrosBlock = new MacrosSetBlock((BuildPropertyPage) fParent));
@ -331,7 +332,7 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
return null; return null;
} }
public IPreferenceStore getToolSettingsPreferenceStore() public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore()
{ {
return toolsSettingsBlock.getPreferenceStore(); return toolsSettingsBlock.getPreferenceStore();
} }
@ -419,4 +420,19 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
return false; return false;
} }
public boolean containsDefaults(){
Iterator iter = getOptionPages().iterator();
while (iter.hasNext()) {
ICOptionPage tab = (ICOptionPage)iter.next();
if(tab instanceof ToolsSettingsBlock){
if(!((ToolsSettingsBlock)tab).containsDefaults())
return false;
} else if(tab instanceof ResourceCustomBuildStepBlock) {
if(!((ResourceCustomBuildStepBlock)tab).containsDefaults())
return false;
} else
return false;
}
return true;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2004 IBM Corporation and others. * Copyright (c) 2002, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -35,7 +35,7 @@ public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs() * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
*/ */
protected void addTabs() { protected void addTabs() {
errParserBlock = new ErrorParserBlock(); errParserBlock = new ErrorParserBlock(null);
addTab(errParserBlock); addTab(errParserBlock);
addTab(binaryParserBlock = new BinaryParserBlock()); addTab(binaryParserBlock = new BinaryParserBlock());
} }

View file

@ -10,14 +10,17 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui; package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
@ -26,18 +29,20 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
@ -88,7 +93,7 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
private static final String rcbsToolInputTypeName = new String("Resource Custom Build Step Input Type"); //$NON-NLS-1$ private static final String rcbsToolInputTypeName = new String("Resource Custom Build Step Input Type"); //$NON-NLS-1$
private static final String rcbsToolOutputTypeId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype"); //$NON-NLS-1$ private static final String rcbsToolOutputTypeId = new String("org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype"); //$NON-NLS-1$
private static final String rcbsToolOutputTypeName = new String("Resource Custom Build Step Output Type"); //$NON-NLS-1$ private static final String rcbsToolOutputTypeName = new String("Resource Custom Build Step Output Type"); //$NON-NLS-1$
private static final String PATH_SEPERATOR = ";"; //$NON-NLS-1$
/* /*
* Dialog widgets * Dialog widgets
*/ */
@ -102,17 +107,55 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
* Bookeeping variables * Bookeeping variables
*/ */
private ResourceBuildPropertyPage resParent; private ResourceBuildPropertyPage resParent;
private String resBuildInputs;
private String resBuildOutputs;
private String resBuildAnnouncement;
private String resBuildCommand;
// Has the page been changed? // Has the page been changed?
private boolean dirty = false; private boolean dirty = false;
private ModifyListener widgetModified = new ModifyListener() { private ModifyListener widgetModified = new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
if(e.widget == buildInputs){
String val = buildInputs.getText().trim();
IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
if(rcbs != null){
IAdditionalInput input = rcbs.getInputTypes()[0].getAdditionalInputs()[0];
if(!createList(input.getPaths()).equals(val)){
input.setPaths(val);
setValues();
setDirty(true); setDirty(true);
} }
}
} else if(e.widget == buildOutputs){
String val = buildOutputs.getText().trim();
IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
if(rcbs != null){
IOutputType output = rcbs.getOutputTypes()[0];
if(!createList(output.getOutputNames()).equals(val)){
output.setOutputNames(val);
setValues();
setDirty(true);
}
}
} else if(e.widget == buildCommand){
String val = buildCommand.getText().trim();
IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
if(rcbs != null && !rcbs.getToolCommand().equals(val)){
rcbs.setToolCommand(val);
setValues();
setDirty(true);
}
} else if(e.widget == buildDescription){
String val = buildDescription.getText().trim();
IResourceConfiguration rcCfg = resParent.getCurrentResourceConfigClone();
ITool rcbs = getRcbsTool(rcCfg,!"".equals(val)); //$NON-NLS-1$
if(rcbs != null && !rcbs.getAnnouncement().equals(val)){
rcbs.setAnnouncement(val);
setValues();
setDirty(true);
}
}
}
}; };
@ -177,6 +220,14 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
gd1.horizontalSpan = 1; gd1.horizontalSpan = 1;
gd1.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; gd1.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
rcbsApplicabilitySelector.setLayoutData(gd1); rcbsApplicabilitySelector.setLayoutData(gd1);
rcbsApplicabilitySelector.addSelectionListener(
new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
resParent.getCurrentResourceConfigClone().setRcbsApplicability(
selectionToApplicability(rcbsApplicabilitySelector.getSelectionIndex()));
setDirty(true);
}
});
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -297,6 +348,7 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
protected void initializeValues() { protected void initializeValues() {
setValues(); setValues();
setDirty(false);
} }
public void updateValues() { public void updateValues() {
@ -304,11 +356,8 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
} }
protected void setValues() { protected void setValues() {
IResourceConfiguration resConfig; IResourceConfiguration resConfig = resParent.getCurrentResourceConfigClone();
String[] buildInputsPaths;
String[] buildOutputsPaths;
boolean foundRcbsTool = false;
int idx;
/* /*
* Examine the tools defined for the resource configuration. * Examine the tools defined for the resource configuration.
* There should be at most one tool defined for a custom build step which was not an * There should be at most one tool defined for a custom build step which was not an
@ -317,44 +366,25 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
* If the rcbs tool has not been defined yet, clear the field values. * If the rcbs tool has not been defined yet, clear the field values.
* Finally, set the rcbsApplicability selector from the current value in the resource configuration. * Finally, set the rcbsApplicability selector from the current value in the resource configuration.
*/ */
resConfig = resParent.getCurrentResourceConfig(); ITool tool = getRcbsTool(resConfig,false);
ITool [] tools = resConfig.getTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
if (tool.getCustomBuildStep() && !tool.isExtensionElement()) {
buildInputsPaths = tool.getInputTypes()[0].getAdditionalInputs()[0].getPaths();
resBuildInputs = ""; //$NON-NLS-1$
for ( int j = 0; j < buildInputsPaths.length; j++ ){
resBuildInputs += buildInputsPaths[j] + ";"; //$NON-NLS-1$
}
int len = resBuildInputs.length();
resBuildInputs = resBuildInputs.substring(0,len-1);
buildInputs.setText(resBuildInputs);
buildOutputsPaths = tool.getOutputTypes()[0].getOutputNames(); if(tool != null){
resBuildOutputs = ""; //$NON-NLS-1$ String tmp = createList(tool.getInputTypes()[0].getAdditionalInputs()[0].getPaths());
for ( int j = 0; j < buildOutputsPaths.length; j++ ){ if(!tmp.equals(buildInputs.getText()))
resBuildOutputs += buildOutputsPaths[j] + ";"; //$NON-NLS-1$ buildInputs.setText(tmp);
}
len = resBuildOutputs.length();
resBuildOutputs = resBuildOutputs.substring(0,len-1);
buildOutputs.setText(resBuildOutputs);
resBuildCommand = tool.getToolCommand(); tmp = createList(tool.getOutputTypes()[0].getOutputNames());
buildCommand.setText(resBuildCommand); if(!tmp.equals(buildOutputs.getText()))
buildOutputs.setText(tmp);
resBuildAnnouncement = tool.getAnnouncement(); tmp = tool.getToolCommand();
buildDescription.setText(resBuildAnnouncement); if(!tmp.equals(buildCommand.getText()))
buildCommand.setText(tmp);
foundRcbsTool = true; tmp = tool.getAnnouncement();
break; if(!tmp.equals(buildDescription.getText()))
} buildDescription.setText(tmp);
} } else {
/*
* If an rcbs tool has not been created yet, just blank the fields.
*/
if(!foundRcbsTool) {
buildInputs.setText(""); //$NON-NLS-1$ buildInputs.setText(""); //$NON-NLS-1$
buildOutputs.setText(""); //$NON-NLS-1$ buildOutputs.setText(""); //$NON-NLS-1$
buildCommand.setText(""); //$NON-NLS-1$ buildCommand.setText(""); //$NON-NLS-1$
@ -364,29 +394,36 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
/* /*
* Set the state of the rcbs applicability selector. * Set the state of the rcbs applicability selector.
*/ */
switch(resConfig.getRcbsApplicability()){ rcbsApplicabilitySelector.select(applicabilityToSelection(resConfig.getRcbsApplicability()));
case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE:
idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE)); // setDirty(false);
break; }
case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER:
idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER)); private int selectionToApplicability(int index){
break; String sel = rcbsApplicabilitySelector.getItem(index);
case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE: if(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE).equals(sel)){
idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE)); return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE;
break; } else if(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER).equals(sel)){
case IResourceConfiguration.KIND_DISABLE_RCBS_TOOL: return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER;
idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_DISABLE)); } else if(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE).equals(sel)){
break; return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE;
default: }
/* return IResourceConfiguration.KIND_DISABLE_RCBS_TOOL;
* If we get an unexpected value, use the normal default of override. }
*/
idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE)); private int applicabilityToSelection(int val){
break; switch(val){
} case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER:
rcbsApplicabilitySelector.select(idx); return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER));
case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE:
return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE));
case IResourceConfiguration.KIND_DISABLE_RCBS_TOOL:
return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_DISABLE));
case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE:
default:
return rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE));
}
setDirty(false);
} }
public void removeValues(String id) { public void removeValues(String id) {
@ -398,46 +435,13 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
*/ */
public void performDefaults() { public void performDefaults() {
IResourceConfiguration resConfig; IResourceConfiguration cloneResConfig;
// Display a "Confirm" dialog box, since: cloneResConfig = resParent.getCurrentResourceConfigClone();
// 1. The defaults are immediately applied removeRcbsTools(cloneResConfig);
// 2. The action cannot be undone
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
boolean shouldDefault = MessageDialog.openConfirm(shell,
ManagedBuilderUIMessages.getResourceString(CONFIRM_DEFAULT_TITLE),
ManagedBuilderUIMessages.getResourceString(CONFIRM_DEFAULT_MESSAGE));
if (!shouldDefault) return;
/*
* Examine the tools defined for the resource configuration.
* There should be at most one tool defined for a custom build step which was not an
* extension element (not defined by a tool integrator in a manifest).
* If the rcbs tool has been defined, remove the tool from the resource configuration.
* If the rcbs tool was not disabled before now, indicate that a rebuild will be needed.
* Set the rcbsApplicability in the resource configuration to "disabled" by default.
* Update the field values.
*/
resConfig = resParent.getCurrentResourceConfig();
ITool [] tools = resConfig.getTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
if (tool.getCustomBuildStep() && !tool.isExtensionElement()) {
resConfig.removeTool(tool);
break;
}
}
/*
* If the rcbs tool was not disabled, it will be after restoring defaults.
* This transition implies a rebuild is needed.
*/
if(resConfig.getRcbsApplicability() != IResourceConfiguration.KIND_DISABLE_RCBS_TOOL){
resConfig.getParent().setRebuildState(true);
}
resConfig.setRcbsApplicability(IResourceConfiguration.KIND_DISABLE_RCBS_TOOL);
setValues(); setValues();
setDirty(false); setDirty(true);
} }
/* /*
@ -445,11 +449,10 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor) * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor)
*/ */
public void performApply(IProgressMonitor monitor) throws CoreException { public void performApply(IProgressMonitor monitor) throws CoreException {
IResourceConfiguration resConfig; IResourceConfiguration cloneResConfig;
boolean foundRcbsTool = false; IResourceConfiguration rcConfig;
boolean rebuildNeeded = false; boolean rebuildNeeded = false;
boolean rcbsStillDisabledSoNoRebuild = false; boolean rcbsStillDisabledSoNoRebuild = false;
int idx;
/* /*
* Gather the users input. * Gather the users input.
@ -464,42 +467,31 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
* selection. * selection.
*/ */
resBuildInputs = buildInputs.getText().trim(); cloneResConfig = resParent.getCurrentResourceConfigClone();
resBuildOutputs = buildOutputs.getText().trim(); ITool cloneTool = getRcbsTool(cloneResConfig, false);
resBuildCommand = buildCommand.getText().trim();
resBuildAnnouncement = buildDescription.getText().trim();
resConfig = resParent.getCurrentResourceConfig(); rcConfig = resParent.getCurrentResourceConfig(false);
ITool [] tools = resConfig.getTools(); if(cloneTool == null){
for (int i = 0; i < tools.length; i++) { if(rcConfig != null)
ITool tool = tools[i]; rebuildNeeded = removeRcbsTools(rcConfig);
if (tool.getCustomBuildStep() && !tool.isExtensionElement()) { } else {
tool.getInputTypes()[0].getAdditionalInputs()[0].setPaths(resBuildInputs); if(rcConfig == null)
tool.getOutputTypes()[0].setOutputNames(resBuildOutputs); rcConfig = resParent.getCurrentResourceConfig(true);
tool.setToolCommand(resBuildCommand);
tool.setAnnouncement(resBuildAnnouncement);
if (tool.isDirty()) {
rebuildNeeded = true;
}
foundRcbsTool = true;
break;
}
}
if(!foundRcbsTool) {
ITool rcbsTool;
IInputType rcbsToolInputType;
IAdditionalInput rcbsToolInputTypeAdditionalInput;
IOutputType rcbsToolOutputType;
rcbsTool = resConfig.createTool(null,rcbsToolId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolName,false); //$NON-NLS-1$
rcbsToolInputType = rcbsTool.createInputType(null,rcbsToolInputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolInputTypeName,false); //$NON-NLS-1$ ITool realTool = getRcbsTool(rcConfig,true);
rcbsToolInputTypeAdditionalInput = rcbsToolInputType.createAdditionalInput(resBuildInputs);
rcbsToolInputTypeAdditionalInput.setKind(IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY); realTool.getInputTypes()[0].getAdditionalInputs()[0].setPaths(
rcbsToolOutputType = rcbsTool.createOutputType(null,rcbsToolOutputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolOutputTypeName,false); //$NON-NLS-1$ createList(
rcbsToolOutputType.setOutputNames(resBuildOutputs); cloneTool.getInputTypes()[0].getAdditionalInputs()[0].getPaths()));
rcbsTool.setCustomBuildStep(true); realTool.getOutputTypes()[0].setOutputNames(
rcbsTool.setToolCommand(resBuildCommand); createList(
rcbsTool.setAnnouncement(resBuildAnnouncement); cloneTool.getOutputTypes()[0].getOutputNames()));
realTool.setToolCommand(
cloneTool.getToolCommand());
realTool.setAnnouncement(
cloneTool.getAnnouncement());
if (realTool.isDirty()) {
rebuildNeeded = true; rebuildNeeded = true;
} }
@ -507,34 +499,84 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
* Get the state of the rcbs applicability selector and set the rcbsApplicability attribute in the * Get the state of the rcbs applicability selector and set the rcbsApplicability attribute in the
* resource configuration. * resource configuration.
*/ */
idx = rcbsApplicabilitySelector.getSelectionIndex(); rcConfig.setRcbsApplicability(
if(idx == rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER))) { cloneResConfig.getRcbsApplicability());
resConfig.setRcbsApplicability(IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER);
} else if(rcConfig.getRcbsApplicability() == IResourceConfiguration.KIND_DISABLE_RCBS_TOOL)
if(idx == rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE))) {
resConfig.setRcbsApplicability(IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE);
} else
if (idx == rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_DISABLE))) {
/*
* If the rcbs tool was disabled and will remain disabled, no rebuild is required.
*/
if(resConfig.getRcbsApplicability() == IResourceConfiguration.KIND_DISABLE_RCBS_TOOL){
rcbsStillDisabledSoNoRebuild = true; rcbsStillDisabledSoNoRebuild = true;
}
resConfig.setRcbsApplicability(IResourceConfiguration.KIND_DISABLE_RCBS_TOOL); if (rcConfig.isDirty()) {
} else {
resConfig.setRcbsApplicability(IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE);
}
if (resConfig.isDirty()) {
rebuildNeeded = true; rebuildNeeded = true;
} }
if (rebuildNeeded && !rcbsStillDisabledSoNoRebuild) { if (rebuildNeeded && !rcbsStillDisabledSoNoRebuild) {
resConfig.getParent().setRebuildState(true); rcConfig.getParent().setRebuildState(true);
} }
setDirty(false); setDirty(false);
} }
}
private String createList(String[] items) {
if(items == null)
return new String();
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(PATH_SEPERATOR);
}
}
return path.toString();
}
private boolean removeRcbsTools(IResourceConfiguration rcConfig){
ITool tools[] = getRcbsTools(rcConfig);
if(tools != null){
for(int i = 0; i < tools.length; i++)
rcConfig.removeTool(tools[i]);
boolean rebuildNeeded =
rcConfig.getRcbsApplicability() != IResourceConfiguration.KIND_DISABLE_RCBS_TOOL;
rcConfig.setRcbsApplicability(IResourceConfiguration.KIND_DISABLE_RCBS_TOOL);
return rebuildNeeded;
}
return false;
}
private ITool getRcbsTool(IResourceConfiguration rcConfig, boolean create){
ITool rcbsTools[] = getRcbsTools(rcConfig);
ITool rcbsTool = null;
if(rcbsTools != null)
rcbsTool = rcbsTools[0];
else if (create) {
rcbsTool = rcConfig.createTool(null,rcbsToolId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolName,false); //$NON-NLS-1$
rcbsTool.setCustomBuildStep(true);
IInputType rcbsToolInputType = rcbsTool.createInputType(null,rcbsToolInputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolInputTypeName,false); //$NON-NLS-1$
IAdditionalInput rcbsToolInputTypeAdditionalInput = rcbsToolInputType.createAdditionalInput(new String());
rcbsToolInputTypeAdditionalInput.setKind(IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY);
rcbsTool.createOutputType(null,rcbsToolOutputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolOutputTypeName,false); //$NON-NLS-1$
}
return rcbsTool;
}
private ITool[] getRcbsTools(IResourceConfiguration rcConfig){
List list = new ArrayList();
ITool tools[] = rcConfig.getTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
if (tool.getCustomBuildStep() && !tool.isExtensionElement()) {
list.add(tool);
}
}
if(list.size() != 0)
return (ITool[])list.toArray(new ITool[list.size()]);
return null;
}
public IPreferenceStore getPreferenceStore() { public IPreferenceStore getPreferenceStore() {
return null; return null;
@ -554,4 +596,23 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage {
return dirty; return dirty;
} }
public void setVisible(boolean visible){
if(visible)
setValues();
super.setVisible(visible);
}
public boolean containsDefaults(){
return containsDefaults(resParent.getCurrentResourceConfigClone());
}
protected boolean containsDefaults(IResourceConfiguration rcCfg){
ITool tools[] = getRcbsTools(rcCfg);
if(tools == null)
return true;
return false;
}
} }

View file

@ -17,21 +17,25 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider; import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractBuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildOptionSettingsPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPage;
import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolsSettingsStore; import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolSettingsPreferenceStore;
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider; import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider; import org.eclipse.cdt.managedbuilder.ui.properties.ToolListLabelProvider;
@ -43,15 +47,13 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.ScrolledComposite;
@ -62,7 +64,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
public class ToolsSettingsBlock extends AbstractCOptionPage { public class ToolsSettingsBlock extends AbstractCOptionPage {
@ -90,8 +91,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
* Bookeeping variables * Bookeeping variables
*/ */
private Map configToPageListMap; private Map configToPageListMap;
private BuildToolsSettingsStore settingsStore; private BuildToolSettingsPreferenceStore settingsStore;
private Map settingsStoreMap;
private BuildPropertyPage parent; private BuildPropertyPage parent;
private ResourceBuildPropertyPage resParent; private ResourceBuildPropertyPage resParent;
private BuildSettingsPage currentSettingsPage; private BuildSettingsPage currentSettingsPage;
@ -100,6 +100,8 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
private ITool selectedTool; private ITool selectedTool;
private Object element; private Object element;
private boolean defaultNeeded;
/** /**
* The minimum page size; 200 by 200 by default. * The minimum page size; 200 by 200 by default.
* *
@ -152,6 +154,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
this.parent = parent; this.parent = parent;
configToPageListMap = new HashMap(); configToPageListMap = new HashMap();
this.element = element; this.element = element;
settingsStore = new BuildToolSettingsPreferenceStore(this);
} }
public ToolsSettingsBlock(ResourceBuildPropertyPage resParent, Object element) public ToolsSettingsBlock(ResourceBuildPropertyPage resParent, Object element)
@ -161,6 +164,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
this.resParent = resParent; this.resParent = resParent;
configToPageListMap = new HashMap(); configToPageListMap = new HashMap();
this.element = element; this.element = element;
settingsStore = new BuildToolSettingsPreferenceStore(this);
} }
public void createControl(Composite parent) { public void createControl(Composite parent) {
@ -232,11 +236,11 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
} }
if (currentSettingsPage == null) { if (currentSettingsPage == null) {
if ( this.element instanceof IProject) { if ( this.element instanceof IProject) {
currentSettingsPage = new BuildOptionSettingsPage(parent.getSelectedConfiguration(), category); currentSettingsPage = new BuildOptionSettingsPage(parent,parent.getSelectedConfigurationClone(), category);
pages.add(currentSettingsPage); pages.add(currentSettingsPage);
currentSettingsPage.setContainer(parent); currentSettingsPage.setContainer(parent);
} else if ( this.element instanceof IFile) { } else if ( this.element instanceof IFile) {
currentSettingsPage = new BuildOptionSettingsPage(resParent.getCurrentResourceConfig(), category); currentSettingsPage = new BuildOptionSettingsPage(resParent,resParent.getCurrentResourceConfigClone(), category);
pages.add(currentSettingsPage); pages.add(currentSettingsPage);
currentSettingsPage.setContainer(resParent); currentSettingsPage.setContainer(resParent);
} }
@ -254,18 +258,6 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
} }
currentSettingsPage.setVisible(true); currentSettingsPage.setVisible(true);
// save the last page build options.
// If the last page is tool page then parse all the options
// and put it in the appropriate preference store.
if (oldPage != null && oldPage != currentSettingsPage){
if(oldPage instanceof BuildOptionSettingsPage) {
((BuildOptionSettingsPage)oldPage).storeSettings();
}
else if(oldPage instanceof BuildToolSettingsPage) {
((BuildToolSettingsPage)oldPage).storeSettings();
//((BuildToolSettingsPage)oldPage).parseAllOptions();
}
}
//update the field editors in the current page //update the field editors in the current page
if(currentSettingsPage instanceof BuildOptionSettingsPage) if(currentSettingsPage instanceof BuildOptionSettingsPage)
((BuildOptionSettingsPage)currentSettingsPage).updateFields(); ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
@ -305,11 +297,13 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
} }
if (currentSettingsPage == null) { if (currentSettingsPage == null) {
if ( this.element instanceof IProject) { if ( this.element instanceof IProject) {
currentSettingsPage = new BuildToolSettingsPage(parent.getSelectedConfiguration(), tool, obtainMacroProvider()); currentSettingsPage = new BuildToolSettingsPage(parent,
parent.getSelectedConfigurationClone(), tool);
pages.add(currentSettingsPage); pages.add(currentSettingsPage);
currentSettingsPage.setContainer(parent); currentSettingsPage.setContainer(parent);
} else if(this.element instanceof IFile) { } else if(this.element instanceof IFile) {
currentSettingsPage = new BuildToolSettingsPage(resParent.getCurrentResourceConfig(), tool, obtainMacroProvider()); currentSettingsPage = new BuildToolSettingsPage(resParent,
resParent.getCurrentResourceConfigClone(), tool);
pages.add(currentSettingsPage); pages.add(currentSettingsPage);
currentSettingsPage.setContainer(resParent); currentSettingsPage.setContainer(resParent);
} }
@ -340,7 +334,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
} }
// Update the field editor that displays all the build options // Update the field editor that displays all the build options
if(currentSettingsPage instanceof BuildToolSettingsPage) if(currentSettingsPage instanceof BuildToolSettingsPage)
((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField(); ((BuildToolSettingsPage)currentSettingsPage).setValues();
if (oldPage != null && oldPage != currentSettingsPage) if (oldPage != null && oldPage != currentSettingsPage)
oldPage.setVisible(false); oldPage.setVisible(false);
@ -384,9 +378,12 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
} }
public void setVisible(boolean visible){ public void setVisible(boolean visible){
// Update the field editor that displays all the build options if(visible){
if(visible && currentSettingsPage instanceof BuildToolSettingsPage) selectedCategory = null;
((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField(); selectedTool = null;
handleOptionSelection();
}
super.setVisible(visible);
} }
protected void setValues() { protected void setValues() {
@ -401,32 +398,15 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
optionList.setContentProvider(provider); optionList.setContentProvider(provider);
} }
if ( element instanceof IProject ) { if ( element instanceof IProject ) {
config = parent.getSelectedConfiguration(); config = parent.getSelectedConfigurationClone();
optionList.setInput(config); optionList.setInput(config);
} else if ( element instanceof IFile){ } else if ( element instanceof IFile){
resConfig = resParent.getCurrentResourceConfig(); resConfig = resParent.getCurrentResourceConfigClone();
optionList.setInput(resConfig); optionList.setInput(resConfig);
} }
optionList.expandAll(); optionList.expandAll();
// Create (or retrieve) the settings store for the configuration/resource configuration
BuildToolsSettingsStore store = null;
if ( element instanceof IProject ) {
store = (BuildToolsSettingsStore) getSettingsStoreMap().get(parent.getSelectedConfiguration().getId());
if (store == null) {
store = new BuildToolsSettingsStore(parent.getSelectedConfiguration());
getSettingsStoreMap().put(parent.getSelectedConfiguration().getId(), store);
}
} else if ( element instanceof IFile) {
store = (BuildToolsSettingsStore) getSettingsStoreMap().get(resParent.getCurrentResourceConfig().getId());
if (store == null) {
store = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig());
getSettingsStoreMap().put(resParent.getCurrentResourceConfig().getId(), store);
}
}
settingsStore = store;
// Determine what the selection in the tree should be // Determine what the selection in the tree should be
Object primary = null; Object primary = null;
if (selectedTool != null) { if (selectedTool != null) {
@ -476,20 +456,25 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
// Select the first tool in the list // Select the first tool in the list
Object[] elements = null; Object[] elements = null;
if( element instanceof IProject){ if( element instanceof IProject){
elements = provider.getElements(parent.getSelectedConfiguration()); elements = provider.getElements(parent.getSelectedConfigurationClone());
} else if ( element instanceof IFile) { } else if ( element instanceof IFile) {
elements = provider.getElements(resParent.getCurrentResourceConfig()); elements = provider.getElements(resParent.getCurrentResourceConfigClone());
} }
primary = elements.length > 0 ? elements[0] : null; primary = elements.length > 0 ? elements[0] : null;
} }
if (primary != null) { if (primary != null) {
if(primary instanceof IOptionCategory){
if(resConfig != null)
settingsStore.setSelection(resConfig,(IOptionCategory)primary);
else
settingsStore.setSelection(config,(IOptionCategory)primary);
}
optionList.setSelection(new StructuredSelection(primary), true); optionList.setSelection(new StructuredSelection(primary), true);
} }
} }
public void removeValues(String id) { public void removeValues(String id) {
getSettingsStoreMap().remove(id);
} }
private void handleOptionSelection() { private void handleOptionSelection() {
@ -498,6 +483,12 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
// Set the option page based on the selection // Set the option page based on the selection
Object element = selection.getFirstElement(); Object element = selection.getFirstElement();
if(element instanceof IOptionCategory){
if(resParent != null)
settingsStore.setSelection(resParent.getCurrentResourceConfigClone(),(IOptionCategory)element);
else
settingsStore.setSelection(parent.getSelectedConfigurationClone(),(IOptionCategory)element);
}
if (element instanceof ITool) { if (element instanceof ITool) {
displayOptionsForTool((ITool)element); displayOptionsForTool((ITool)element);
} else if (element instanceof IOptionCategory) { } else if (element instanceof IOptionCategory) {
@ -517,7 +508,9 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
ManagedBuildManager.performValueHandlerEvent(parent.getSelectedConfiguration(), ManagedBuildManager.performValueHandlerEvent(parent.getSelectedConfiguration(),
IManagedOptionValueHandler.EVENT_SETDEFAULT, false); IManagedOptionValueHandler.EVENT_SETDEFAULT, false);
} else if ( element instanceof IFile) { } else if ( element instanceof IFile) {
ManagedBuildManager.performValueHandlerEvent(resParent.getCurrentResourceConfig(), IResourceConfiguration rcCfg = resParent.getCurrentResourceConfig(false);
if(rcCfg != null)
ManagedBuildManager.performValueHandlerEvent(rcCfg,
IManagedOptionValueHandler.EVENT_SETDEFAULT); IManagedOptionValueHandler.EVENT_SETDEFAULT);
} }
} }
@ -532,6 +525,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
} else if ( element instanceof IFile) { } else if ( element instanceof IFile) {
performDefaults( (IFile)element); performDefaults( (IFile)element);
} }
defaultNeeded = true;
return; return;
} }
@ -539,76 +533,41 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
// TODO: Should this reset all tools of the configuration, or just // TODO: Should this reset all tools of the configuration, or just
// the currently selected tool category? Right now it is all tools. // the currently selected tool category? Right now it is all tools.
// Display a "Confirm" dialog box, since:
// 1. The defaults are immediately applied
// 2. The action cannot be undone
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
boolean shouldDefault = MessageDialog.openConfirm(shell,
ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.defaults.title"), //$NON-NLS-1$
ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.defaults.message")); //$NON-NLS-1$
if (!shouldDefault) return;
// Empty the page list
List pages = getPagesForConfig();
pages.clear();
// Get the build manager to reset build info for project // Get the build manager to reset build info for project
ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration()); ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfigurationClone());
ITool tools[] = parent.getSelectedConfigurationClone().getFilteredTools();
// Recreate the settings store for the configuration for( int i = 0; i < tools.length; i++ ){
settingsStore = new BuildToolsSettingsStore(parent.getSelectedConfiguration()); if(!tools[i].getCustomBuildStep())
tools[i].setToolCommand(null);
// Write out the build model info }
ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration());
ManagedBuildManager.saveBuildInfo(parent.getProject(), false);
// Call an MBS CallBack function to inform that default settings have been applied.
performSetDefaultsEventCallBack();
// Reset the category or tool selection and run selection event handler // Reset the category or tool selection and run selection event handler
selectedCategory = null; selectedCategory = null;
selectedTool = null; selectedTool = null;
handleOptionSelection(); handleOptionSelection();
setDirty(false); setDirty(true);
} }
public void performDefaults(IFile file) { public void performDefaults(IFile file) {
// TODO: Should this reset all options of the tool in current resource configuration, or just // TODO: Should this reset all options of the tool in current resource configuration, or just
// the currently selected tool category? Right now it is all options. // the currently selected tool category? Right now it is all options.
// Display a "Confirm" dialog box, since:
// 1. The defaults are immediately applied
// 2. The action cannot be undone
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
boolean shouldDefault = MessageDialog.openConfirm(shell,
ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.defaults.title"), //$NON-NLS-1$
ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.defaults.message")); //$NON-NLS-1$
if (!shouldDefault) return;
// Empty the page list
List pages = getPagesForConfig();
pages.clear();
// Get the build manager to reset build info for project // Get the build manager to reset build info for project
ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig()); ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfigClone());
ITool tools[] = resParent.getCurrentResourceConfigClone().getTools();
// Recreate the settings store for the configuration for( int i = 0; i < tools.length; i++ ){
settingsStore = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig()); if(!tools[i].getCustomBuildStep())
tools[i].setToolCommand(null);
// Write out the build model info }
ManagedBuildManager.setDefaultConfiguration(resParent.getProject(), resParent.getSelectedConfiguration());
ManagedBuildManager.saveBuildInfo(resParent.getProject(), false);
// Call an MBS CallBack function to inform that default settings have been applied.
performSetDefaultsEventCallBack();
// Reset the category or tool selection and run selection event handler // Reset the category or tool selection and run selection event handler
selectedCategory = null; selectedCategory = null;
selectedTool = null; selectedTool = null;
handleOptionSelection(); handleOptionSelection();
setDirty(false); setDirty(true);
} }
/* /*
@ -617,30 +576,233 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
*/ */
public void performApply(IProgressMonitor monitor) throws CoreException { public void performApply(IProgressMonitor monitor) throws CoreException {
// Force each settings page to update if(element instanceof IFile)
List pages = getPagesForConfig(); resParent.getCurrentResourceConfig(true);
// Make sure we have something to work on
if (pages == null) { if(defaultNeeded){
// Nothing to do if(element instanceof IFile)
return; ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig(true));
else
ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration());
performSetDefaultsEventCallBack();
defaultNeeded = false;
} }
ListIterator iter = pages.listIterator(); //some options might be changed that do not belong to the created pages,
while (iter.hasNext()) { //we need to save all options instead
BuildSettingsPage page = (BuildSettingsPage) iter.next(); saveAll();
if (page == null) continue;
if (page instanceof BuildToolSettingsPage) { setDirty(false);
// if the currentsettings page is not the tool settings page }
// then update the all build options field editor based on the
// build options in other options settings page. private void saveAll(){
if (!(currentSettingsPage instanceof BuildToolSettingsPage)) if(resParent != null)
((BuildToolSettingsPage)page).updateAllOptionField(); saveResourceConfig();
((BuildToolSettingsPage)page).performOk(); else
} else if (page instanceof BuildOptionSettingsPage) { saveConfig();
((BuildOptionSettingsPage)page).performOk(); }
private void saveResourceConfig(){
IResourceConfiguration cloneRcCfg = resParent.getCurrentResourceConfigClone();
ITool tools[] = cloneRcCfg.getTools();
for(int i = 0; i < tools.length; i++){
saveHoldsOptions(tools[i]);
} }
} }
setDirty(false); private void saveHoldsOptions(IHoldsOptions holder){
if(holder instanceof ITool && ((ITool)holder).getCustomBuildStep())
return;
AbstractBuildPropertyPage page = resParent != null ?
(AbstractBuildPropertyPage)resParent : (AbstractBuildPropertyPage)parent;
IHoldsOptions realHo = page.getRealHoldsOptions(holder);
if(realHo != null){
if(holder instanceof ITool)
((ITool)realHo).setToolCommand(((ITool)holder).getToolCommand());
IOption options[] = holder.getOptions();
for(int i = 0; i < options.length; i++){
saveOption(options[i], holder);
}
}
}
private void saveOption(IOption clonedOption, IHoldsOptions cloneHolder){
IConfiguration realCfg = null;
IResourceConfiguration realRcCfg = null;
IBuildObject handler = null;
IOption realOption;
IHoldsOptions realHolder;
if(resParent != null){
realOption = resParent.getRealOption(clonedOption,cloneHolder);
realHolder = resParent.getRealHoldsOptions(cloneHolder);
realRcCfg = (IResourceConfiguration)((ITool)realHolder).getParent();
realCfg = realRcCfg.getParent();
handler = realRcCfg;
} else {
realOption = parent.getRealOption(clonedOption,cloneHolder);
realHolder = parent.getRealHoldsOptions(cloneHolder);
realCfg = parent.getConfigurationFromHoldsOptions(realHolder);
handler = realCfg;
}
try {
// Transfer value from preference store to options
IOption setOption = null;
switch (clonedOption.getValueType()) {
case IOption.BOOLEAN :
boolean boolVal = clonedOption.getBooleanValue();
if(realRcCfg != null) {
setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, boolVal);
} else {
setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, boolVal);
}
// Reset the preference store since the Id may have changed
// if (setOption != option) {
// getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
break;
case IOption.ENUMERATED :
String enumVal = clonedOption.getStringValue();
String enumId = clonedOption.getEnumeratedId(enumVal);
if(realRcCfg != null) {
setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption,
(enumId != null && enumId.length() > 0) ? enumId : enumVal);
} else {
setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption,
(enumId != null && enumId.length() > 0) ? enumId : enumVal);
}
// Reset the preference store since the Id may have changed
// if (setOption != option) {
// getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
break;
case IOption.STRING :
String strVal = clonedOption.getStringValue();
if(realRcCfg != null){
setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, strVal);
} else {
setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, strVal);
}
// Reset the preference store since the Id may have changed
// if (setOption != option) {
// getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
break;
case IOption.STRING_LIST :
case IOption.INCLUDE_PATH :
case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES :
case IOption.OBJECTS :
String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]);
if( realRcCfg != null){
setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, listVal);
}else {
setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, listVal);
}
// Reset the preference store since the Id may have changed
// if (setOption != option) {
// getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
// fe.setPreferenceName(setOption.getId());
// }
break;
default :
break;
}
// Call an MBS CallBack function to inform that Settings related to Apply/OK button
// press have been applied.
if (setOption == null)
setOption = realOption;
if (setOption.getValueHandler().handleValue(
handler,
setOption.getOptionHolder(),
setOption,
setOption.getValueHandlerExtraArgument(),
IManagedOptionValueHandler.EVENT_APPLY)) {
// TODO : Event is handled successfully and returned true.
// May need to do something here say log a message.
} else {
// Event handling Failed.
}
} catch (BuildException e) {
} catch (ClassCastException e) {
}
}
private void saveConfig(){
IConfiguration cfg = parent.getSelectedConfigurationClone();
IToolChain tc = cfg.getToolChain();
saveHoldsOptions(tc);
ITool tools[] = tc.getTools();
for(int i = 0; i < tools.length; i++){
saveHoldsOptions(tools[i]);
}
}
public boolean containsDefaults(){
if(resParent == null)
return false;
return containsDefaults(resParent.getCurrentResourceConfigClone());
}
protected boolean containsDefaults(IResourceConfiguration rcCfg){
IConfiguration cfg = rcCfg.getParent();
ITool tools[] = rcCfg.getTools();
for(int i = 0; i < tools.length; i++){
ITool tool = tools[i];
if(!tool.getCustomBuildStep()){
IOption options[] = tool.getOptions();
for( int j = 0; j < options.length; j++){
IOption option = options[j];
if(option.getParent() == tool){
IOption ext = option;
do{
if(ext.isExtensionElement())
break;
} while((ext = ext.getSuperClass()) != null);
if(ext != null){
ITool cfgTool = cfg.getToolChain().getTool(tool.getSuperClass().getId());
if(cfgTool != null){
IOption defaultOpt = cfgTool.getOptionBySuperClassId(ext.getId());
try {
if(defaultOpt != null && defaultOpt.getValueType() == option.getValueType()){
Object value = option.getValue();
Object defaultVal = defaultOpt.getValue();
if(value.equals(defaultVal))
continue;
//TODO: check list also
}
}catch (BuildException e) {
}
}
}
return false;
}
}
}
}
return true;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -651,44 +813,32 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
List pages = null; List pages = null;
if ( element instanceof IProject) { if ( element instanceof IProject) {
// Make sure that something was selected // Make sure that something was selected
if (parent.getSelectedConfiguration() == null) { if (parent.getSelectedConfigurationClone() == null) {
return null; return null;
} }
pages = (List) configToPageListMap.get(parent.getSelectedConfiguration().getId()); pages = (List) configToPageListMap.get(parent.getSelectedConfigurationClone().getId());
} else if (element instanceof IFile) { } else if (element instanceof IFile) {
if ( resParent.getCurrentResourceConfig() == null ) { if ( resParent.getCurrentResourceConfigClone() == null ) {
return null; return null;
} }
pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfig().getId()); pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfigClone().getId());
} }
if (pages == null) { if (pages == null) {
pages = new ArrayList(); pages = new ArrayList();
if ( element instanceof IProject) { if ( element instanceof IProject) {
configToPageListMap.put(parent.getSelectedConfiguration().getId(), pages); configToPageListMap.put(parent.getSelectedConfigurationClone().getId(), pages);
} else if ( element instanceof IFile) { } else if ( element instanceof IFile) {
configToPageListMap.put(resParent.getCurrentResourceConfig().getId(), pages); configToPageListMap.put(resParent.getCurrentResourceConfigClone().getId(), pages);
} }
} }
return pages; return pages;
} }
public IPreferenceStore getPreferenceStore() { public BuildToolSettingsPreferenceStore getPreferenceStore() {
return settingsStore; return settingsStore;
} }
/* (non-Javadoc)
* Safe accessor method
*
* @return Returns the Map of configurations to preference stores.
*/
protected Map getSettingsStoreMap() {
if (settingsStoreMap == null) {
settingsStoreMap = new HashMap();
}
return settingsStoreMap;
}
/** /**
* Sets the "dirty" state * Sets the "dirty" state
*/ */
@ -736,7 +886,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage {
* the user-modified macros that are not applied yet * the user-modified macros that are not applied yet
* If the "Build Macros" tab is not available, returns the default BuildMacroProvider * If the "Build Macros" tab is not available, returns the default BuildMacroProvider
*/ */
protected BuildMacroProvider obtainMacroProvider(){ public BuildMacroProvider obtainMacroProvider(){
ICOptionContainer container = getContainer(); ICOptionContainer container = getContainer();
ManagedBuildOptionBlock optionBlock = null; ManagedBuildOptionBlock optionBlock = null;
if(container instanceof BuildPropertyPage){ if(container instanceof BuildPropertyPage){

View file

@ -0,0 +1,212 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.ui.dialogs.PropertyPage;
public abstract class AbstractBuildPropertyPage extends PropertyPage {
private Map clonedConfigMap;
private Map getClonedConfigMap(){
if(clonedConfigMap == null)
clonedConfigMap = new HashMap();
return clonedConfigMap;
}
public IConfiguration getClonedConfig(IConfiguration config){
IConfiguration clonedCfg = (IConfiguration)getClonedConfigMap().get(config.getId());
if(clonedCfg == null){
clonedCfg = new Configuration((ManagedProject)config.getManagedProject(),
(Configuration)config,
ManagedBuildManager.calculateChildId(config.getId(), null),
true,
true);
getClonedConfigMap().put(config.getId(),clonedCfg);
}
return clonedCfg;
}
public IConfiguration getRealConfig(IConfiguration config){
Set set = getClonedConfigMap().entrySet();
Iterator iter = set.iterator();
while(iter.hasNext()){
Map.Entry entry = (Map.Entry)iter.next();
if(entry.getValue().equals(config))
return config.getManagedProject().getConfiguration((String)entry.getKey());
}
return null;
}
public IToolChain getClonedToolChain(IToolChain toolChain){
return getClonedConfig(toolChain.getParent()).getToolChain();
}
public IToolChain getRealToolChain(IToolChain toolChain){
IConfiguration cfg = getRealConfig(toolChain.getParent());
if(cfg != null)
return cfg.getToolChain();
return null;
}
public IHoldsOptions getClonedHoldsOptions(IHoldsOptions ho){
if(ho instanceof IToolChain)
return getClonedToolChain((IToolChain)ho);
else if(ho instanceof ITool)
return getClonedTool((ITool)ho);
return null;
}
public IHoldsOptions getRealHoldsOptions(IHoldsOptions ho){
if(ho instanceof IToolChain)
return getRealToolChain((IToolChain)ho);
else if(ho instanceof ITool)
return getRealTool((ITool)ho);
return null;
}
public IResourceConfiguration getClonedRcConfig(IResourceConfiguration rcCfg){
return getClonedConfig(rcCfg.getParent()).getResourceConfiguration(rcCfg.getResourcePath());
}
public IResourceConfiguration getRealRcConfig(IResourceConfiguration rcCfg){
IConfiguration cfg = getRealConfig(rcCfg.getParent());
if(cfg != null)
return cfg.getResourceConfiguration(rcCfg.getResourcePath());
return null;
}
public ITool getClonedTool(ITool tool){
IConfiguration cfg = getConfigurationFromTool(tool);
if(cfg != null)
return getToolForConfig(getClonedConfig(cfg),tool);
return null;
}
public ITool getRealTool(ITool tool){
IConfiguration cfg = getConfigurationFromTool(tool);
if(cfg != null){
cfg = getRealConfig(cfg);
if(cfg != null)
return getToolForConfig(cfg,tool);
}
return null;
}
protected ITool getToolForConfig(IConfiguration cfg, ITool tool){
if(tool.getParent() instanceof IToolChain){
ITool tools[] = cfg.getTools();
for(int i = 0; i < tools.length; i++){
if(tool.getSuperClass() != null){
if(tools[i].getSuperClass() != null && tools[i].getSuperClass().getId().equals(
tool.getSuperClass().getId()))
return tools[i];
}
//TODO: shoud we handle this?
}
} else if (tool.getParent() instanceof IResourceConfiguration){
IResourceConfiguration rcCfg = (IResourceConfiguration)tool.getParent();
IResourceConfiguration otherRcCfg = cfg.getResourceConfiguration(rcCfg.getResourcePath());
ITool tools[] = otherRcCfg.getTools();
ITool superTool = tool.getSuperClass();
if(superTool != null && (superTool = superTool.getSuperClass()) != null){
for(int i = 0; i < tools.length; i++){
ITool otherSuperTool = tools[i].getSuperClass();
if(otherSuperTool != null
&& (otherSuperTool = otherSuperTool.getSuperClass()) != null
&& otherSuperTool.getId().equals(superTool.getId()))
return tools[i];
}
}
}
return null;
}
public IConfiguration getConfigurationFromTool(ITool tool){
IBuildObject bo = tool.getParent();
if(bo instanceof IToolChain)
return ((IToolChain)bo).getParent();
else if(bo instanceof IResourceConfiguration)
return ((IResourceConfiguration)bo).getParent();
return null;
}
public IConfiguration getConfigurationFromHoldsOptions(IHoldsOptions ho){
if(ho instanceof IToolChain)
return ((IToolChain)ho).getParent();
else if(ho instanceof ITool)
return getConfigurationFromTool((ITool)ho);
return null;
}
public IOption getClonedOption(IOption option, IHoldsOptions ho){
IHoldsOptions clonedHo = getClonedHoldsOptions(ho);
if(clonedHo != null)
return getOptionForHoldsOptions(clonedHo,option);
return null;
}
public IOption getRealOption(IOption option, IHoldsOptions ho){
IHoldsOptions realHo = getRealHoldsOptions(ho);
if(realHo != null)
return getOptionForHoldsOptions(realHo,option);
return null;
}
protected IOption getOptionForHoldsOptions(IHoldsOptions ho, IOption otherOption){
IOption opt = null;
if(otherOption.isExtensionElement())
opt = ho.getOptionBySuperClassId(otherOption.getId());
else if(otherOption.getSuperClass() != null)
opt = ho.getOptionBySuperClassId(otherOption.getSuperClass().getId());
if(opt != null)
return opt;
return otherOption;
}
public IOptionCategory getClonedOptionCategory(IOptionCategory optCategory){
if(optCategory instanceof Tool)
return (Tool)getClonedTool((Tool)optCategory);
return optCategory;
}
public IOptionCategory getRealOptionCategory(IOptionCategory optCategory){
if(optCategory instanceof Tool)
return (Tool)getRealTool((Tool)optCategory);
return optCategory;
}
/* protected String calculateId(String id){
String version = ManagedBuildManager.getVersionFromIdAndVersion(id);
int n = ManagedBuildManager.getRandomNumber();
if ( version != null) // If the 'id' contains version information
return ManagedBuildManager.getIdFromIdAndVersion(id) + "." + n + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
return id + "." + n; //$NON-NLS-1$
}
*/
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2004 IBM Corporation and others. * Copyright (c) 2002, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -116,6 +116,10 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
getPreferenceStore().setValue(getPreferenceName(), selected); getPreferenceStore().setValue(getPreferenceName(), selected);
} }
public String getSelection(){
return selected;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls() * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
*/ */

View file

@ -10,10 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties; package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector; import java.util.Vector;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
@ -21,39 +22,43 @@ import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FileFieldEditor; import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import java.lang.AssertionError;
public class BuildOptionSettingsPage extends BuildSettingsPage { public class BuildOptionSettingsPage extends BuildSettingsPage {
private Map fieldsMap = new HashMap(); private Map fieldsMap = new HashMap();
private IOptionCategory category; private IOptionCategory clonedCategory;
private boolean isItResourceConfigPage; private boolean isItResourceConfigPage;
private Map fieldEditorsToParentMap = new HashMap(); private Map fieldEditorsToParentMap = new HashMap();
private AbstractBuildPropertyPage buildPropPage;
public BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) { public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
IConfiguration clonedConfig, IOptionCategory clonedCategory) {
// Cache the configuration and option category this page is created for // Cache the configuration and option category this page is created for
super(configuration); super(clonedConfig);
this.category = category; this.clonedCategory = clonedCategory;
isItResourceConfigPage = false; isItResourceConfigPage = false;
buildPropPage = page;
} }
public BuildOptionSettingsPage(IResourceConfiguration resConfig, IOptionCategory category) { public BuildOptionSettingsPage(AbstractBuildPropertyPage page,
IResourceConfiguration clonedResConfig, IOptionCategory clonedCategory) {
// Cache the configuration and option category this page is created for // Cache the configuration and option category this page is created for
super(resConfig); super(clonedResConfig);
this.category = category; this.clonedCategory = clonedCategory;
isItResourceConfigPage = true; isItResourceConfigPage = true;
buildPropPage = page;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize() * @see org.eclipse.jface.preference.IPreferencePage#computeSize()
@ -61,17 +66,6 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
public Point computeSize() { public Point computeSize() {
return super.computeSize(); return super.computeSize();
} }
/* (non-Javadoc)
* Private access function which returns the correct configuration
* argument for valueHandler call-backs.
*/
private IBuildObject getConfigurationHandle() {
if ( isItResourceConfigPage ) {
return resConfig;
} else {
return configuration;
}
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
@ -83,9 +77,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// for each // for each
Object[][] options; Object[][] options;
if ( isItResourceConfigPage ) { if ( isItResourceConfigPage ) {
options = category.getOptions(resConfig); options = clonedCategory.getOptions(clonedResConfig);
} else { } else {
options = category.getOptions(configuration); options = clonedCategory.getOptions(clonedConfig);
} }
for (int index = 0; index < options.length; ++index) { for (int index = 0; index < options.length; ++index) {
@ -93,6 +87,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
IHoldsOptions holder = (IHoldsOptions)options[index][0]; IHoldsOptions holder = (IHoldsOptions)options[index][0];
if (holder == null) break; // The array may not be full if (holder == null) break; // The array may not be full
IOption opt = (IOption)options[index][1]; IOption opt = (IOption)options[index][1];
String prefName = getToolSettingsPreferenceStore().getOptionPrefName(opt);
// check to see if the option has an applicability calculator // check to see if the option has an applicability calculator
@ -101,9 +96,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// is the option visible? // is the option visible?
IBuildObject config; IBuildObject config;
if ( isItResourceConfigPage ) { if ( isItResourceConfigPage ) {
config = resConfig; config = clonedResConfig;
} else { } else {
config = configuration; config = clonedConfig;
} }
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) { if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) {
@ -122,13 +117,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.BROWSE_DIR: case IOption.BROWSE_DIR:
Composite fieldEditorParent2 = getFieldEditorParent(); Composite fieldEditorParent2 = getFieldEditorParent();
DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor( DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor(
opt.getId(), opt.getName(), fieldEditorParent2); prefName, opt.getName(), fieldEditorParent2);
setFieldEditorEnablement(holder, setFieldEditorEnablement(holder,
opt, applicabilityCalculator, dirFieldEditor, fieldEditorParent2); opt, applicabilityCalculator, dirFieldEditor, fieldEditorParent2);
addField(dirFieldEditor); addField(dirFieldEditor);
fieldsMap.put(opt.getId(), dirFieldEditor); fieldsMap.put(prefName, dirFieldEditor);
fieldEditorsToParentMap.put(dirFieldEditor, fieldEditorParent2); fieldEditorsToParentMap.put(dirFieldEditor, fieldEditorParent2);
break; break;
@ -136,26 +131,26 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.BROWSE_FILE: case IOption.BROWSE_FILE:
Composite fieldEditorParent3 = getFieldEditorParent(); Composite fieldEditorParent3 = getFieldEditorParent();
FileFieldEditor fileFieldEditor = new FileFieldEditor( FileFieldEditor fileFieldEditor = new FileFieldEditor(
opt.getId(), opt.getName(), fieldEditorParent3); prefName, opt.getName(), fieldEditorParent3);
setFieldEditorEnablement(holder, setFieldEditorEnablement(holder,
opt, applicabilityCalculator, fileFieldEditor, fieldEditorParent3); opt, applicabilityCalculator, fileFieldEditor, fieldEditorParent3);
addField(fileFieldEditor); addField(fileFieldEditor);
fieldsMap.put(opt.getId(), fileFieldEditor); fieldsMap.put(prefName, fileFieldEditor);
fieldEditorsToParentMap.put(fileFieldEditor, fieldEditorParent3); fieldEditorsToParentMap.put(fileFieldEditor, fieldEditorParent3);
break; break;
case IOption.BROWSE_NONE: case IOption.BROWSE_NONE:
Composite fieldEditorParent4 = getFieldEditorParent(); Composite fieldEditorParent4 = getFieldEditorParent();
StringFieldEditor stringField = new StringFieldEditor( StringFieldEditor stringField = new StringFieldEditor(
opt.getId(), opt.getName(), fieldEditorParent4); prefName, opt.getName(), fieldEditorParent4);
setFieldEditorEnablement(holder, setFieldEditorEnablement(holder,
opt, applicabilityCalculator, stringField, fieldEditorParent4); opt, applicabilityCalculator, stringField, fieldEditorParent4);
addField(stringField); addField(stringField);
fieldsMap.put(opt.getId(), stringField); fieldsMap.put(prefName, stringField);
fieldEditorsToParentMap.put(stringField, fieldEditorParent4); fieldEditorsToParentMap.put(stringField, fieldEditorParent4);
break; break;
@ -168,13 +163,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
case IOption.BOOLEAN: case IOption.BOOLEAN:
Composite fieldEditorParent5 = getFieldEditorParent(); Composite fieldEditorParent5 = getFieldEditorParent();
BooleanFieldEditor booleanField = new BooleanFieldEditor( BooleanFieldEditor booleanField = new BooleanFieldEditor(
opt.getId(), opt.getName(), fieldEditorParent5); prefName, opt.getName(), fieldEditorParent5);
setFieldEditorEnablement(holder, setFieldEditorEnablement(holder,
opt, applicabilityCalculator, booleanField, fieldEditorParent5); opt, applicabilityCalculator, booleanField, fieldEditorParent5);
addField(booleanField); addField(booleanField);
fieldsMap.put(opt.getId(), booleanField); fieldsMap.put(prefName, booleanField);
fieldEditorsToParentMap.put(booleanField, fieldEditorParent5); fieldEditorsToParentMap.put(booleanField, fieldEditorParent5);
break; break;
case IOption.ENUMERATED: case IOption.ENUMERATED:
@ -195,7 +190,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
String[] enumNames = opt.getApplicableValues(); String[] enumNames = opt.getApplicableValues();
Vector enumValidList = new Vector(); Vector enumValidList = new Vector();
for (int i = 0; i < enumNames.length; ++i) { for (int i = 0; i < enumNames.length; ++i) {
if (opt.getValueHandler().isEnumValueAppropriate(getConfigurationHandle(), if (opt.getValueHandler().isEnumValueAppropriate(config,
opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) { opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) {
enumValidList.add(enumNames[i]); enumValidList.add(enumNames[i]);
} }
@ -205,13 +200,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
Composite fieldEditorParent6 = getFieldEditorParent(); Composite fieldEditorParent6 = getFieldEditorParent();
BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor( BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
opt.getId(), opt.getName(), enumValidNames, sel, fieldEditorParent6); prefName, opt.getName(), enumValidNames, sel, fieldEditorParent6);
setFieldEditorEnablement(holder, setFieldEditorEnablement(holder,
opt, applicabilityCalculator, comboField, fieldEditorParent6); opt, applicabilityCalculator, comboField, fieldEditorParent6);
addField(comboField); addField(comboField);
fieldsMap.put(opt.getId(), comboField); fieldsMap.put(prefName, comboField);
fieldEditorsToParentMap.put(comboField, fieldEditorParent6); fieldEditorsToParentMap.put(comboField, fieldEditorParent6);
break; break;
case IOption.INCLUDE_PATH: case IOption.INCLUDE_PATH:
@ -222,13 +217,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
Composite fieldEditorParent7 = getFieldEditorParent(); Composite fieldEditorParent7 = getFieldEditorParent();
FileListControlFieldEditor listField = new FileListControlFieldEditor( FileListControlFieldEditor listField = new FileListControlFieldEditor(
opt.getId(), opt.getName(), fieldEditorParent7, opt.getBrowseType()); prefName, opt.getName(), fieldEditorParent7, opt.getBrowseType());
setFieldEditorEnablement(holder, setFieldEditorEnablement(holder,
opt, applicabilityCalculator, listField, fieldEditorParent7); opt, applicabilityCalculator, listField, fieldEditorParent7);
addField(listField); addField(listField);
fieldsMap.put(opt.getId(), listField); fieldsMap.put(prefName, listField);
fieldEditorsToParentMap.put(listField, fieldEditorParent7); fieldEditorsToParentMap.put(listField, fieldEditorParent7);
break; break;
default: default:
@ -249,7 +244,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
*/ */
public boolean isForCategory(IOptionCategory category) { public boolean isForCategory(IOptionCategory category) {
if (category != null) { if (category != null) {
return category.equals(this.category); return category.equals(this.clonedCategory);
} }
return false; return false;
} }
@ -262,87 +257,103 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
boolean ok = super.performOk(); boolean ok = super.performOk();
// Write the preference store values back to the build model // Write the preference store values back to the build model
Object[][] options; Object[][] clonedOptions;
IResourceConfiguration realRcCfg = null;
IConfiguration realCfg = null;
IBuildObject handler = null;
if (isItResourceConfigPage){ if (isItResourceConfigPage){
options = category.getOptions(resConfig); realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig);
if(realRcCfg == null)
return false;
handler = realRcCfg;
clonedOptions = clonedCategory.getOptions(clonedResConfig);
} else { } else {
options = category.getOptions(configuration); realCfg = buildPropPage.getRealConfig(clonedConfig);
if(realCfg == null)
return false;
handler = realCfg;
clonedOptions = clonedCategory.getOptions(clonedConfig);
} }
for (int i = 0; i < options.length; i++) { for (int i = 0; i < clonedOptions.length; i++) {
IHoldsOptions holder = (IHoldsOptions)options[i][0]; IHoldsOptions clonedHolder = (IHoldsOptions)clonedOptions[i][0];
if (holder == null) break; // The array may not be full if (clonedHolder == null) break; // The array may not be full
IOption option = (IOption)options[i][1]; IOption clonedOption = (IOption)clonedOptions[i][1];
IHoldsOptions realHolder = buildPropPage.getRealHoldsOptions(clonedHolder);
if(realHolder == null) continue;
IOption realOption = buildPropPage.getRealOption(clonedOption, clonedHolder);
if(realOption == null) continue;
try { try {
// Transfer value from preference store to options // Transfer value from preference store to options
IOption setOption = null; IOption setOption = null;
switch (option.getValueType()) { switch (clonedOption.getValueType()) {
case IOption.BOOLEAN : case IOption.BOOLEAN :
boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId()); boolean boolVal = clonedOption.getBooleanValue();
if(isItResourceConfigPage) { if(isItResourceConfigPage) {
setOption = ManagedBuildManager.setOption(resConfig, holder, option, boolVal); setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, boolVal);
} else { } else {
setOption = ManagedBuildManager.setOption(configuration, holder, option, boolVal); setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, boolVal);
} }
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal); // getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); // FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
fe.setPreferenceName(setOption.getId()); // fe.setPreferenceName(setOption.getId());
} // }
break; break;
case IOption.ENUMERATED : case IOption.ENUMERATED :
String enumVal = getToolSettingsPreferenceStore().getString(option.getId()); String enumVal = clonedOption.getStringValue();
String enumId = option.getEnumeratedId(enumVal); String enumId = clonedOption.getEnumeratedId(enumVal);
if(isItResourceConfigPage) { if(isItResourceConfigPage) {
setOption = ManagedBuildManager.setOption(resConfig, holder, option, setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption,
(enumId != null && enumId.length() > 0) ? enumId : enumVal); (enumId != null && enumId.length() > 0) ? enumId : enumVal);
} else { } else {
setOption = ManagedBuildManager.setOption(configuration, holder, option, setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption,
(enumId != null && enumId.length() > 0) ? enumId : enumVal); (enumId != null && enumId.length() > 0) ? enumId : enumVal);
} }
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal); // getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); // FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
fe.setPreferenceName(setOption.getId()); // fe.setPreferenceName(setOption.getId());
} // }
break; break;
case IOption.STRING : case IOption.STRING :
String strVal = getToolSettingsPreferenceStore().getString(option.getId()); String strVal = clonedOption.getStringValue();
if(isItResourceConfigPage){ if(isItResourceConfigPage){
setOption = ManagedBuildManager.setOption(resConfig, holder, option, strVal); setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, strVal);
} else { } else {
setOption = ManagedBuildManager.setOption(configuration, holder, option, strVal); setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, strVal);
} }
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal); // getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); // FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
fe.setPreferenceName(setOption.getId()); // fe.setPreferenceName(setOption.getId());
} // }
break; break;
case IOption.STRING_LIST : case IOption.STRING_LIST :
case IOption.INCLUDE_PATH : case IOption.INCLUDE_PATH :
case IOption.PREPROCESSOR_SYMBOLS : case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES : case IOption.LIBRARIES :
case IOption.OBJECTS : case IOption.OBJECTS :
String listStr = getToolSettingsPreferenceStore().getString(option.getId()); String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]);
String[] listVal = BuildToolsSettingsStore.parseString(listStr);
if( isItResourceConfigPage){ if( isItResourceConfigPage){
setOption = ManagedBuildManager.setOption(resConfig, holder, option, listVal); setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, listVal);
}else { }else {
setOption = ManagedBuildManager.setOption(configuration, holder, option, listVal); setOption = ManagedBuildManager.setOption(realCfg, realHolder, realOption, listVal);
} }
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr); // getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); // FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId());
fe.setPreferenceName(setOption.getId()); // fe.setPreferenceName(setOption.getId());
} // }
break; break;
default : default :
break; break;
@ -351,10 +362,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// Call an MBS CallBack function to inform that Settings related to Apply/OK button // Call an MBS CallBack function to inform that Settings related to Apply/OK button
// press have been applied. // press have been applied.
if (setOption == null) if (setOption == null)
setOption = option; setOption = realOption;
if (setOption.getValueHandler().handleValue( if (setOption.getValueHandler().handleValue(
getConfigurationHandle(), handler,
setOption.getOptionHolder(), setOption.getOptionHolder(),
setOption, setOption,
setOption.getValueHandlerExtraArgument(), setOption.getValueHandlerExtraArgument(),
@ -364,7 +375,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
} else { } else {
// Event handling Failed. // Event handling Failed.
} }
} catch (BuildException e) {} } catch (BuildException e) {
} catch (ClassCastException e) {
}
} }
return ok; return ok;
@ -374,6 +388,38 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
* Update field editors in this page when the page is loaded. * Update field editors in this page when the page is loaded.
*/ */
public void updateFields() { public void updateFields() {
Object[][] options;
if (isItResourceConfigPage) {
options = clonedCategory.getOptions(clonedResConfig);
} else {
options = clonedCategory.getOptions(clonedConfig);
}
// some option has changed on this page... update enabled/disabled state for all options
for (int index = 0; index < options.length; ++index) {
// Get the option
IHoldsOptions holder = (IHoldsOptions) options[index][0];
if (holder == null)
break; // The array may not be full
IOption opt = (IOption) options[index][1];
String prefName = getToolSettingsPreferenceStore().getOptionPrefName(opt);
// is the option on this page?
if (fieldsMap.containsKey(prefName)) {
// check to see if the option has an applicability calculator
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
if (applicabilityCalculator != null) {
FieldEditor fieldEditor = (FieldEditor) fieldsMap.get(prefName);
Composite parent = (Composite) fieldEditorsToParentMap.get(fieldEditor);
setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, parent);
}
}
}
Collection fieldsList = fieldsMap.values(); Collection fieldsList = fieldsMap.values();
Iterator iter = fieldsList.iterator(); Iterator iter = fieldsList.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -389,7 +435,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
* saves all field editors * saves all field editors
*/ */
public void storeSettings() { public void storeSettings() {
super.performOk(); // super.performOk();
} }
private void setFieldEditorEnablement(IHoldsOptions holder, IOption option, private void setFieldEditorEnablement(IHoldsOptions holder, IOption option,
@ -400,9 +446,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// if the option is not enabled then disable it // if the option is not enabled then disable it
IBuildObject config; IBuildObject config;
if ( isItResourceConfigPage ) { if ( isItResourceConfigPage ) {
config = resConfig; config = clonedResConfig;
} else { } else {
config = configuration; config = clonedConfig;
} }
if (!optionApplicability.isOptionEnabled(config, holder, option )) { if (!optionApplicability.isOptionEnabled(config, holder, option )) {
fieldEditor.setEnabled(false, parent); fieldEditor.setEnabled(false, parent);
@ -418,35 +464,122 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// allow superclass to handle as well // allow superclass to handle as well
super.propertyChange(event); super.propertyChange(event);
// some option has changed on this page... update enabled/disabled state for all options Object source = event.getSource();
IOption changedOption = null;
IHoldsOptions changedHolder = null;
IOption newOption = null;
String id = null;
if(source instanceof FieldEditor){
FieldEditor fe = (FieldEditor)source;
id = fe.getPreferenceName();
Object option[] = this.getToolSettingsPreferenceStore().getOption(id);
if(option != null){
changedOption = (IOption)option[1];
changedHolder = (IHoldsOptions)option[0];
try {
switch(changedOption.getValueType()){
case IOption.STRING:
if(fe instanceof StringFieldEditor){
String val = ((StringFieldEditor)fe).getStringValue();
if (isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
} else {
newOption = clonedConfig.setOption(changedHolder,changedOption,val);
}
}
break;
case IOption.BOOLEAN:
if(fe instanceof BooleanFieldEditor){
boolean val = ((BooleanFieldEditor)fe).getBooleanValue();
if (isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
} else {
newOption = clonedConfig.setOption(changedHolder,changedOption,val);
}
}
break;
case IOption.ENUMERATED:
if(fe instanceof BuildOptionComboFieldEditor){
String name = ((BuildOptionComboFieldEditor)fe).getSelection();
String enumId = changedOption.getEnumeratedId(name);
if(isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder, changedOption,
(enumId != null && enumId.length() > 0) ? enumId : name);
} else {
newOption = clonedConfig.setOption(changedHolder, changedOption,
(enumId != null && enumId.length() > 0) ? enumId : name);
}
}
break;
case IOption.INCLUDE_PATH:
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS:
if(fe instanceof FileListControlFieldEditor){
String val[] =((FileListControlFieldEditor)fe).getStringListValue();
if (isItResourceConfigPage) {
newOption = clonedResConfig.setOption(changedHolder,changedOption,val);
} else {
newOption = clonedConfig.setOption(changedHolder,changedOption,val);
}
}
break;
default:
break;
}
} catch (BuildException e) {
}
}
}
Object[][] options; Object[][] options;
if (isItResourceConfigPage) { if (isItResourceConfigPage) {
options = category.getOptions(resConfig); options = clonedCategory.getOptions(clonedResConfig);
} else { } else {
options = category.getOptions(configuration); options = clonedCategory.getOptions(clonedConfig);
} }
// some option has changed on this page... update enabled/disabled state for all options
for (int index = 0; index < options.length; ++index) { for (int index = 0; index < options.length; ++index) {
// Get the option // Get the option
IHoldsOptions holder = (IHoldsOptions) options[index][0]; IHoldsOptions holder = (IHoldsOptions) options[index][0];
if (holder == null) if (holder == null)
break; // The array may not be full break; // The array may not be full
IOption opt = (IOption) options[index][1]; IOption opt = (IOption) options[index][1];
String prefName = getToolSettingsPreferenceStore().getOptionPrefName(opt);
// is the option on this page? // is the option on this page?
if (fieldsMap.containsKey(opt.getId())) { if (fieldsMap.containsKey(prefName)) {
// check to see if the option has an applicability calculator // check to see if the option has an applicability calculator
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator(); IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
if (applicabilityCalculator != null) { if (applicabilityCalculator != null) {
FieldEditor fieldEditor = (FieldEditor) fieldsMap.get(opt.getId()); FieldEditor fieldEditor = (FieldEditor) fieldsMap.get(prefName);
Composite parent = (Composite) fieldEditorsToParentMap.get(fieldEditor); Composite parent = (Composite) fieldEditorsToParentMap.get(fieldEditor);
setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, parent); setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, parent);
} }
} }
} }
Iterator iter = fieldsMap.values().iterator();
while (iter.hasNext()) {
FieldEditor editor = (FieldEditor) iter.next();
if(id == null || !id.equals(editor.getPreferenceName()))
editor.load();
}
} }
} }

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
@ -55,10 +56,9 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.help.WorkbenchHelp;
public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, public class BuildPropertyPage extends AbstractBuildPropertyPage implements IWorkbenchPropertyPage,
IPreferencePageContainer, ICOptionContainer { IPreferencePageContainer, ICOptionContainer {
/* /*
* String constants * String constants
@ -96,6 +96,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
private IProjectType[] projectTypes; private IProjectType[] projectTypes;
private IProjectType selectedProjectType; private IProjectType selectedProjectType;
private IConfiguration[] configurations; private IConfiguration[] configurations;
private IConfiguration clonedConfiguration;
private IConfiguration selectedConfiguration; private IConfiguration selectedConfiguration;
private Point lastShellSize; private Point lastShellSize;
protected ManagedBuildOptionBlock fOptionBlock; protected ManagedBuildOptionBlock fOptionBlock;
@ -251,6 +252,17 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
if (!applyOptionBlock()) return false; if (!applyOptionBlock()) return false;
if (!applyDefaultConfiguration()) return false; if (!applyDefaultConfiguration()) return false;
if (!writeBuildInfo()) return false; if (!writeBuildInfo()) return false;
clonedConfiguration.setDirty(false);
//check for the inexistent configurations environment data stored in project preferences
EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
return true;
}
public boolean performCancel() {
EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
return true; return true;
} }
@ -400,6 +412,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return selectedConfiguration; return selectedConfiguration;
} }
public IConfiguration getSelectedConfigurationClone(){
return clonedConfiguration;
}
/* (non-Javadoc) /* (non-Javadoc)
* @return * @return
*/ */
@ -423,7 +439,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
/* (non-Javadoc) /* (non-Javadoc)
* Return the IPreferenceStore of the Tool Settings block * Return the IPreferenceStore of the Tool Settings block
*/ */
public IPreferenceStore getToolSettingsPreferenceStore() public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore()
{ {
return fOptionBlock.getToolSettingsPreferenceStore(); return fOptionBlock.getToolSettingsPreferenceStore();
} }
@ -523,6 +539,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Set the new selected configuration // Set the new selected configuration
selectedConfiguration = newConfig; selectedConfiguration = newConfig;
ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration); ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
clonedConfiguration = getClonedConfig(selectedConfiguration);
// TODO: Set the appropriate error parsers... // TODO: Set the appropriate error parsers...
// TODO: Binary parsers too? // TODO: Binary parsers too?
fOptionBlock.updateValues(); fOptionBlock.updateValues();
@ -536,8 +553,8 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
if(selectedProjectType != null && !selectedProjectType.isSupported()){ if(selectedProjectType != null && !selectedProjectType.isSupported()){
setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_PROJ),IMessageProvider.WARNING); setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_PROJ),IMessageProvider.WARNING);
} }
else if(selectedConfiguration != null){ else if(clonedConfiguration != null){
if(selectedConfiguration.isSupported()){ if(clonedConfiguration.isSupported()){
setMessage(null,IMessageProvider.NONE); setMessage(null,IMessageProvider.NONE);
} }
else{ else{

View file

@ -19,14 +19,15 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
public abstract class BuildSettingsPage extends FieldEditorPreferencePage { public abstract class BuildSettingsPage extends FieldEditorPreferencePage {
protected IConfiguration configuration; protected IConfiguration clonedConfig;
protected IResourceConfiguration resConfig; protected IResourceConfiguration clonedResConfig;
private boolean dirty = false; private boolean dirty = false;
/** /**
* @param style * @param style
*/ */
protected BuildSettingsPage(IConfiguration config) { protected BuildSettingsPage(IConfiguration clonedConfig) {
// fix for PR 63973 // fix for PR 63973
// If we use a grid layout then widgets that should be layed out horizontally, // If we use a grid layout then widgets that should be layed out horizontally,
// e.g. StringButtonFieldEditor, will have their component widgets // e.g. StringButtonFieldEditor, will have their component widgets
@ -36,10 +37,10 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage {
super(FLAT); super(FLAT);
// end fix for 63973 // end fix for 63973
noDefaultAndApplyButton(); noDefaultAndApplyButton();
configuration = config; this.clonedConfig = clonedConfig;
} }
protected BuildSettingsPage(IResourceConfiguration resConfig) { protected BuildSettingsPage(IResourceConfiguration clonedResConfig) {
// fix for PR 63973 // fix for PR 63973
// If we use a grid layout then widgets that should be layed out horizontally, // If we use a grid layout then widgets that should be layed out horizontally,
// e.g. StringButtonFieldEditor, will have their component widgets // e.g. StringButtonFieldEditor, will have their component widgets
@ -49,8 +50,11 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage {
super(FLAT); super(FLAT);
// end fix for 63973 // end fix for 63973
noDefaultAndApplyButton(); noDefaultAndApplyButton();
this.resConfig = resConfig;
this.clonedResConfig = clonedResConfig;
this.clonedConfig = clonedResConfig.getParent();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/ */
@ -63,7 +67,7 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage {
/** /**
* Return the tool settings preference store * Return the tool settings preference store
*/ */
protected IPreferenceStore getToolSettingsPreferenceStore() { protected BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore() {
IPreferencePageContainer container = getContainer(); IPreferencePageContainer container = getContainer();
if (container instanceof BuildPropertyPage) { if (container instanceof BuildPropertyPage) {
return ((BuildPropertyPage)container).getToolSettingsPreferenceStore(); return ((BuildPropertyPage)container).getToolSettingsPreferenceStore();

View file

@ -22,17 +22,14 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider; import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor; import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo; import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor; import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver; import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
@ -40,8 +37,8 @@ import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro; import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
public class BuildToolSettingsPage extends BuildSettingsPage { public class BuildToolSettingsPage extends BuildSettingsPage {
@ -57,79 +54,41 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
// field editor that displays all the build options for a particular tool // field editor that displays all the build options for a particular tool
private MultiLineTextFieldEditor allOptionFieldEditor; private MultiLineTextFieldEditor allOptionFieldEditor;
// all build options preference store id //tool command command
private String allOptionsId = ""; //$NON-NLS-1$ private StringFieldEditor commandStringField;
// A list of safe options to put unrecognized values in // A list of safe options to put unrecognized values in
private Vector defaultOptionNames; private Vector defaultOptionNames;
// Map that holds all string options and its values // Map that holds all string options and its values
private HashMap stringOptionsMap; private HashMap stringOptionsMap;
// Tool the settings belong to
private ITool tool; private ITool clonedTool;
// Map that holds all user object options and its values // Map that holds all user object options and its values
private HashMap userObjsMap; private HashMap userObjsMap;
private boolean isItResourceConfigPage; private boolean isItResourceConfigPage;
//the build macro provider to be used for macro resolution private AbstractBuildPropertyPage buildPropPage;
private BuildMacroProvider fProvider;
//macro substitutor used in the macro resolution in UI public BuildToolSettingsPage(AbstractBuildPropertyPage page,
//resolves all macros except for the option-specific macros IConfiguration clonedCfg, ITool clonedTool) {
//and the explicit file macros
public class UIMacroSubstitutor extends DefaultMacroSubstitutor {
private BuildMacroProvider fProvider;
public UIMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter, BuildMacroProvider provider){
super(contextType,contextData,inexistentMacroValue,listDelimiter);
fProvider = provider;
}
public UIMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
super(contextInfo,inexistentMacroValue,listDelimiter);
}
protected IMacroContextInfo getMacroContextInfo(int contextType, Object contextData){
if(fProvider != null)
return fProvider.getMacroContextInfo(contextType,contextData);
return super.getMacroContextInfo();
}
protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
if(macro instanceof MbsMacroSupplier.FileContextMacro){
MbsMacroSupplier.FileContextMacro fileMacro = (MbsMacroSupplier.FileContextMacro)macro;
if(fileMacro.isExplicit()){
String name = macro.getName();
return new ResolvedMacro(name,MacroResolver.createMacroReference(name));
}
} else if (macro instanceof MbsMacroSupplier.OptionMacro) {
String name = macro.getName();
return new ResolvedMacro(name,MacroResolver.createMacroReference(name));
}
return super.resolveMacro(macro);
}
}
public BuildToolSettingsPage(IConfiguration configuration, ITool tool, BuildMacroProvider provider) {
// Cache the configuration and tool this page is for // Cache the configuration and tool this page is for
super(configuration); super(clonedCfg);
this.tool = tool; this.clonedTool = clonedTool;
allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$ buildPropPage = page;
stringOptionsMap = new HashMap(); stringOptionsMap = new HashMap();
userObjsMap = new HashMap(); userObjsMap = new HashMap();
isItResourceConfigPage = false; isItResourceConfigPage = false;
fProvider = provider;
} }
public BuildToolSettingsPage(IResourceConfiguration resConfig, ITool tool, BuildMacroProvider provider) {
public BuildToolSettingsPage(AbstractBuildPropertyPage page,
IResourceConfiguration clonedRcCfg, ITool clonedTool) {
// Cache the configuration and tool this page is for // Cache the configuration and tool this page is for
super(resConfig); super(clonedRcCfg);
this.tool = tool; this.clonedTool = clonedTool;
allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$ buildPropPage = page;
stringOptionsMap = new HashMap(); stringOptionsMap = new HashMap();
userObjsMap = new HashMap(); userObjsMap = new HashMap();
isItResourceConfigPage = true; isItResourceConfigPage = true;
fProvider = provider;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#computeSize() * @see org.eclipse.jface.preference.IPreferencePage#computeSize()
@ -137,17 +96,6 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
public Point computeSize() { public Point computeSize() {
return super.computeSize(); return super.computeSize();
} }
/* (non-Javadoc)
* Private access function which returns the correct configuration
* argument for valueHandler call-backs.
*/
private IBuildObject getConfigurationHandle() {
if ( isItResourceConfigPage ) {
return resConfig;
} else {
return configuration;
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -158,16 +106,15 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// Load up the preference store // Load up the preference store
super.createFieldEditors(); super.createFieldEditors();
// Add a string editor to edit the tool command // Add a string editor to edit the tool command
StringFieldEditor stringField = new StringFieldEditor(tool.getId(), commandStringField = new StringFieldEditor(clonedTool.getId(),
ManagedBuilderUIMessages.getResourceString(COMMAND), ManagedBuilderUIMessages.getResourceString(COMMAND),
getFieldEditorParent()); getFieldEditorParent());
stringField.setEmptyStringAllowed(false); commandStringField.setEmptyStringAllowed(false);
addField(stringField); addField(commandStringField);
// Add a field editor that displays over all build options // Add a field editor that displays over all build options
allOptionFieldEditor = new MultiLineTextFieldEditor(allOptionsId, allOptionFieldEditor = new MultiLineTextFieldEditor(BuildToolSettingsPreferenceStore.ALL_OPTIONS_ID,
ALL_OPTIONS, getFieldEditorParent()); ALL_OPTIONS, getFieldEditorParent());
allOptionFieldEditor.getTextControl().setEditable(false); allOptionFieldEditor.getTextControl().setEditable(false);
getToolSettingsPreferenceStore().setValue(allOptionsId, ""); //$NON-NLS-1$
addField(allOptionFieldEditor); addField(allOptionFieldEditor);
} }
@ -255,112 +202,6 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
} }
} }
/**
* Returns all the build options string
*
* @return String
* @throws BuildException
*/
private String getToolFlags() throws BuildException {
StringBuffer buf = new StringBuffer();
ArrayList flags = new ArrayList();
// get the options for this tool
IOption[] options = tool.getOptions();
String listStr = ""; //$NON-NLS-1$
String[] listVal = null;
IBuildObject parent = configuration != null ? (IBuildObject)configuration.getToolChain() : (IBuildObject)resConfig;
IBuildObject config = configuration != null ? (IBuildObject)configuration : (IBuildObject)resConfig;
IMacroSubstitutor macroSubstitutor = new UIMacroSubstitutor(0,null,EMPTY_STRING,WHITESPACE,fProvider);
for (int k = 0; k < options.length; k++) {
IOption option = options[k];
buf.setLength( 0 );
// check to see if the option has an applicability calculator
IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
if (applicabilityCalculator == null || applicabilityCalculator.isOptionUsedInCommandLine(config, tool, option)) {
try{
switch (option.getValueType()) {
case IOption.BOOLEAN :
String boolCmd;
if (getToolSettingsPreferenceStore().getBoolean(option.getId())) {
boolCmd = option.getCommand();
} else {
// Note: getCommandFalse is new with CDT 2.0
boolCmd = option.getCommandFalse();
}
if (boolCmd != null && boolCmd.length() > 0) {
buf.append(boolCmd);
}
break;
case IOption.ENUMERATED :
String enumCommand = getToolSettingsPreferenceStore().getString(
option.getId());
if (enumCommand.indexOf(DEFAULT_SEPERATOR) != -1)
enumCommand = option.getSelectedEnum();
String enumeration = option.getEnumCommand(enumCommand);
if (enumeration.length() > 0) {
buf.append(enumeration);
}
break;
case IOption.STRING :
String strCmd = option.getCommand();
String val = getToolSettingsPreferenceStore().getString(option.getId());
// add this string option value to the list
stringOptionsMap.put(option, val);
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(null,null,option,parent));
if (val.length() > 0 && (val = MacroResolver.resolveToString(val,macroSubstitutor)).length() > 0) {
buf.append(evaluateCommand( strCmd, val ));
}
break;
case IOption.STRING_LIST :
case IOption.INCLUDE_PATH :
case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES :
case IOption.OBJECTS :
String cmd = option.getCommand();
listStr = getToolSettingsPreferenceStore().getString(option.getId());
if (cmd == null)
userObjsMap.put(option, listStr);
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(null,null,option,parent));
listVal = MacroResolver.resolveStringListValues(BuildToolsSettingsStore.parseString(listStr),macroSubstitutor,true);
for (int j = 0; j < listVal.length; j++) {
String temp = listVal[j];
if(temp.length() > 0)
buf.append( evaluateCommand( cmd, temp ) + ITool.WHITE_SPACE);
}
break;
default :
break;
}
if( buf.toString().trim().length() > 0 ) flags.add( buf.toString().trim() );
} catch (BuildMacroException e) {
}
}
}
String outputName = "temp"; //$NON-NLS-1$
if (tool.getDefaultInputExtension() != null) {
outputName += tool.getDefaultInputExtension();
}
String[] f = new String[ flags.size() ];
String cmd = tool.getToolCommand();
try{
macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(null,null,null,parent));
String resolved = MacroResolver.resolveToString(cmd,macroSubstitutor);
if ((resolved = resolved.trim()).length() > 0)
cmd = resolved;
} catch (BuildMacroException e) {
}
IManagedCommandLineGenerator gen = tool.getCommandLineGenerator();
IManagedCommandLineInfo info = gen.generateCommandLineInfo( tool, cmd, (String[])flags.toArray( f ),
tool.getOutputFlag(), tool.getOutputPrefix(), outputName, new String[0], tool.getCommandLinePattern() );
return info.getFlags();
}
/** /**
* Answers <code>true</code> if the receiver manages settings for the * Answers <code>true</code> if the receiver manages settings for the
* argument * argument
@ -370,7 +211,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
*/ */
public boolean isForTool(ITool tool) { public boolean isForTool(ITool tool) {
if (tool != null) { if (tool != null) {
return tool.equals(this.tool); return tool.equals(this.clonedTool);
} }
return false; return false;
} }
@ -381,7 +222,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
*/ */
public void parseAllOptions() { public void parseAllOptions() {
// Get the all build options string from all options field // Get the all build options string from all options field
String alloptions = getToolSettingsPreferenceStore().getString(allOptionsId); String alloptions = getToolSettingsPreferenceStore().getString(BuildToolSettingsPreferenceStore.ALL_OPTIONS_ID);
// list that holds the options for the option type other than // list that holds the options for the option type other than
// boolean,string and enumerated // boolean,string and enumerated
List optionsList = new ArrayList(); List optionsList = new ArrayList();
@ -394,7 +235,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String optionValue = (String)optIter.next(); String optionValue = (String)optIter.next();
boolean optionValueExist = false; boolean optionValueExist = false;
// get the options for this tool // get the options for this tool
IOption[] options = tool.getOptions(); IOption[] options = clonedTool.getOptions();
for (int k = 0; k < options.length; ++k) { for (int k = 0; k < options.length; ++k) {
IOption opt = options[k]; IOption opt = options[k];
String name = opt.getId(); String name = opt.getId();
@ -422,14 +263,12 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String boolCommand; String boolCommand;
boolCommand = opt.getCommand(); boolCommand = opt.getCommand();
if (boolCommand != null && boolCommand.equals(optionValue)) { if (boolCommand != null && boolCommand.equals(optionValue)) {
getToolSettingsPreferenceStore() setOption(opt, true);
.setValue(opt.getId(), true);
optionValueExist = true; optionValueExist = true;
} }
boolCommand = opt.getCommandFalse(); boolCommand = opt.getCommandFalse();
if (boolCommand != null && boolCommand.equals(optionValue)) { if (boolCommand != null && boolCommand.equals(optionValue)) {
getToolSettingsPreferenceStore() setOption(opt, false);
.setValue(opt.getId(), false);
optionValueExist = true; optionValueExist = true;
} }
break; break;
@ -444,8 +283,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
} }
} }
if (!enumeration.equals("")) //$NON-NLS-1$ if (!enumeration.equals("")) //$NON-NLS-1$
getToolSettingsPreferenceStore() setOption(opt, enumeration);
.setValue(opt.getId(), enumeration);
break; break;
case IOption.STRING_LIST : case IOption.STRING_LIST :
case IOption.INCLUDE_PATH : case IOption.INCLUDE_PATH :
@ -486,7 +324,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
if (alloptions.indexOf(vals[t]) != -1) if (alloptions.indexOf(vals[t]) != -1)
buf.append(vals[t] + ITool.WHITE_SPACE); buf.append(vals[t] + ITool.WHITE_SPACE);
} }
getToolSettingsPreferenceStore().setValue(((IOption) key).getId(), setOption(((IOption) key),
buf.toString().trim()); buf.toString().trim());
} }
} }
@ -499,20 +337,19 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
Object key = iterator.next(); Object key = iterator.next();
String val = (String) userObjsMap.get(key); String val = (String) userObjsMap.get(key);
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
String[] vals = BuildToolsSettingsStore.parseString(val); String[] vals = parseString(val);
for (int t = 0; t < vals.length; t++) { for (int t = 0; t < vals.length; t++) {
if (alloptions.indexOf(vals[t]) != -1) if (alloptions.indexOf(vals[t]) != -1)
list.add(vals[t]); list.add(vals[t]);
} }
String listArr[] = new String[list.size()]; String listArr[] = new String[list.size()];
list.toArray(listArr); list.toArray(listArr);
String liststr = BuildToolsSettingsStore.createList(listArr); setOption(((IOption) key), listArr);
getToolSettingsPreferenceStore().setValue(((IOption) key).getId(), liststr);
} }
} }
// Now update the preference store with parsed options // Now update the preference store with parsed options
// Get the options for this tool // Get the options for this tool
IOption[] options = tool.getOptions(); IOption[] options = clonedTool.getOptions();
for (int k = 0; k < options.length; ++k) { for (int k = 0; k < options.length; ++k) {
IOption opt = options[k]; IOption opt = options[k];
String name = opt.getId(); String name = opt.getId();
@ -525,22 +362,21 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
if (opt.getCommand() != null if (opt.getCommand() != null
&& opt.getCommand().length() > 0 && opt.getCommand().length() > 0
&& !optsList.contains(opt.getCommand())) && !optsList.contains(opt.getCommand()))
getToolSettingsPreferenceStore().setValue(opt.getId(), false); setOption(opt, false);
if (opt.getCommandFalse() != null if (opt.getCommandFalse() != null
&& opt.getCommandFalse().length() > 0 && opt.getCommandFalse().length() > 0
&& !optsList.contains(opt.getCommandFalse())) && !optsList.contains(opt.getCommandFalse()))
getToolSettingsPreferenceStore().setValue(opt.getId(), true); setOption(opt, true);
break; break;
case IOption.STRING : case IOption.STRING :
// TODO create a lst of valid default string options for the tool // TODO create a lst of valid default string options for the tool
if (getDefaultOptionNames().contains(opt.getName())) { if (getDefaultOptionNames().contains(opt.getName())) {
String newOptions = getToolSettingsPreferenceStore().getString( String newOptions = opt.getStringValue();
opt.getId());
if (addnOptions.length() > 0) { if (addnOptions.length() > 0) {
newOptions = newOptions + ITool.WHITE_SPACE newOptions = newOptions + ITool.WHITE_SPACE
+ addnOptions.toString().trim(); + addnOptions.toString().trim();
} }
getToolSettingsPreferenceStore().setValue(opt.getId(), newOptions); setOption(opt, newOptions);
} }
break; break;
case IOption.STRING_LIST : case IOption.STRING_LIST :
@ -559,8 +395,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
String[] strlist = new String[newList.size()]; String[] strlist = new String[newList.size()];
newList.toArray(strlist); newList.toArray(strlist);
newList.clear(); newList.clear();
getToolSettingsPreferenceStore().setValue(opt.getId(), setOption(opt, strlist);
BuildToolsSettingsStore.createList(strlist));
break; break;
default : default :
break; break;
@ -569,6 +404,44 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
} }
} }
public static String[] parseString(String stringList) {
if (stringList == null || stringList.length() == 0) {
return new String[0];
} else {
return stringList.split(DEFAULT_SEPERATOR);
}
}
protected void setOption(IOption option, boolean value){
try{
if(isItResourceConfigPage)
clonedResConfig.setOption(clonedTool,option,value);
else
clonedConfig.setOption(clonedTool,option,value);
} catch (BuildException e){
}
}
protected void setOption(IOption option, String value){
try{
if(isItResourceConfigPage)
clonedResConfig.setOption(clonedTool,option,value);
else
clonedConfig.setOption(clonedTool,option,value);
} catch (BuildException e){
}
}
protected void setOption(IOption option, String value[]){
try{
if(isItResourceConfigPage)
clonedResConfig.setOption(clonedTool,option,value);
else
clonedConfig.setOption(clonedTool,option,value);
} catch (BuildException e){
}
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
*/ */
@ -580,63 +453,85 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
//parseAllOptions(); //parseAllOptions();
// Write the preference store values back to the build model // Write the preference store values back to the build model
IOptionCategory category = (IOptionCategory)tool; IOptionCategory clonedCategory = (IOptionCategory)clonedTool;
Object[][] options; ITool tool = buildPropPage.getRealTool(clonedTool);
if(tool == null)
return false;
Object[][] clonedOptions;
IResourceConfiguration realRcCfg = null;
IConfiguration realCfg = null;
IBuildObject handler = null;
if (isItResourceConfigPage){ if (isItResourceConfigPage){
options = category.getOptions(resConfig); realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig);
if(realRcCfg == null)
return false;
handler = realRcCfg;
clonedOptions = clonedCategory.getOptions(clonedResConfig);
} else { } else {
options = category.getOptions(configuration); realCfg = buildPropPage.getRealConfig(clonedConfig);
if(realCfg == null)
return false;
handler = realCfg;
clonedOptions = clonedCategory.getOptions(clonedConfig);
} }
if ( options == null)
if ( clonedOptions == null)
return true; return true;
for (int i = 0; i < options.length; i++) { for (int i = 0; i < clonedOptions.length; i++) {
ITool tool = (ITool)options[i][0]; ITool clonedTool = (ITool)clonedOptions[i][0];
if (tool == null) break; // The array may not be full if (clonedTool == null) break; // The array may not be full
IOption option = (IOption)options[i][1]; IOption clonedOption = (IOption)clonedOptions[i][1];
ITool realTool = buildPropPage.getRealTool(clonedTool);
if(realTool == null) continue;
IOption realOption = buildPropPage.getRealOption(clonedOption, clonedTool);
if(realOption == null) continue;
try { try {
// Transfer value from preference store to options // Transfer value from preference store to options
IOption setOption = null; IOption setOption = null;
switch (option.getValueType()) { switch (clonedOption.getValueType()) {
case IOption.BOOLEAN : case IOption.BOOLEAN :
boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId()); boolean boolVal = clonedOption.getBooleanValue();;
setOption = ManagedBuildManager.setOption(configuration, tool, option, boolVal); setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, boolVal);
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal); // getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal);
} // }
break; break;
case IOption.ENUMERATED : case IOption.ENUMERATED :
String enumVal = getToolSettingsPreferenceStore().getString(option.getId()); String enumVal = clonedOption.getStringValue();
String enumId = option.getEnumeratedId(enumVal); String enumId = clonedOption.getEnumeratedId(enumVal);
setOption = ManagedBuildManager.setOption(configuration, tool, option, setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption,
(enumId != null && enumId.length() > 0) ? enumId : enumVal); (enumId != null && enumId.length() > 0) ? enumId : enumVal);
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal); // getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal);
} // }
break; break;
case IOption.STRING : case IOption.STRING :
String strVal = getToolSettingsPreferenceStore().getString(option.getId()); String strVal = clonedOption.getStringValue();
setOption = ManagedBuildManager.setOption(configuration, tool, option, strVal); setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, strVal);
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal); // getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal);
} // }
break; break;
case IOption.STRING_LIST : case IOption.STRING_LIST :
case IOption.INCLUDE_PATH : case IOption.INCLUDE_PATH :
case IOption.PREPROCESSOR_SYMBOLS : case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES : case IOption.LIBRARIES :
case IOption.OBJECTS : case IOption.OBJECTS :
String listStr = getToolSettingsPreferenceStore().getString(option.getId()); // String listStr = getToolSettingsPreferenceStore().getString(option.getId());
String[] listVal = BuildToolsSettingsStore.parseString(listStr); String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]);
setOption = ManagedBuildManager.setOption(configuration, tool, option, listVal); setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, listVal);
// Reset the preference store since the Id may have changed // Reset the preference store since the Id may have changed
if (setOption != option) { // if (setOption != option) {
getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr); // getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr);
} // }
break; break;
default : default :
break; break;
@ -645,10 +540,10 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// Call an MBS CallBack function to inform that Settings related to Apply/OK button // Call an MBS CallBack function to inform that Settings related to Apply/OK button
// press have been applied. // press have been applied.
if (setOption == null) if (setOption == null)
setOption = option; setOption = realOption;
if (setOption.getValueHandler().handleValue( if (setOption.getValueHandler().handleValue(
getConfigurationHandle(), handler,
setOption.getOptionHolder(), setOption.getOptionHolder(),
setOption, setOption,
setOption.getValueHandlerExtraArgument(), setOption.getValueHandlerExtraArgument(),
@ -658,18 +553,20 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
} else { } else {
// Event handling Failed. // Event handling Failed.
} }
} catch (BuildException e) {} } catch (BuildException e) {
} catch (ClassCastException e) {
}
} }
// Save the tool command if it has changed // Save the tool command if it has changed
// Get the actual value out of the field editor // Get the actual value out of the field editor
String command = getToolSettingsPreferenceStore().getString(tool.getId()); String command = clonedTool.getToolCommand();
if (command.length() > 0 && if (command.length() > 0 &&
(!command.equals(tool.getToolCommand()))) { (!command.equals(tool.getToolCommand()))) {
if ( isItResourceConfigPage ) { if ( isItResourceConfigPage ) {
ManagedBuildManager.setToolCommand(resConfig, tool, command); ManagedBuildManager.setToolCommand(realRcCfg, tool, command);
} else { } else {
ManagedBuildManager.setToolCommand(configuration, tool, command); ManagedBuildManager.setToolCommand(realCfg, tool, command);
} }
} }
@ -680,20 +577,28 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
* saves all field editors * saves all field editors
*/ */
public void storeSettings() { public void storeSettings() {
super.performOk(); // super.performOk();
} }
/** /**
* Update the field editor that displays all the build options * Update the field editor that displays all the build options
*/ */
public void updateAllOptionField() { public void updateAllOptionField() {
try {
String flags = getToolFlags();
if (flags != null) {
getToolSettingsPreferenceStore().setValue(allOptionsId, flags);
allOptionFieldEditor.load(); allOptionFieldEditor.load();
} }
} catch (BuildException e) {
public void setValues(){
commandStringField.load();
updateAllOptionField();
}
public void propertyChange(PropertyChangeEvent event) {
// allow superclass to handle as well
super.propertyChange(event);
if(event.getSource() == commandStringField){
clonedTool.setToolCommand(commandStringField.getStringValue());
updateAllOptionField();
} }
} }
} }

View file

@ -0,0 +1,435 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.Collection;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor;
import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
import org.eclipse.cdt.managedbuilder.internal.macros.MbsMacroSupplier;
import org.eclipse.cdt.managedbuilder.internal.ui.ToolsSettingsBlock;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacro;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
public class BuildToolSettingsPreferenceStore implements IPreferenceStore {
public static final String DEFAULT_SEPERATOR = ";"; //$NON-NLS-1$
private final static String EMPTY_STRING = new String();
private final static String WHITESPACE = " "; //$NON-NLS-1$
public final static String ALL_OPTIONS_ID = EMPTY_STRING;
private IConfiguration config;
private IResourceConfiguration rcConfig;
private IOptionCategory optCategory;
private ListenerList listenerList;
private boolean dirtyFlag;
private ToolsSettingsBlock block;
//macro substitutor used in the macro resolution in UI
//resolves all macros except for the option-specific macros
//and the explicit file macros
public class UIMacroSubstitutor extends DefaultMacroSubstitutor {
private BuildMacroProvider fProvider;
public UIMacroSubstitutor(int contextType, Object contextData, String inexistentMacroValue, String listDelimiter, BuildMacroProvider provider){
super(contextType,contextData,inexistentMacroValue,listDelimiter);
fProvider = provider;
}
public UIMacroSubstitutor(IMacroContextInfo contextInfo, String inexistentMacroValue, String listDelimiter){
super(contextInfo,inexistentMacroValue,listDelimiter);
}
protected IMacroContextInfo getMacroContextInfo(int contextType, Object contextData){
if(fProvider != null)
return fProvider.getMacroContextInfo(contextType,contextData);
return super.getMacroContextInfo();
}
protected ResolvedMacro resolveMacro(IBuildMacro macro) throws BuildMacroException{
if(macro instanceof MbsMacroSupplier.FileContextMacro){
MbsMacroSupplier.FileContextMacro fileMacro = (MbsMacroSupplier.FileContextMacro)macro;
if(fileMacro.isExplicit()){
String name = macro.getName();
return new ResolvedMacro(name,MacroResolver.createMacroReference(name));
}
} else if (macro instanceof MbsMacroSupplier.OptionMacro) {
String name = macro.getName();
return new ResolvedMacro(name,MacroResolver.createMacroReference(name));
}
return super.resolveMacro(macro);
}
}
public BuildToolSettingsPreferenceStore(ToolsSettingsBlock block){
this.block = block;
}
public void setSelection(IConfiguration cfg, IOptionCategory category){
optCategory = category;
rcConfig = null;
config = cfg;
}
public void setSelection(IResourceConfiguration cfg, IOptionCategory category){
optCategory = category;
rcConfig = cfg;
config = cfg.getParent();
}
public IOptionCategory getSelecedCategory(){
return optCategory;
}
public IResourceConfiguration getSelectedRcConfig(){
return rcConfig;
}
public IConfiguration getSelectedConfig(){
return config;
}
public String getOptionPrefName(IOption option){
IOption extOption = getExtensionOption(option);
if(extOption != null)
return extOption.getId();
return option.getId();
}
private static IOption getExtensionOption(IOption option){
do {
if(option.isExtensionElement())
return option;
} while ((option = option.getSuperClass()) != null);
return null;
}
public void addPropertyChangeListener(IPropertyChangeListener listener) {
listenerList.add(listener);
}
public boolean contains(String name) {
if(optCategory instanceof Tool){
if(optCategory.getId().equals(name))
return true;
else if(ALL_OPTIONS_ID.equals(name))
return true;
} else if(getOptionValue(name) != null){
return true;
}
return false;
}
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 );
}
}
}
public boolean getBoolean(String name) {
Object val = getOptionValue(name);
if(val instanceof Boolean)
return ((Boolean)val).booleanValue();
return getDefaultBoolean(name);
}
public boolean getDefaultBoolean(String name) {
return false;
}
public double getDefaultDouble(String name) {
return 0;
}
public float getDefaultFloat(String name) {
return 0;
}
public int getDefaultInt(String name) {
return 0;
}
public long getDefaultLong(String name) {
return 0;
}
public String getDefaultString(String name) {
return EMPTY_STRING;
}
public double getDouble(String name) {
return getDefaultDouble(name);
}
public float getFloat(String name) {
return getDefaultFloat(name);
}
public int getInt(String name) {
return getDefaultInt(name);
}
public long getLong(String name) {
return getDefaultLong(name);
}
public String getString(String name) {
if(optCategory instanceof Tool){
if(optCategory.getId().equals(name))
return ((Tool)optCategory).getToolCommand();
else if(ALL_OPTIONS_ID.equals(name)){
try {
return listToString(((Tool)optCategory).getToolCommandFlags(
null,
null,
new UIMacroSubstitutor(
0,
null,
EMPTY_STRING,
WHITESPACE,
block.obtainMacroProvider())),
WHITESPACE);
} catch (BuildException e) {
}
}
} else {
Object val = getOptionValue(name);
if(val instanceof String)
return (String)val;
else if(val instanceof Collection)
return listToString((String[])((Collection)val).toArray(new String[0]));
}
return getDefaultString(name);
}
public static String listToString(String[] items) {
return listToString(items,DEFAULT_SEPERATOR);
}
protected Object getOptionValue(String name){
Object option[] = getOption(name);
if(option != null){
try {
IOption opt = (IOption)option[1];
Object val = opt.getValue();
if(opt.getValueType() == IOption.ENUMERATED && val instanceof String)
val = opt.getEnumName((String)val);
return val;
} catch (BuildException e) {
}
}
return null;
}
public Object[] getOption(String name){
Object options[][];
if(rcConfig != null)
options = optCategory.getOptions(rcConfig);
else
options = optCategory.getOptions(config);
for(int i = 0; i < options.length; i++){
IHoldsOptions ho = (IHoldsOptions)options[i][0];
if(ho == null) break;
IOption option = (IOption)options[i][1];
if(option.getId().equals(name)
|| (!option.isExtensionElement()
&& option.getSuperClass() != null
&& option.getSuperClass().getId().equals(name)))
return options[i];
}
return null;
}
public boolean isDefault(String name) {
return false;
}
public boolean needsSaving() {
return dirtyFlag;
}
public void putValue(String name, String value) {
setValue(name,value);
}
public void removePropertyChangeListener(IPropertyChangeListener listener) {
listenerList.remove(listener);
}
public void setDefault(String name, double value) {
}
public void setDefault(String name, float value) {
}
public void setDefault(String name, int value) {
}
public void setDefault(String name, long value) {
}
public void setDefault(String name, String defaultObject) {
}
public void setDefault(String name, boolean value) {
}
public void setToDefault(String name) {
}
protected void setDirty( boolean isDirty )
{
dirtyFlag = isDirty;
}
public void setValue(String name, double value) {
}
public void setValue(String name, float value) {
}
public void setValue(String name, int value) {
}
public void setValue(String name, long value) {
}
public void setValue(String name, String value) {
if(optCategory instanceof Tool){
if(optCategory.getId().equals(name))
((Tool)optCategory).setToolCommand(value);
} else
setOptionValue(name,value);
}
public void setValue(String name, boolean value) {
setOptionValue(name,new Boolean(value));
}
protected void setOptionValue(String name, Object value){
Object opt[] = getOption(name);
if(opt != null){
IOption option = (IOption)opt[1];
IHoldsOptions holder = (IHoldsOptions)opt[0];
IOption newOption = null;
try{
switch(option.getValueType()){
case IOption.STRING:
if(value instanceof String){
if (rcConfig != null) {
newOption = rcConfig.setOption(holder,option,(String)value);
} else {
newOption = config.setOption(holder,option,(String)value);
}
}
break;
case IOption.BOOLEAN:
if(value instanceof Boolean){
boolean val = ((Boolean)value).booleanValue();
if (rcConfig != null) {
newOption = rcConfig.setOption(holder,option,val);
} else {
newOption = config.setOption(holder,option,val);
}
}
break;
case IOption.ENUMERATED:
if(value instanceof String){
String val = (String)value;
String enumId = option.getEnumeratedId(val);
if(rcConfig != null) {
newOption = rcConfig.setOption(holder, option,
(enumId != null && enumId.length() > 0) ? enumId : val);
} else {
newOption = config.setOption(holder, option,
(enumId != null && enumId.length() > 0) ? enumId : val);
}
}
break;
case IOption.INCLUDE_PATH:
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS:
if(value instanceof String){
String val[] = parseString((String)value);
if (rcConfig != null) {
newOption = rcConfig.setOption(holder,option,val);
} else {
newOption = config.setOption(holder,option,val);
}
}
break;
default:
break;
}
if(newOption != option){
//TODO: ???
}
} catch (BuildException e){
}
}
}
public static String[] parseString(String stringList) {
if (stringList == null || stringList.length() == 0) {
return new String[0];
} else {
return stringList.split(DEFAULT_SEPERATOR);
}
}
public static String listToString(String items[], String separator){
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(separator);
}
}
return path.toString();
}
}

View file

@ -1,537 +0,0 @@
/*******************************************************************************
* Copyright (c) 2002, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
public class BuildToolsSettingsStore implements IPreferenceStore {
public static final String DEFAULT_SEPERATOR = ";"; //$NON-NLS-1$
// List of listeners on the property store
private ListenerList listenerList;
private Map settingsMap;
private boolean dirtyFlag;
private IConfiguration owner;
private IResourceConfiguration resConfigOwner;
// private IFile file;
/**
*
*/
public BuildToolsSettingsStore() {
listenerList = new ListenerList();
dirtyFlag = false;
}
/**
* @param config
*/
public BuildToolsSettingsStore (IConfiguration config) {
this();
owner = config;
resConfigOwner = null;
// Now populate the options map
populateSettingsMap();
}
public BuildToolsSettingsStore(IResourceConfiguration resConfig) {
this();
// owner = resConfig.getParent();
owner = null;
resConfigOwner = resConfig;
populateSettingsMap();
}
/**
*
*/
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
public void addPropertyChangeListener(IPropertyChangeListener listener) {
listenerList.add(listener);
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
*/
public boolean contains(String name) {
return getSettingsMap().containsKey(name);
}
/**
* Answers a <code>String</code> containing the strings passed in the
* argument separated by the DEFAULT_SEPERATOR
*
* @param items An array of strings
* @return
*/
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();
}
/* (non-Javadoc)
* @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 );
}
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
*/
public boolean getBoolean(String name) {
Object b = getSettingsMap().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);
}
/**
* Accessor to extract the configuration that owns the property store.
*
* @return Returns the <code>IConfiguration</code> that owns the receiver.
* @since 2.0
*/
public IConfiguration getOwner() {
return owner;
}
/* (non-Javadoc)
* Answers the map containing the strings associated with each option
* ID.
*
* @return
*/
private Map getSettingsMap() {
if (settingsMap == null) {
settingsMap = new HashMap();
}
return settingsMap;
}
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
Object[][] options;
if(resConfigOwner != null) {
options = cat.getOptions(resConfigOwner);
} else {
options = cat.getOptions(owner);
}
if ( options == null)
return;
for (int j = 0; j < options.length; ++j) {
IHoldsOptions optionHolder = (IHoldsOptions)options[j][0];
if (optionHolder == null) break; // The array may not be full
IOption opt = (IOption)options[j][1];
String name = opt.getId();
Object value;
try {
// Switch on the type of option
switch (opt.getValueType()) {
case IOption.BOOLEAN :
try {
value = new Boolean(opt.getBooleanValue());
} catch (BuildException e) {
// Exception occurs if there's an option value type mismatch
break;
}
getSettingsMap().put(name, value);
break;
case IOption.ENUMERATED :
try{
String selId;
selId = opt.getSelectedEnum();
value = opt.getEnumName(selId);
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
case IOption.STRING :
try {
value = opt.getStringValue();
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
case IOption.STRING_LIST :
try {
value = createList(opt.getStringListValue());
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
case IOption.INCLUDE_PATH :
try {
value = createList(opt.getIncludePaths());
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
case IOption.PREPROCESSOR_SYMBOLS :
try {
value = createList(opt.getDefinedSymbols());
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
case IOption.LIBRARIES :
try {
value = createList(opt.getLibraries());
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
case IOption.OBJECTS :
try {
value = createList(opt.getUserObjects());
} catch (BuildException e) {
break;
}
getSettingsMap().put(name, value);
break;
default :
break;
}
} catch (BuildException e) {}
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
*/
public String getString(String name) {
Object s = getSettingsMap().get(name);
if ( s instanceof String )
{
return (String)s;
}
return getDefaultString(name);
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String)
*/
public boolean isDefault(String name) {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
*/
public boolean needsSaving() {
return dirtyFlag;
}
/**
* @param stringList
* @return
*/
public static String[] parseString(String stringList) {
if (stringList == null || stringList.length() == 0) {
return new String[0];
} else {
return stringList.split(BuildToolsSettingsStore.DEFAULT_SEPERATOR);
}
}
/* (non-Javadoc)
*
*/
private void populateSettingsMap() {
// Each configuration has a list of tools
ITool [] tools;
IOptionCategory [] toolChainsCategories;
int index;
// If resConfigOwner is not null, get the resource specific tools.
if ( resConfigOwner != null) {
tools = resConfigOwner.getTools();
// Resource configurations do not support categories that
// are children of toolchains. The reason for this is that
// options in such categories are intended to be global.
// TODO: Remove this restriction in future?
toolChainsCategories = new IOptionCategory[0];
} else {
// Get the tools
tools = owner.getFilteredTools();
// Get the the option categories of the toolChain
IToolChain toolChain = owner.getToolChain();
toolChainsCategories = toolChain.getChildCategories();
}
// Add the tools options to the map
for (index = 0; index < tools.length; ++index) {
// Add the tool to the map
ITool tool = tools[index];
getSettingsMap().put(tool.getId(), tool.getToolCommand());
// Add the options defined for the tool
IOptionCategory cat = tool.getTopOptionCategory();
getOptionsForCategory(cat);
}
// Add the tool chain options to the map
for (index = 0; index < toolChainsCategories.length; ++index) {
// Add the options defined for the category
getOptionsForCategory(toolChainsCategories[index]);
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String)
*/
public void putValue(String name, String value) {
Object oldValue = getSettingsMap().get(name);
if (oldValue == null || !oldValue.equals(value))
{
getSettingsMap().put(name, value);
setDirty(true);
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
public void removePropertyChangeListener(IPropertyChangeListener listener) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, double)
*/
public void setDefault(String name, double value) {
}
/* (non-Javadoc)
* @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) {
}
/* (non-Javadoc)
* @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))
{
getSettingsMap().put(name, value);
setDirty(true);
firePropertyChangeEvent(name, oldValue, value);
}
}
/* (non-Javadoc)
* @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)
{
getSettingsMap().put(name, new Boolean(value));
setDirty(true);
firePropertyChangeEvent(name, new Boolean(oldValue), new Boolean(value));
}
}
/**
* @return Returns the resConfigOwner.
*/
public IResourceConfiguration getResConfigOwner() {
return resConfigOwner;
}
/**
* @param resConfigOwner The resConfigOwner to set.
*/
public void setResConfigOwner(IResourceConfiguration resConfigOwner) {
this.resConfigOwner = resConfigOwner;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004 BitMethods Inc and others. * Copyright (c) 2004, 2005 BitMethods Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,6 +11,10 @@
package org.eclipse.cdt.managedbuilder.ui.properties; package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIImages;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
@ -132,6 +136,10 @@ public class FileListControl {
// The type of browse support that is required // The type of browse support that is required
private int browseType; private int browseType;
private IPath path; private IPath path;
private java.util.List listeners = new ArrayList();
private String oldValue[];
private static final String ADD_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.add"); //$NON-NLS-1$ private static final String ADD_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.add"); //$NON-NLS-1$
private static final String DEL_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.delete"); //$NON-NLS-1$ private static final String DEL_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.delete"); //$NON-NLS-1$
private static final String EDIT_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.edit"); //$NON-NLS-1$ private static final String EDIT_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.edit"); //$NON-NLS-1$
@ -153,6 +161,7 @@ public class FileListControl {
.get(ManagedBuilderUIImages.IMG_FILELIST_MOVEUP); .get(ManagedBuilderUIImages.IMG_FILELIST_MOVEUP);
private final Image IMG_MOVEDOWN = ManagedBuilderUIImages private final Image IMG_MOVEDOWN = ManagedBuilderUIImages
.get(ManagedBuilderUIImages.IMG_FILELIST_MOVEDOWN); .get(ManagedBuilderUIImages.IMG_FILELIST_MOVEDOWN);
/** /**
* Constructor * Constructor
* *
@ -277,7 +286,44 @@ public class FileListControl {
for (int i = 0; i < listVal.length; i++) { for (int i = 0; i < listVal.length; i++) {
list.add(listVal[i]); list.add(listVal[i]);
} }
checkNotificationNeeded();
} }
public void addChangeListener(IFileListChangeListener listener){
listeners.add(listener);
}
public void removeChangeListener(IFileListChangeListener listener){
listeners.remove(listener);
}
public void checkNotificationNeeded(){
String items[] = getItems();
if(oldValue != null){
if(oldValue.length == items.length){
int i;
for(i = 0; i < oldValue.length; i++){
if(!oldValue[i].equals(items[i]))
break;
}
if(i == oldValue.length)
return;
}
String old[] = oldValue;
System.arraycopy(items,0,oldValue = new String[items.length],0,items.length);
notifyListeners(old,oldValue);
} else{
System.arraycopy(items,0,oldValue = new String[items.length],0,items.length);
}
}
public void notifyListeners(String oldVal[], String newVal[]){
Iterator iter = listeners.iterator();
while(iter.hasNext()){
((IFileListChangeListener)iter.next()).fileListChanged(this,oldVal,newVal);
}
}
/** /**
* Set selection * Set selection
* *
@ -299,8 +345,10 @@ public class FileListControl {
* removes all items from list control * removes all items from list control
*/ */
public void removeAll() { public void removeAll() {
if (list != null) if (list != null){
list.removeAll(); list.removeAll();
checkNotificationNeeded();
}
} }
/** /**
* get list items * get list items
@ -361,6 +409,7 @@ public class FileListControl {
list.add(input, 0); list.add(input, 0);
list.setSelection(0); list.setSelection(0);
} }
checkNotificationNeeded();
} }
selectionChanged(); selectionChanged();
@ -375,10 +424,14 @@ public class FileListControl {
String title = ManagedBuilderUIMessages.getResourceString("FileListControl.deletedialog.title"); //$NON-NLS-1$ String title = ManagedBuilderUIMessages.getResourceString("FileListControl.deletedialog.title"); //$NON-NLS-1$
boolean delDir = MessageDialog.openQuestion(list.getShell(), title, boolean delDir = MessageDialog.openQuestion(list.getShell(), title,
quest); quest);
if (delDir && index != -1) if (delDir && index != -1){
list.remove(index); list.remove(index);
} else if (index != -1) checkNotificationNeeded();
}
} else if (index != -1){
list.remove(index); list.remove(index);
checkNotificationNeeded();
}
selectionChanged(); selectionChanged();
} }
/** /**
@ -391,6 +444,7 @@ public class FileListControl {
list.setItem(index - 1, curSelList); list.setItem(index - 1, curSelList);
list.setItem(index, preList); list.setItem(index, preList);
list.setSelection(index - 1); list.setSelection(index - 1);
checkNotificationNeeded();
selectionChanged(); selectionChanged();
} }
/** /**
@ -403,6 +457,7 @@ public class FileListControl {
list.setItem(index + 1, curSelList); list.setItem(index + 1, curSelList);
list.setItem(index, nextList); list.setItem(index, nextList);
list.setSelection(index + 1); list.setSelection(index + 1);
checkNotificationNeeded();
selectionChanged(); selectionChanged();
} }
/** /**
@ -421,6 +476,7 @@ public class FileListControl {
newItem = dialog.getValue(); newItem = dialog.getValue();
if (newItem != null && !newItem.equals(selItem)) { if (newItem != null && !newItem.equals(selItem)) {
list.setItem(index, newItem); list.setItem(index, newItem);
checkNotificationNeeded();
selectionChanged(); selectionChanged();
} }
} }
@ -511,4 +567,14 @@ public class FileListControl {
return input; return input;
} }
public Label getLabelControl(){
return title;
}
public void setEnabled(boolean enabled){
title.setEnabled(enabled);
toolBar.setEnabled(enabled);
list.setEnabled(enabled);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004 BitMethods Inc and others. * Copyright (c) 2004, 2005 BitMethods Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,7 +14,14 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
@ -22,6 +29,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.List;
/** /**
@ -96,10 +104,24 @@ public class FileListControlFieldEditor extends FieldEditor {
topLayout, topLayout,
getLabelText(), getLabelText(),
getType()); getType());
list.addChangeListener(new IFileListChangeListener(){
public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
handleFileListChange(fileList,oldValue,newValue);
}
});
topLayout.setLayout(layout); topLayout.setLayout(layout);
} }
private void handleFileListChange(FileListControl fileList, String oldValue[], String newValue[]){
values = fileList.getItems();
fireValueChanged(
FileListControlFieldEditor.this.getPreferenceName(),
createList(oldValue),
createList(newValue));
}
/** /**
* Returns the browseType of this field editor's file list control * Returns the browseType of this field editor's file list control
* @return * @return
@ -128,8 +150,8 @@ public class FileListControlFieldEditor extends FieldEditor {
list.setList(array); list.setList(array);
list.setSelection(0); list.setSelection(0);
// Set the resource the editor works for // Set the resource the editor works for
if (store instanceof BuildToolsSettingsStore) { if (store instanceof BuildToolSettingsPreferenceStore) {
IConfiguration config = ((BuildToolsSettingsStore)store).getOwner(); IConfiguration config = ((BuildToolSettingsPreferenceStore)store).getSelectedConfig();
if (config != null) { if (config != null) {
IResource project = config.getOwner(); IResource project = config.getOwner();
if (project != null) { if (project != null) {
@ -165,6 +187,10 @@ public class FileListControlFieldEditor extends FieldEditor {
getPreferenceStore().setValue(getPreferenceName(), s); getPreferenceStore().setValue(getPreferenceName(), s);
} }
public String[] getStringListValue(){
return list.getItems();
}
/** /**
* Returns the number of basic controls this field editor consists of. * Returns the number of basic controls this field editor consists of.
* *
@ -222,4 +248,12 @@ public class FileListControlFieldEditor extends FieldEditor {
} }
public Label getLabelControl(Composite parent) {
return list.getLabelControl();
}
public void setEnabled(boolean enabled, Composite parent) {
list.setEnabled(enabled);
}
} }

View file

@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright (c) 2005 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
public interface IFileListChangeListener {
void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]);
}

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
@ -57,11 +58,10 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.help.WorkbenchHelp;
public class ResourceBuildPropertyPage extends PropertyPage implements public class ResourceBuildPropertyPage extends AbstractBuildPropertyPage implements
IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer { IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer {
/* /*
* String constants * String constants
@ -90,6 +90,7 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
private static final String MSG_RC_NON_BUILD = PREFIX + ".rc.non.build"; //$NON-NLS-1$ private static final String MSG_RC_NON_BUILD = PREFIX + ".rc.non.build"; //$NON-NLS-1$
private static final String MSG_RC_GENERATED = PREFIX + ".rc.generated"; //$NON-NLS-1$ private static final String MSG_RC_GENERATED = PREFIX + ".rc.generated"; //$NON-NLS-1$
private static final boolean DEFAULT_EXCLUDE_VALUE = false;
/* /*
* Dialog widgets * Dialog widgets
*/ */
@ -102,16 +103,16 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
/* /*
* Bookeeping variables * Bookeeping variables
*/ */
private boolean isExcluded = false;
private boolean noContentOnPage = false; private boolean noContentOnPage = false;
private IConfiguration[] configurations; private IConfiguration[] configurations;
private IConfiguration selectedConfiguration; private IConfiguration selectedConfiguration;
private IResourceConfiguration currentResourceConfig; private IConfiguration clonedConfiguration;
private IResourceConfiguration clonedResourceConfig;
private Point lastShellSize; private Point lastShellSize;
protected ManagedBuildOptionBlock fOptionBlock; protected ManagedBuildOptionBlock fOptionBlock;
protected boolean displayedConfig = false; protected boolean displayedConfig = false;
/** /**
* Default constructor * Default constructor
*/ */
@ -223,10 +224,10 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
Group tabGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(RESOURCE_SETTINGS_LABEL), 1); Group tabGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(RESOURCE_SETTINGS_LABEL), 1);
gd = new GridData(GridData.FILL_BOTH); gd = new GridData(GridData.FILL_BOTH);
tabGroup.setLayoutData(gd); tabGroup.setLayoutData(gd);
fOptionBlock.createContents(tabGroup, getElement());
// Update the contents of the configuration widget // Update the contents of the configuration widget
populateConfigurations(); populateConfigurations();
fOptionBlock.createContents(tabGroup, getElement());
WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP); WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP);
} }
@ -325,17 +326,18 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
// Set the new selected configuration // Set the new selected configuration
selectedConfiguration = newConfig; selectedConfiguration = newConfig;
ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration); ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
clonedConfiguration = getClonedConfig(selectedConfiguration);
// Set the current Resource Configuration // Set the current Resource Configuration
setCurrentResourceConfig(findCurrentResourceConfig()); clonedResourceConfig = getCurrentResourceConfig(clonedConfiguration,true);
isExcluded = getCurrentResourceConfig().isExcluded();
fOptionBlock.updateValues(); fOptionBlock.updateValues();
excludedCheckBox.setSelection(isExcluded); excludedCheckBox.setSelection(isExcluded());
} }
} }
return; return;
} }
/* /*
* This method updates the property page message * This method updates the property page message
*/ */
@ -438,7 +440,7 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
protected void performDefaults() { protected void performDefaults() {
fOptionBlock.performDefaults(); fOptionBlock.performDefaults();
excludedCheckBox.setSelection(getCurrentResourceConfig().isExcluded()); excludedCheckBox.setSelection(getCurrentResourceConfigClone().isExcluded());
super.performDefaults(); super.performDefaults();
} }
@ -458,7 +460,13 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
IRunnableWithProgress runnable = new IRunnableWithProgress() { IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) { public void run(IProgressMonitor monitor) {
if(containsDefaults()){
removeCurrentResourceConfig();
return;
}
fOptionBlock.performApply(monitor); fOptionBlock.performApply(monitor);
getCurrentResourceConfig(true).setExclude(getCurrentResourceConfigClone().isExcluded());
} }
}; };
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable); IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
@ -475,9 +483,10 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
// Write out the build model info // Write out the build model info
ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration()); ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration());
if ( getCurrentResourceConfig().isExcluded() != isExcluded() ) {
getCurrentResourceConfig().setExclude(isExcluded()); if(getCurrentResourceConfigClone().isDirty()){
selectedConfiguration.setRebuildState(true); selectedConfiguration.setRebuildState(true);
getCurrentResourceConfigClone().setDirty(false);
} }
ManagedBuildManager.saveBuildInfo(getProject(), false); ManagedBuildManager.saveBuildInfo(getProject(), false);
@ -486,9 +495,26 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
if (bi != null & bi instanceof ManagedBuildInfo) { if (bi != null & bi instanceof ManagedBuildInfo) {
((ManagedBuildInfo)bi).initializePathEntries(); ((ManagedBuildInfo)bi).initializePathEntries();
} }
EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
return true; return true;
} }
public boolean containsDefaults(){
if(getCurrentResourceConfigClone().isExcluded() != DEFAULT_EXCLUDE_VALUE)
return false;
return fOptionBlock.containsDefaults();
}
public boolean performCancel() {
EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject());
return true;
}
private void populateConfigurations() { private void populateConfigurations() {
ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration); ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration);
@ -518,54 +544,31 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
/** /**
* @return Returns the currentResourceConfig. * @return Returns the currentResourceConfig.
*/ */
public IResourceConfiguration getCurrentResourceConfig() { public IResourceConfiguration getCurrentResourceConfigClone() {
return currentResourceConfig; return clonedResourceConfig;
} }
/** public IResourceConfiguration getCurrentResourceConfig(boolean create) {
* @param currentResourceConfig return getCurrentResourceConfig(selectedConfiguration,create);
* The currentResourceConfig to set.
*/
public void setCurrentResourceConfig(
IResourceConfiguration currentResourceConfig) {
if (currentResourceConfig != null)
this.currentResourceConfig = currentResourceConfig;
else {
IFile file = (IFile) getElement();
// create a new resource configuration for this resource.
this.currentResourceConfig = selectedConfiguration.createResourceConfiguration(file);
}
} }
// Check whether a resource configuration already exists for the current
// resource in selectedConfiguration.
// if so, return the resource configuration, otherwise return null.
public IResourceConfiguration findCurrentResourceConfig() { private IResourceConfiguration getCurrentResourceConfig(IConfiguration cfg, boolean create){
IResourceConfiguration rcCfg = cfg.getResourceConfiguration(((IFile)getElement()).getFullPath().toString());
IResourceConfiguration resConfigElement = null; if(rcCfg == null && create)
rcCfg = cfg.createResourceConfiguration((IFile)getElement());
// Check if the selected configuration has any resourceConfigurations. return rcCfg;
if (selectedConfiguration.getResourceConfigurations().length == 0)
return null;
IResourceConfiguration[] resourceConfigurations = selectedConfiguration
.getResourceConfigurations();
IFile file = (IFile) getElement();
// Check whether a resource configuration is already exists for the
// selected file.
for (int i = 0; i < resourceConfigurations.length; i++) {
resConfigElement = resourceConfigurations[i];
if (file.getFullPath().toString().equals(
resConfigElement.getResourcePath())) {
return resConfigElement;
}
} }
return null; public boolean removeCurrentResourceConfig(){
IResourceConfiguration rcCfg = getCurrentResourceConfig(false);
if(rcCfg != null){
selectedConfiguration.removeResourceConfiguration(rcCfg);
return true;
} }
return false;
}
/** /**
* @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons() * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
*/ */
@ -610,10 +613,11 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
/* (non-Javadoc) /* (non-Javadoc)
* Return the IPreferenceStore of the Tool Settings block * Return the IPreferenceStore of the Tool Settings block
*/ */
public IPreferenceStore getToolSettingsPreferenceStore() public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore()
{ {
return fOptionBlock.getToolSettingsPreferenceStore(); return fOptionBlock.getToolSettingsPreferenceStore();
} }
public Preferences getPreferences() public Preferences getPreferences()
{ {
return null; return null;
@ -625,12 +629,14 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
* @return Returns the isExcluded. * @return Returns the isExcluded.
*/ */
public boolean isExcluded(){ public boolean isExcluded(){
return isExcluded; return getCurrentResourceConfigClone().isExcluded();
} }
/** /**
* @param isExcluded The isExcluded to set. * @param isExcluded The isExcluded to set.
*/ */
public void setExcluded(boolean isExcluded) { public void setExcluded(boolean isExcluded) {
this.isExcluded = isExcluded; getCurrentResourceConfigClone().setExclude(isExcluded);
fOptionBlock.updateValues();
} }
} }