diff options
author | Leo Treggiari | 2005-05-26 21:18:14 +0000 |
---|---|---|
committer | Leo Treggiari | 2005-05-26 21:18:14 +0000 |
commit | 74d7f358452d3dd2b96b9d1f3f2778a7303553fe (patch) | |
tree | 4f859b53f52652762f15ea482451c561d6f4413b /build/org.eclipse.cdt.managedbuilder.ui | |
parent | 107015f42710bd6aa44335ede117d866b68eaaef (diff) | |
download | org.eclipse.cdt-74d7f358452d3dd2b96b9d1f3f2778a7303553fe.tar.gz org.eclipse.cdt-74d7f358452d3dd2b96b9d1f3f2778a7303553fe.tar.xz org.eclipse.cdt-74d7f358452d3dd2b96b9d1f3f2778a7303553fe.zip |
Add IOptionApplicability callback
Add more multi-version tool-chain support
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui')
3 files changed, 176 insertions, 58 deletions
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 ab2c073f152..adec1f7eff8 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 @@ -377,7 +377,17 @@ public class BuildSettingsBlock extends AbstractCOptionPage { if (builder.isExtensionElement()) { IToolChain tc = selectedConfiguration.getToolChain(); int nnn = ManagedBuildManager.getRandomNumber(); - String subId = builder.getId() + "." + nnn; //$NON-NLS-1$ + 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); } 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 831540185fe..264727916f2 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 @@ -17,6 +17,7 @@ import java.util.Collection; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IOptionApplicability; import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; @@ -27,13 +28,16 @@ import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FileFieldEditor; +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 boolean isItResourceConfigPage; + private Map fieldEditorsToParentMap = new HashMap(); public BuildOptionSettingsPage(IConfiguration configuration, IOptionCategory category) { // Cache the configuration and option category this page is created for @@ -75,51 +79,84 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { ITool tool = (ITool)options[index][0]; if (tool == null) break; // The array may not be full IOption opt = (IOption)options[index][1]; + + // check to see if the option has an applicability calculator + IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator(); + + // is the option visible? + if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(tool)) { + try { // Figure out which type the option is and add a proper field // editor for it switch (opt.getValueType()) { - case IOption.STRING : - // fix for PR 63973 - // Check browse type. - // If browsing is set, use a field editor that has a browse button of - // the appropriate type. - // Otherwise, use a regular text field. - switch(opt.getBrowseType()) - { - case IOption.BROWSE_DIR : - DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor( - opt.getId(), opt.getName(), getFieldEditorParent()); - addField(dirFieldEditor); - fieldsMap.put(opt.getId(), dirFieldEditor); - break; - - case IOption.BROWSE_FILE: - FileFieldEditor fileFieldEditor = new FileFieldEditor( - opt.getId(), opt.getName(), getFieldEditorParent()); - addField(fileFieldEditor); - fieldsMap.put(opt.getId(), fileFieldEditor); - break; - - case IOption.BROWSE_NONE: - StringFieldEditor stringField = new StringFieldEditor( - opt.getId(), opt.getName(), getFieldEditorParent()); - addField(stringField); - fieldsMap.put(opt.getId(), stringField); - break; - - default: - // should not be possible - throw( new AssertionError()); } - // end fix for 63973 - break; - case IOption.BOOLEAN : + case IOption.STRING: + // fix for PR 63973 + // Check browse type. + // If browsing is set, use a field editor that has a + // browse button of + // the appropriate type. + // Otherwise, use a regular text field. + switch (opt.getBrowseType()) { + case IOption.BROWSE_DIR: + Composite fieldEditorParent2 = getFieldEditorParent(); + DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor( + opt.getId(), opt.getName(), fieldEditorParent2); + + setFieldEditorEnablement(tool, + applicabilityCalculator, dirFieldEditor, fieldEditorParent2); + + addField(dirFieldEditor); + fieldsMap.put(opt.getId(), dirFieldEditor); + fieldEditorsToParentMap.put(dirFieldEditor, fieldEditorParent2); + + break; + + case IOption.BROWSE_FILE: + Composite fieldEditorParent3 = getFieldEditorParent(); + FileFieldEditor fileFieldEditor = new FileFieldEditor( + opt.getId(), opt.getName(), fieldEditorParent3); + + setFieldEditorEnablement(tool, + applicabilityCalculator, fileFieldEditor, fieldEditorParent3); + + addField(fileFieldEditor); + fieldsMap.put(opt.getId(), fileFieldEditor); + fieldEditorsToParentMap.put(fileFieldEditor, fieldEditorParent3); + break; + + case IOption.BROWSE_NONE: + Composite fieldEditorParent4 = getFieldEditorParent(); + StringFieldEditor stringField = new StringFieldEditor( + opt.getId(), opt.getName(), fieldEditorParent4); + + setFieldEditorEnablement(tool, + applicabilityCalculator, stringField, fieldEditorParent4); + + addField(stringField); + fieldsMap.put(opt.getId(), stringField); + fieldEditorsToParentMap.put(stringField, fieldEditorParent4); + break; + + default: + // should not be possible + throw (new AssertionError()); + } + // end fix for 63973 + break; + case IOption.BOOLEAN: + Composite fieldEditorParent5 = getFieldEditorParent(); BooleanFieldEditor booleanField = new BooleanFieldEditor( - opt.getId(), opt.getName(), getFieldEditorParent()); + opt.getId(), opt.getName(), fieldEditorParent5); + + setFieldEditorEnablement(tool, + applicabilityCalculator, booleanField, fieldEditorParent5); + addField(booleanField); - fieldsMap.put(opt.getId(),booleanField); + fieldsMap.put(opt.getId(), booleanField); + fieldEditorsToParentMap.put(booleanField, fieldEditorParent5); break; - case IOption.ENUMERATED : + case IOption.ENUMERATED: String selId; String sel; try { @@ -130,37 +167,47 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { // wrong break; } + + Composite fieldEditorParent6 = getFieldEditorParent(); BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor( - opt.getId(), opt.getName(), opt - .getApplicableValues(), sel, - getFieldEditorParent()); + opt.getId(), opt.getName(), opt.getApplicableValues(), sel, fieldEditorParent6); + + setFieldEditorEnablement(tool, + applicabilityCalculator, comboField, fieldEditorParent6); + addField(comboField); fieldsMap.put(opt.getId(), comboField); + fieldEditorsToParentMap.put(comboField, fieldEditorParent6); break; - case IOption.INCLUDE_PATH : - case IOption.STRING_LIST : - case IOption.PREPROCESSOR_SYMBOLS : - case IOption.LIBRARIES : - case IOption.OBJECTS : - FileListControlFieldEditor listField = - new FileListControlFieldEditor( - opt.getId(), - opt.getName(), - getFieldEditorParent(), - opt.getBrowseType()); + case IOption.INCLUDE_PATH: + case IOption.STRING_LIST: + case IOption.PREPROCESSOR_SYMBOLS: + case IOption.LIBRARIES: + case IOption.OBJECTS: + + Composite fieldEditorParent7 = getFieldEditorParent(); + FileListControlFieldEditor listField = new FileListControlFieldEditor( + opt.getId(), opt.getName(), fieldEditorParent7, opt.getBrowseType()); + + setFieldEditorEnablement(tool, + applicabilityCalculator, listField, fieldEditorParent7); + addField(listField); fieldsMap.put(opt.getId(), listField); + fieldEditorsToParentMap.put(listField, fieldEditorParent7); break; - default : + default: break; - } - } catch (BuildException e) {} + } + } catch (BuildException e) { + } + } } } /** - * Answers <code>true</code> if the settings page has been created for - * the option category specified in the argument. + * Answers <code>true</code> if the settings page has been created for the + * option category specified in the argument. * * @param category * @return @@ -290,4 +337,56 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { public void storeSettings() { super.performOk(); } + + private void setFieldEditorEnablement(ITool tool, IOptionApplicability optionApplicability, + FieldEditor fieldEditor, Composite parent) { + if (optionApplicability == null) + return; + + // if the option is not enabled then disable it + if (!optionApplicability.isOptionEnabled(tool)) { + fieldEditor.setEnabled(false, parent); + } else { + fieldEditor.setEnabled(true, parent); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + // allow superclass to handle as well + super.propertyChange(event); + + // some option has changed on this page... update enabled/disabled state for all options + + Object[][] options; + if (isItResourceConfigPage) { + options = category.getOptions(resConfig); + } else { + options = category.getOptions(configuration); + } + + for (int index = 0; index < options.length; ++index) { + // Get the option + ITool tool = (ITool) options[index][0]; + if (tool == null) + break; // The array may not be full + IOption opt = (IOption) options[index][1]; + + // is the option on this page? + if (fieldsMap.containsKey(opt.getId())) { + // check to see if the option has an applicability calculator + IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator(); + + if (applicabilityCalculator != null) { + FieldEditor fieldEditor = (FieldEditor) fieldsMap.get(opt.getId()); + Composite parent = (Composite) fieldEditorsToParentMap.get(fieldEditor); + setFieldEditorEnablement(tool, applicabilityCalculator, fieldEditor, parent); + } + } + + } + } + } 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 3212cd0c2f6..ab2eb71fa1d 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 @@ -21,6 +21,7 @@ import java.util.Vector; 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.IOptionApplicability; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator; import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; import org.eclipse.cdt.managedbuilder.core.IOption; @@ -260,6 +261,11 @@ public class BuildToolSettingsPage extends BuildSettingsPage { 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(tool)) { + try{ switch (option.getValueType()) { case IOption.BOOLEAN : @@ -313,11 +319,14 @@ public class BuildToolSettingsPage extends BuildSettingsPage { break; default : break; + } if( buf.toString().trim().length() > 0 ) flags.add( buf.toString().trim() ); } catch (BuildMacroException e) { } + + } } String outputName = "temp"; //$NON-NLS-1$ |