Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:24 Go to next message
sam mn is currently offline sam mn
Messages: 25
Registered: August 2010
Junior Member
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 13:34 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 16:46 Go to previous messageGo to next message
Vasil Lukach is currently offline Vasil Lukach
Messages: 1
Registered: May 2011
Junior Member
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 17:22 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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: Thu Oct 23 15:54:18 GMT 2014

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

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