Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] patch for 95762 - request for ability to dynamically determine enablement of options

https://bugs.eclipse.org/bugs/show_bug.cgi?id=95762

 

The patch to managedbuilder.core.tests will require that the benchmark projects be regenerated.

 

___________________________________________

 

Chris Recoskie

Software Designer

IDE Frameworks Group

Texas Instruments, Toronto

 

 

 

cvs diff -u -wb (in directory C:\cdt_option_visibility\org.eclipse.cdt-build\org.eclipse.cdt.managedbuilder.ui\)
cvs diff: Empty password used - try 'cvs login' with a real password

cvs diff: Diffing .
cvs diff: Diffing icons
cvs diff: Diffing icons/dlcl16
cvs diff: Diffing icons/elcl16
cvs diff: Diffing icons/full
cvs diff: Diffing icons/full/build16
cvs diff: Diffing icons/full/list
cvs diff: Diffing icons/full/wizban
cvs diff: Diffing schema
cvs diff: Diffing src
cvs diff: Diffing src/org
cvs diff: Diffing src/org/eclipse
cvs diff: Diffing src/org/eclipse/cdt
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal/ui
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/toolchain
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/toolchain/gnu
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/toolchain/gnu/cygwin
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/ui
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/ui/actions
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/ui/properties
Index: src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java,v
retrieving revision 1.9
diff -u -w -b -r1.9 BuildOptionSettingsPage.java
--- src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java	12 May 2005 22:55:55 -0000	1.9
+++ src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java	25 May 2005 17:23:47 -0000
@@ -17,6 +17,7 @@
 
 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.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,6 +79,13 @@
 			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()) {
+		
 			try {
 				// Figure out which type the option is and add a proper field
 				// editor for it
@@ -88,24 +99,43 @@
 					 	switch(opt.getBrowseType())
 					 	{
 					 		case IOption.BROWSE_DIR :
+									Composite fieldEditorParent2 = getFieldEditorParent();
 					 			DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor(
-										opt.getId(), opt.getName(), getFieldEditorParent());
+											opt.getId(), opt.getName(), fieldEditorParent2);
+									
+									setFieldEditorEnablement(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(), getFieldEditorParent());			
+											opt.getId(), opt.getName(), fieldEditorParent3);
+									
+									setFieldEditorEnablement(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(), getFieldEditorParent());
+											opt.getId(), opt.getName(), fieldEditorParent4);
+									
+									setFieldEditorEnablement(applicabilityCalculator, stringField, fieldEditorParent4);
+									
 								addField(stringField);
 								fieldsMap.put(opt.getId(), stringField);
+									fieldEditorsToParentMap.put(stringField, fieldEditorParent4);
 					 			break;
 					 						
 					 		default:
@@ -114,10 +144,16 @@
 					 	// 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(applicabilityCalculator, booleanField, fieldEditorParent5);
+
 						addField(booleanField);
 						fieldsMap.put(opt.getId(),booleanField);
+							fieldEditorsToParentMap.put(booleanField, fieldEditorParent5);
 						break;
 					case IOption.ENUMERATED :
 						String selId;
@@ -130,26 +166,40 @@
 							// wrong
 							break;
 						}
+							
+							Composite fieldEditorParent6 = getFieldEditorParent();
+							
 						BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
 								opt.getId(), opt.getName(), opt
 										.getApplicableValues(), sel,
-								getFieldEditorParent());
+									fieldEditorParent6);
+							
+							setFieldEditorEnablement(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 :
+							
+							Composite fieldEditorParent7 = getFieldEditorParent();
+							
 						FileListControlFieldEditor listField =
 							new FileListControlFieldEditor(
 								opt.getId(),
 								opt.getName(),
-								getFieldEditorParent(),
+									fieldEditorParent7,
 								opt.getBrowseType());
+							
+							setFieldEditorEnablement(applicabilityCalculator, listField, fieldEditorParent7);
+							
 						addField(listField);
 						fieldsMap.put(opt.getId(), listField);
+							fieldEditorsToParentMap.put(listField, fieldEditorParent7);
 						break;
 					default :
 						break;
@@ -157,6 +207,7 @@
 			} catch (BuildException e) {}
 		}
 	}
