Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » eRCP » Unable to update command label using TextState
Unable to update command label using TextState [message #631833] Sat, 09 October 2010 00:10 Go to next message
Teddy Yueh is currently offline Teddy YuehFriend
Messages: 5
Registered: October 2010
Junior Member
I've scoured the web for the entire day trying to find an example on how to implement what I read concerning changing a command label dynamically here:

http:// wiki.eclipse.org/Platform_UI_Command_Design#Issue_102_-_Comm ands_implementation_of_label_changing

I have the a command defined in my plugin.xml that uses the suggested schema:

   <command
         description="Hoping to change my state"
         id="my.commandWithState"
         name="Command Wtih State">
      <state
            class="org.eclipse.jface.menus.TextState"
            id="NAME"/>
   </command>

In my handler, I have tried a lot of variations (including calling "getValue" before trying to set it in hopes of forcing a load to be called), but basically the gist is:

public Object execute(final ExecutionEvent pEvent) throws ExecutionException {
        pEvent.getCommand().getState("my.commandWithState").setValue("UPDATED!");
        return null;
    }


The state value itself is updated, but not persisted. I specified a style of "push" in the menuContribution area of my plugin.xml and the text on the command is always "Command With State" since I did not specify a label (though i expected it to change...)

I'm using Eclipse 3.6 so I assume I have the updates that supposedly allow this from 3.3.

The only way I have been able to set the text on the command ui object is to have my handler implement IElementUpdater like I'm working with a ToggleState. This allows me to change the text a total of 1 time, when I first start the product.

Sad I'm about to tear my hair out.

1) The command "label" is not updated and
2) the state value is not persisted even though TextState extends PersistedState.

What d>_<b? Many thanks in advance for any input.

-Teddy

[Updated on: Sat, 09 October 2010 00:12]

Report message to a moderator

Re: Unable to update command label using TextState [message #663011 is a reply to message #631833] Sat, 02 April 2011 00:09 Go to previous message
Teddy Yueh is currently offline Teddy YuehFriend
Messages: 5
Registered: October 2010
Junior Member
Having found no alternative, I've extended TextState and set the persist flag to true myself.
Previous Topic:How to Implement Calender control
Next Topic:eRCP run in Android?
Goto Forum:
  


Current Time: Sun Oct 06 11:30:05 GMT 2024

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

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

Back to the top