How to update the checked state of a command per window? [message #336462] |
Mon, 15 June 2009 14:55 |
Eclipse User |
|
|
|
Originally posted by: eclipse-newsgroups.scharf.gr
I have a very hard time finding information
about commands.
Here is a vary simple problem:
- I want to have a command that has a checked (toggle) state
- There is boolean a variable associated with each window
- I want the checked state represent the state of this variable
- when the state changes, the command should change its state
- when handler is called, it should toggle the variable
I have no idea how to do this with commands....
Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
|
|
|
|
Re: How to update the checked state of a command per window? [message #336469 is a reply to message #336465] |
Mon, 15 June 2009 19:58 |
Eclipse User |
|
|
|
Originally posted by: eclipse-newsgroups.scharf.gr
Hi Paul,
thank you for the answer! (I'll try this out
tomorrow)
How would I figure all this out without asking the
newsgroup? I feel really stupid and I don't know
how to figure out all the complexity of commands.
Maybe a set of relatively simple examples would help a lot.
It turns out that the actual code that gets executed int
the handler is not the problem. The problem is hooking
the handlers and commands into the application which
includes plugin.xml and window.getService(IHandlerService.class)
all things that are very hard to figure out.
Michael
> Your handler would be updating the state after implementing
> IElementUpdater. But ...
>
> You would need to use
> org.eclipse.ui.commands.ICommandService.refreshElements(Stri ng, Map) to
> request that the command update its checked state when the active window
> changes, so it can reflect the correct state.
>
> Commands in 3.x run off of a global application context. There is also
> only one global command (backed by the currently active handler), so
> within one window it becomes impossible to show different states for one
> command. Between windows, it might just be possible assuming you are
> updating your state to the correctly active window.
>
> Or instead of one handler that needs to manage the state for the
> application, programmaticly activate a handler when creating each
> separate window using window.getService(IHandlerService.class) to get
> the IHandlerService in each case (since that will scope the handler to
> that window only).
>
> PW
>
>
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03358 seconds