+	}
 	
 	/**
 	 * Answers <code>true</code> if the settings page has been created for 
@@ -290,4 +341,58 @@
 	public void storeSettings() {
 		super.performOk();
 	}
+	
+	private void setFieldEditorEnablement(IOptionApplicability optionApplicability,
+			FieldEditor fieldEditor, Composite parent) {
+		if (optionApplicability == null)
+			return;
+
+		// if the option is not enabled then disable it
+		if (!optionApplicability.isOptionEnabled()) {
+			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(applicabilityCalculator, fieldEditor, parent);
+				}
+			}
+
+		}
+	}
+
 }
Index: src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java,v
retrieving revision 1.19
diff -u -w -b -r1.19 BuildToolSettingsPage.java
--- src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java	19 May 2005 16:22:49 -0000	1.19
+++ src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java	25 May 2005 17:18:32 -0000
@@ -21,6 +21,7 @@
 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,12 @@
 		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()) {
+			
 			try{
 			switch (option.getValueType()) {
 				case IOption.BOOLEAN :
@@ -313,11 +320,14 @@
 					break;
 				default :
 					break;
+	
 			}
 			if( buf.toString().trim().length() > 0 ) flags.add( buf.toString().trim() );
 			} catch (BuildMacroException e) {
 				
 			}
+			
+			}
 		}
 		
 		String outputName = "temp";		//$NON-NLS-1$
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/ui/wizards

***** CVS exited normally with code 1 *****

cvs diff -u -wb (in directory C:\cdt_option_visibility\org.eclipse.cdt-build\org.eclipse.cdt.managedbuilder.core\)
cvs diff: Empty password used - try 'cvs login' with a real password

? src/org/eclipse/cdt/managedbuilder/core/IOptionApplicability.java
cvs diff: Diffing .
cvs diff: Diffing schema
Index: schema/buildDefinitions.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd,v
retrieving revision 1.9
diff -u -w -b -r1.9 buildDefinitions.exsd
--- schema/buildDefinitions.exsd	19 May 2005 16:19:09 -0000	1.9
+++ schema/buildDefinitions.exsd	25 May 2005 15:28:32 -0000
@@ -1035,6 +1035,16 @@
                </documentation>

             </annotation>

          </attribute>

+         <attribute name="applicabilityCalculator" type="string">

+            <annotation>

+               <documentation>

+                  Optional class which is used to determine dynamically at runtime whether the option is visible, enabled, and used in command line generation.  This class must impelment the IOptionApplicability interface.  If no calculator is specified then the option is always visible, enabled, and used in command line generation.

+               </documentation>

+               <appInfo>

+                  <meta.attribute kind="java"/>

+               </appInfo>

+            </annotation>

+         </attribute>

       </complexType>

    </element>

 

@@ -1219,7 +1229,6 @@
                   Represents the InputFileName macro value. The macro specifies the input file name. The input file has the following meaning:

 1.	If a tool does not accept building multiple files of the primary input type with one tool invocation, the input file is the file of the primary input type being built.

 2.	If a tool accepts building multiple files of the primary input type with one tool invocation the input file is undefined and the macros representing the input file contain information about one of the inputs of the primary input type being built.

-

                </documentation>

             </annotation>

          </attribute>

@@ -1257,7 +1266,6 @@
                   Represents the OutputFileName macro value. The macro specifies the output file name. The output file has the following meaning:

 1.	If a tool is not capable of producing multiple files of the primary output type with one tool invocation the output file is the file of the primary output type that is built with a given tool invocation.

 2.	If a tool is capable of producing multiple files of the primary output type with one tool invocation the output file is undefined and the macros representing the output file contain information about one of the files of the primary output type that are built with a given tool invocation.

-

                </documentation>

             </annotation>

          </attribute>

cvs diff: Diffing src
cvs diff: Diffing src/org
cvs diff: Diffing src/org/eclipse
cvs diff: Diffing src/org/eclipse/cdt
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/core
Index: src/org/eclipse/cdt/managedbuilder/core/IOption.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java,v
retrieving revision 1.9
diff -u -w -b -r1.9 IOption.java
--- src/org/eclipse/cdt/managedbuilder/core/IOption.java	28 Oct 2004 17:16:53 -0000	1.9
+++ src/org/eclipse/cdt/managedbuilder/core/IOption.java	25 May 2005 15:41:16 -0000
@@ -10,6 +10,8 @@
  *******************************************************************************/
 package org.eclipse.cdt.managedbuilder.core;
 
