コード例 #1
0
 protected void executePictogramHandler(final Pictogram pictogram, MouseEvent mouseEvent) {
   final IHandler handler = pictogram.getHandler();
   final ExecutionEvent executionEvent = createExecutionEvent(mouseEvent);
   if (pictogram.getHandlerContextValidator().isValidContext(executionEvent)) {
     try {
       handler.execute(executionEvent);
     } catch (final ExecutionException e) {
       e.printStackTrace();
     }
   }
 }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public void widgetSelected(SelectionEvent event) {
   IHandler handler;
   if (isShow) {
     handler = new NodeChildrenShowHandler();
   } else {
     handler = new NodeChildrenHideHandler();
   }
   try {
     handler.execute(null);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #3
0
  private void addSave(IMenuManager menu) {
    ICommandService commandService =
        (ICommandService) fContainer.getWorkbenchPart().getSite().getService(ICommandService.class);
    final Command command = commandService.getCommand(IWorkbenchCommandConstants.FILE_SAVE);

    final IHandler handler = command.getHandler();
    if (handler != null) {
      if (fSaveContributionItem == null) {
        fSaveContributionItem =
            new CommandContributionItem(
                new CommandContributionItemParameter(
                    fContainer.getWorkbenchPart().getSite(),
                    null,
                    command.getId(),
                    CommandContributionItem.STYLE_PUSH));
      }
      // save is an editable dependent action, ie add only when edit
      // is possible
      if (handler.isHandled() && getSourceViewer().isEditable()) menu.add(fSaveContributionItem);
    }
  }