eclipse-rcp calling a command with parameter in code
Tech-Today

eclipse-rcp calling a command with parameter in code


In case you come up with the same situation as mine, here's how I've done it.

1.) in your eclipse-rcp's project's plugin.xml create a new command with a parameter, set the ids
Example
-commandId: org.ipiel.demo.commands.click
-commandParameterId: org.ipiel.demo.commands.click.paramenter1

Here's the code


ArrayList parameters = new ArrayList();
IParameter iparam;

//get the command from plugin.xml
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ICommandService cmdService = (ICommandService)window.getService(ICommandService.class);
Command cmd = cmdService.getCommand("org.ipiel.demo.commands.click");

//get the parameter
iparam = cmd.getParameter("org.ipiel.demo.commands.click.paramenter1");
Parameterization params = new Parameterization(iparam, "commandValue");
parameters.add(params);

//build the parameterized command
ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()]));

//execute the command
IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
handlerService.executeCommand(pc, null);




- How To Create A Modularized Maven Project In Eclipse
I've just noticed that it's easier to do this now on eclipse-jee-indigo, no need to use the console :-) I'll try to make this write up short, but I guess it will not be. So first, you should have the ff installed (if you don't know how...

- Add Eclipse-rcp's Views Short List, Perspective Short List In The Org.eclipse.ui.menus Plugin Via Dynamic Compoundcontributionitem Class
Recently, I've encountered a problem wherein I wanted to display the eclipse-rcp's list of view, perspective etc using the extension org.eclipse.ui.menus. The problem can easily solved by the ApplicationActionBarAdvisor, see the code below: private...

- How To Open A View Using The Eclipse-rcp's Plugin.xml's Extension Tab. Passing The View Id As A Command Parameter.
1.) Create a new HelloWorld RCP project 2.) Open the plugin.xml file and click the Extension tab 3.) Add the extension org.eclipse.ui.commands a.) right click and select New->command b.) set the command's id to command.showView c.) set the defaultHandler...

- How To Show Dynamic Command Based On Perspective In Eclipse-rcp, Does Not Work On Toolbar And Main Menu
1.) Using the HelloWorld project template, add org.eclipse.core.expressions in your application's plugin.xml's Dependencies tab. 2.) In the extension tab do the following: a.) add org.eclipse.core.expressions.definition, set its id to onValidationPerspective...

- Open A View In The Eclipse-rcp's Extension Tab Using The Showviewhandler Class
Let's do this quick. 1.) Create a new HelloWorld Plug-in Project and name it CommandParameter. 2.) Open the plugin.xml and click the Extensions tab. 3.) In the All Extensions tab click the Add button and under the Extension Point Filter: search "view"....



Tech-Today








.