1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Bug 436147. Changed the way of handling "Restore Defaults" to reset the

values to default values instead of removing the options.

Change-Id: I748206ab90aa07d161a437af0b6fc4e3d3a7161b
Signed-off-by: mazab <mohamed_azab@mentor.com>
Reviewed-on: https://git.eclipse.org/r/27519
Tested-by: Hudson CI
Reviewed-by: Elena Laskavaia <elaskavaia.cdt@gmail.com>
This commit is contained in:
mazab 2014-05-29 11:36:04 +02:00 committed by Elena Laskavaia
parent 6ff7af7dc6
commit 597c1dbc69

View file

@ -36,6 +36,7 @@ import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
@ -47,6 +48,7 @@ import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.buildproperties.BuildPropertyManager;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildFolderData;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
@ -1325,28 +1327,45 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
toolChain.resolveProjectReferences(onLoad);
}
/**
* Reset the options of the given holder to the default values
*/
private void resetOptionSettings(IHoldsOptions holder) {
IOption[] opts = holder.getOptions();
for (IOption opt : opts) {
Object val = opt.getDefaultValue();
if (val instanceof Boolean) {
ManagedBuildManager.setOption(toolChain.getParent(), holder, opt, (Boolean)val);
} else if (val instanceof String[]) {
ManagedBuildManager.setOption(toolChain.getParent(), holder, opt, (String[])val);
} else if (val instanceof String){
ManagedBuildManager.setOption(toolChain.getParent(), holder, opt, (String)val);
} else if (val == null) {
holder.removeOption(opt);
} else {
ManagedBuilderCorePlugin.error("Unknown type of value " + val + " for " + opt); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
public void resetOptionSettings() {
// We just need to remove all Options
// (Bug 438367) Removing all the options and relying on automatic creating when modifying/using the option
// will result in problems in the following cases:
// - When changing an option affects values of other options.
// - When the option has a FieldEditor that holds an instance of the option, that
// will result on having multiple copies of the option in some cases.
// Instead, will reset the value of each option to its default value.
ITool[] tools = getTools();
IToolChain toolChain = getToolChain();
IOption[] opts;
for (ITool tool : tools) {
resetOptionSettings(tool);
}
resetOptionSettings(toolChain);
// Send out the event to notify the options that they are about to be removed.
// Do not do this for the child resource configurations as they are handled when
// the configuration itself is destroyed.
// ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE, false);
// Remove the configurations
for (ITool tool : tools) {
opts = tool.getOptions();
for (IOption opt : opts) {
tool.removeOption(opt);
}
}
opts = toolChain.getOptions();
for (IOption opt : opts) {
toolChain.removeOption(opt);
}
// rebuildNeeded = true;
}