[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Content outline context menu

Fabio Mancinelli wrote:
Hi everybody,

I am trying to add a context (popup) menu to the outline view associated to an editor.

The outline is created in the standard way using the getAdapter() method in the editor.

Now the question is what is the standard and suggested way to add a context menu to the displayed outline in order to perform custom action on the items shown in the outline?
Simply create the menu on your widget(s) and register it with the site. Here's some sample code taken from the Java outline page:

MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager m) {
contextMenuAboutToShow(m);
}
});
fMenu= manager.createContextMenu(tree);
tree.setMenu(fMenu);


IPageSite site= getSite();
site.registerContextMenu(JavaPlugin.getPluginId() + ".outline", manager, fOutlineViewer); //$NON-NLS-1$


Dani

Thanks, Fabio