diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java index 73dd1133ed8..453fde57045 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java @@ -470,5 +470,11 @@ public interface IConfiguration extends IBuildObject { * @return IConfigurationBuildMacroSupplier */ public IConfigurationBuildMacroSupplier getBuildMacroSupplier(); + + /** + * answers true if the configuration is temporary, otherwise - false + * @return boolean + */ + public boolean isTemporary(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index f64a27042e3..ba677f2485e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -1529,7 +1529,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI // Create the internal representation of the project's MBS information buildInfo = new ManagedBuildInfo(project, (Element)node, fileVersion); if (fileVersion != null) { - buildInfo.setVersion(fileVersion); + // buildInfo.setVersion(fileVersion); PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion); PluginVersionIdentifier version21 = new PluginVersionIdentifier("2.1"); //$NON-NLS-1$ // 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; } + /* + * 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 */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java index a880d7b9df9..b33be6b53d0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildObject.java @@ -119,4 +119,12 @@ public class BuildObject implements IBuildObject { public void setManagedBuildRevision(String managedBuildRevision) { this.managedBuildRevision = managedBuildRevision; } + + /* + * updates revision for this build object and all its children + */ + public void updateManagedBuildRevision(String revision){ + setManagedBuildRevision(revision); + setVersion(getVersionFromId()); + } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index c881fd5df63..07d2a1cea47 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -23,21 +23,23 @@ import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CProjectNature; 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.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; 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.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.ITool; +import org.eclipse.cdt.managedbuilder.core.IToolChain; 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.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.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -76,6 +78,7 @@ public class Configuration extends BuildObject implements IConfiguration { private boolean isDirty = false; private boolean rebuildNeeded = false; 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 cloneChildren If true, 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); setName(cloneConfig.getName()); + this.description = cloneConfig.getDescription(); this.managedProject = managedProject; isExtensionConfig = false; + this.isTemporary = temporary; // set managedBuildRevision setManagedBuildRevision(cloneConfig.getManagedBuildRevision()); @@ -264,39 +269,48 @@ public class Configuration extends BuildObject implements IConfiguration { // Clone the configuration's children // Tool Chain - int nnn = ManagedBuildManager.getRandomNumber(); String subId; - String tmpId; String subName; if (cloneConfig.parent != null) { - tmpId = cloneConfig.parent.getToolChain().getId(); + subId = ManagedBuildManager.calculateChildId( + cloneConfig.parent.getToolChain().getId(), + null); subName = cloneConfig.parent.getToolChain().getName(); } else { - tmpId = cloneConfig.getToolChain().getId(); + subId = ManagedBuildManager.calculateChildId( + cloneConfig.getToolChain().getId(), + null); 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) { 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 { // Add a tool-chain element that specifies as its superClass the // tool-chain that is the child of the configuration. ToolChain superChain = (ToolChain)cloneConfig.getToolChain(); - tmpId = superChain.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$ - } + subId = ManagedBuildManager.calculateChildId( + superChain.getId(), + null); IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false); // For each option/option category child of the tool-chain that is @@ -312,15 +326,8 @@ public class Configuration extends BuildObject implements IConfiguration { ITool[] tools = superChain.getTools(); for (int i=0; inull if none. * @@ -1477,7 +1498,6 @@ public class ToolChain extends HoldsOptions implements IToolChain { public void checkForMigrationSupport() { - String tmpId = null; boolean isExists = false; if (getSuperClass() == null) { @@ -1655,4 +1675,19 @@ public class ToolChain extends HoldsOptions implements IToolChain { public IConfigurationElement getCurrentMbsVersionConversionElement() { 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); + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java index e9941eee2b6..0cbe8a0c900 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/StorableEnvironment.java @@ -90,10 +90,13 @@ public class StorableEnvironment { if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$ return null; - StorableEnvVar var = new StorableEnvVar(name, value, op, delimiter); - addVariable(var); - fIsDirty = true; - fIsChanged = true; + IBuildEnvironmentVariable var = checkVariable(name,value,op,delimiter); + if(var == null){ + var = new StorableEnvVar(name, value, op, delimiter); + addVariable(var); + fIsDirty = true; + fIsChanged = true; + } return var; } @@ -109,6 +112,23 @@ public class StorableEnvironment { 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. * If the dirty state is true, that means that the environment @@ -162,6 +182,35 @@ public class StorableEnvironment { 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(){ Collection vars = getMap().values(); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java index ac815d2f087..a68d1f160b1 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/envvar/UserDefinedEnvironmentSupplier.java @@ -17,6 +17,8 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; 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.IWorkspace; import org.eclipse.core.resources.ProjectScope; @@ -47,56 +49,35 @@ public class UserDefinedEnvironmentSupplier extends EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$ }; - private StorableEnvironment fConfigurationVariables; - private StorableEnvironment fProjectVariables; private StorableEnvironment fWorkspaceVariables; - private IConfiguration fCurrentCfg = null; - private IManagedProject fCurrentProj = null; - protected StorableEnvironment getEnvironment(Object context){ + return getEnvironment(context,true); + } + + protected StorableEnvironment getEnvironment(Object context, boolean forceLoad){ if(context == null) return null; StorableEnvironment env = null; if(context instanceof IConfiguration){ - IConfiguration newCfg = (IConfiguration)context; - if(fCurrentCfg == newCfg && fConfigurationVariables != null){ - env = fConfigurationVariables; - } - else{ - env = loadEnvironment(newCfg); - if(env != null){ - if(fConfigurationVariables != null) - try{ - storeEnvironment(fConfigurationVariables,fCurrentCfg,false); - } catch(CoreException e){ - } - fConfigurationVariables = env; - fCurrentCfg = newCfg; - } + IConfiguration cfg = (IConfiguration)context; + env = ((ToolChain)cfg.getToolChain()).getUserDefinedEnvironment(); + if(env == null && forceLoad){ + env = loadEnvironment(cfg); + ((ToolChain)cfg.getToolChain()).setUserDefinedEnvironment(env); } } - else if(context instanceof IManagedProject){ - IManagedProject newProj = (IManagedProject)context; - if(fCurrentProj == newProj && fProjectVariables != null){ - env = fProjectVariables; - } - 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 ManagedProject){ + ManagedProject proj = (ManagedProject)context; + env = proj.getUserDefinedEnvironmet(); + if(env == null && forceLoad){ + env = loadEnvironment(proj); + proj.setUserDefinedEnvironmet(env); } } else if(context instanceof IWorkspace){ - if(fWorkspaceVariables == null) + if(fWorkspaceVariables == null && forceLoad) fWorkspaceVariables = loadEnvironment(context); env = fWorkspaceVariables; } @@ -189,7 +170,7 @@ public class UserDefinedEnvironmentSupplier extends return; try{ - String ids[] = prefNode.childrenNames(); + String ids[] = prefNode.keys(); boolean found = false; for( int i = 0; i < ids.length; i++){ if(managedProject.getConfiguration(ids[i]) == null){ @@ -206,29 +187,22 @@ public class UserDefinedEnvironmentSupplier extends } 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){ try{ storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force); } 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,7 +235,8 @@ public class UserDefinedEnvironmentSupplier extends if(env == null) return null; IBuildEnvironmentVariable var = env.createVariable(name,value,op,delimiter); - setRebuildStateForContext(context); + if(env.isChanged()) + setRebuildStateForContext(context); return var; } @@ -284,6 +259,16 @@ public class UserDefinedEnvironmentSupplier extends 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){ if(context == null) return; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java index c53d7fbb91a..8b701cd7b9f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/StorableMacros.java @@ -102,12 +102,93 @@ public class StorableMacros { if(name == null || "".equals(name = name.trim()) || MacroResolver.isStringListMacro(type)) //$NON-NLS-1$ return null; - StorableBuildMacro macro = new StorableBuildMacro(name, type, value); - addMacro(macro); - fIsDirty = true; - fIsChanged = true; + IBuildMacro macro = checkMacro(name, type, value); + if(macro == null){ + macro = new StorableBuildMacro(name, type, value); + addMacro(macro); + fIsDirty = true; + fIsChanged = true; + } 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){ String name = copy.getName(); @@ -116,19 +197,28 @@ public class StorableMacros { int type = copy.getMacroValueType(); - StorableBuildMacro macro = null; + IBuildMacro macro = null; try{ if(MacroResolver.isStringListMacro(type)){ String value[] = copy.getStringListValue(); - macro = new StorableBuildMacro(name, type, value); + macro = checkMacro(name, type, value); + if(macro == null){ + macro = new StorableBuildMacro(name, type, value); + addMacro(macro); + fIsDirty = true; + fIsChanged = true; + } } else { String value = copy.getStringValue(); - macro = new StorableBuildMacro(name, type, value); + macro = checkMacro(name, type, value); + if(macro == null){ + macro = new StorableBuildMacro(name, type, value); + addMacro(macro); + fIsDirty = true; + fIsChanged = true; + } } - addMacro(macro); - fIsDirty = true; - fIsChanged = true; }catch(BuildMacroException e){ } @@ -139,10 +229,13 @@ public class StorableMacros { if(name == null || "".equals(name = name.trim()) || !MacroResolver.isStringListMacro(type)) //$NON-NLS-1$ return null; - StorableBuildMacro macro = new StorableBuildMacro(name, type, value); - addMacro(macro); - fIsDirty = true; - fIsChanged = true; + IBuildMacro macro = checkMacro(name, type, value); + if(macro == null){ + macro = new StorableBuildMacro(name, type, value); + addMacro(macro); + fIsDirty = true; + fIsChanged = true; + } return macro; } @@ -215,7 +308,7 @@ public class StorableMacros { 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$ return null; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java index 9c50642be93..0ec62d2c11e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/UserDefinedMacroSupplier.java @@ -152,7 +152,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier { return null; IBuildMacro macro = macros.createMacro(macroName,type,value); - if(macro != null) + if(macros.isChanged()) setRebuildStateForContext(contextType, contextData); return macro; @@ -171,7 +171,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier { return null; IBuildMacro macro = macros.createMacro(macroName,type,value); - if(macro != null) + if(macros.isChanged()) setRebuildStateForContext(contextType, contextData); return macro; @@ -189,7 +189,7 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier { return null; IBuildMacro macro = macros.createMacro(copy); - if(macro != null) + if(macros.isChanged()) setRebuildStateForContext(contextType, contextData); return macro; @@ -214,6 +214,16 @@ public class UserDefinedMacroSupplier implements IBuildMacroSupplier { if(macros.deleteAll()) 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); + } /* * diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java index 2118a3e150d..30057a03c34 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java @@ -746,7 +746,7 @@ class UpdateManagedProject12 { } // Upgrade the version - ((ManagedBuildInfo)info).setVersion("2.1.0"); + ((ManagedBuildInfo)info).setVersion("2.1.0"); //$NON-NLS-1$ info.setValid(true); } catch (CoreException e){ throw e; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java index 8c337c4c2d2..a5f9824671d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java @@ -97,7 +97,7 @@ class UpdateManagedProject20 { } } // Upgrade the version - ((ManagedBuildInfo)info).setVersion("2.1.0"); + ((ManagedBuildInfo)info).setVersion("2.1.0"); //$NON-NLS-1$ info.setValid(true); }catch (CoreException e){ throw e; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java index ea04f2e0b58..edb0a290a1d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java @@ -306,6 +306,7 @@ public class UpdateManagedProjectManager { } ),null)); } + } catch (CoreException e) { fIsInfoReadOnly = true; throw e; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java index 836cd5dc1a6..e4872ef1cc5 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java @@ -76,19 +76,38 @@ public class BuildSettingsBlock extends AbstractCOptionPage { * Bookeeping variables */ 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? private boolean dirty = false; private ModifyListener widgetModified = new ModifyListener() { public void modifyText(ModifyEvent e) { - setDirty(true); + IConfiguration config = parent.getSelectedConfigurationClone(); + if(e.widget == buildArtifactName){ + String val = buildArtifactName.getText().trim(); + if(!val.equals(config.getArtifactName())){ + config.setArtifactName(val); + setValues(); + 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 () { public void widgetSelected(SelectionEvent e) { handleUseDefaultPressed(); - setDirty(true); } }); makeCommandDefault.addDisposeListener(new DisposeListener() { @@ -243,7 +261,14 @@ public class BuildSettingsBlock extends AbstractCOptionPage { buildMacrosExpand.setForeground(buildMacrosExpandGroup.getForeground()); buildMacrosExpand.addSelectionListener(new SelectionAdapter () { public void widgetSelected(SelectionEvent e) { - setDirty(true); + 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); + } } }); buildMacrosExpand.addDisposeListener(new DisposeListener() { @@ -255,36 +280,39 @@ public class BuildSettingsBlock extends AbstractCOptionPage { protected void initializeValues() { setValues(); + setDirty(false); } public void updateValues() { setValues(); - useDefaultMake = !parent.getSelectedConfiguration().hasOverriddenBuildCommand(); - makeCommandDefault.setSelection(useDefaultMake); + makeCommandDefault.setSelection(!parent.getSelectedConfigurationClone().hasOverriddenBuildCommand()); makeCommandEntry.setEditable(!makeCommandDefault.getSelection()); } protected void setValues() { - artifactName = parent.getSelectedConfiguration().getArtifactName(); - buildArtifactName.setText(artifactName); - artifactExt = parent.getSelectedConfiguration().getArtifactExtension(); - buildArtifactExt.setText(artifactExt); - makeCommand = parent.getSelectedConfiguration().getBuildCommand(); - String makeArgs = parent.getSelectedConfiguration().getBuildArguments(); + IConfiguration config = parent.getSelectedConfigurationClone(); + if(!config.getArtifactName().equals(buildArtifactName.getText())) + buildArtifactName.setText(config.getArtifactName()); + + if(!config.getArtifactExtension().equals(buildArtifactExt.getText())) + buildArtifactExt.setText(config.getArtifactExtension()); + String makeCommand = config.getBuildCommand(); + String makeArgs = config.getBuildArguments(); if (makeArgs != null) { makeCommand += " " + makeArgs; //$NON-NLS-1$ } - makeCommandEntry.setText(makeCommand); + if(!makeCommand.equals(makeCommandEntry.getText())) + makeCommandEntry.setText(makeCommand); BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); - if(!provider.canKeepMacrosInBuildfile(this.parent.getSelectedConfiguration())) + if(!provider.canKeepMacrosInBuildfile(config)) buildMacrosExpandGroup.setVisible(false); else { buildMacrosExpandGroup.setVisible(true); - buildMacrosExpand.setSelection(provider.areMacrosExpandedInBuildfile(parent.getSelectedConfiguration())); + buildMacrosExpand.setSelection(provider.areMacrosExpandedInBuildfile(config)); } - setDirty(false); +// setDirty(false); } public void removeValues(String id) { @@ -297,36 +325,24 @@ public class BuildSettingsBlock extends AbstractCOptionPage { */ public void performDefaults() { - // 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("BuildSettingsBlock.defaults.title"), //$NON-NLS-1$ - 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(); + IConfiguration cloneConfig = parent.getSelectedConfigurationClone(); + cloneConfig.setArtifactName(cloneConfig.getManagedProject().getDefaultArtifactName()); + cloneConfig.setArtifactExtension(null); + IBuilder cloneBuilder = cloneConfig.getToolChain().getBuilder(); + if (!cloneBuilder.isExtensionElement()) { + cloneConfig.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 BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); - provider.expandMacrosInBuildfile(config,false); + provider.expandMacrosInBuildfile(cloneConfig,false); setValues(); makeCommandDefault.setSelection(true); 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) */ 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(); - IBuilder builder = selectedConfiguration.getToolChain().getBuilder(); - boolean setBuilderValues = false; - + IConfiguration cloneConfig = parent.getSelectedConfigurationClone(); + + String buildCommand = cloneConfig.getBuildCommand(); + String buildArgs = cloneConfig.getBuildArguments(); + String artifactName = cloneConfig.getArtifactName(); + String artifactExt = cloneConfig.getArtifactExtension(); + // Set the build output name if (!selectedConfiguration.getArtifactName().equals(artifactName)) { - setBuilderValues = true; + selectedConfiguration.setArtifactName(artifactName); } // Set the build output extension if (!selectedConfiguration.getArtifactExtension().equals(artifactExt)) { - setBuilderValues = true; + selectedConfiguration.setArtifactExtension(artifactExt); } // Set the new make command - String makeCommandOnly = null; - String makeArguments = null; - 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 the configuration does not already have a "local" builder, we - // 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); - } + if(!selectedConfiguration.getBuildCommand().equals(buildCommand)) + selectedConfiguration.setBuildCommand(buildCommand); + if(!selectedConfiguration.getBuildArguments().equals(buildArgs)) + selectedConfiguration.setBuildArguments(buildArgs); + BuildMacroProvider provider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider(); - if(provider.canKeepMacrosInBuildfile(this.parent.getSelectedConfiguration())) - provider.expandMacrosInBuildfile(selectedConfiguration,buildMacrosExpand.getSelection()); + provider.expandMacrosInBuildfile( + selectedConfiguration, + provider.areMacrosExpandedInBuildfile(cloneConfig)); setDirty(false); } @@ -534,9 +509,7 @@ public class BuildSettingsBlock extends AbstractCOptionPage { */ public void setVisible(boolean visible) { if (visible) { - useDefaultMake = !parent.getSelectedConfiguration().hasOverriddenBuildCommand(); - makeCommandDefault.setSelection(useDefaultMake); - makeCommandEntry.setEditable(!makeCommandDefault.getSelection()); + setValues(); } super.setVisible(visible); } @@ -547,16 +520,16 @@ public class BuildSettingsBlock extends AbstractCOptionPage { protected void handleUseDefaultPressed() { // If the state of the button is unchecked, then we want to enable the edit widget boolean checked = makeCommandDefault.getSelection(); + IConfiguration config = parent.getSelectedConfigurationClone(); if (checked == true) { - // TODO: This should NOT change the configuration immediately - - // it should set an intermediate variable and wait for OK/Apply - parent.getSelectedConfiguration().setBuildCommand(null); - parent.getSelectedConfiguration().setBuildArguments(null); + config.setBuildCommand(null); + config.setBuildArguments(null); makeCommandEntry.setEditable(false); } else { makeCommandEntry.setEditable(true); } setValues(); + setDirty(true); } /** diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java index 8c3978971a0..e11187a1155 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java @@ -62,17 +62,43 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage { * Bookeeping variables */ private BuildPropertyPage parent; - private String preBuildCommand; - private String preBuildAnnounce; - private String postBuildCommand; - private String postBuildAnnounce; // Has the page been changed? private boolean dirty = false; private ModifyListener widgetModified = new ModifyListener() { public void modifyText(ModifyEvent e) { - setDirty(true); + IConfiguration config = parent.getSelectedConfigurationClone(); + if(e.widget == preBuildCmd){ + String val = preBuildCmd.getText().trim(); + if(!val.equals(config.getPrebuildStep())){ + config.setPrebuildStep(val); + setValues(); + 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() { setValues(); + setDirty(false); } public void updateValues() { @@ -227,15 +254,18 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage { protected void setValues() { // Fetch values from the current configuration and set in the UI - preBuildCommand = parent.getSelectedConfiguration().getPrebuildStep(); - preBuildCmd.setText(preBuildCommand); - preBuildAnnounce = parent.getSelectedConfiguration().getPreannouncebuildStep(); - preBuildAnnc.setText(preBuildAnnounce); - postBuildCommand = parent.getSelectedConfiguration().getPostbuildStep(); - postBuildCmd.setText(postBuildCommand); - postBuildAnnounce = parent.getSelectedConfiguration().getPostannouncebuildStep(); - postBuildAnnc.setText(postBuildAnnounce); - setDirty(false); //Indicate that the UI state is consistent with internal state + IConfiguration config = parent.getSelectedConfigurationClone(); + if(!config.getPrebuildStep().equals(preBuildCmd.getText())) + preBuildCmd.setText(config.getPrebuildStep()); + + if(!config.getPreannouncebuildStep().equals(preBuildAnnc.getText())) + preBuildAnnc.setText(config.getPreannouncebuildStep()); + + if(!config.getPostbuildStep().equals(postBuildCmd.getText())) + postBuildCmd.setText(config.getPostbuildStep()); + + if(!config.getPostannouncebuildStep().equals(postBuildAnnc.getText())) + postBuildAnnc.setText(config.getPostannouncebuildStep()); } public void removeValues(String id) { @@ -247,32 +277,16 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage { * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ public void performDefaults() { - IConfiguration config = parent.getSelectedConfiguration(); - boolean mustSetValue = false; - - // 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("BuildStepsSettingsBlock.defaults.title"), //$NON-NLS-1$ - ManagedBuilderUIMessages.getResourceString("BuildStepsSettingsBlock.defaults.message")); //$NON-NLS-1$ - if (!shouldDefault) return; + IConfiguration cloneConfig = parent.getSelectedConfigurationClone(); - // 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); + cloneConfig.setPrebuildStep(null); + cloneConfig.setPreannouncebuildStep(null); + cloneConfig.setPostbuildStep(null); + cloneConfig.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 setValues(); + setDirty(true); } @@ -282,36 +296,26 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage { */ 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(); - boolean mustSetValue = false; + IConfiguration cloneConfig = parent.getSelectedConfigurationClone(); - if (!selectedConfiguration.getPrebuildStep().equals(preBuildCommand)) { - mustSetValue = true; + if (!selectedConfiguration.getPrebuildStep().equals( + cloneConfig.getPrebuildStep())) { + selectedConfiguration.setPrebuildStep(cloneConfig.getPrebuildStep()); } - else if (!selectedConfiguration.getPreannouncebuildStep().equals(preBuildAnnounce)) { - mustSetValue = true; + if (!selectedConfiguration.getPreannouncebuildStep().equals( + cloneConfig.getPreannouncebuildStep())) { + selectedConfiguration.setPreannouncebuildStep(cloneConfig.getPreannouncebuildStep()); } - else if (!selectedConfiguration.getPostbuildStep().equals(postBuildCommand)) { - mustSetValue = true; + if (!selectedConfiguration.getPostbuildStep().equals( + cloneConfig.getPostbuildStep())) { + selectedConfiguration.setPostbuildStep(cloneConfig.getPostbuildStep()); } - else if (!selectedConfiguration.getPostannouncebuildStep().equals(postBuildAnnounce)) { - mustSetValue = true; + if (!selectedConfiguration.getPostannouncebuildStep().equals( + 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 } @@ -334,4 +338,10 @@ public class BuildStepSettingsBlock extends AbstractCOptionPage { public boolean isDirty() { return dirty; } + + public void setVisible(boolean visible){ + if(visible) + setValues(); + super.setVisible(visible); + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java index 44632206723..a725c33bcb6 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentBlock.java @@ -42,6 +42,7 @@ import org.eclipse.cdt.managedbuilder.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.IBuildMacro; import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; 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.BuildPropertyPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; @@ -253,6 +254,9 @@ public class EnvironmentBlock extends AbstractCOptionPage { */ public IEnvironmentVariableSupplier[] getSuppliers(Object context){ IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context); + + if(context == fContext && storeDirectly()) + return suppliers; if(suppliers == null || suppliers.length == 0) return suppliers; @@ -288,7 +292,7 @@ public class EnvironmentBlock extends AbstractCOptionPage { if(context != fContext) return null; - return (IBuildEnvironmentVariable)getUserVariables().get(name); + return getUserVariable(name); } /* (non-Javadoc) @@ -298,8 +302,7 @@ public class EnvironmentBlock extends AbstractCOptionPage { if(context != fContext) return null; - Collection vars = getUserVariables().values(); - return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]); + return getUserVariables(); } } @@ -457,7 +460,7 @@ public class EnvironmentBlock extends AbstractCOptionPage { /* * returns the map containing the user-defined variables */ - private Map getUserVariables(){ + private Map getUserVariablesMap(){ Map map = new HashMap(); if(fUserSupplier != null) { if(!fDeleteAll){ @@ -489,6 +492,14 @@ public class EnvironmentBlock extends AbstractCOptionPage { 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 */ @@ -515,28 +526,41 @@ public class EnvironmentBlock extends AbstractCOptionPage { private void addUserVariable(String name, String value, int op, String delimiter){ if(!canCreate(name)) return; - fDeleteAll = false; - BuildEnvVar newVar = new BuildEnvVar(name,value,op,delimiter); - if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) - name = name.toUpperCase(); - getDeletedUserVariableNames().remove(name); - getAddedUserVariables().put(name,newVar); + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.createVariable(name,value, op, delimiter, fContext); + } else { + fDeleteAll = false; + BuildEnvVar newVar = new BuildEnvVar(name,value,op,delimiter); + if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) + name = name.toUpperCase(); + getDeletedUserVariableNames().remove(name); + getAddedUserVariables().put(name,newVar); + } fModified = true; } + protected boolean storeDirectly(){ + if(fContext instanceof IConfiguration) + return ((IConfiguration)fContext).isTemporary(); + return false; + } + /* * deletes a user variable * 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 */ private void deleteUserVariable(String name){ - fDeleteAll = false; - if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) - name = name.toUpperCase(); - getAddedUserVariables().remove(name); - getDeletedUserVariableNames().add(name); - + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.deleteVariable(name, fContext); + } else { + fDeleteAll = false; + if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) + name = name.toUpperCase(); + getAddedUserVariables().remove(name); + getDeletedUserVariableNames().add(name); + } fModified = true; } @@ -545,10 +569,13 @@ public class EnvironmentBlock extends AbstractCOptionPage { * the applyUserVariables() should be called to delete those variabes from the user supplier */ private void deleteAllUserVariables(){ - fDeleteAll = true; - getDeletedUserVariableNames().clear(); - getAddedUserVariables().clear(); - + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.deleteAll(fContext); + } else { + fDeleteAll = true; + getDeletedUserVariableNames().clear(); + getAddedUserVariables().clear(); + } fModified = true; } @@ -570,13 +597,13 @@ public class EnvironmentBlock extends AbstractCOptionPage { * returns a user variable of a given name */ private IBuildEnvironmentVariable getUserVariable(String name){ - Map vars = getUserVariables(); - if(vars == null) - return null; - if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive()) name = name.toUpperCase(); - return (IBuildEnvironmentVariable)vars.get(name); + + if(fUserSupplier != null && storeDirectly()) + return fUserSupplier.getVariable(name, fContext); + + return (IBuildEnvironmentVariable)getUserVariablesMap().get(name); } /* @@ -585,23 +612,34 @@ public class EnvironmentBlock extends AbstractCOptionPage { */ private void applyUserVariables(){ if(fUserSupplier != null){ - if(fDeleteAll){ - fUserSupplier.deleteAll(fContext); - } - else{ - Iterator iter = getDeletedUserVariableNames().iterator(); - while(iter.hasNext()){ - fUserSupplier.deleteVariable((String)iter.next(),fContext); + 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); } - - iter = getAddedUserVariables().values().iterator(); - while(iter.hasNext()){ - IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next(); - fUserSupplier.createVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter(),fContext); + } else { + if(fDeleteAll){ + fUserSupplier.deleteAll(fContext); + } + else{ + Iterator iter = getDeletedUserVariableNames().iterator(); + while(iter.hasNext()){ + fUserSupplier.deleteVariable((String)iter.next(),fContext); + } + + iter = getAddedUserVariables().values().iterator(); + while(iter.hasNext()){ + IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next(); + fUserSupplier.createVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter(),fContext); + } + + getDeletedUserVariableNames().clear(); + getAddedUserVariables().clear(); } - - getDeletedUserVariableNames().clear(); - getAddedUserVariables().clear(); } } } @@ -611,6 +649,7 @@ public class EnvironmentBlock extends AbstractCOptionPage { */ private void storeUserVariables(){ applyUserVariables(); + if(fUserSupplier != null) fUserSupplier.serialize(false); } @@ -813,12 +852,11 @@ public class EnvironmentBlock extends AbstractCOptionPage { // handleSelectionChanged(fEditableList); if(fUserSupplier != null) { - Collection vars = getUserVariables().values(); - Iterator iter = vars.iterator(); + IBuildEnvironmentVariable variables[] = getUserVariables(); - List list = new ArrayList(vars.size()); - while(iter.hasNext()){ - IBuildEnvironmentVariable userVar = (IBuildEnvironmentVariable)iter.next(); + List list = new ArrayList(variables.length); + for( int i = 0; i < variables.length; i++ ){ + IBuildEnvironmentVariable userVar = variables[i]; if(userVar != null){ IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true); IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java index 996ff0bbde3..53efc1a0724 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/EnvironmentSetBlock.java @@ -150,10 +150,10 @@ public class EnvironmentSetBlock extends AbstractCOptionPage { if(fParentContainer instanceof BuildPropertyPage){ BuildPropertyPage page = (BuildPropertyPage)fParentContainer; - if(page.getSelectedConfiguration() != null) - fFolderTabs[1].setContext(page.getSelectedConfiguration().getManagedProject()); + if(page.getSelectedConfigurationClone() != null) + fFolderTabs[1].setContext(page.getSelectedConfigurationClone().getManagedProject()); - fFolderTabs[0].setContext(page.getSelectedConfiguration()); + fFolderTabs[0].setContext(page.getSelectedConfigurationClone()); fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo()); } else { diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java index 7c3de7e7081..1f86d805e8f 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ErrorParserBlock.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,10 +12,11 @@ package org.eclipse.cdt.managedbuilder.internal.ui; 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.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.NewManagedProjectWizard; import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock; @@ -26,9 +27,12 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.preference.IPreferenceStore; public class ErrorParserBlock extends AbstractErrorParserBlock { - - public ErrorParserBlock() { + private BuildPropertyPage parent; + private String errorParsers[]; + + public ErrorParserBlock(BuildPropertyPage parent) { super(); + this.parent = parent; } protected String[] getErrorParserIDs(IConfiguration config) { @@ -45,8 +49,11 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { } 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 // managed build project, and the user selects the error parsers // 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 // This is invoked by the managed builder new project wizard before the // project is created. + if(parent != null){ + return getErrorParserIDs(parent.getSelectedConfigurationClone()); + } ICOptionContainer container = getContainer(); if (container instanceof NewManagedProjectOptionPage) { NewManagedProjectOptionPage parent = (NewManagedProjectOptionPage)getContainer(); @@ -82,7 +92,11 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { } 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) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < parsers.length; i++) { @@ -96,10 +110,32 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { public IPreferenceStore getPreferenceStore() { 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() { super.setValues(); + if(parent != null && parent.getSelectedConfigurationClone() != null) + errorParsers = getErrorParserIDs(parent.getSelectedConfigurationClone()); + // TODO: This reset belongs in AbstractErrorParserBlock.java? // Reset the "dirty" flag listDirty = false; @@ -108,6 +144,11 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { public void performApply(IProgressMonitor monitor) throws CoreException { 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? // Reset the "dirty" flag listDirty = false; @@ -127,4 +168,32 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { public boolean isDirty() { 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(); + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java index 3b47c49dc49..9a8ae9ca746 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosBlock.java @@ -20,9 +20,9 @@ import java.util.Map; import java.util.Set; 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.EnvironmentVariableProvider; -import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacro; import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider; import org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroContextInfo; 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.IBuildMacroStatus; 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.BuildPropertyPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; @@ -328,6 +329,10 @@ public class MacrosBlock extends AbstractCOptionPage { */ public IBuildMacroSupplier[] getSuppliers(int contextType, Object contextData){ IBuildMacroSupplier suppliers[] = super.getSuppliers(contextType,contextData); + + if(contextType == fContextType && contextData == fContextData && storeDirectly()) + return suppliers; + if(suppliers == null || suppliers.length == 0) return suppliers; if(!(suppliers[0] instanceof UserDefinedMacroSupplier)) @@ -362,7 +367,7 @@ public class MacrosBlock extends AbstractCOptionPage { if(contextType != fContextType || contextData != fContextData) return null; - return (IBuildMacro)getUserMacros().get(name); + return getUserMacro(name); } /* (non-Javadoc) @@ -372,8 +377,7 @@ public class MacrosBlock extends AbstractCOptionPage { if(contextType != fContextType || contextData != fContextData) return null; - Collection macros = getUserMacros().values(); - return (IBuildMacro[])macros.toArray(new IBuildMacro[macros.size()]); + return getUserMacros(); } } @@ -557,10 +561,7 @@ public class MacrosBlock extends AbstractCOptionPage { fIsEditable = editable; } - /* - * returns the map containing the user-defined macros - */ - private Map getUserMacros(){ + private Map getUserMacrosMap(){ Map map = new HashMap(); if(fUserSupplier != null) { if(!fDeleteAll){ @@ -587,6 +588,18 @@ public class MacrosBlock extends AbstractCOptionPage { } 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 @@ -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 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)) return; - fDeleteAll = false; - BuildMacro newMacro = new BuildMacro(name,type,value); - getDeletedUserMacroNames().remove(name); - getAddedUserMacros().put(name,newMacro); - + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.createMacro(newMacro, fContextType, fContextData); + } else { + fDeleteAll = false; + BuildMacro newMacro = new BuildMacro(name,type,value); + getDeletedUserMacroNames().remove(name); + getAddedUserMacros().put(name,newMacro); + } fModified = true; } - +*/ /* * creates a user macro * 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(); if(!canCreate(name)) return; - fDeleteAll = false; - getDeletedUserMacroNames().remove(name); - getAddedUserMacros().put(name,newMacro); + + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.createMacro(newMacro, fContextType, fContextData); + } else { + fDeleteAll = false; + getDeletedUserMacroNames().remove(name); + getAddedUserMacros().put(name,newMacro); + } 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 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)) return; - fDeleteAll = false; - BuildMacro newMacro = new BuildMacro(name,type,value); - getDeletedUserMacroNames().remove(name); - getAddedUserMacros().put(name,newMacro); - + + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.createMacro(newMacro, fContextType, fContextData); + } else { + fDeleteAll = false; + BuildMacro newMacro = new BuildMacro(name,type,value); + getDeletedUserMacroNames().remove(name); + getAddedUserMacros().put(name,newMacro); + } fModified = true; } - +*/ /* * deletes a user macro * 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 */ private void deleteUserMacro(String name){ - fDeleteAll = false; - getAddedUserMacros().remove(name); - getDeletedUserMacroNames().add(name); - + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.deleteMacro(name, fContextType, fContextData); + } else { + fDeleteAll = false; + getAddedUserMacros().remove(name); + getDeletedUserMacroNames().add(name); + } fModified = true; } @@ -672,10 +700,13 @@ public class MacrosBlock extends AbstractCOptionPage { * the applyUserMacros() should be called to delete those macros from the user supplier */ private void deleteAllUserMacros(){ - fDeleteAll = true; - getDeletedUserMacroNames().clear(); - getAddedUserMacros().clear(); - + if(storeDirectly() && fUserSupplier != null){ + fUserSupplier.deleteAll(fContextType, fContextData); + } else { + fDeleteAll = true; + getDeletedUserMacroNames().clear(); + getAddedUserMacros().clear(); + } fModified = true; } @@ -697,7 +728,10 @@ public class MacrosBlock extends AbstractCOptionPage { * returns a user macro of a given 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) return null; @@ -710,23 +744,35 @@ public class MacrosBlock extends AbstractCOptionPage { */ private void applyUserMacros(){ if(fUserSupplier != null){ - if(fDeleteAll){ - fUserSupplier.deleteAll(fContextType,fContextData); - } - else{ - Iterator iter = getDeletedUserMacroNames().iterator(); - while(iter.hasNext()){ - fUserSupplier.deleteMacro((String)iter.next(),fContextType,fContextData); + 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); } - - iter = getAddedUserMacros().values().iterator(); - while(iter.hasNext()){ - IBuildMacro macro = (IBuildMacro)iter.next(); - fUserSupplier.createMacro(macro,fContextType,fContextData); + } else { + if(fDeleteAll){ + fUserSupplier.deleteAll(fContextType,fContextData); + } + else{ + Iterator iter = getDeletedUserMacroNames().iterator(); + while(iter.hasNext()){ + fUserSupplier.deleteMacro((String)iter.next(),fContextType,fContextData); + } + + iter = getAddedUserMacros().values().iterator(); + while(iter.hasNext()){ + IBuildMacro macro = (IBuildMacro)iter.next(); + fUserSupplier.createMacro(macro,fContextType,fContextData); + } + + getDeletedUserMacroNames().clear(); + getAddedUserMacros().clear(); } - - getDeletedUserMacroNames().clear(); - getAddedUserMacros().clear(); } } } @@ -906,12 +952,11 @@ public class MacrosBlock extends AbstractCOptionPage { if(fEditableTable == null || fContextType == 0) return; - Collection values = getUserMacros().values(); - ArrayList list = new ArrayList(values.size()); - for(Iterator iter = values.iterator(); iter.hasNext();){ - Object next = iter.next(); - if(next != null) - list.add(next); + IBuildMacro macros[] = getUserMacros(); + ArrayList list = new ArrayList(macros.length); + for(int i = 0; i < macros.length; i++){ + if(macros[i] != null) + list.add(macros[i]); } fEditableTable.setInput(list.toArray(new IBuildMacro[list.size()])); } @@ -1238,4 +1283,12 @@ public class MacrosBlock extends AbstractCOptionPage { } return null; } + + protected boolean storeDirectly(){ + if(fContextType == IBuildMacroProvider.CONTEXT_CONFIGURATION + && fContextData instanceof IConfiguration) + return ((IConfiguration)fContextData).isTemporary(); + return false; + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java index 8eb9455e86a..300cdd449ce 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/MacrosSetBlock.java @@ -153,10 +153,10 @@ import org.eclipse.swt.widgets.Group; if(fParentContainer instanceof BuildPropertyPage){ BuildPropertyPage page = (BuildPropertyPage)fParentContainer; - if(page.getSelectedConfiguration() != null) - fFolderTabs[1].setContext(IBuildMacroProvider.CONTEXT_PROJECT,page.getSelectedConfiguration().getManagedProject()); + if(page.getSelectedConfigurationClone() != null) + 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()); } /* else { diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java index bd697a43738..16d119a8934 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java @@ -14,6 +14,7 @@ import java.util.Iterator; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage; 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.ui.dialogs.BinaryParserBlock; import org.eclipse.cdt.ui.dialogs.ICOptionPage; @@ -76,7 +77,7 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { addTab(toolsSettingsBlock = new ToolsSettingsBlock((BuildPropertyPage) fParent, element)); addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent)); addTab(buildStepSettingsBlock = new BuildStepSettingsBlock((BuildPropertyPage) fParent)); - addTab(errParserBlock = new ErrorParserBlock()); + addTab(errParserBlock = new ErrorParserBlock((BuildPropertyPage) fParent)); addTab(binaryParserBlock = new BinaryParserBlock()); addTab(environmentBlock = new EnvironmentSetBlock((BuildPropertyPage) fParent)); addTab(macrosBlock = new MacrosSetBlock((BuildPropertyPage) fParent)); @@ -331,11 +332,11 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { return null; } - public IPreferenceStore getToolSettingsPreferenceStore() + public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore() { return toolsSettingsBlock.getPreferenceStore(); } - + public void update() { super.update(); ICOptionPage tab = getCurrentPage(); @@ -419,4 +420,19 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { 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; + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java index 801942dcea6..7e6340edaf1 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedProjectOptionBlock.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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() */ protected void addTabs() { - errParserBlock = new ErrorParserBlock(); + errParserBlock = new ErrorParserBlock(null); addTab(errParserBlock); addTab(binaryParserBlock = new BinaryParserBlock()); } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java index 70569f1ce9e..ee7b8add7d7 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ResourceCustomBuildStepBlock.java @@ -10,14 +10,17 @@ *******************************************************************************/ 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.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.ui.properties.ResourceBuildPropertyPage; +import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; 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.accessibility.AccessibleAdapter; 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.DisposeListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.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.Shell; +import org.eclipse.swt.widgets.Text; 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 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 PATH_SEPERATOR = ";"; //$NON-NLS-1$ /* * Dialog widgets */ @@ -102,16 +107,54 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { * Bookeeping variables */ private ResourceBuildPropertyPage resParent; - private String resBuildInputs; - private String resBuildOutputs; - private String resBuildAnnouncement; - private String resBuildCommand; // Has the page been changed? private boolean dirty = false; private ModifyListener widgetModified = new ModifyListener() { public void modifyText(ModifyEvent e) { - setDirty(true); + 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); + } + } + } 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.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; rcbsApplicabilitySelector.setLayoutData(gd1); + rcbsApplicabilitySelector.addSelectionListener( + new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + resParent.getCurrentResourceConfigClone().setRcbsApplicability( + selectionToApplicability(rcbsApplicabilitySelector.getSelectionIndex())); + setDirty(true); + } + }); } /* (non-Javadoc) @@ -297,6 +348,7 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { protected void initializeValues() { setValues(); + setDirty(false); } public void updateValues() { @@ -304,11 +356,8 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { } protected void setValues() { - IResourceConfiguration resConfig; - String[] buildInputsPaths; - String[] buildOutputsPaths; - boolean foundRcbsTool = false; - int idx; + IResourceConfiguration resConfig = resParent.getCurrentResourceConfigClone(); + /* * 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 @@ -317,44 +366,25 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { * 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. */ - resConfig = resParent.getCurrentResourceConfig(); - 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); + ITool tool = getRcbsTool(resConfig,false); + + if(tool != null){ + String tmp = createList(tool.getInputTypes()[0].getAdditionalInputs()[0].getPaths()); + if(!tmp.equals(buildInputs.getText())) + buildInputs.setText(tmp); - buildOutputsPaths = tool.getOutputTypes()[0].getOutputNames(); - resBuildOutputs = ""; //$NON-NLS-1$ - for ( int j = 0; j < buildOutputsPaths.length; j++ ){ - resBuildOutputs += buildOutputsPaths[j] + ";"; //$NON-NLS-1$ - } - len = resBuildOutputs.length(); - resBuildOutputs = resBuildOutputs.substring(0,len-1); - buildOutputs.setText(resBuildOutputs); - - resBuildCommand = tool.getToolCommand(); - buildCommand.setText(resBuildCommand); - - resBuildAnnouncement = tool.getAnnouncement(); - buildDescription.setText(resBuildAnnouncement); - - foundRcbsTool = true; - break; - } - } - - /* - * If an rcbs tool has not been created yet, just blank the fields. - */ - if(!foundRcbsTool) { + tmp = createList(tool.getOutputTypes()[0].getOutputNames()); + if(!tmp.equals(buildOutputs.getText())) + buildOutputs.setText(tmp); + + tmp = tool.getToolCommand(); + if(!tmp.equals(buildCommand.getText())) + buildCommand.setText(tmp); + + tmp = tool.getAnnouncement(); + if(!tmp.equals(buildDescription.getText())) + buildDescription.setText(tmp); + } else { buildInputs.setText(""); //$NON-NLS-1$ buildOutputs.setText(""); //$NON-NLS-1$ buildCommand.setText(""); //$NON-NLS-1$ @@ -364,31 +394,38 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { /* * Set the state of the rcbs applicability selector. */ - switch(resConfig.getRcbsApplicability()){ - case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE: - idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE)); - break; - case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER: - idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER)); - break; - case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE: - idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE)); - break; - case IResourceConfiguration.KIND_DISABLE_RCBS_TOOL: - idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_DISABLE)); - break; - default: - /* - * If we get an unexpected value, use the normal default of override. - */ - idx = rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE)); - break; - } - rcbsApplicabilitySelector.select(idx); + rcbsApplicabilitySelector.select(applicabilityToSelection(resConfig.getRcbsApplicability())); - setDirty(false); +// setDirty(false); } + private int selectionToApplicability(int index){ + String sel = rcbsApplicabilitySelector.getItem(index); + if(ManagedBuilderUIMessages.getResourceString(RCBS_OVERRIDE).equals(sel)){ + return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE; + } else if(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER).equals(sel)){ + return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER; + } else if(ManagedBuilderUIMessages.getResourceString(RCBS_BEFORE).equals(sel)){ + return IResourceConfiguration.KIND_APPLY_RCBS_TOOL_BEFORE; + } + return IResourceConfiguration.KIND_DISABLE_RCBS_TOOL; + } + + private int applicabilityToSelection(int val){ + switch(val){ + case IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER: + 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)); + } + + } + public void removeValues(String id) { // Nothing to do... } @@ -398,46 +435,13 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ public void performDefaults() { - IResourceConfiguration resConfig; + IResourceConfiguration cloneResConfig; - // 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(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); + cloneResConfig = resParent.getCurrentResourceConfigClone(); + removeRcbsTools(cloneResConfig); + setValues(); - setDirty(false); + setDirty(true); } /* @@ -445,11 +449,10 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor) */ public void performApply(IProgressMonitor monitor) throws CoreException { - IResourceConfiguration resConfig; - boolean foundRcbsTool = false; + IResourceConfiguration cloneResConfig; + IResourceConfiguration rcConfig; boolean rebuildNeeded = false; boolean rcbsStillDisabledSoNoRebuild = false; - int idx; /* * Gather the users input. @@ -464,77 +467,116 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { * selection. */ - resBuildInputs = buildInputs.getText().trim(); - resBuildOutputs = buildOutputs.getText().trim(); - resBuildCommand = buildCommand.getText().trim(); - resBuildAnnouncement = buildDescription.getText().trim(); + cloneResConfig = resParent.getCurrentResourceConfigClone(); + ITool cloneTool = getRcbsTool(cloneResConfig, false); + + rcConfig = resParent.getCurrentResourceConfig(false); + if(cloneTool == null){ + if(rcConfig != null) + rebuildNeeded = removeRcbsTools(rcConfig); + } else { + if(rcConfig == null) + rcConfig = resParent.getCurrentResourceConfig(true); + + + ITool realTool = getRcbsTool(rcConfig,true); + + realTool.getInputTypes()[0].getAdditionalInputs()[0].setPaths( + createList( + cloneTool.getInputTypes()[0].getAdditionalInputs()[0].getPaths())); + realTool.getOutputTypes()[0].setOutputNames( + createList( + cloneTool.getOutputTypes()[0].getOutputNames())); + realTool.setToolCommand( + cloneTool.getToolCommand()); + realTool.setAnnouncement( + cloneTool.getAnnouncement()); + if (realTool.isDirty()) { + rebuildNeeded = true; + } - resConfig = resParent.getCurrentResourceConfig(); - ITool [] tools = resConfig.getTools(); + /* + * Get the state of the rcbs applicability selector and set the rcbsApplicability attribute in the + * resource configuration. + */ + rcConfig.setRcbsApplicability( + cloneResConfig.getRcbsApplicability()); + + if(rcConfig.getRcbsApplicability() == IResourceConfiguration.KIND_DISABLE_RCBS_TOOL) + rcbsStillDisabledSoNoRebuild = true; + + if (rcConfig.isDirty()) { + rebuildNeeded = true; + } + + if (rebuildNeeded && !rcbsStillDisabledSoNoRebuild) { + rcConfig.getParent().setRebuildState(true); + } + + 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()) { - tool.getInputTypes()[0].getAdditionalInputs()[0].setPaths(resBuildInputs); - tool.getOutputTypes()[0].setOutputNames(resBuildOutputs); - tool.setToolCommand(resBuildCommand); - tool.setAnnouncement(resBuildAnnouncement); - if (tool.isDirty()) { - rebuildNeeded = true; - } - foundRcbsTool = true; - break; + list.add(tool); } } - 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$ - rcbsToolInputTypeAdditionalInput = rcbsToolInputType.createAdditionalInput(resBuildInputs); - rcbsToolInputTypeAdditionalInput.setKind(IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY); - rcbsToolOutputType = rcbsTool.createOutputType(null,rcbsToolOutputTypeId + "." + ManagedBuildManager.getRandomNumber(),rcbsToolOutputTypeName,false); //$NON-NLS-1$ - rcbsToolOutputType.setOutputNames(resBuildOutputs); - rcbsTool.setCustomBuildStep(true); - rcbsTool.setToolCommand(resBuildCommand); - rcbsTool.setAnnouncement(resBuildAnnouncement); - rebuildNeeded = true; - } - - /* - * Get the state of the rcbs applicability selector and set the rcbsApplicability attribute in the - * resource configuration. - */ - idx = rcbsApplicabilitySelector.getSelectionIndex(); - if(idx == rcbsApplicabilitySelector.indexOf(ManagedBuilderUIMessages.getResourceString(RCBS_AFTER))) { - resConfig.setRcbsApplicability(IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AFTER); - } else - 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; - } - resConfig.setRcbsApplicability(IResourceConfiguration.KIND_DISABLE_RCBS_TOOL); - } else { - resConfig.setRcbsApplicability(IResourceConfiguration.KIND_APPLY_RCBS_TOOL_AS_OVERRIDE); - } - if (resConfig.isDirty()) { - rebuildNeeded = true; - } - - if (rebuildNeeded && !rcbsStillDisabledSoNoRebuild) { - resConfig.getParent().setRebuildState(true); - } - - setDirty(false); - } + if(list.size() != 0) + return (ITool[])list.toArray(new ITool[list.size()]); + return null; + } public IPreferenceStore getPreferenceStore() { return null; @@ -553,5 +595,24 @@ public class ResourceCustomBuildStepBlock extends AbstractCOptionPage { public boolean isDirty() { 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; + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java index 58208cece9e..95ef2279bfe 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ToolsSettingsBlock.java @@ -17,21 +17,25 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +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.IHoldsOptions; 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.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.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.BuildPreferencePage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage; 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.ToolListContentProvider; 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.runtime.CoreException; 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.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; 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.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; 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.Control; import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Shell; public class ToolsSettingsBlock extends AbstractCOptionPage { @@ -90,8 +91,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { * Bookeeping variables */ private Map configToPageListMap; - private BuildToolsSettingsStore settingsStore; - private Map settingsStoreMap; + private BuildToolSettingsPreferenceStore settingsStore; private BuildPropertyPage parent; private ResourceBuildPropertyPage resParent; private BuildSettingsPage currentSettingsPage; @@ -99,6 +99,8 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { private ToolListContentProvider provider; private ITool selectedTool; private Object element; + + private boolean defaultNeeded; /** * The minimum page size; 200 by 200 by default. @@ -152,6 +154,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { this.parent = parent; configToPageListMap = new HashMap(); this.element = element; + settingsStore = new BuildToolSettingsPreferenceStore(this); } public ToolsSettingsBlock(ResourceBuildPropertyPage resParent, Object element) @@ -161,6 +164,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { this.resParent = resParent; configToPageListMap = new HashMap(); this.element = element; + settingsStore = new BuildToolSettingsPreferenceStore(this); } public void createControl(Composite parent) { @@ -232,11 +236,11 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { } if (currentSettingsPage == null) { if ( this.element instanceof IProject) { - currentSettingsPage = new BuildOptionSettingsPage(parent.getSelectedConfiguration(), category); + currentSettingsPage = new BuildOptionSettingsPage(parent,parent.getSelectedConfigurationClone(), category); pages.add(currentSettingsPage); currentSettingsPage.setContainer(parent); } else if ( this.element instanceof IFile) { - currentSettingsPage = new BuildOptionSettingsPage(resParent.getCurrentResourceConfig(), category); + currentSettingsPage = new BuildOptionSettingsPage(resParent,resParent.getCurrentResourceConfigClone(), category); pages.add(currentSettingsPage); currentSettingsPage.setContainer(resParent); } @@ -254,18 +258,6 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { } 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 if(currentSettingsPage instanceof BuildOptionSettingsPage) ((BuildOptionSettingsPage)currentSettingsPage).updateFields(); @@ -305,11 +297,13 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { } if (currentSettingsPage == null) { if ( this.element instanceof IProject) { - currentSettingsPage = new BuildToolSettingsPage(parent.getSelectedConfiguration(), tool, obtainMacroProvider()); + currentSettingsPage = new BuildToolSettingsPage(parent, + parent.getSelectedConfigurationClone(), tool); pages.add(currentSettingsPage); currentSettingsPage.setContainer(parent); } else if(this.element instanceof IFile) { - currentSettingsPage = new BuildToolSettingsPage(resParent.getCurrentResourceConfig(), tool, obtainMacroProvider()); + currentSettingsPage = new BuildToolSettingsPage(resParent, + resParent.getCurrentResourceConfigClone(), tool); pages.add(currentSettingsPage); currentSettingsPage.setContainer(resParent); } @@ -340,7 +334,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { } // Update the field editor that displays all the build options if(currentSettingsPage instanceof BuildToolSettingsPage) - ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField(); + ((BuildToolSettingsPage)currentSettingsPage).setValues(); if (oldPage != null && oldPage != currentSettingsPage) oldPage.setVisible(false); @@ -384,9 +378,12 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { } public void setVisible(boolean visible){ - // Update the field editor that displays all the build options - if(visible && currentSettingsPage instanceof BuildToolSettingsPage) - ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField(); + if(visible){ + selectedCategory = null; + selectedTool = null; + handleOptionSelection(); + } + super.setVisible(visible); } protected void setValues() { @@ -401,32 +398,15 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { optionList.setContentProvider(provider); } if ( element instanceof IProject ) { - config = parent.getSelectedConfiguration(); + config = parent.getSelectedConfigurationClone(); optionList.setInput(config); } else if ( element instanceof IFile){ - resConfig = resParent.getCurrentResourceConfig(); + resConfig = resParent.getCurrentResourceConfigClone(); optionList.setInput(resConfig); } 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 Object primary = null; if (selectedTool != null) { @@ -476,20 +456,25 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { // Select the first tool in the list Object[] elements = null; if( element instanceof IProject){ - elements = provider.getElements(parent.getSelectedConfiguration()); + elements = provider.getElements(parent.getSelectedConfigurationClone()); } else if ( element instanceof IFile) { - elements = provider.getElements(resParent.getCurrentResourceConfig()); + elements = provider.getElements(resParent.getCurrentResourceConfigClone()); } primary = elements.length > 0 ? elements[0] : 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); } } public void removeValues(String id) { - getSettingsStoreMap().remove(id); } private void handleOptionSelection() { @@ -498,6 +483,12 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { // Set the option page based on the selection 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) { displayOptionsForTool((ITool)element); } else if (element instanceof IOptionCategory) { @@ -517,7 +508,9 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { ManagedBuildManager.performValueHandlerEvent(parent.getSelectedConfiguration(), IManagedOptionValueHandler.EVENT_SETDEFAULT, false); } else if ( element instanceof IFile) { - ManagedBuildManager.performValueHandlerEvent(resParent.getCurrentResourceConfig(), + IResourceConfiguration rcCfg = resParent.getCurrentResourceConfig(false); + if(rcCfg != null) + ManagedBuildManager.performValueHandlerEvent(rcCfg, IManagedOptionValueHandler.EVENT_SETDEFAULT); } } @@ -532,6 +525,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { } else if ( element instanceof IFile) { performDefaults( (IFile)element); } + defaultNeeded = true; return; } @@ -539,76 +533,41 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { // TODO: Should this reset all tools of the configuration, or just // 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 - ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration()); + ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfigurationClone()); + ITool tools[] = parent.getSelectedConfigurationClone().getFilteredTools(); + for( int i = 0; i < tools.length; i++ ){ + if(!tools[i].getCustomBuildStep()) + tools[i].setToolCommand(null); + } - // Recreate the settings store for the configuration - settingsStore = new BuildToolsSettingsStore(parent.getSelectedConfiguration()); - - // 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 selectedCategory = null; selectedTool = null; handleOptionSelection(); - setDirty(false); + setDirty(true); } public void performDefaults(IFile file) { // 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. - // 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 - ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig()); - - // Recreate the settings store for the configuration - settingsStore = new BuildToolsSettingsStore(resParent.getCurrentResourceConfig()); - - // 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(); + ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfigClone()); + ITool tools[] = resParent.getCurrentResourceConfigClone().getTools(); + for( int i = 0; i < tools.length; i++ ){ + if(!tools[i].getCustomBuildStep()) + tools[i].setToolCommand(null); + } // Reset the category or tool selection and run selection event handler selectedCategory = null; selectedTool = null; handleOptionSelection(); - setDirty(false); + setDirty(true); } /* @@ -617,31 +576,234 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { */ public void performApply(IProgressMonitor monitor) throws CoreException { - // Force each settings page to update - List pages = getPagesForConfig(); - // Make sure we have something to work on - if (pages == null) { - // Nothing to do - return; - } - ListIterator iter = pages.listIterator(); - while (iter.hasNext()) { - BuildSettingsPage page = (BuildSettingsPage) iter.next(); - if (page == null) continue; - if (page instanceof BuildToolSettingsPage) { - // 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. - if (!(currentSettingsPage instanceof BuildToolSettingsPage)) - ((BuildToolSettingsPage)page).updateAllOptionField(); - ((BuildToolSettingsPage)page).performOk(); - } else if (page instanceof BuildOptionSettingsPage) { - ((BuildOptionSettingsPage)page).performOk(); - } + if(element instanceof IFile) + resParent.getCurrentResourceConfig(true); + + if(defaultNeeded){ + if(element instanceof IFile) + ManagedBuildManager.resetResourceConfiguration(resParent.getProject(), resParent.getCurrentResourceConfig(true)); + else + ManagedBuildManager.resetConfiguration(parent.getProject(), parent.getSelectedConfiguration()); + + performSetDefaultsEventCallBack(); + + defaultNeeded = false; } + //some options might be changed that do not belong to the created pages, + //we need to save all options instead + saveAll(); setDirty(false); } + + private void saveAll(){ + if(resParent != null) + saveResourceConfig(); + else + saveConfig(); + } + + private void saveResourceConfig(){ + IResourceConfiguration cloneRcCfg = resParent.getCurrentResourceConfigClone(); + + ITool tools[] = cloneRcCfg.getTools(); + + for(int i = 0; i < tools.length; i++){ + saveHoldsOptions(tools[i]); + } + } + + 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) * Answers the list of settings pages for the selected configuration @@ -651,44 +813,32 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { List pages = null; if ( element instanceof IProject) { // Make sure that something was selected - if (parent.getSelectedConfiguration() == null) { + if (parent.getSelectedConfigurationClone() == null) { return null; } - pages = (List) configToPageListMap.get(parent.getSelectedConfiguration().getId()); + pages = (List) configToPageListMap.get(parent.getSelectedConfigurationClone().getId()); } else if (element instanceof IFile) { - if ( resParent.getCurrentResourceConfig() == null ) { + if ( resParent.getCurrentResourceConfigClone() == null ) { return null; } - pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfig().getId()); + pages = (List) configToPageListMap.get(resParent.getCurrentResourceConfigClone().getId()); } if (pages == null) { pages = new ArrayList(); if ( element instanceof IProject) { - configToPageListMap.put(parent.getSelectedConfiguration().getId(), pages); + configToPageListMap.put(parent.getSelectedConfigurationClone().getId(), pages); } else if ( element instanceof IFile) { - configToPageListMap.put(resParent.getCurrentResourceConfig().getId(), pages); + configToPageListMap.put(resParent.getCurrentResourceConfigClone().getId(), pages); } } return pages; } - public IPreferenceStore getPreferenceStore() { + public BuildToolSettingsPreferenceStore getPreferenceStore() { 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 */ @@ -736,7 +886,7 @@ public class ToolsSettingsBlock extends AbstractCOptionPage { * the user-modified macros that are not applied yet * If the "Build Macros" tab is not available, returns the default BuildMacroProvider */ - protected BuildMacroProvider obtainMacroProvider(){ + public BuildMacroProvider obtainMacroProvider(){ ICOptionContainer container = getContainer(); ManagedBuildOptionBlock optionBlock = null; if(container instanceof BuildPropertyPage){ diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java new file mode 100644 index 00000000000..2f416d7593a --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/AbstractBuildPropertyPage.java @@ -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$ + } +*/ +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java index 8c07c191218..241c3f7f0f7 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionComboFieldEditor.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -116,6 +116,10 @@ public class BuildOptionComboFieldEditor extends FieldEditor { getPreferenceStore().setValue(getPreferenceName(), selected); } + public String getSelection(){ + return selected; + } + /* (non-Javadoc) * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls() */ diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java index 978b3a8c761..60279eaf64f 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java @@ -10,10 +10,11 @@ *******************************************************************************/ 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.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Vector; 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.IHoldsOptions; 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.IOptionApplicability; import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; 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.FieldEditor; import org.eclipse.jface.preference.FileFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; -import java.lang.AssertionError; public class BuildOptionSettingsPage extends BuildSettingsPage { private Map fieldsMap = new HashMap(); - private IOptionCategory category; + private IOptionCategory clonedCategory; private boolean isItResourceConfigPage; 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 - super(configuration); - this.category = category; + super(clonedConfig); + this.clonedCategory = clonedCategory; 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 - super(resConfig); - this.category = category; + super(clonedResConfig); + this.clonedCategory = clonedCategory; isItResourceConfigPage = true; + buildPropPage = page; } /* (non-Javadoc) * @see org.eclipse.jface.preference.IPreferencePage#computeSize() @@ -61,18 +66,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { public Point 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) * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() */ @@ -83,9 +77,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { // for each Object[][] options; if ( isItResourceConfigPage ) { - options = category.getOptions(resConfig); + options = clonedCategory.getOptions(clonedResConfig); } else { - options = category.getOptions(configuration); + options = clonedCategory.getOptions(clonedConfig); } for (int index = 0; index < options.length; ++index) { @@ -93,6 +87,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { 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); // check to see if the option has an applicability calculator @@ -101,9 +96,9 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { // is the option visible? IBuildObject config; if ( isItResourceConfigPage ) { - config = resConfig; + config = clonedResConfig; } else { - config = configuration; + config = clonedConfig; } if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) { @@ -122,13 +117,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { case IOption.BROWSE_DIR: Composite fieldEditorParent2 = getFieldEditorParent(); DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor( - opt.getId(), opt.getName(), fieldEditorParent2); + prefName, opt.getName(), fieldEditorParent2); setFieldEditorEnablement(holder, opt, applicabilityCalculator, dirFieldEditor, fieldEditorParent2); addField(dirFieldEditor); - fieldsMap.put(opt.getId(), dirFieldEditor); + fieldsMap.put(prefName, dirFieldEditor); fieldEditorsToParentMap.put(dirFieldEditor, fieldEditorParent2); break; @@ -136,26 +131,26 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { case IOption.BROWSE_FILE: Composite fieldEditorParent3 = getFieldEditorParent(); FileFieldEditor fileFieldEditor = new FileFieldEditor( - opt.getId(), opt.getName(), fieldEditorParent3); + prefName, opt.getName(), fieldEditorParent3); setFieldEditorEnablement(holder, opt, applicabilityCalculator, fileFieldEditor, fieldEditorParent3); addField(fileFieldEditor); - fieldsMap.put(opt.getId(), fileFieldEditor); + fieldsMap.put(prefName, fileFieldEditor); fieldEditorsToParentMap.put(fileFieldEditor, fieldEditorParent3); break; case IOption.BROWSE_NONE: Composite fieldEditorParent4 = getFieldEditorParent(); StringFieldEditor stringField = new StringFieldEditor( - opt.getId(), opt.getName(), fieldEditorParent4); + prefName, opt.getName(), fieldEditorParent4); setFieldEditorEnablement(holder, opt, applicabilityCalculator, stringField, fieldEditorParent4); addField(stringField); - fieldsMap.put(opt.getId(), stringField); + fieldsMap.put(prefName, stringField); fieldEditorsToParentMap.put(stringField, fieldEditorParent4); break; @@ -168,13 +163,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { case IOption.BOOLEAN: Composite fieldEditorParent5 = getFieldEditorParent(); BooleanFieldEditor booleanField = new BooleanFieldEditor( - opt.getId(), opt.getName(), fieldEditorParent5); + prefName, opt.getName(), fieldEditorParent5); setFieldEditorEnablement(holder, opt, applicabilityCalculator, booleanField, fieldEditorParent5); addField(booleanField); - fieldsMap.put(opt.getId(), booleanField); + fieldsMap.put(prefName, booleanField); fieldEditorsToParentMap.put(booleanField, fieldEditorParent5); break; case IOption.ENUMERATED: @@ -195,7 +190,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { String[] enumNames = opt.getApplicableValues(); Vector enumValidList = new Vector(); 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])) { enumValidList.add(enumNames[i]); } @@ -205,13 +200,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { Composite fieldEditorParent6 = getFieldEditorParent(); BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor( - opt.getId(), opt.getName(), enumValidNames, sel, fieldEditorParent6); + prefName, opt.getName(), enumValidNames, sel, fieldEditorParent6); setFieldEditorEnablement(holder, opt, applicabilityCalculator, comboField, fieldEditorParent6); addField(comboField); - fieldsMap.put(opt.getId(), comboField); + fieldsMap.put(prefName, comboField); fieldEditorsToParentMap.put(comboField, fieldEditorParent6); break; case IOption.INCLUDE_PATH: @@ -222,13 +217,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { Composite fieldEditorParent7 = getFieldEditorParent(); FileListControlFieldEditor listField = new FileListControlFieldEditor( - opt.getId(), opt.getName(), fieldEditorParent7, opt.getBrowseType()); + prefName, opt.getName(), fieldEditorParent7, opt.getBrowseType()); setFieldEditorEnablement(holder, opt, applicabilityCalculator, listField, fieldEditorParent7); addField(listField); - fieldsMap.put(opt.getId(), listField); + fieldsMap.put(prefName, listField); fieldEditorsToParentMap.put(listField, fieldEditorParent7); break; default: @@ -249,7 +244,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { */ public boolean isForCategory(IOptionCategory category) { if (category != null) { - return category.equals(this.category); + return category.equals(this.clonedCategory); } return false; } @@ -262,87 +257,103 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { boolean ok = super.performOk(); // 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){ - options = category.getOptions(resConfig); + realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig); + if(realRcCfg == null) + return false; + handler = realRcCfg; + clonedOptions = clonedCategory.getOptions(clonedResConfig); } 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++) { - IHoldsOptions holder = (IHoldsOptions)options[i][0]; - if (holder == null) break; // The array may not be full - IOption option = (IOption)options[i][1]; + for (int i = 0; i < clonedOptions.length; i++) { + IHoldsOptions clonedHolder = (IHoldsOptions)clonedOptions[i][0]; + if (clonedHolder == null) break; // The array may not be full + 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 { // Transfer value from preference store to options IOption setOption = null; - switch (option.getValueType()) { + switch (clonedOption.getValueType()) { case IOption.BOOLEAN : - boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId()); + boolean boolVal = clonedOption.getBooleanValue(); if(isItResourceConfigPage) { - setOption = ManagedBuildManager.setOption(resConfig, holder, option, boolVal); + setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, boolVal); } 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 - if (setOption != option) { - getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal); - FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); - fe.setPreferenceName(setOption.getId()); - } +// 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 = getToolSettingsPreferenceStore().getString(option.getId()); - String enumId = option.getEnumeratedId(enumVal); + String enumVal = clonedOption.getStringValue(); + String enumId = clonedOption.getEnumeratedId(enumVal); if(isItResourceConfigPage) { - setOption = ManagedBuildManager.setOption(resConfig, holder, option, + setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, (enumId != null && enumId.length() > 0) ? enumId : enumVal); } else { - setOption = ManagedBuildManager.setOption(configuration, holder, option, + 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()); - } +// 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 = getToolSettingsPreferenceStore().getString(option.getId()); + String strVal = clonedOption.getStringValue(); if(isItResourceConfigPage){ - setOption = ManagedBuildManager.setOption(resConfig, holder, option, strVal); + setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, strVal); } 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 - if (setOption != option) { - getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal); - FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); - fe.setPreferenceName(setOption.getId()); - } +// 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 listStr = getToolSettingsPreferenceStore().getString(option.getId()); - String[] listVal = BuildToolsSettingsStore.parseString(listStr); + String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]); if( isItResourceConfigPage){ - setOption = ManagedBuildManager.setOption(resConfig, holder, option, listVal); + setOption = ManagedBuildManager.setOption(realRcCfg, realHolder, realOption, listVal); }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 - if (setOption != option) { - getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr); - FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); - fe.setPreferenceName(setOption.getId()); - } +// if (setOption != option) { +// getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr); +// FieldEditor fe = (FieldEditor)fieldsMap.get(option.getId()); +// fe.setPreferenceName(setOption.getId()); +// } break; default : break; @@ -351,10 +362,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { // Call an MBS CallBack function to inform that Settings related to Apply/OK button // press have been applied. if (setOption == null) - setOption = option; + setOption = realOption; if (setOption.getValueHandler().handleValue( - getConfigurationHandle(), + handler, setOption.getOptionHolder(), setOption, setOption.getValueHandlerExtraArgument(), @@ -364,7 +375,10 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { } else { // Event handling Failed. } - } catch (BuildException e) {} + } catch (BuildException e) { + } catch (ClassCastException e) { + } + } return ok; @@ -374,6 +388,38 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { * Update field editors in this page when the page is loaded. */ 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(); Iterator iter = fieldsList.iterator(); while (iter.hasNext()) { @@ -389,7 +435,7 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { * saves all field editors */ public void storeSettings() { - super.performOk(); +// super.performOk(); } 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 IBuildObject config; if ( isItResourceConfigPage ) { - config = resConfig; + config = clonedResConfig; } else { - config = configuration; + config = clonedConfig; } if (!optionApplicability.isOptionEnabled(config, holder, option )) { fieldEditor.setEnabled(false, parent); @@ -417,36 +463,123 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { public void propertyChange(PropertyChangeEvent event) { // allow superclass to handle as well super.propertyChange(event); + + Object source = event.getSource(); + IOption changedOption = null; + IHoldsOptions changedHolder = null; + IOption newOption = null; + String id = null; - // some option has changed on this page... update enabled/disabled state for all options + 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; if (isItResourceConfigPage) { - options = category.getOptions(resConfig); + options = clonedCategory.getOptions(clonedResConfig); } 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) { // 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(opt.getId())) { + 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(opt.getId()); + FieldEditor fieldEditor = (FieldEditor) fieldsMap.get(prefName); Composite parent = (Composite) fieldEditorsToParentMap.get(fieldEditor); 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(); + } + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java index 6518374837c..77f18ba9274 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; 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.ManagedBuilderHelpContextIds; 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.ui.IWorkbenchPropertyPage; import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; -import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.help.WorkbenchHelp; -public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, +public class BuildPropertyPage extends AbstractBuildPropertyPage implements IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer { /* * String constants @@ -96,6 +96,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert private IProjectType[] projectTypes; private IProjectType selectedProjectType; private IConfiguration[] configurations; + private IConfiguration clonedConfiguration; private IConfiguration selectedConfiguration; private Point lastShellSize; protected ManagedBuildOptionBlock fOptionBlock; @@ -251,9 +252,20 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert if (!applyOptionBlock()) return false; if (!applyDefaultConfiguration()) 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; + } /** * Apply any changes that have been made in the managed build option block @@ -400,6 +412,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert return selectedConfiguration; } + public IConfiguration getSelectedConfigurationClone(){ + return clonedConfiguration; + } + /* (non-Javadoc) * @return */ @@ -423,7 +439,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert /* (non-Javadoc) * Return the IPreferenceStore of the Tool Settings block */ - public IPreferenceStore getToolSettingsPreferenceStore() + public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore() { return fOptionBlock.getToolSettingsPreferenceStore(); } @@ -521,8 +537,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert } } // Set the new selected configuration - selectedConfiguration = newConfig; + selectedConfiguration = newConfig; ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration); + clonedConfiguration = getClonedConfig(selectedConfiguration); // TODO: Set the appropriate error parsers... // TODO: Binary parsers too? fOptionBlock.updateValues(); @@ -536,8 +553,8 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert if(selectedProjectType != null && !selectedProjectType.isSupported()){ setMessage(ManagedBuilderUIMessages.getResourceString(MSG_UNSUPPORTED_PROJ),IMessageProvider.WARNING); } - else if(selectedConfiguration != null){ - if(selectedConfiguration.isSupported()){ + else if(clonedConfiguration != null){ + if(clonedConfiguration.isSupported()){ setMessage(null,IMessageProvider.NONE); } else{ diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java index 8083f38f23c..c51f2a64e7d 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java @@ -19,14 +19,15 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.PropertyChangeEvent; public abstract class BuildSettingsPage extends FieldEditorPreferencePage { - protected IConfiguration configuration; - protected IResourceConfiguration resConfig; + protected IConfiguration clonedConfig; + protected IResourceConfiguration clonedResConfig; + private boolean dirty = false; /** * @param style */ - protected BuildSettingsPage(IConfiguration config) { + protected BuildSettingsPage(IConfiguration clonedConfig) { // fix for PR 63973 // If we use a grid layout then widgets that should be layed out horizontally, // e.g. StringButtonFieldEditor, will have their component widgets @@ -36,10 +37,10 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage { super(FLAT); // end fix for 63973 noDefaultAndApplyButton(); - configuration = config; + this.clonedConfig = clonedConfig; } - protected BuildSettingsPage(IResourceConfiguration resConfig) { + protected BuildSettingsPage(IResourceConfiguration clonedResConfig) { // fix for PR 63973 // If we use a grid layout then widgets that should be layed out horizontally, // e.g. StringButtonFieldEditor, will have their component widgets @@ -49,8 +50,11 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage { super(FLAT); // end fix for 63973 noDefaultAndApplyButton(); - this.resConfig = resConfig; + + this.clonedResConfig = clonedResConfig; + this.clonedConfig = clonedResConfig.getParent(); } + /* (non-Javadoc) * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() */ @@ -63,7 +67,7 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage { /** * Return the tool settings preference store */ - protected IPreferenceStore getToolSettingsPreferenceStore() { + protected BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore() { IPreferencePageContainer container = getContainer(); if (container instanceof BuildPropertyPage) { return ((BuildPropertyPage)container).getToolSettingsPreferenceStore(); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java index f4afbca91b5..5b390eccf31 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java @@ -22,17 +22,14 @@ 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.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.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; import org.eclipse.cdt.managedbuilder.core.ITool; 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.DefaultMacroSubstitutor; -import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData; import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo; import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor; 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.macros.BuildMacroException; import org.eclipse.cdt.managedbuilder.macros.IBuildMacro; -import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.graphics.Point; public class BuildToolSettingsPage extends BuildSettingsPage { @@ -57,79 +54,41 @@ public class BuildToolSettingsPage extends BuildSettingsPage { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ // field editor that displays all the build options for a particular tool private MultiLineTextFieldEditor allOptionFieldEditor; - // all build options preference store id - private String allOptionsId = ""; //$NON-NLS-1$ + //tool command command + private StringFieldEditor commandStringField; // A list of safe options to put unrecognized values in private Vector defaultOptionNames; // Map that holds all string options and its values private HashMap stringOptionsMap; - // Tool the settings belong to - private ITool tool; + + private ITool clonedTool; // Map that holds all user object options and its values private HashMap userObjsMap; private boolean isItResourceConfigPage; - //the build macro provider to be used for macro resolution - private BuildMacroProvider fProvider; + private AbstractBuildPropertyPage buildPropPage; - //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 BuildToolSettingsPage(IConfiguration configuration, ITool tool, BuildMacroProvider provider) { + public BuildToolSettingsPage(AbstractBuildPropertyPage page, + IConfiguration clonedCfg, ITool clonedTool) { // Cache the configuration and tool this page is for - super(configuration); - this.tool = tool; - allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$ + super(clonedCfg); + this.clonedTool = clonedTool; + buildPropPage = page; stringOptionsMap = new HashMap(); userObjsMap = new HashMap(); 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 - super(resConfig); - this.tool = tool; - allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$ + super(clonedRcCfg); + this.clonedTool = clonedTool; + buildPropPage = page; stringOptionsMap = new HashMap(); userObjsMap = new HashMap(); isItResourceConfigPage = true; - fProvider = provider; } /* (non-Javadoc) * @see org.eclipse.jface.preference.IPreferencePage#computeSize() @@ -137,18 +96,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { public Point 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) * @@ -158,16 +106,15 @@ public class BuildToolSettingsPage extends BuildSettingsPage { // Load up the preference store super.createFieldEditors(); // Add a string editor to edit the tool command - StringFieldEditor stringField = new StringFieldEditor(tool.getId(), + commandStringField = new StringFieldEditor(clonedTool.getId(), ManagedBuilderUIMessages.getResourceString(COMMAND), getFieldEditorParent()); - stringField.setEmptyStringAllowed(false); - addField(stringField); + commandStringField.setEmptyStringAllowed(false); + addField(commandStringField); // Add a field editor that displays over all build options - allOptionFieldEditor = new MultiLineTextFieldEditor(allOptionsId, + allOptionFieldEditor = new MultiLineTextFieldEditor(BuildToolSettingsPreferenceStore.ALL_OPTIONS_ID, ALL_OPTIONS, getFieldEditorParent()); allOptionFieldEditor.getTextControl().setEditable(false); - getToolSettingsPreferenceStore().setValue(allOptionsId, ""); //$NON-NLS-1$ 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 true if the receiver manages settings for the * argument @@ -370,7 +211,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { */ public boolean isForTool(ITool tool) { if (tool != null) { - return tool.equals(this.tool); + return tool.equals(this.clonedTool); } return false; } @@ -381,7 +222,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { */ public void parseAllOptions() { // 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 // boolean,string and enumerated List optionsList = new ArrayList(); @@ -394,7 +235,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { String optionValue = (String)optIter.next(); boolean optionValueExist = false; // get the options for this tool - IOption[] options = tool.getOptions(); + IOption[] options = clonedTool.getOptions(); for (int k = 0; k < options.length; ++k) { IOption opt = options[k]; String name = opt.getId(); @@ -422,14 +263,12 @@ public class BuildToolSettingsPage extends BuildSettingsPage { String boolCommand; boolCommand = opt.getCommand(); if (boolCommand != null && boolCommand.equals(optionValue)) { - getToolSettingsPreferenceStore() - .setValue(opt.getId(), true); + setOption(opt, true); optionValueExist = true; } boolCommand = opt.getCommandFalse(); if (boolCommand != null && boolCommand.equals(optionValue)) { - getToolSettingsPreferenceStore() - .setValue(opt.getId(), false); + setOption(opt, false); optionValueExist = true; } break; @@ -444,8 +283,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { } } if (!enumeration.equals("")) //$NON-NLS-1$ - getToolSettingsPreferenceStore() - .setValue(opt.getId(), enumeration); + setOption(opt, enumeration); break; case IOption.STRING_LIST : case IOption.INCLUDE_PATH : @@ -486,7 +324,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { if (alloptions.indexOf(vals[t]) != -1) buf.append(vals[t] + ITool.WHITE_SPACE); } - getToolSettingsPreferenceStore().setValue(((IOption) key).getId(), + setOption(((IOption) key), buf.toString().trim()); } } @@ -499,20 +337,19 @@ public class BuildToolSettingsPage extends BuildSettingsPage { Object key = iterator.next(); String val = (String) userObjsMap.get(key); ArrayList list = new ArrayList(); - String[] vals = BuildToolsSettingsStore.parseString(val); + String[] vals = parseString(val); for (int t = 0; t < vals.length; t++) { if (alloptions.indexOf(vals[t]) != -1) list.add(vals[t]); } String listArr[] = new String[list.size()]; list.toArray(listArr); - String liststr = BuildToolsSettingsStore.createList(listArr); - getToolSettingsPreferenceStore().setValue(((IOption) key).getId(), liststr); + setOption(((IOption) key), listArr); } } // Now update the preference store with parsed options // Get the options for this tool - IOption[] options = tool.getOptions(); + IOption[] options = clonedTool.getOptions(); for (int k = 0; k < options.length; ++k) { IOption opt = options[k]; String name = opt.getId(); @@ -525,22 +362,21 @@ public class BuildToolSettingsPage extends BuildSettingsPage { if (opt.getCommand() != null && opt.getCommand().length() > 0 && !optsList.contains(opt.getCommand())) - getToolSettingsPreferenceStore().setValue(opt.getId(), false); + setOption(opt, false); if (opt.getCommandFalse() != null && opt.getCommandFalse().length() > 0 && !optsList.contains(opt.getCommandFalse())) - getToolSettingsPreferenceStore().setValue(opt.getId(), true); + setOption(opt, true); break; case IOption.STRING : // TODO create a lst of valid default string options for the tool if (getDefaultOptionNames().contains(opt.getName())) { - String newOptions = getToolSettingsPreferenceStore().getString( - opt.getId()); + String newOptions = opt.getStringValue(); if (addnOptions.length() > 0) { newOptions = newOptions + ITool.WHITE_SPACE + addnOptions.toString().trim(); } - getToolSettingsPreferenceStore().setValue(opt.getId(), newOptions); + setOption(opt, newOptions); } break; case IOption.STRING_LIST : @@ -559,8 +395,7 @@ public class BuildToolSettingsPage extends BuildSettingsPage { String[] strlist = new String[newList.size()]; newList.toArray(strlist); newList.clear(); - getToolSettingsPreferenceStore().setValue(opt.getId(), - BuildToolsSettingsStore.createList(strlist)); + setOption(opt, strlist); break; default : 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) * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() */ @@ -580,63 +453,85 @@ public class BuildToolSettingsPage extends BuildSettingsPage { //parseAllOptions(); // Write the preference store values back to the build model - IOptionCategory category = (IOptionCategory)tool; - Object[][] options; - if ( isItResourceConfigPage ) { - options = category.getOptions(resConfig); + IOptionCategory clonedCategory = (IOptionCategory)clonedTool; + ITool tool = buildPropPage.getRealTool(clonedTool); + if(tool == null) + return false; + Object[][] clonedOptions; + IResourceConfiguration realRcCfg = null; + IConfiguration realCfg = null; + IBuildObject handler = null; + + if (isItResourceConfigPage){ + realRcCfg = buildPropPage.getRealRcConfig(clonedResConfig); + if(realRcCfg == null) + return false; + handler = realRcCfg; + clonedOptions = clonedCategory.getOptions(clonedResConfig); } 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; - for (int i = 0; i < options.length; i++) { - ITool tool = (ITool)options[i][0]; - if (tool == null) break; // The array may not be full - IOption option = (IOption)options[i][1]; + for (int i = 0; i < clonedOptions.length; i++) { + ITool clonedTool = (ITool)clonedOptions[i][0]; + if (clonedTool == null) break; // The array may not be full + 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 { // Transfer value from preference store to options IOption setOption = null; - switch (option.getValueType()) { + switch (clonedOption.getValueType()) { case IOption.BOOLEAN : - boolean boolVal = getToolSettingsPreferenceStore().getBoolean(option.getId()); - setOption = ManagedBuildManager.setOption(configuration, tool, option, boolVal); + boolean boolVal = clonedOption.getBooleanValue();; + setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, boolVal); // Reset the preference store since the Id may have changed - if (setOption != option) { - getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal); - } + // if (setOption != option) { + // getToolSettingsPreferenceStore().setValue(setOption.getId(), boolVal); + // } break; case IOption.ENUMERATED : - String enumVal = getToolSettingsPreferenceStore().getString(option.getId()); - String enumId = option.getEnumeratedId(enumVal); - setOption = ManagedBuildManager.setOption(configuration, tool, option, + String enumVal = clonedOption.getStringValue(); + String enumId = clonedOption.getEnumeratedId(enumVal); + setOption = ManagedBuildManager.setOption(realCfg, realTool, 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); - } +// if (setOption != option) { +// getToolSettingsPreferenceStore().setValue(setOption.getId(), enumVal); +// } break; case IOption.STRING : - String strVal = getToolSettingsPreferenceStore().getString(option.getId()); - setOption = ManagedBuildManager.setOption(configuration, tool, option, strVal); + String strVal = clonedOption.getStringValue(); + setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, strVal); // Reset the preference store since the Id may have changed - if (setOption != option) { - getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal); - } +// if (setOption != option) { +// getToolSettingsPreferenceStore().setValue(setOption.getId(), strVal); +// } break; case IOption.STRING_LIST : case IOption.INCLUDE_PATH : case IOption.PREPROCESSOR_SYMBOLS : case IOption.LIBRARIES : case IOption.OBJECTS : - String listStr = getToolSettingsPreferenceStore().getString(option.getId()); - String[] listVal = BuildToolsSettingsStore.parseString(listStr); - setOption = ManagedBuildManager.setOption(configuration, tool, option, listVal); +// String listStr = getToolSettingsPreferenceStore().getString(option.getId()); + String[] listVal = (String[])((List)clonedOption.getValue()).toArray(new String[0]); + setOption = ManagedBuildManager.setOption(realCfg, realTool, realOption, listVal); // Reset the preference store since the Id may have changed - if (setOption != option) { - getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr); - } +// if (setOption != option) { +// getToolSettingsPreferenceStore().setValue(setOption.getId(), listStr); +// } break; default : break; @@ -645,10 +540,10 @@ public class BuildToolSettingsPage extends BuildSettingsPage { // Call an MBS CallBack function to inform that Settings related to Apply/OK button // press have been applied. if (setOption == null) - setOption = option; + setOption = realOption; if (setOption.getValueHandler().handleValue( - getConfigurationHandle(), + handler, setOption.getOptionHolder(), setOption, setOption.getValueHandlerExtraArgument(), @@ -658,18 +553,20 @@ public class BuildToolSettingsPage extends BuildSettingsPage { } else { // Event handling Failed. } - } catch (BuildException e) {} + } catch (BuildException e) { + } catch (ClassCastException e) { + } } // Save the tool command if it has changed // Get the actual value out of the field editor - String command = getToolSettingsPreferenceStore().getString(tool.getId()); + String command = clonedTool.getToolCommand(); if (command.length() > 0 && (!command.equals(tool.getToolCommand()))) { if ( isItResourceConfigPage ) { - ManagedBuildManager.setToolCommand(resConfig, tool, command); + ManagedBuildManager.setToolCommand(realRcCfg, tool, command); } else { - ManagedBuildManager.setToolCommand(configuration, tool, command); + ManagedBuildManager.setToolCommand(realCfg, tool, command); } } @@ -680,20 +577,28 @@ public class BuildToolSettingsPage extends BuildSettingsPage { * saves all field editors */ public void storeSettings() { - super.performOk(); +// super.performOk(); } /** * Update the field editor that displays all the build options */ public void updateAllOptionField() { - try { - String flags = getToolFlags(); - if (flags != null) { - getToolSettingsPreferenceStore().setValue(allOptionsId, flags); - allOptionFieldEditor.load(); - } - } catch (BuildException e) { + allOptionFieldEditor.load(); + } + + 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(); } } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPreferenceStore.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPreferenceStore.java new file mode 100644 index 00000000000..87c2d9c13b9 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPreferenceStore.java @@ -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(); + + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java deleted file mode 100644 index df36009984f..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java +++ /dev/null @@ -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 String 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 IConfiguration 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; - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java index ccbf1dc839f..a0a81c8c6b0 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControl.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,10 @@ 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.internal.ui.ManagedBuilderUIImages; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages; @@ -132,6 +136,10 @@ public class FileListControl { // The type of browse support that is required private int browseType; 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 DEL_STR = ManagedBuilderUIMessages.getResourceString("FileListControl.delete"); //$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); private final Image IMG_MOVEDOWN = ManagedBuilderUIImages .get(ManagedBuilderUIImages.IMG_FILELIST_MOVEDOWN); + /** * Constructor * @@ -277,7 +286,44 @@ public class FileListControl { for (int i = 0; i < listVal.length; 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 * @@ -299,8 +345,10 @@ public class FileListControl { * removes all items from list control */ public void removeAll() { - if (list != null) + if (list != null){ list.removeAll(); + checkNotificationNeeded(); + } } /** * get list items @@ -361,6 +409,7 @@ public class FileListControl { list.add(input, 0); list.setSelection(0); } + checkNotificationNeeded(); } selectionChanged(); @@ -375,10 +424,14 @@ public class FileListControl { String title = ManagedBuilderUIMessages.getResourceString("FileListControl.deletedialog.title"); //$NON-NLS-1$ boolean delDir = MessageDialog.openQuestion(list.getShell(), title, quest); - if (delDir && index != -1) + if (delDir && index != -1){ list.remove(index); - } else if (index != -1) + checkNotificationNeeded(); + } + } else if (index != -1){ list.remove(index); + checkNotificationNeeded(); + } selectionChanged(); } /** @@ -391,6 +444,7 @@ public class FileListControl { list.setItem(index - 1, curSelList); list.setItem(index, preList); list.setSelection(index - 1); + checkNotificationNeeded(); selectionChanged(); } /** @@ -403,6 +457,7 @@ public class FileListControl { list.setItem(index + 1, curSelList); list.setItem(index, nextList); list.setSelection(index + 1); + checkNotificationNeeded(); selectionChanged(); } /** @@ -421,6 +476,7 @@ public class FileListControl { newItem = dialog.getValue(); if (newItem != null && !newItem.equals(selItem)) { list.setItem(index, newItem); + checkNotificationNeeded(); selectionChanged(); } } @@ -511,4 +567,14 @@ public class FileListControl { return input; } + + public Label getLabelControl(){ + return title; + } + + public void setEnabled(boolean enabled){ + title.setEnabled(enabled); + toolBar.setEnabled(enabled); + list.setEnabled(enabled); + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java index 007b7c8e92f..cbbb75616d9 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/FileListControlFieldEditor.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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.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.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.jface.preference.FieldEditor; 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.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; /** @@ -96,9 +104,23 @@ public class FileListControlFieldEditor extends FieldEditor { topLayout, getLabelText(), getType()); - + list.addChangeListener(new IFileListChangeListener(){ + + public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) { + handleFileListChange(fileList,oldValue,newValue); + } + + }); 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 @@ -128,8 +150,8 @@ public class FileListControlFieldEditor extends FieldEditor { list.setList(array); list.setSelection(0); // Set the resource the editor works for - if (store instanceof BuildToolsSettingsStore) { - IConfiguration config = ((BuildToolsSettingsStore)store).getOwner(); + if (store instanceof BuildToolSettingsPreferenceStore) { + IConfiguration config = ((BuildToolSettingsPreferenceStore)store).getSelectedConfig(); if (config != null) { IResource project = config.getOwner(); if (project != null) { @@ -164,6 +186,10 @@ public class FileListControlFieldEditor extends FieldEditor { if (s != null) getPreferenceStore().setValue(getPreferenceName(), s); } + + public String[] getStringListValue(){ + return list.getItems(); + } /** * Returns the number of basic controls this field editor consists of. @@ -221,5 +247,13 @@ public class FileListControlFieldEditor extends FieldEditor { protected void adjustForNumColumns(int numColumns) { } + + public Label getLabelControl(Composite parent) { + return list.getLabelControl(); + } + + public void setEnabled(boolean enabled, Composite parent) { + list.setEnabled(enabled); + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/IFileListChangeListener.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/IFileListChangeListener.java new file mode 100644 index 00000000000..0ab1b277132 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/IFileListChangeListener.java @@ -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[]); +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java index bdfd9364e5f..55f764d8bac 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ResourceBuildPropertyPage.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; 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.ManagedBuilderHelpContextIds; 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.ui.IWorkbenchPropertyPage; import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; -import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.help.WorkbenchHelp; -public class ResourceBuildPropertyPage extends PropertyPage implements +public class ResourceBuildPropertyPage extends AbstractBuildPropertyPage implements IWorkbenchPropertyPage, IPreferencePageContainer, ICOptionContainer { /* * String constants @@ -89,7 +89,8 @@ public class ResourceBuildPropertyPage extends PropertyPage implements private static final String MSG_CONFIG_NOTSELECTED = PREFIX + ".config.notselected"; //$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 boolean DEFAULT_EXCLUDE_VALUE = false; /* * Dialog widgets */ @@ -102,16 +103,16 @@ public class ResourceBuildPropertyPage extends PropertyPage implements /* * Bookeeping variables */ - private boolean isExcluded = false; private boolean noContentOnPage = false; - private IConfiguration[] configurations; private IConfiguration selectedConfiguration; - private IResourceConfiguration currentResourceConfig; + private IConfiguration clonedConfiguration; + private IResourceConfiguration clonedResourceConfig; private Point lastShellSize; protected ManagedBuildOptionBlock fOptionBlock; protected boolean displayedConfig = false; + /** * Default constructor */ @@ -223,10 +224,10 @@ public class ResourceBuildPropertyPage extends PropertyPage implements Group tabGroup = ControlFactory.createGroup(composite, ManagedBuilderUIMessages.getResourceString(RESOURCE_SETTINGS_LABEL), 1); gd = new GridData(GridData.FILL_BOTH); tabGroup.setLayoutData(gd); - fOptionBlock.createContents(tabGroup, getElement()); - // Update the contents of the configuration widget populateConfigurations(); + fOptionBlock.createContents(tabGroup, getElement()); + WorkbenchHelp.setHelp(composite,ManagedBuilderHelpContextIds.MAN_PROJ_BUILD_PROP); } @@ -325,17 +326,18 @@ public class ResourceBuildPropertyPage extends PropertyPage implements // Set the new selected configuration selectedConfiguration = newConfig; ManagedBuildManager.setSelectedConfiguration(getProject(), selectedConfiguration); + clonedConfiguration = getClonedConfig(selectedConfiguration); // Set the current Resource Configuration - setCurrentResourceConfig(findCurrentResourceConfig()); + clonedResourceConfig = getCurrentResourceConfig(clonedConfiguration,true); - isExcluded = getCurrentResourceConfig().isExcluded(); fOptionBlock.updateValues(); - excludedCheckBox.setSelection(isExcluded); + excludedCheckBox.setSelection(isExcluded()); } } return; } + /* * This method updates the property page message */ @@ -438,7 +440,7 @@ public class ResourceBuildPropertyPage extends PropertyPage implements protected void performDefaults() { fOptionBlock.performDefaults(); - excludedCheckBox.setSelection(getCurrentResourceConfig().isExcluded()); + excludedCheckBox.setSelection(getCurrentResourceConfigClone().isExcluded()); super.performDefaults(); } @@ -458,7 +460,13 @@ public class ResourceBuildPropertyPage extends PropertyPage implements IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { + if(containsDefaults()){ + removeCurrentResourceConfig(); + return; + } + fOptionBlock.performApply(monitor); + getCurrentResourceConfig(true).setExclude(getCurrentResourceConfigClone().isExcluded()); } }; IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable); @@ -475,10 +483,11 @@ public class ResourceBuildPropertyPage extends PropertyPage implements // Write out the build model info ManagedBuildManager.setDefaultConfiguration(getProject(), getSelectedConfiguration()); - if ( getCurrentResourceConfig().isExcluded() != isExcluded() ) { - getCurrentResourceConfig().setExclude(isExcluded()); - selectedConfiguration.setRebuildState(true); - } + + if(getCurrentResourceConfigClone().isDirty()){ + selectedConfiguration.setRebuildState(true); + getCurrentResourceConfigClone().setDirty(false); + } ManagedBuildManager.saveBuildInfo(getProject(), false); @@ -486,8 +495,25 @@ public class ResourceBuildPropertyPage extends PropertyPage implements if (bi != null & bi instanceof ManagedBuildInfo) { ((ManagedBuildInfo)bi).initializePathEntries(); } + + EnvironmentVariableProvider.fUserSupplier.checkInexistentConfigurations(clonedConfiguration.getManagedProject()); + 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() { @@ -518,54 +544,31 @@ public class ResourceBuildPropertyPage extends PropertyPage implements /** * @return Returns the currentResourceConfig. */ - public IResourceConfiguration getCurrentResourceConfig() { - return currentResourceConfig; + public IResourceConfiguration getCurrentResourceConfigClone() { + return clonedResourceConfig; + } + + public IResourceConfiguration getCurrentResourceConfig(boolean create) { + return getCurrentResourceConfig(selectedConfiguration,create); } - /** - * @param currentResourceConfig - * 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); + + private IResourceConfiguration getCurrentResourceConfig(IConfiguration cfg, boolean create){ + IResourceConfiguration rcCfg = cfg.getResourceConfiguration(((IFile)getElement()).getFullPath().toString()); + if(rcCfg == null && create) + rcCfg = cfg.createResourceConfiguration((IFile)getElement()); + return rcCfg; + } + + public boolean removeCurrentResourceConfig(){ + IResourceConfiguration rcCfg = getCurrentResourceConfig(false); + if(rcCfg != null){ + selectedConfiguration.removeResourceConfiguration(rcCfg); + return true; } + return false; } - - // 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() { - - IResourceConfiguration resConfigElement = null; - - // Check if the selected configuration has any resourceConfigurations. - 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; - } /** * @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons() */ @@ -610,10 +613,11 @@ public class ResourceBuildPropertyPage extends PropertyPage implements /* (non-Javadoc) * Return the IPreferenceStore of the Tool Settings block */ - public IPreferenceStore getToolSettingsPreferenceStore() + public BuildToolSettingsPreferenceStore getToolSettingsPreferenceStore() { return fOptionBlock.getToolSettingsPreferenceStore(); } + public Preferences getPreferences() { return null; @@ -624,13 +628,15 @@ public class ResourceBuildPropertyPage extends PropertyPage implements /** * @return Returns the isExcluded. */ - public boolean isExcluded() { - return isExcluded; + public boolean isExcluded(){ + return getCurrentResourceConfigClone().isExcluded(); } + /** * @param isExcluded The isExcluded to set. */ public void setExcluded(boolean isExcluded) { - this.isExcluded = isExcluded; + getCurrentResourceConfigClone().setExclude(isExcluded); + fOptionBlock.updateValues(); } }