Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ToggelCommand dynamically assign state
ToggelCommand dynamically assign state [message #817062] Fri, 09 March 2012 15:38 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member

i want to have a toggel type command (in popup menu) but i do not want to give default state(true|false), i want to decide that based on property of selected object at the run time. Is it possible to add this using extensions interface or i need to add menu programmatically?

Re: ToggelCommand dynamically assign state [message #825912 is a reply to message #817062] Wed, 21 March 2012 12:12 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

For toggle commands, their is a Command State object that controls the state. But that state is valid for the command globally. One option is to just use the global command state and update it on a selection changed using org.eclipse.ui.handlers.HandlerUtil.toggleCommandState(Command).

The other possible solution would be to have your handler be an IElementUpdater. On selection change you can call org.eclipse.ui.commands.ICommandService.refreshElements(String, Map). Your handler can use the selection to figure out if it should set the toggle to checked or not.

Previous Topic:RCP and Database
Next Topic:Adding Global Actions Like Open Project, Save Project
Goto Forum:

Current Time: Mon May 01 02:45:04 GMT 2017

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

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