/** * Run command with specified id * * @param service * @param id * @param event */ public static void executeCommand(IHandlerService service, String id, Event event) { try { service.executeCommand(id, event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, false); } catch (NotDefinedException e) { Activator.handleError(e.getMessage(), e, false); } catch (NotEnabledException e) { Activator.handleError(e.getMessage(), e, false); } catch (NotHandledException e) { Activator.handleError(e.getMessage(), e, false); } }
public static void executeCommand(IViewSite site, String command) { ICommandService cmdService = (ICommandService) site.getService(ICommandService.class); IHandlerService hdlService = (IHandlerService) site.getService(IHandlerService.class); Command cmd = cmdService.getCommand(command); try { hdlService.executeCommand(cmd.getId(), null); } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } }
protected void setItemText(MMenuItem model, MenuItem item) { String text = model.getLocalizedLabel(); if (model instanceof MHandledItem) { MHandledItem handledItem = (MHandledItem) model; IEclipseContext context = getContext(model); EBindingService bs = (EBindingService) context.get(EBindingService.class.getName()); ParameterizedCommand cmd = handledItem.getWbCommand(); if (cmd != null && (text == null || text.length() == 0)) { try { text = cmd.getName(); } catch (NotDefinedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } TriggerSequence sequence = bs.getBestSequenceFor(handledItem.getWbCommand()); if (sequence != null) { text = text + '\t' + sequence.format(); } item.setText(text == null ? handledItem.getCommand().getElementId() : text); } else { super.setItemText(model, item); } }