0

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 the toolbar has the button "Add" in it. My problem is if I run this code again, but I change the name from "add" to lets say "Insert" :

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

my toolbar has the command with still the name "Add" on it. I simply can't change that name anymore, unless I define a command with another id instead of "editor.commands.macro.add1"

How can I simply edit the name that appears in the toolbar? Thanks!

greg-449
  • 109,219
  • 232
  • 102
  • 145
Cata
  • 21
  • 2
  • When you say: "run the code again" do you mean restarting eclipse? or using the debugger? – Arye Shemesh Aug 31 '15 at 06:36
  • Sorry.. I mean simply Run the plugin app again. If I define a new command for the first time with a unique id (programmatically) 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.. – Cata Aug 31 '15 at 08:34
  • Can you explain what do you mean by "close the plugin" and "launch the plugin"? Is it done via Eclipse? It seems like once you registered a command id it is cached somewhere and the second getCommand() API call returns the cached command, but intuitively I'd expect the cache to clear when restarting Eclipse or your application. – Arye Shemesh Aug 31 '15 at 13:25

0 Answers0