Bug 242431 - [api] Register a new unique context menu id, so contributions can be made to all our views
Summary: [api] Register a new unique context menu id, so contributions can be made to ...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Kevin Doyle CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 249320
  Show dependency tree
 
Reported: 2008-07-29 13:29 EDT by Kevin Doyle CLA
Modified: 2008-11-12 13:18 EST (History)
4 users (show)

See Also:


Attachments
Patch (10.28 KB, patch)
2008-11-11 09:37 EST, Kevin Doyle CLA
no flags Details | Diff
Updated patch (9.69 KB, patch)
2008-11-11 11:33 EST, Kevin Doyle CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2008-07-29 13:29:17 EDT
Currently using the org.eclipse.ui.menu's extension point we can only contribute to a specific view.

In 3.1 we should register another menu id in all the views, such that contributions can be made to that id and show up in all views.
Comment 1 Martin Oberhuber CLA 2008-07-29 13:41:26 EDT
I don't understand. Wouldn't an ObjectContribution help?
Comment 2 Kevin Doyle CLA 2008-07-29 13:57:19 EDT
For the org.eclipse.ui.menu's extension point this is how the locationURI works:

locationURI - A URI specification that defines the insertion point at which the contained additions will be added. The format for the URI is comprised of three basic parts: Scheme: One of "menu", "popup" or "toolbar. Indicates the type of the manager used to handle the contributions Id: This is either the id of an existing menu, a view id or the id of the editor 'type' Query: The query format is <placement>=<id> where: <placement> is either "before" or "after" and <id> is the id of an existing menu item 
Comment 3 Martin Oberhuber CLA 2008-07-29 14:54:27 EDT
I cannot see the benefit of contributing to an unknown number of context menus in an unknown number of views.

Usually, the context menu should be related to the context (that's where its name comes from). The context is either a specific view (so you'd want to contribute to the menu of that view), or a specific object that's selected (so you'd want to contribute an ObjectContribution, that works regardless of what view the object is currently displayed in).

What kind of use case do you have in mind?
Comment 4 Kevin Doyle CLA 2008-07-29 15:13:34 EDT
This is contributing 1 new context menu id that all the views share in common.

So I can create say User Actions and contribute it to that context menu id and it shows up in all views, instead of copying and pasting the code to contribute it to each view individually. 

Remote Systems, Remote Details, Scratchpad, and Monitor should all show the same actions when right clicking on a file/folder.
Comment 5 Martin Oberhuber CLA 2008-07-29 15:50:09 EDT
So again, if your contribution is bound to the object (an IRemoteFile), then why not make a menu contribution that works on any IRemoteFile regardless of the view in which it is shown?
Comment 6 Kevin Doyle CLA 2008-07-29 16:26:36 EDT
You are thinking popUpMenu not menu's extension point.  That can't be done with the menu's extension point.
Comment 7 Martin Oberhuber CLA 2008-07-30 09:13:30 EDT
Fair enough, but why not use popUpMenu in that case?

You are trying to register a menu item against an object (IRemoteFile) irrespective of where it occurs. ObjectContribution seems to be the only correct place for this, IMHO.
Comment 8 Kevin Doyle CLA 2008-07-30 09:18:48 EDT
Certain case's can't be handled by the popUpMenu's extension as far as I'm aware.  Like dynamic menu's.  Thats why we used the menu's extension point for the User Actions/Compile menu's.
Comment 9 Kevin Doyle CLA 2008-11-11 09:37:03 EST
Created attachment 117550 [details]
Patch
Comment 10 Kevin Doyle CLA 2008-11-11 09:38:52 EST
Attached a patch that registers the new context menu id and an example for Launch Shell of how it can be used without duplicating code for every view.

Any thoughts on what the context menu id should be?  I took the category id for our view's and added menu to it: org.eclipse.rse.view.menu
Comment 11 Martin Oberhuber CLA 2008-11-11 09:57:56 EST
What about

   popup:org.eclipse.rse.views.common

Since I't think that "popup" already conveys that we're talking about a context menu. Need to make sure though that we don't run into name clashes.

I'm a bit confused though... your patch only removes a "Launch Shell" contribution to the systemView, does that mean that "Launch Shell" is currently not available from any folder in the Tableview or Monitor?
Comment 12 Kevin Doyle CLA 2008-11-11 10:08:45 EST
(In reply to comment #11)
> What about
> 
>    popup:org.eclipse.rse.views.common

You mean org.eclipse.rse.views.common without the popup as that's not part of the menu id.  You specify that in the menu's extension for where you want it to go.

> Since I't think that "popup" already conveys that we're talking about a context
> menu. Need to make sure though that we don't run into name clashes.
> 
> I'm a bit confused though... your patch only removes a "Launch Shell"
> contribution to the systemView, does that mean that "Launch Shell" is currently
> not available from any folder in the Tableview or Monitor?

All of our views now register there context menu with the new id as well as there own view id.  This way when we contribute Launch Shell to that menu id it is available in all views.  Launch Shell shows up in Remote Systems, Scratchpad, Table, and Monitor now.  You can still contribute a menu to a specific view by using the view id.
Comment 13 Martin Oberhuber CLA 2008-11-11 10:15:47 EST
Sound good. I think you should list the affected views in the Javadoc in ISystemContextMenuConstants as well, to be clear. What about dialogs re-using the SystemView widget (form), would these also be affected?
Comment 14 Kevin Doyle CLA 2008-11-11 11:33:06 EST
Created attachment 117559 [details]
Updated patch
Comment 15 Kevin Doyle CLA 2008-11-11 11:34:35 EST
(In reply to comment #13)
> Sound good. I think you should list the affected views in the Javadoc in
> ISystemContextMenuConstants as well, to be clear. What about dialogs re-using
> the SystemView widget (form), would these also be affected?

Updated the javadoc.  Dialogs that reuse the SystemView widget won't have these contributions.  I've also noted that in the javadoc.  This is the same as it worked before when specifying a view id.
Comment 16 Kevin Doyle CLA 2008-11-12 10:29:12 EST
I've committed the changes.
Comment 17 Martin Oberhuber CLA 2008-11-12 11:08:08 EST
Please add the missing @since 3.1 tag on your new field in ISystemContextMenuConstants.
Comment 18 Kevin Doyle CLA 2008-11-12 11:16:31 EST
Fixed.
Comment 19 Martin Oberhuber CLA 2008-11-12 12:59:50 EST
For the records, any plugin which uses the new rse.views.common markup in order to contribute its menu to all the RSE views needs to change its bundle dependency in the MANIFEST.MF to say that it requires rse.ui version 3.1 at least: [3.1,4.0)

The comment in ISystemContextMenuConstants doesn't list the remote search results view as a potential view ID where the menu is contributed, but the code checkin seemed to reference that one as well. Which is correct?
Comment 20 Kevin Doyle CLA 2008-11-12 13:14:51 EST
(In reply to comment #19)
> The comment in ISystemContextMenuConstants doesn't list the remote search
> results view as a potential view ID where the menu is contributed, but the code
> checkin seemed to reference that one as well. Which is correct?
> 

Remote Search is also a potential view ID.  Javadocs have been updated.
Comment 21 Martin Oberhuber CLA 2008-11-12 13:18:15 EST
Thanks.
Comment 22 Martin Oberhuber CLA 2008-11-12 13:18:44 EST
Marking the bug as API since the new view ID was added.