+import org.eclipse.core.runtime.IConfigurationElement;
+
 /**
  * 
  */
@@ -49,6 +51,7 @@
 	public static final String IS_DEFAULT = "isDefault"; //$NON-NLS-1$
 	public static final String LIST_VALUE = "listOptionValue"; //$NON-NLS-1$
 	public static final String RESOURCE_FILTER = "resourceFilter"; //$NON-NLS-1$
+	public static final String APPLICABILITY_CALCULATOR = "applicabilityCalculator"; //$NON-NLS-1$
 	public static final String TYPE_BOOL = "boolean"; //$NON-NLS-1$
 	public static final String TYPE_ENUM = "enumerated"; //$NON-NLS-1$
 	public static final String TYPE_INC_PATH = "includePath"; //$NON-NLS-1$
@@ -126,6 +129,19 @@
 	public void setResourceFilter(int filter);
 	
 	/**
+	 * Returns the plugin.xml element of the applicabilityCalculator extension or <code>null</code> if none. 
+	 *  
+	 * @return IConfigurationElement
+	 */
+	public IConfigurationElement getApplicabilityCalculatorElement();
+	
+	/**
+	 * @return an instance of the class that calculates whether the option is visible,
+	 * enabled, and used in command line generation
+	 */
+	public IOptionApplicability getApplicabilityCalculator();
+	
+	/**
 	 * Answers an array of strings containing the built-in values 
 	 * defined for a stringList, includePaths, definedSymbols, or libs
 	 * option. If none have been defined, the array will be empty but
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/envvar
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal/core
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java,v
retrieving revision 1.38
diff -u -w -b -r1.38 ManagedBuildInfo.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java	19 May 2005 16:19:09 -0000	1.38
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java	25 May 2005 16:55:23 -0000
@@ -33,6 +33,7 @@
 import org.eclipse.cdt.managedbuilder.core.IBuilder;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
 import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
 import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
 import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
@@ -439,18 +440,30 @@
 					IOption option = opts[j];
 					try {
 						if (option.getValueType() == IOption.INCLUDE_PATH) {
-							// Get all the user-defined paths from the option as absolute paths
+							
+							// check to see if the option has an applicability
+							// calculator
+							IOptionApplicability applicabilityCalculator = option
+									.getApplicabilityCalculator();
+
+							if (applicabilityCalculator == null
+									|| applicabilityCalculator.isOptionUsedInCommandLine()) {
+
+								// Get all the user-defined paths from the
+								// option as absolute paths
 							String[] userPaths = option.getIncludePaths();
 							for (int index = 0; index < userPaths.length; ++index) {
 								IPath userPath = new Path(userPaths[index]);
 								if (userPath.isAbsolute()) {
 									paths.add(userPath.toOSString());
 								} else {
-									IPath absPath = root.addTrailingSeparator().append(userPath);
+										IPath absPath = root.addTrailingSeparator()
+												.append(userPath);
 									paths.add(absPath.makeAbsolute().toOSString());
 								}
 							}
 						}
+						}
 					} catch (BuildException e) {
 						// TODO: report error
 						continue;
@@ -482,13 +495,22 @@
 					IOption option = opts[i];
 					try {
 						if (option.getValueType() == IOption.LIBRARIES) {
+							
+							// check to see if the option has an applicability calculator
+							IOptionApplicability applicabilitytCalculator = option.getApplicabilityCalculator();
+							
+							if (applicabilitytCalculator == null
+									|| applicabilitytCalculator.isOptionUsedInCommandLine())
+							{
 							String command = option.getCommand();
 							String[] allLibs = option.getLibraries();
-							for (int j = 0; j < allLibs.length; j++) {
+								for (int j = 0; j < allLibs.length; j++)
+								{
 								String string = allLibs[j];
 								libs.add(command + string);
 							}
 						}
+						}
 					} catch (BuildException e) {
 						// TODO: report error
 						continue;
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java,v
retrieving revision 1.16
diff -u -w -b -r1.16 Option.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Option.java	21 Apr 2005 02:05:04 -0000	1.16
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Option.java	25 May 2005 17:24:11 -0000
@@ -21,12 +21,15 @@
 
 import org.eclipse.cdt.managedbuilder.core.BuildException;
 import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
 import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
 import org.eclipse.cdt.managedbuilder.core.IOption;
 import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
 import org.eclipse.cdt.managedbuilder.core.IProjectType;
 import org.eclipse.cdt.managedbuilder.core.ITool;
 import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -58,11 +61,12 @@
 	private Integer valueType;
 	private Boolean isAbstract;
 	private Integer resourceFilter;
+	private IConfigurationElement applicabilityCalculatorElement = null;
+	private IOptionApplicability applicabilityCalculator = null;
 	//  Miscellaneous
 	private boolean isExtensionOption = false;
 	private boolean isDirty = false;
 	private boolean resolved = true;
-
 	/*
 	 *  C O N S T R U C T O R S
 	 */
