Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to disable perspective's popup menu item
how to disable perspective's popup menu item [message #674579] Fri, 27 May 2011 08:24 Go to next message
Eclipse UserFriend
perspective's popup menu/context menu has items like 'Save As...', 'Reset', 'Close', 'Dock On'....


would like to disable 'close' in that context menu.

Have done some search in this forum and saw some threads saying as not possible.
Is this something possible ?
Re: how to disable perspective's popup menu item [message #674592 is a reply to message #674579] Fri, 27 May 2011 09:34 Go to previous messageGo to next message
Eclipse UserFriend
No, it is not possible to customize the current perspective switcher. That menu item is added in org.eclipse.ui.internal.PerspectiveSwitcher.createPopup(ToolBar, IPerspectiveDescriptor).

You would have to completely implement your own perspective switcher, similar to the code used by PerspectiveSwitcher.

PW
Re: how to disable perspective's popup menu item [message #675490 is a reply to message #674579] Tue, 31 May 2011 12:46 Go to previous messageGo to next message
Eclipse UserFriend
You can add you handler for command org.eclipse.ui.window.closePerspective:
<plugin>
<extension
point="org.eclipse.ui.handlers">
<handler
class="example.commands.UnsupportedCommandEliminator"
commandId="org.eclipse.ui.window.closePerspective">
</handler>
</extension>
</plugin>

(dirty solution)

or replace functionality of PerspectiveBarManager. For example for disable perspective bar menu you can use following code (is called in startup):

private void disablePerspectiveToolbarMenu() {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow == null) {
return;
}
PerspectiveBarManager perspectiveBarManager = ((WorkbenchWindow)workbenchWindow).getPerspectiveBar();
if (perspectiveBarManager == null) {
return;
}
ToolBar toolBar = perspectiveBarManager.getControl();
Listener[] listeners = toolBar.getListeners(SWT.MenuDetect);
if (listeners != null){
for (Listener listener : listeners){
toolBar.removeListener(SWT.MenuDetect, listener);
}
}
}

Regards,
Vasil Lukach
Re: how to disable perspective's popup menu item [message #675502 is a reply to message #675490] Tue, 31 May 2011 13:22 Go to previous message
Eclipse UserFriend
I'll just add that removing the menus won't work in eclipse 4.x with the compat layer as the perspective switcher implementation has changed.

PW
Previous Topic:How to programmatically minimize/ restore folder with views
Next Topic:Disabling Eclipse plugins upon startup programmatically
Goto Forum:
  


Current Time: Sun Aug 31 15:10:24 EDT 2025

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

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

Back to the top