Command Parameter RCP (Eclipse RCP)
Open MANIFEST.MF file and right click on the Command and select "commandParameter" from "New".
After creating "commandParameter", enter the details, like "id", "name" and make optional as "false".
Code in View (or Editor):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ICommandService commandService = (ICommandService) getSite().getService(ICommandService.class); IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); // Enter the ID of the Command as the argument to getCommand() method in next line. Command sysoComm = commandService.getCommand("ResumeParser.commands.sampleCommand"); HashMap<String, String> paramsForCommand = new HashMap<String, String>(); // Enter the Command Parameter id as the Key in the following line. paramsForCommand.put("ResumeParser.commandParameter2", text.getText()); ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(sysoComm, paramsForCommand); try { handlerService.executeCommand(paramCommand, null); } catch (Exception ee) { ee.printStackTrace(); } |
Following is the code of execute() method of the Handler (AbstractHandler) class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * the command has been executed, so extract extract the needed information * from the application context. */ public Object execute(ExecutionEvent event) throws ExecutionException { // Provide the id of the "Command Parameter" as the argument of the getParameter method. String commandValue = event.getParameter("ResumeParser.commandParameter2"); System.out.println(commandValue); return null; } |
Thank you ...
Comments
Post a Comment