mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Roll back changes with isOptionVisible()
This commit is contained in:
parent
ba4b0ab3ed
commit
8a3ee52100
1 changed files with 102 additions and 108 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2007 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
|
||||
|
@ -121,114 +121,114 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
|
||||
IBuildObject config = fInfo;
|
||||
|
||||
// Check for (un)visibility is now performed in setFieldEditorEnablement()
|
||||
// if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt))
|
||||
// {
|
||||
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) {
|
||||
|
||||
try {
|
||||
// Figure out which type the option is and add a proper field
|
||||
// editor for it
|
||||
Composite fieldEditorParent = getFieldEditorParent();
|
||||
FieldEditor fieldEditor;
|
||||
|
||||
try {
|
||||
// Figure out which type the option is and add a proper field
|
||||
// editor for it
|
||||
Composite fieldEditorParent = getFieldEditorParent();
|
||||
FieldEditor fieldEditor;
|
||||
|
||||
switch (opt.getValueType()) {
|
||||
case IOption.STRING: {
|
||||
StringFieldEditor stringField;
|
||||
|
||||
// If browsing is set, use a field editor that has a
|
||||
// browse button of the appropriate type.
|
||||
switch (opt.getBrowseType()) {
|
||||
case IOption.BROWSE_DIR: {
|
||||
stringField = new DirectoryFieldEditor(optId, opt.getName(), fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.BROWSE_FILE: {
|
||||
stringField = new FileFieldEditor(optId, opt.getName(), fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.BROWSE_NONE: {
|
||||
final StringFieldEditorM local = new StringFieldEditorM(optId, opt.getName(), fieldEditorParent);
|
||||
stringField = local;
|
||||
local.getTextControl().addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
local.valueChanged();
|
||||
switch (opt.getValueType()) {
|
||||
case IOption.STRING: {
|
||||
StringFieldEditor stringField;
|
||||
|
||||
// If browsing is set, use a field editor that has a
|
||||
// browse button of the appropriate type.
|
||||
switch (opt.getBrowseType()) {
|
||||
case IOption.BROWSE_DIR: {
|
||||
stringField = new DirectoryFieldEditor(optId, opt.getName(), fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.BROWSE_FILE: {
|
||||
stringField = new FileFieldEditor(optId, opt.getName(), fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.BROWSE_NONE: {
|
||||
final StringFieldEditorM local = new StringFieldEditorM(optId, opt.getName(), fieldEditorParent);
|
||||
stringField = local;
|
||||
local.getTextControl().addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
local.valueChanged();
|
||||
}
|
||||
});
|
||||
} break;
|
||||
|
||||
default: {
|
||||
throw new BuildException(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
} break;
|
||||
|
||||
default: {
|
||||
throw new BuildException(null);
|
||||
}
|
||||
stringField.getTextControl(fieldEditorParent).setToolTipText(opt.getToolTip());
|
||||
stringField.getLabelControl(fieldEditorParent).setToolTipText(opt.getToolTip());
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(stringField.getTextControl(fieldEditorParent), opt.getContextId());
|
||||
fieldEditor = stringField;
|
||||
} break;
|
||||
|
||||
case IOption.BOOLEAN: {
|
||||
fieldEditor = new TriStateBooleanFieldEditor(
|
||||
optId,
|
||||
opt.getName(),
|
||||
opt.getToolTip(),
|
||||
fieldEditorParent,
|
||||
opt.getContextId(),
|
||||
ohs,
|
||||
curr);
|
||||
} break;
|
||||
|
||||
case IOption.ENUMERATED: {
|
||||
String selId = opt.getSelectedEnum();
|
||||
String sel = opt.getEnumName(selId);
|
||||
|
||||
// Get all applicable values for this enumerated Option, But display
|
||||
// only the enumerated values that are valid (static set of enumerated values defined
|
||||
// in the plugin.xml file) in the UI Combobox. This refrains the user from selecting an
|
||||
// invalid value and avoids issuing an error message.
|
||||
String[] enumNames = opt.getApplicableValues();
|
||||
Vector<String> enumValidList = new Vector<String>();
|
||||
for (int i = 0; i < enumNames.length; ++i) {
|
||||
if (opt.getValueHandler().isEnumValueAppropriate(config,
|
||||
opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) {
|
||||
enumValidList.add(enumNames[i]);
|
||||
}
|
||||
}
|
||||
String[] enumValidNames = new String[enumValidList.size()];
|
||||
enumValidList.copyInto(enumValidNames);
|
||||
|
||||
fieldEditor = new BuildOptionComboFieldEditor(optId, opt.getName(), opt.getToolTip(), opt.getContextId(), enumValidNames, sel, fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:
|
||||
case IOption.INCLUDE_FILES:
|
||||
case IOption.LIBRARY_PATHS:
|
||||
case IOption.LIBRARY_FILES:
|
||||
case IOption.MACRO_FILES:
|
||||
case IOption.UNDEF_INCLUDE_PATH:
|
||||
case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
|
||||
case IOption.UNDEF_INCLUDE_FILES:
|
||||
case IOption.UNDEF_LIBRARY_PATHS:
|
||||
case IOption.UNDEF_LIBRARY_FILES:
|
||||
case IOption.UNDEF_MACRO_FILES: {
|
||||
fieldEditor = new FileListControlFieldEditor(optId, opt.getName(), opt.getToolTip(), opt.getContextId(), fieldEditorParent, opt.getBrowseType());
|
||||
} break;
|
||||
|
||||
default:
|
||||
throw new BuildException(null);
|
||||
}
|
||||
|
||||
stringField.getTextControl(fieldEditorParent).setToolTipText(opt.getToolTip());
|
||||
stringField.getLabelControl(fieldEditorParent).setToolTipText(opt.getToolTip());
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(stringField.getTextControl(fieldEditorParent), opt.getContextId());
|
||||
fieldEditor = stringField;
|
||||
} break;
|
||||
setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, fieldEditorParent);
|
||||
|
||||
case IOption.BOOLEAN: {
|
||||
fieldEditor = new TriStateBooleanFieldEditor(
|
||||
optId,
|
||||
opt.getName(),
|
||||
opt.getToolTip(),
|
||||
fieldEditorParent,
|
||||
opt.getContextId(),
|
||||
ohs,
|
||||
curr);
|
||||
} break;
|
||||
addField(fieldEditor);
|
||||
fieldsMap.put(optId, fieldEditor);
|
||||
fieldEditorsToParentMap.put(fieldEditor, fieldEditorParent);
|
||||
|
||||
case IOption.ENUMERATED: {
|
||||
String selId = opt.getSelectedEnum();
|
||||
String sel = opt.getEnumName(selId);
|
||||
|
||||
// Get all applicable values for this enumerated Option, But display
|
||||
// only the enumerated values that are valid (static set of enumerated values defined
|
||||
// in the plugin.xml file) in the UI Combobox. This refrains the user from selecting an
|
||||
// invalid value and avoids issuing an error message.
|
||||
String[] enumNames = opt.getApplicableValues();
|
||||
Vector<String> enumValidList = new Vector<String>();
|
||||
for (int i = 0; i < enumNames.length; ++i) {
|
||||
if (opt.getValueHandler().isEnumValueAppropriate(config,
|
||||
opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) {
|
||||
enumValidList.add(enumNames[i]);
|
||||
}
|
||||
}
|
||||
String[] enumValidNames = new String[enumValidList.size()];
|
||||
enumValidList.copyInto(enumValidNames);
|
||||
|
||||
fieldEditor = new BuildOptionComboFieldEditor(optId, opt.getName(), opt.getToolTip(), opt.getContextId(), enumValidNames, sel, fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.INCLUDE_PATH:
|
||||
case IOption.STRING_LIST:
|
||||
case IOption.PREPROCESSOR_SYMBOLS:
|
||||
case IOption.LIBRARIES:
|
||||
case IOption.OBJECTS:
|
||||
case IOption.INCLUDE_FILES:
|
||||
case IOption.LIBRARY_PATHS:
|
||||
case IOption.LIBRARY_FILES:
|
||||
case IOption.MACRO_FILES:
|
||||
case IOption.UNDEF_INCLUDE_PATH:
|
||||
case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
|
||||
case IOption.UNDEF_INCLUDE_FILES:
|
||||
case IOption.UNDEF_LIBRARY_PATHS:
|
||||
case IOption.UNDEF_LIBRARY_FILES:
|
||||
case IOption.UNDEF_MACRO_FILES: {
|
||||
fieldEditor = new FileListControlFieldEditor(optId, opt.getName(), opt.getToolTip(), opt.getContextId(), fieldEditorParent, opt.getBrowseType());
|
||||
} break;
|
||||
|
||||
default:
|
||||
throw new BuildException(null);
|
||||
} catch (BuildException e) {
|
||||
}
|
||||
|
||||
setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, fieldEditorParent);
|
||||
|
||||
addField(fieldEditor);
|
||||
fieldsMap.put(optId, fieldEditor);
|
||||
fieldEditorsToParentMap.put(fieldEditor, fieldEditorParent);
|
||||
|
||||
} catch (BuildException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,14 +415,8 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
if (optionApplicability == null)
|
||||
return;
|
||||
|
||||
IBuildObject config = fInfo;
|
||||
|
||||
if (!optionApplicability.isOptionVisible(config, holder, option )) {
|
||||
fieldEditor.setEnabled(false, parent); // temporary: instead of setVisible
|
||||
return;
|
||||
}
|
||||
|
||||
// if the option is not enabled then disable it
|
||||
IBuildObject config = fInfo;
|
||||
if (!optionApplicability.isOptionEnabled(config, holder, option )) {
|
||||
fieldEditor.setEnabled(false, parent);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue