Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 320949

Summary: Add ability to contribute custom field-editor GUI to the Build Option Settings page
Product: [Tools] CDT Reporter: Baltasar Belyavsky <bbelyavsky>
Component: cdt-build-managedAssignee: Chris Recoskie <recoskie>
Status: RESOLVED FIXED QA Contact: Chris Recoskie <recoskie>
Severity: enhancement    
Priority: P3 CC: cdt-build-managed-inbox, jaiswal.123, jamesblackburn+eclipse, marcin.swiezawski, miwako.tokugawa, richard.horbach, yevshif
Version: 7.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Workspace patch - applies to HEAD.
none
Updated patch - applies to HEAD
none
Updated patch - applies to HEAD recoskie: iplog+

Description Baltasar Belyavsky CLA 2010-07-26 15:03:29 EDT
Build Identifier: 3.6.0 [I20100608-0911]

Currently the CDT Build Option Settings page supports a limited number of field-editors which are displayed based on the valueType of the underlying build-option.  This patch allows to contribute a custom field-editor for an option.

The patch adds two new optional attributes to the <option> element in the buildDefinitions extension-point.  The 'fieldEditor' attribute specifies the class of the field-editor implementation.  The 'fieldEditorExtraArgument' allows the contributor to specify a free-form string argument to the field-editor (we use this to specify encoded XML meta-data to further parameterize our custom field-editor).

If the two optional extension-point attributes aren't specified, CDT defaults to the old behaviour.  The custom field-editor itself also has a programmatic way to "abort" itself, and default to the original behaviour (through returning 'false' in the ICustomBuildOptionEditor.init() method).

The managedbuild model (IOption class) stores the field-editor as the IConfigurationElement in order not to introduce any unnecessary dependencies on JFace.  The field-editor itself is instantiated only from the UI layer.

Reproducible: Always

Steps to Reproduce:
N/A.
Comment 1 Baltasar Belyavsky CLA 2010-07-26 15:05:39 EDT
Created attachment 175261 [details]
Workspace patch - applies to HEAD.
Comment 2 Baltasar Belyavsky CLA 2011-01-14 13:39:25 EST
Created attachment 186838 [details]
Updated patch - applies to HEAD
Comment 3 Chris Recoskie CLA 2011-02-01 11:12:18 EST
In reply to comment #0)
> The managedbuild model (IOption class) stores the field-editor as the
> IConfigurationElement in order not to introduce any unnecessary dependencies on
> JFace.  The field-editor itself is instantiated only from the UI layer.

In general I support the idea of adding custom editors for options.  I think this aspect of the patch needs to be reworked though.  IConfigurationElements are not supposed to be long-lived objects so you shouldn't be using them as handles.  Also, since you are contributing UI it doesn't make sense to contribute the editor itself in the core plugin, it really ought to be in the UI plugin.

I think a better way to do this would be for there to be an option editor extension point in managedbuilder.ui.  Contributions to that point would allow one to specify an option editor and a mandatory string ID.  Then the Option element in the buildDefinitions in managedbuilder.core could optionally specify the string ID of the editor it should use.  That way there are no UI APIs bleeding through into the core.  At the time the UI is generated, the Option's editor ID would be consulted to see if a special editor should be instantiated, and instantiate it as necessary.
Comment 4 Baltasar Belyavsky CLA 2011-02-01 16:43:42 EST
Created attachment 188093 [details]
Updated patch - applies to HEAD

Chris,

Thanks for looking into this. I've uploaded an updated patch incorporating your feedback.  

In summary, I've added a new extension-point -  "org.eclipse.cdt.managedbuilder.ui.buildDefinitionsUI". I gave it a generic name, "buildDefinitionsUI", in case if anyone in the future needs to add any other UI contributions with the need to reference them from the core.buildDefinitions extension-point. And also to give this new extension-point a logical connection to the core.buildDefinitions extension-point.  Just as before, the custom field-editor still gets instantiated  only at the point when the dialog page is rendered on the UI thread.

Let me know if you have any other comments.

Thanks!
Comment 5 Chris Recoskie CLA 2011-03-09 17:28:22 EST
Comment on attachment 188093 [details]
Updated patch - applies to HEAD

Applied to HEAD.  Thanks.
Comment 6 Chris Recoskie CLA 2011-03-09 17:29:02 EST
Marking FIXED.
Comment 7 CDT Genie CLA 2011-03-09 18:23:38 EST
*** cdt cvs genie on behalf of crecoskie ***
Bug 320949 - Add ability to contribute custom field-editor GUI to the Build Option Settings page

[*] IOption.java 1.31 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java?root=Tools_Project&r1=1.30&r2=1.31

[*] Option.java 1.52 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java?root=Tools_Project&r1=1.51&r2=1.52
[*] OptionReference.java 1.39 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java?root=Tools_Project&r1=1.38&r2=1.39

[*] buildDefinitions.exsd 1.48 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd?root=Tools_Project&r1=1.47&r2=1.48

[*] plugin.properties 1.70 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui/plugin.properties?root=Tools_Project&r1=1.69&r2=1.70
[*] plugin.xml 1.134 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui/plugin.xml?root=Tools_Project&r1=1.133&r2=1.134

[+] buildDefinitionsUI.exsd  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui/schema/buildDefinitionsUI.exsd?root=Tools_Project&revision=1.1&view=markup

[*] BuildOptionSettingsUI.java 1.25 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java?root=Tools_Project&r1=1.24&r2=1.25
[+] ICustomBuildOptionEditor.java  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ICustomBuildOptionEditor.java?root=Tools_Project&revision=1.1&view=markup