Bug 186578 - Should Plug-ins view have "Show In" as one menu with submenus?
Summary: Should Plug-ins view have "Show In" as one menu with submenus?
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.3 RC2   Edit
Assignee: Noam Chitayat CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-05-11 11:21 EDT by Kevin McGuire CLA
Modified: 2007-06-05 18:57 EDT (History)
2 users (show)

See Also:
baumanbr: review+
wassim.melhem: review+


Attachments
Patch for bug 186578. (4.94 KB, patch)
2007-05-16 17:29 EDT, Noam Chitayat CLA
no flags Details | Diff
Revised patch for 186578. (9.07 KB, patch)
2007-05-18 16:22 EDT, Noam Chitayat CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin McGuire CLA 2007-05-11 11:21:16 EDT
3.3 N0510

The Package Explorer and other navigators have one "Show In" menu, with a submenu with entries for each of the different target views.

The Plug-ins view has two menus, "Show in Resource Navigator" and "Show in Package Explorer".

It would be good to have some consistency in this regard and I'd suggest we follow the Package Explorer pattern, since a submenu makes it easier to add targets and takes up less top level menu space.

Thus:
1.  The plug-ins view should be one menu with a submenu with "Navigator" and "Packapge Explorer".
2.  The Show-In menu should probably be bound to Alt-Shift-W like in the Package Explorer.
Comment 1 Wassim Melhem CLA 2007-05-14 18:43:32 EDT
Nice polish defect for Noam.
Comment 2 Noam Chitayat CLA 2007-05-16 09:38:28 EDT
The menu reorganization is done, but unfortunately the keybinding is a little more complicated. It looks like the original 'Alt+Shift+W' command is bound to the window context, so it seems that I can't override the original behaviour. In every case, pressing Alt+Shift+W in the Plugins view brings up a context menu that says '<No available views>', but it should say the two options available in our 'Show In' submenu from the right-click context.

Paul, I've been told by Wassim that you understand the 'black art' of keybinding. Any advice would be appreciated. :)

I've tried two things:
1) In the view code itself, I've tried to set the action associated with the existing command to a new action (using a call to setGlobalActionHandler). This still results in the original action showing through.

2) Create a PDE context that is a child of the window context and bind my own command to that context. Then map the command I've created to the action I want in the same way as done above. Same result.
Comment 3 Paul Webster CLA 2007-05-16 10:19:27 EDT
Views like the problems view take advantage of ContributionItemFactory.VIEWS_SHOW_IN to populate their showIn items.  for example check out org.eclipse.ui.views.markers.internal.MarkerView getAdapter(*) which provides the IShowInSource and createShowInMenu(*) which creates the correct menu for the context menu ... although this isn't strictly necessary.

Then the ALT+SHIFT+W menu is created for free.

That's how the other parts use the Show In menu and keybindings.


But your option 2) should definitely work.

1. create your command
2. create a context, child of org.eclipse.ui.contexts.window
3. create a keybinding for that context->command
4. in your view createPartControl, use getSite().getService(*) to get the IContextService and IHandlerService
5. activate your context
6. if you declare a handler you don't need the IHandlerService.  But if you are instantiating a handler programmatically (or sticking an Action in an ActionHandler) you do that in the createPartControl(*) as well.

Later,
PW
Comment 4 Noam Chitayat CLA 2007-05-16 17:29:16 EDT
Created attachment 67530 [details]
Patch for bug 186578.

As per Paul's suggestion, this code overrides the getAdapter(*) class to use the existing 'Alt+Shift+W' functionality. I've noticed that a History option appears in the context that pops up. This option is not in the right-click context menu yet. We'll investigate and correct that later, but for now the existing functionality has been fixed and is consistent with the Package Explorer.

Paul, thank you very much for your help.
Comment 5 Wassim Melhem CLA 2007-05-16 17:46:46 EDT
Brian, please review.

The History issue is covered in bug 170156
Comment 6 Noam Chitayat CLA 2007-05-18 16:22:50 EDT
Created attachment 67867 [details]
Revised patch for 186578.

The original patch encountered problems populating the 'Show In' context with views when the user invokes the context from the Plug-In Development perspective.

Currently, as mentioned in bug 173649, there's no way to alter the Show In contexts application-wide whenever a new resource view is added to Eclipse that should appear in the 'Show In' menu. Until there's a solution to the above bug, we're down to the two solutions described in the bug description. Since the first option doesn't affect non-PDE perspectives, the Plug-In Development view's 'Show In' context might be left unpopulated in certain perspectives that are not under our control.

As a result, we're going with Option B, which is to let the Plug-in Development view specify which views will appear in its "Show In" context. Please keep in mind that until bug 173649 is fixed, this means that the View needs to be updated whenever we want to change how the 'Show In' context is populated (i.e. adding or removing a 'Show In' view).
Comment 7 Wassim Melhem CLA 2007-05-18 16:58:41 EDT
Noam, the patch works great.
Comment 8 Brian Bauman CLA 2007-05-21 11:44:16 EDT
If I didn't know any better, I would have thought Noam hacked my computer and saw my solution :)

The only thing I added to the patch was the removal of ShowInWorkspaceAction.  Other than that, the patch was perfect.

Nice job Noam.