Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How do I change command's name show in toolbar programmatically in rcp?
How do I change command's name show in toolbar programmatically in rcp? [message #1706799] Mon, 31 August 2015 08:51 Go to next message
Cata E. is currently offline Cata E.Friend
Messages: 2
Registered: August 2015
Junior Member
If I define programmatically a new command for the first time with a unique id, add it to the toolbar and Run the app, I see it's name in the toolbar. But if I close the plugin, change the name of the command in code where i define it and launch the plugin again, I still get the old name in the toolbar. My command's name simply doesn't want to update..

My code..
I am creating a command programmaticaly:
final Command commandAdd = commandService.getCommand( "editor.commands.macro.add1");

    commandAdd.define( "Add", "Add Macro", commandService
            .getCategory( "editor.category.macrogroup" ) );


Then I create a Contribution item and add it to the toolbar:

CommandContributionItemParameter addMacroParameter =
                new CommandContributionItemParameter( serviceLocator , "", commandAdd.getId(),
                    CommandContributionItem.STYLE_PUSH );
        CommandContributionItem add = new CommandContributionItem(addMacroParameter);

toolBarManager.add(add);


Right now if I launch the plugin app, the toolbar has the button "Add" in it. My problem is if I change the name from "add" to lets say "Insert" in code and relaunch the app, I still see "Add" in my toolbar instead of insert.

final Command commandAdd = commandService.getCommand( "editor.commands.macro.add1");
        commandAdd.define( "Insert", "Add Macro", commandService
                .getCategory( "editor.category.macrogroup" ) );



I also tried to set addMacroParameter.label = "Insert", but it still doesn't make any difference. If instead I change the command's id, the changes appear: if I use "editor.commands.macro.add2" instead of "editor.commands.macro.add1". But I want to be able to update command's name programmatically, without creating another one with another unique id.
Re: How do I change command's name show in toolbar programmatically in rcp? [message #1706886 is a reply to message #1706799] Mon, 31 August 2015 15:26 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

Command definitions are persisted out and restored on restart; they're not meant to be changed or updated. Think of a command as being like a Java interface, and a handler as a particular implementation class. If you want to change the label text dynamically, you do that via a handler that implements IElementUpdater.
Previous Topic:How to get drop event in Eclipse RCP tableview cell?
Next Topic:tableviewer double-click opens editor and clicks button on new editor
Goto Forum:
  


Current Time: Tue Nov 24 05:12:18 GMT 2020

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

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

Back to the top