@@ -284,6 +288,14 @@
 		} else if (resFilterStr.equals(PROJECT)) {
 			resourceFilter = new Integer(FILTER_PROJECT);
 		}
+		
+		// get the applicability calculator, if any
+		String applicabilityCalculatorStr = element.getAttribute(APPLICABILITY_CALCULATOR); 
+		if (applicabilityCalculatorStr != null && element instanceof DefaultManagedConfigElement) {
+			applicabilityCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();			
+		}
+		
+		
 	}
 	
 	/* (non-Javadoc)
@@ -761,6 +773,45 @@
 		return resourceFilter.intValue();
 	}
 
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculatorElement()
+	 */
+	public IConfigurationElement getApplicabilityCalculatorElement() {
+		if (applicabilityCalculatorElement == null) {
+			if (superClass != null) {
+				return superClass.getApplicabilityCalculatorElement();
+			}
+		}
+		return applicabilityCalculatorElement;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculator()
+	 */
+	public IOptionApplicability getApplicabilityCalculator() {
+		if (applicabilityCalculator != null) {
+			return applicabilityCalculator;
+		}
+
+		IConfigurationElement element = getApplicabilityCalculatorElement();
+		if (element != null) {
+			try {
+				if (element.getAttribute(APPLICABILITY_CALCULATOR) != null) {
+					applicabilityCalculator = (IOptionApplicability) element
+							.createExecutableExtension(APPLICABILITY_CALCULATOR);
+					return applicabilityCalculator;
+				}
+			} catch (CoreException e) {
+			}
+		}
+		return null;
+	}
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.build.managed.IOption#getBuiltIns()
 	 */
Index: src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java,v
retrieving revision 1.17
diff -u -w -b -r1.17 OptionReference.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java	28 Oct 2004 17:16:53 -0000	1.17
+++ src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java	25 May 2005 17:08:19 -0000
@@ -16,11 +16,13 @@
 import java.util.ListIterator;
 
 import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
 import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
 import org.eclipse.cdt.managedbuilder.core.IOption;
 import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
 import org.eclipse.cdt.managedbuilder.core.ITool;
 import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.runtime.IConfigurationElement;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -688,6 +690,24 @@
 		return FILTER_ALL;
 	}
 	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculator()
