Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ToggelCommand dynamically assign state
ToggelCommand dynamically assign state [message #817062] Fri, 09 March 2012 10:38 Go to next message
Eclipse UserFriend
Hi,

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?

cheer,
Re: ToggelCommand dynamically assign state [message #825912 is a reply to message #817062] Wed, 21 March 2012 08:12 Go to previous message
Eclipse UserFriend
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.

PW
Previous Topic:Updating treeviewer from editor
Next Topic:Adding command, menu contributions, handlers programmatically
Goto Forum:
  


Current Time: Fri Jul 11 21:45:39 EDT 2025

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

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

Back to the top