Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to disable/hide a menu item
How to disable/hide a menu item [message #666413] Wed, 20 April 2011 07:26 Go to next message
Aivar Annamaa is currently offline Aivar Annamaa
Messages: 32
Registered: July 2009
Member
Id like to disable (or hide) a menu item of my plugin if program is in certain state. I tried implementing "isEnabled" in respective command's handler -- this would restrict executing the command (a message pops up saying "the chosen operation is not enabled") but the menu item is neither hidden nor disabled until it's clicked once.

I tried setting "checkEnabled"=true in menu definition under visibleWhen in plugin.xml, but it didn't help

I really hope it's possible to do it without using a MenuItemStateProviderNotifierService Smile

[Updated on: Wed, 20 April 2011 07:45]

Report message to a moderator

Re: How to disable/hide a menu item [message #666478 is a reply to message #666413] Wed, 20 April 2011 09:58 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You use org.eclipse.ui.menus and a visibleWhen clause on your command
menu item.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: How to disable/hide a menu item [message #667026 is a reply to message #666478] Tue, 26 April 2011 10:39 Go to previous message
Aivar Annamaa is currently offline Aivar Annamaa
Messages: 32
Registered: July 2009
Member
I finally got my thing working (by using a custom PropertyTester). But I was not able to use "visibleWhen" without any children and checkEnabled=true -- according to documentation it should delegate decision to command's (or command handler's?) "isEnabled", but it didn't work like that.

[Updated on: Tue, 26 April 2011 10:39]

Report message to a moderator

Previous Topic:UpdateManager Reconciling
Next Topic:CompareEditor throwing Null Exception when selected
Goto Forum:
  


Current Time: Sat Aug 23 01:47:21 EDT 2014

Powered by FUDForum. Page generated in 0.01781 seconds