+	 */
+	public IOptionApplicability getApplicabilityCalculator() {
+		return option.getApplicabilityCalculator();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculatorElement()
+	 */
+	public IConfigurationElement getApplicabilityCalculatorElement() {
+		return option.getApplicabilityCalculatorElement();
+	}
+
 	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
 	 */
Index: src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java,v
retrieving revision 1.31
diff -u -w -b -r1.31 Tool.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java	20 May 2005 02:34:37 -0000	1.31
+++ src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java	25 May 2005 15:46:38 -0000
@@ -22,6 +22,7 @@
 import org.eclipse.cdt.managedbuilder.core.IBuildObject;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
 import org.eclipse.cdt.managedbuilder.core.IInputType;
 import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
 import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
@@ -2187,13 +2188,18 @@
 	 * @return
 	 * @throws BuildException
 	 */
-	public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation, IMacroSubstitutor macroSubstitutor) throws BuildException{
+	public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation,
+			IMacroSubstitutor macroSubstitutor) throws BuildException {
 		IOption[] opts = getOptions();
 		ArrayList flags = new ArrayList();
 		StringBuffer sb = new StringBuffer();
 		for (int index = 0; index < opts.length; index++) {
 			IOption option = opts[index];
 			sb.setLength( 0 );
+
+			// check to see if the option has an applicability calculator
+			IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
+			if (applicabilityCalculator == null || applicabilityCalculator.isOptionUsedInCommandLine()) {
 			try{
 			switch (option.getValueType()) {
 			case IOption.BOOLEAN :
@@ -2219,16 +2225,23 @@
 			case IOption.STRING :
 				String strCmd = option.getCommand();
 				String val = option.getStringValue();
-					macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(inputFileLocation,outputFileLocation,option,getParent()));
-					if (val.length() > 0 && (val = MacroResolver.resolveToString(val,macroSubstitutor)).length() > 0) {
+						macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+								new FileContextData(inputFileLocation, outputFileLocation, option,
+										getParent()));
+						if (val.length() > 0
+								&& (val = MacroResolver.resolveToString(val, macroSubstitutor))
+										.length() > 0) {
 					sb.append( evaluateCommand( strCmd, val ) );
 				}
 				break;
 				
 			case IOption.STRING_LIST :
 				String listCmd = option.getCommand();
-					macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(inputFileLocation,outputFileLocation,option,getParent()));
-					String[] list = MacroResolver.resolveStringListValues(option.getStringListValue(),macroSubstitutor,true);
+						macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+								new FileContextData(inputFileLocation, outputFileLocation, option,
+										getParent()));
+						String[] list = MacroResolver.resolveStringListValues(option
+								.getStringListValue(), macroSubstitutor, true);
 					if(list != null){
 				for (int j = 0; j < list.length; j++) {
 					String temp = list[j];
@@ -2240,8 +2253,11 @@
 				
 			case IOption.INCLUDE_PATH :
 				String incCmd = option.getCommand();
-					macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(inputFileLocation,outputFileLocation,option,getParent()));
-					String[] paths = MacroResolver.resolveStringListValues(option.getIncludePaths(),macroSubstitutor,true);
+						macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+								new FileContextData(inputFileLocation, outputFileLocation, option,
+										getParent()));
+						String[] paths = MacroResolver.resolveStringListValues(option
+								.getIncludePaths(), macroSubstitutor, true);
 					if(paths != null){
 				for (int j = 0; j < paths.length; j++) {
 					String temp = paths[j];
@@ -2253,14 +2269,18 @@
 
 			case IOption.PREPROCESSOR_SYMBOLS :
 				String defCmd = option.getCommand();
-					macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,new FileContextData(inputFileLocation,outputFileLocation,option,getParent()));
-					String[] symbols = MacroResolver.resolveStringListValues(option.getDefinedSymbols(),macroSubstitutor,true);
+						macroSubstitutor.setMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE,
+								new FileContextData(inputFileLocation, outputFileLocation, option,
+										getParent()));
+						String[] symbols = MacroResolver.resolveStringListValues(option
+								.getDefinedSymbols(), macroSubstitutor, true);
 					if(symbols != null){
 				for (int j = 0; j < symbols.length; j++) {
 					String temp = symbols[j];
 							if(temp.length() > 0)
 					sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE);
 				}
+
 					}
 				break;
 
@@ -2268,11 +2288,13 @@
 				break;
 			}
 				
