Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Enabling/Disabling a command
Enabling/Disabling a command [message #559076] Wed, 15 September 2010 14:17 Go to next message
Giddi Ohm is currently offline Giddi OhmFriend
Messages: 10
Registered: September 2010
Junior Member
I'm new to SWT so please bare with me.

How do I disable a command based on a state in my program? I have PLAY command which puts my application in a play-state after the command has been confirmed by the user. I've created a STOP command and put it on a toolbar and assigned a handler to it, but the isEnabled() method isn't called often enough.

The STOP command's isEnabled() method is invoked immediately before and after the dialog is shown (most likely a result of the application window losing and gaining focus), but not after my code has regained control. Hence the stop button is never enabled.

I want to achieve something like this in my PLAY handler:
//state == IDLE;
if(openQuestion(...))
{
setState(PLAYING);
// somehow enable the STOP command
}

I have looked at the command service class but there seems to be no method of triggering an enable-evaluation of all commands. I've tried with and without enabledWhen to no avail.

I have no problems doing this with actions or action delegates, but I want to learn how to use commands from the beginning even though the framework seems overly complex for standard applications.

Please advice.
Re: Enabling/Disabling a command [message #559135 is a reply to message #559076] Wed, 15 September 2010 17:17 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You want eclipse.platform or eclipse.platform.rcp

PW

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


Previous Topic:CTRL+Enter in a Textbox in a Wizard
Next Topic:Why SWT on Gnome?
Goto Forum:
  


Current Time: Thu Nov 27 18:58:50 GMT 2014

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

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