Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Context menu in a Form Dialog
Context menu in a Form Dialog [message #493867] Wed, 28 October 2009 10:29 Go to next message
Willie Zayas is currently offline Willie ZayasFriend
Messages: 1
Registered: October 2009
Junior Member
Hi all, this might be a silly question. I hope that you can help
me out with this. Rolling Eyes

I developed an application using views(extend ViewPart) and
perspectives, one of these views had a TableViewer which had
associated a Context Menu using the following code:

* Contextual menu initialization
private void initializeMenu() {
MenuManager menuManager = new MenuManager();
Menu menu = menuManager.createContextMenu(table);
getSite().registerContextMenu(menuManager, tableViewer);

The menu was registred as a contribution associated with the View (as
recommended in most books and tutorials) in the plugin.xml file using
the following id: View

By client request I had to migrate the application to dialogs, so I
chose to extend the FormDialog class and put there the code on the
views. So far everything has worked fine except for the context menu
which does not work. I had to comment out the last two lines of the
initializeMenu() method since the getSite() method is not available to
the form dialog. I've read that the context menus can only be
associated with a View, is this true? is there a workaround for this?

Thanks in advance,

Re: Context menu in a Form Dialog [message #644795 is a reply to message #493867] Tue, 14 December 2010 09:35 Go to previous messageGo to next message
suvidh Mising name is currently offline suvidh Mising nameFriend
Messages: 5
Registered: December 2010
Junior Member
I have a similar question with Dialog window where i have to perform right click on the Treeviewer for the context menu to appear, even here we don't have view to associate [plugin.xml]. please let me know if there is any workaround.

Re: Context menu in a Form Dialog [message #644850 is a reply to message #493867] Tue, 14 December 2010 13:24 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Long and the short of it. If you are not in a view, you cannot use a view context menu, since the view you care about *may not be active* when you are in the dialog.

You can, however, continue to use org.eclipse.ui.menus in a dialog, simply specify your own menu id.

You can use IMenuService#populateContributions(*) with ... remember to release the contributions when you don't need that MenuManager any more.


Previous Topic:RCP product deployment problem
Next Topic:Menu visibility control
Goto Forum:

Current Time: Fri Jun 22 03:22:46 GMT 2018

Powered by FUDForum. Page generated in 0.02463 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top