-			if( sb.toString().trim().length() > 0 ) flags.add( sb.toString().trim() );
+					if (sb.toString().trim().length() > 0)
+						flags.add(sb.toString().trim());
 			} catch (BuildMacroException e) {
 				
 			}
 		}
+		}
 		String[] f = new String[ flags.size() ];
 		return (String[])flags.toArray( f );
 	}
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java,v
retrieving revision 1.31
diff -u -w -b -r1.31 ToolReference.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java	19 May 2005 16:19:09 -0000	1.31
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java	25 May 2005 17:09:19 -0000
@@ -20,6 +20,7 @@
 import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
 import org.eclipse.cdt.managedbuilder.core.IInputType;
 import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
 import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
 import org.eclipse.cdt.managedbuilder.core.IOption;
 import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
@@ -440,6 +441,12 @@
 		IOption[] opts = getOptions();
 		for (int index = 0; index < opts.length; index++) {
 			IOption option = opts[index];
+			
+			// check to see if the option has an applicability calculator
+			IOptionApplicability applicabilityCalculator = option.getApplicabilityCalculator();
+			
+			if (applicabilityCalculator == null
+					|| applicabilityCalculator.isOptionUsedInCommandLine()) {
 			switch (option.getValueType()) {
 				case IOption.BOOLEAN :
 					String boolCmd;
@@ -503,6 +510,7 @@
 			}
 
 		}
+		}
 
 		return buf.toString().trim();
 	}
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal/envvar
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal/macros
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/internal/scannerconfig
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/macros
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/makegen
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/makegen/gnu
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/makegen/internal
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/projectconverter
cvs diff: Diffing src/org/eclipse/cdt/managedbuilder/scannerconfig

***** CVS exited normally with code 1 *****

cvs diff -u -wb (in directory C:\cdt_option_visibility\org.eclipse.cdt-build\org.eclipse.cdt.managedbuilder.core.tests\)
cvs diff: Empty password used - try 'cvs login' with a real password

? tests/org/eclipse/cdt/managedbuilder/core/tests/AlwaysOffApplicabilityCalculator.java
? tests/org/eclipse/cdt/managedbuilder/core/tests/AlwaysOnApplicabilityCalculator.java
cvs diff: Diffing .
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml,v
retrieving revision 1.22
diff -u -w -b -r1.22 plugin.xml
--- plugin.xml	23 May 2005 23:56:32 -0000	1.22
+++ plugin.xml	25 May 2005 14:47:23 -0000
@@ -2283,21 +2283,30 @@
 			  valueType="string">
 		  </option>
 		  <option
-			  defaultValue="false"
-			  name="MBS30Opt.Posix.Verbose"
+          applicabilityCalculator="org.eclipse.cdt.managedbuilder.core.tests.AlwaysOnApplicabilityCalculator"
 			  category="gnu.c.compiler.category30.other"
 			  command="-v"
+          defaultValue="true"
 			  id="gnu.c.compiler.option30.misc.verbose"
+          name="MBS30Opt.Posix.Verbose"
 			  valueType="boolean">
 		  </option>
 		  <option
