Bug 193385 - Add context help to the view plug-in template
Summary: Add context help to the view plug-in template
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Adam Archer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-06-19 15:19 EDT by Adam Archer CLA
Modified: 2007-08-07 15:41 EDT (History)
3 users (show)

See Also:


Attachments
Patch (13.44 KB, patch)
2007-06-19 15:48 EDT, Adam Archer CLA
no flags Details | Diff
Patch (18.26 KB, patch)
2007-06-20 11:20 EDT, Adam Archer CLA
no flags Details | Diff
Patch (18.18 KB, patch)
2007-06-20 16:59 EDT, Adam Archer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Archer CLA 2007-06-19 15:19:45 EDT
We should add an option to the view template to create context sensitive help for the view. We should also reduce the number of options on the template and remove the second wizard page.
Comment 1 Adam Archer CLA 2007-06-19 15:48:38 EDT
Created attachment 71796 [details]
Patch

This patch adds the improvements discussed above. I just realized that the use of the <enablement> tag on the contexts.xml file that is generated will probably require the template to be versioned higher than 3.0, where it currently is. This might require some additional review.
Comment 2 Wassim Melhem CLA 2007-06-19 15:54:21 EDT
Adam, you could check the version of the target platform in the template class and decide whether to show/process this option or not.

In this case, you need the target to be >= 3.3
Comment 3 Adam Archer CLA 2007-06-20 11:20:05 EDT
Created attachment 71908 [details]
Patch

This patch includes a version check to decide whether or not to include the <enablement> tag in the xml file. It also prevents an NPE that I got when testing that came from calling AbstractTemplateSection.getTargetVersion() too early (before the model was initialized). This is done with an assertion in the method to allow template developers to be informed when they are calling the method too early.
Comment 4 Brian Bauman CLA 2007-06-20 16:48:10 EDT
Hi Adam.  I was reviewing your patch (and your comment) and figured out why you were having a problem with AbstractTemplateSection.getTargetVersion().  Until now, that function was only called after the user clicked finish and the model existed.  

In your case, you need to check the target version before the user clicks finish and therefore the model is not yet created.  The best thing to do here is to return the Target Platform's version (TargetPlatformHelper.getTargetVersion()) instead of using an Assert.  The current implementation will always fail at the assert which will cause problems when the user clicks next.  By returning the target's version, we take a best guess at what the uesr is targeting and continue on our way.

Wassim, what do you think about adding 'getTargetVersion()' back to IFieldData?  I noticed it was added and then removed during 3.1 development.  I think this would be a better value to key off of for the target version.  If the user targets to run with 3.0, yet has his target platform set to 3.3 (because he forgot to change it), we should not offer the option.
Comment 5 Adam Archer CLA 2007-06-20 16:55:02 EDT
Sorry, Chris discovered my mistake, but I forgot to mention it in the bug. I was using the if statement in initializeFields (3 lines of code) to test the assert, but they should be removed. I actually have that code in the generateFiles method now (check the very bottom of ViewTempalte.java), so it is run after the model is initialized.

Otherwise, the patch should be good and I don't think any changes are required to the templates framework.
Comment 6 Wassim Melhem CLA 2007-06-20 16:58:44 EDT
Brian,

TargetPlatformHelper.getTargetVersion() will not work, because it will not
necessarily match the Eclipse version specified on the first page of the
wizard.

IFieldData is API.  Adding methods to it would be breaking API.  We would need
to introduce a new interface.

Before doing this big production, we would need to revisit the whole New
Project API and do something better as a whole.

I don't think this particular feature should wait for all that.  We can revisit
and improve it later.


Adam,
Please re-attach a better patch that does not contain the extraneous lines.
Comment 7 Adam Archer CLA 2007-06-20 16:59:52 EDT
Created attachment 71958 [details]
Patch
Comment 8 Brian Bauman CLA 2007-06-21 10:37:45 EDT
Figured Adam should get credit for the work he did.
Comment 9 Brian Bauman CLA 2007-06-21 10:43:22 EDT
Slightly modified patch applied to HEAD.  

With the latest patch, we were no longer calling the getTargetVersion before the model was initialized, therefore we did not require any changes to the pde.core plug-in.  

Also removed the BooleanOption 'useEnablement'.  After doing some code searching I figured out PDE evaluated the conditional statements in source files by calling 'getValue(String key)'.  Therefore I removed the BooleanOption and extended 'getValue(String key)' to check to see if the key is useEnablement.  If it was, it would return a new Boolean(getTargetVersion >= 3.3).

The changes were very minor compared to all the work done in the patch.  Thanks for the good work.