Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Disabling a menu button not working
Disabling a menu button not working [message #664256] Fri, 08 April 2011 02:12 Go to next message
AppleJus Mising name is currently offline AppleJus Mising name
Messages: 46
Registered: July 2010
Member
Hello again,

I can disable a direct tool menuitem using:

EModelService uielementService = context.get(EModelService.class);
MDirectToolItem Button = (MDirectToolItem) uielementService.find("eID", application);
Button.setEnabled(false);

I was trying to do the same for a corresponding button in the menu , a MDirectMenuItem, but it does not work..

Help would be really appreciated! Thanks!

Re: Disabling a menu button not working [message #664330 is a reply to message #664256] Fri, 08 April 2011 07:51 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/08/2011 02:12 AM, AppleJus wrote:
> Hello again,
>
> I can disable a direct tool menuitem using:
>
> EModelService uielementService = context.get(EModelService.class);
> MDirectToolItem Button = (MDirectToolItem) uielementService.find("eID",
> application);
> Button.setEnabled(false);
>
> I was trying to do the same for a corresponding button in the menu , a
> MDirectMenuItem, but it does not work..

MDirectMenuItem should be calling your @CanExecute method, is it not?
That's probably it, actually, since not providing a @CanExecute implies
canExecute == true.

The ToolItem pattern needs to be updated so it is invoking @CanExecute
as well.

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


Previous Topic:Disallowing moving a part
Next Topic:Show annotation disabled in 4.1M6
Goto Forum:
  


Current Time: Thu Jul 31 11:50:55 EDT 2014

Powered by FUDForum. Page generated in 0.01923 seconds