-			  defaultValue="false"
+			  defaultValue="true"
 			  name="MBS30Opt.Posix.Ansi"
 			  category="gnu.c.compiler.category30.other"
 			  command="-ansi"
 			  id="gnu.c.compiler.option30.misc.ansi"
 			  valueType="boolean">
 		  </option>
+		  <option
+          applicabilityCalculator="org.eclipse.cdt.managedbuilder.core.tests.AlwaysOffApplicabilityCalculator"
+          command="-fake"
+          defaultValue="true"
+          id="gnu.c.compiler.option30.misc.FakeOption"
+          isAbstract="false"
+          name="MBS30Opt.Posix.FakeOption"
+          valueType="boolean"/>
           <inputType
 		      sources="c"
 			  dependencyExtensions="h"
cvs diff: Diffing .settings
cvs diff: Diffing resources
cvs diff: Diffing resources/oldTypeProjects
cvs diff: Diffing resources/oldTypeProjects/1.2
cvs diff: Diffing resources/oldTypeProjects/2.0
cvs diff: Diffing resources/oldTypeProjects/2.1
cvs diff: Diffing resources/test21Projects
cvs diff: Diffing resources/test21Projects/linkedFolder
cvs diff: Diffing resources/test21Projects/linkedFolder/Benchmarks
cvs diff: Diffing resources/test21Projects/linkedLib
cvs diff: Diffing resources/test21Projects/multiResConfig
cvs diff: Diffing resources/test21Projects/singleFileExe
cvs diff: Diffing resources/test21Projects/twoFileSO
cvs diff: Diffing resources/test30Projects
cvs diff: Diffing resources/test30Projects/copyandDeploy
cvs diff: Diffing resources/test30Projects/deleteFile
cvs diff: Diffing resources/test30Projects/linkedFolder
cvs diff: Diffing resources/test30Projects/linkedFolder/Benchmarks
cvs diff: Diffing resources/test30Projects/linkedLib
cvs diff: Diffing resources/test30Projects/multiResConfig
cvs diff: Diffing resources/test30Projects/singleFileExe
cvs diff: Diffing resources/test30Projects/test30_1
cvs diff: Diffing resources/test30Projects/test30_2
cvs diff: Diffing resources/test30Projects/twoFileSO
cvs diff: Diffing suite
cvs diff: Diffing suite/org
cvs diff: Diffing suite/org/eclipse
cvs diff: Diffing suite/org/eclipse/cdt
cvs diff: Diffing suite/org/eclipse/cdt/managedbuilder
cvs diff: Diffing suite/org/eclipse/cdt/managedbuilder/testplugin
cvs diff: Diffing suite/org/eclipse/cdt/managedbuilder/tests
cvs diff: Diffing suite/org/eclipse/cdt/managedbuilder/tests/suite
cvs diff: Diffing suite/org/eclipse/cdt/standardbuilder
cvs diff: Diffing suite/org/eclipse/cdt/standardbuilder/core
cvs diff: Diffing suite/org/eclipse/cdt/standardbuilder/core/tests
cvs diff: Diffing tests
cvs diff: Diffing tests/org
cvs diff: Diffing tests/org/eclipse
cvs diff: Diffing tests/org/eclipse/cdt
cvs diff: Diffing tests/org/eclipse/cdt/managedbuild
cvs diff: Diffing tests/org/eclipse/cdt/managedbuild/core
cvs diff: Diffing tests/org/eclipse/cdt/managedbuild/core/tests
cvs diff: Diffing tests/org/eclipse/cdt/managedbuilder
cvs diff: Diffing tests/org/eclipse/cdt/managedbuilder/core
cvs diff: Diffing tests/org/eclipse/cdt/managedbuilder/core/tests

***** CVS exited normally with code 1 *****

Attachment: org.eclipse.cdt.managedbuilder.core.tests.zip
Description: org.eclipse.cdt.managedbuilder.core.tests.zip

Attachment: org.eclipse.cdt.managedbuilder.core.zip
Description: org.eclipse.cdt.managedbuilder.core.zip


Back to the top