Eclipse RCP: disable rack context menu

I would like to disable the context menu that appears when I right-click on the perspective toolbar in the rcp application. To clarify, I want the perspective panel and shortcuts to appear, but I don't want the context menu to pop up. The whole promising api toolbar seems internal.

Thanks.

+4
source share
2 answers

You can try this

PerspectiveBarManager perspectiveBarManager = ((WorkbenchWindow) PlatformUI.getWorkbench() .getActiveWorkbenchWindow()).getPerspectiveBar(); ToolBar toolBar = perspectiveBarManager.getControl(); Listener[] listeners = toolBar.getListeners(SWT.MenuDetect); if (listeners != null) { for (Listener listener : listeners) { toolBar.removeListener(SWT.MenuDetect, listener); } } 
+2
source

The PerspectiveSwitcher context menu is created, as you mentioned, in the inner classes of the workbench environment. You cannot prevent it from being created, and you cannot get a link to the PerspectiveSwitcher to somehow suppress the menu, without extensive use of inner classes and a lot of overriding existing functions.

So to make it simple, IMHO it seems that the context menu is not intended to be suppressed.

The easiest and cleanest way to solve your problem is to suppress the entire perspective panel and implement your own. There is a public API for querying existing perspectives (IWorkbench.getPerspectiveRegistry) and switching perspectives (IWorkbenchPage.setPerspective), all you need for coding is the user interface.

+1
source

All Articles