The radio-state we are administrating here is some look&feel identifier
and the corresponding handler applies this look&feel - this works
without problems.

Now we have a *different* command, which is supposed perform two steps:

1) Loading data into a viewer
2) Applying the look&feel as controlled by above radio-state-handler

Step (1) is specific for the second command (handler), no question, but
ideally - to realize (2) - we would like to evaluate the state of the
first radio-state handler to do different stuff based on that state. The
problem is, that by quering

event.getParameter(RadioState.PARAMETER_ID)

we obviously get null, because we are asking the wrong event for it. Is
there a way to ask for the specific parameter value of another command
in this context?

I know that I could use an AbstractSourceProvider to share state
globally, but that would (IMO) not allow to take advantage of the
additional command parameter functionality (e.g. defining the radio
state at the org.eclipse.ui.menus implementation).

Is there some way to realize that?

Thanks & Greetings from Bremen,

Daniel Krügler]]>Daniel KrÃ¼gler2010-12-03T12:41:37-00:00Re: Sharing state between different commandshttps://www.eclipse.org/forums/index.php/mv/msg/201301/642949/#msg_642949
> We have the following situation where it would be nice to realize state
> sharing between *different* commands.
>
> E.g. consider a org.eclipse.ui.commands command that describes a
> radio-state where we re-use the org.eclipse.ui.commands.radioState state
> as nicely described in the article:
>
> http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle- radio-menu.html
>
> The radio-state we are administrating here is some look&feel identifier
> and the corresponding handler applies this look&feel - this works
> without problems.
>
> Now we have a *different* command, which is supposed perform two steps:
>
> 1) Loading data into a viewer
> 2) Applying the look&feel as controlled by above radio-state-handler
>
> Step (1) is specific for the second command (handler), no question, but
> ideally - to realize (2) - we would like to evaluate the state of the
> first radio-state handler to do different stuff based on that state. The
> problem is, that by quering
>
> event.getParameter(RadioState.PARAMETER_ID)
>
> we obviously get null, because we are asking the wrong event for it. Is
> there a way to ask for the specific parameter value of another command
> in this context?

Let me add more information: Since after (1) we want to invoke the first
radio-state handler I used the IHandlerService.executeCommand method
(with second argument null): That invokes the right command, but it's
state values are all null. How can I activate the handler such that it's
current state is transmitted as well?

> I know that I could use an AbstractSourceProvider to share state
> globally, but that would (IMO) not allow to take advantage of the
> additional command parameter functionality (e.g. defining the radio
> state at the org.eclipse.ui.menus implementation).
>
> Is there some way to realize that?
>
> Thanks & Greetings from Bremen,
>
> Daniel Krügler]]>Daniel KrÃ¼gler2010-12-03T13:09:00-00:00Re: Sharing state between different commandshttps://www.eclipse.org/forums/index.php/mv/msg/201301/643025/#msg_643025
> We have the following situation where it would be nice to realize state
> sharing between *different* commands.

> Now we have a *different* command, which is supposed perform two steps:
>
> 1) Loading data into a viewer
> 2) Applying the look&feel as controlled by above radio-state-handler
>
> Step (1) is specific for the second command (handler), no question, but
> ideally - to realize (2) - we would like to evaluate the state of the
> first radio-state handler to do different stuff based on that state. The
> problem is, that by quering
>
> event.getParameter(RadioState.PARAMETER_ID)

You need to get hold of the command (probably from ICommandService) and
then call radioStateCommand.getState() to get the current state.

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com]]>Prakash G.R.2010-12-03T17:08:23-00:00Re: Sharing state between different commandshttps://www.eclipse.org/forums/index.php/mv/msg/201301/643027/#msg_643027
> Let me add more information: Since after (1) we want to invoke the first
> radio-state handler I used the IHandlerService.executeCommand method
> (with second argument null): That invokes the right command, but it's
> state values are all null. How can I activate the handler such that it's
> current state is transmitted as well?

I guess you are calling executeCommand(String, Event). Call the
overloaded method executeCommand(ParameterisedCommand, Event)

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com]]>Prakash G.R.2010-12-03T17:10:29-00:00Re: Sharing state between different commandshttps://www.eclipse.org/forums/index.php/mv/msg/201301/643233/#msg_643233
> On 03/12/10 6:39 PM, Daniel Krügler wrote:
>
>> Let me add more information: Since after (1) we want to invoke the first
>> radio-state handler I used the IHandlerService.executeCommand method
>> (with second argument null): That invokes the right command, but it's
>> state values are all null. How can I activate the handler such that it's
>> current state is transmitted as well?
>
> I guess you are calling executeCommand(String, Event).

Hmmh, maybe I'm misunderstanding something fundamental, but wouldn't
this imply that I need to fill the first argument with the corresponding
parameter values on my own? If so, this is not my intention: The
corresponding command get's it's parameter values from it's own state
that I don't want to manually change. What I don't understand is that
this state seems to be empty when invoked via the first executeCommand
overload.

Thanks & Greetings from Bremen,

Daniel Krügler]]>Daniel KrÃ¼gler2010-12-06T08:15:27-00:00Re: Sharing state between different commandshttps://www.eclipse.org/forums/index.php/mv/msg/201301/643269/#msg_643269
> On 03/12/10 6:11 PM, Daniel Krügler wrote:
>> We have the following situation where it would be nice to realize state
>> sharing between *different* commands.
>
>> Now we have a *different* command, which is supposed perform two steps:
>>
>> 1) Loading data into a viewer
>> 2) Applying the look&feel as controlled by above radio-state-handler
>>
>> Step (1) is specific for the second command (handler), no question, but
>> ideally - to realize (2) - we would like to evaluate the state of the
>> first radio-state handler to do different stuff based on that state. The
>> problem is, that by quering
>>
>> event.getParameter(RadioState.PARAMETER_ID)
>
> You need to get hold of the command (probably from ICommandService) and
> then call radioStateCommand.getState() to get the current state.

Thanks Prakash: Yes, I finally found this solution and it is the correct
one, if I would just to implement my own logic based on this state.

What I don't understand is the following: If I want to invoke another
command from the given command with state via the IHandlerService, I
cannot do this via the

Object executeCommand(String commandId, Event event);

method, but must instead use the overload:

Object executeCommand(ParameterizedCommand command, Event event);

This looks odd to me, because the parameter is a result of an associated
state. Let's assume that the called handler has a
org.eclipse.ui.handlers.RadioState, I now must create a
ParameterizedCommand object that is filled with the state that I need to
read from the command, because otherwise the command parameter within
the called command is not set (null).

I understand that it must be empty, because no-one has set it yet
(usually the menu contribution will set it). So one might assume that
the command should not ask for the parameter but for the state instead.
This would also not work, because then it would never change its radio
state, though.

I think what I'm missing would be a function that just created a
ParameterizedCommand based on the parameter state - Does there exist
something like that?