@Paul,
> You need to use command.getParameters() to add the matching MCommandParameter definition.
Even if I don’t use a parameter the handler is never invoked.
> I assume you are adding the command and handler to the application, right?
yes, but I was not sure if this is necessary if both command and handler are “local”, meaning only relevant to a dynamically created tool item.
For testing I have put them in comments, but if I un-comment and register them both with the application has no effect.
BTW, the same code block works if I add something to the main tool bar, but in this case I add the tool item to a toolbar within the left trim.
Direct tool items work perfectly but they don’t support parameters, that’s why I wanted to use a command.
Best regards,
Kai
From: e4-dev-bounces@xxxxxxxxxxx [mailto:e4-dev-bounces@xxxxxxxxxxx] On Behalf Of Paul Webster
Sent: Freitag, 23. März 2012 12:54
To: E4 Project developer mailing list
Subject: Re: [e4-dev] Programmatically adding a command to a tool item
Hi Kai,
On Fri, Mar 23, 2012 at 7:47 AM, Toedter, Kai <kai.toedter@xxxxxxxxxxx> wrote:
Hi All,
I am currently making last preparations for EclipseCon. To get my personal MinMax Addon running I need to bind a command to a tool item (with a parameter). Here is my source:
MCommand command = MCommandsFactory.INSTANCE.createCommand();
command.setElementId("com.toedter.e4.ui.workbench.addons.minmax.restore");
command.setCommandName("Restore Stack");
command.setDescription("xxx");
command.setContributorURI("kai");
You need to use command.getParameters() to add the matching MCommandParameter definition.
// application.getCommands().add(command);
I assume you are adding the command and handler to the application, right?
Later,
PW
--
Paul Webster
Hi floor. Make me a sammich! - GIR