Package org.eclipse.ui.handlers

Examples of org.eclipse.ui.handlers.IHandlerService


   * Hook double click command to the editor.
   */
  private void hookDoubleClickCommand() {
    viewer.addDoubleClickListener(new IDoubleClickListener() {
      public void doubleClick(DoubleClickEvent event) {
        IHandlerService handlerService = (IHandlerService) getSite()
            .getService(IHandlerService.class);
        try {
          handlerService.executeCommand("SyncYourSecrets.callEditor",
              null);
        } catch (Exception ex) {
          throw new RuntimeException(
              "SyncYourSecrets.callEditor not found");
        }
View Full Code Here


   
    @Override
    public void setActiveEditor(IEditorPart part) {
      ITextEditor textEditor = tryCast(part, ITextEditor.class);
     
      IHandlerService handlerService = getHandlerService(textEditor);
     
      if(handlerActivation != null) {
        handlerService.deactivateHandler(handlerActivation);
        handlerActivation = null;
      }
      IHandler handler = getHandler(textEditor);
      if(handler != null) {
        handlerActivation = handlerService.activateHandler(commandId, handler);
      }
    }
View Full Code Here

  public void run() {
    if (workbenchWindow == null) {
      return;
    }

    IHandlerService handlerService = (IHandlerService) workbenchWindow
        .getService(IHandlerService.class);
    try {
      handlerService.executeCommand(getActionDefinitionId(),
          null);
    } catch (Exception e) {
      WorkbenchPlugin.log(e);
    }
  }
View Full Code Here

   * priority submission handles the same command under the same conditions,
   * that that submission will become the handler.
   * </p>
   */
  void submitGlobalActions() {
    final IHandlerService handlerService = (IHandlerService) getWorkbench().getService(IHandlerService.class);

    /*
     * Mash the action sets and global actions together, with global actions
     * taking priority.
     */
    Map handlersByCommandId = new HashMap();
    handlersByCommandId.putAll(globalActionHandlersByCommandId);

    List newHandlers = new ArrayList(handlersByCommandId.size());

    Iterator existingIter = handlerActivations.iterator();
    while (existingIter.hasNext()) {
      IHandlerActivation next = (IHandlerActivation) existingIter.next();

      String cmdId = next.getCommandId();

      Object handler = handlersByCommandId.get(cmdId);
      if (handler == next.getHandler()) {
        handlersByCommandId.remove(cmdId);
        newHandlers.add(next);
      } else {
        handlerService.deactivateHandler(next);
      }
    }

    final Shell shell = getShell();
    if (shell != null) {
      final Expression expression = new ActiveShellExpression(shell);
      for (Iterator iterator = handlersByCommandId.entrySet().iterator(); iterator
          .hasNext();) {
        Map.Entry entry = (Map.Entry) iterator.next();
        String commandId = (String) entry.getKey();
        IHandler handler = (IHandler) entry.getValue();
        newHandlers.add(handlerService.activateHandler(commandId,
            handler, expression));
      }
    }

    handlerActivations = newHandlers;
View Full Code Here

      // Clear the action sets, fix for bug 27416.
            getActionPresentation().clearActionSets();

      // Remove the handler submissions. Bug 64024.
      final IWorkbench workbench = getWorkbench();
      final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
      handlerService.deactivateHandlers(handlerActivations);
      final Iterator activationItr = handlerActivations.iterator();
      while (activationItr.hasNext()) {
        final IHandlerActivation activation = (IHandlerActivation) activationItr
            .next();
        activation.getHandler().dispose();
View Full Code Here

  private final void initializeDefaultServices() {
    serviceLocator.registerService(IWorkbenchWindow.class, this);
   
    final Expression defaultExpression = new WorkbenchWindowExpression(this);

    final IHandlerService parentHandlerService = (IHandlerService) serviceLocator
        .getService(IHandlerService.class);
    final IHandlerService handlerService = new SlaveHandlerService(
        parentHandlerService, defaultExpression);
    serviceLocator.registerService(IHandlerService.class, handlerService);

    final IContextService parentContextService = (IContextService) serviceLocator
        .getService(IContextService.class);
View Full Code Here

   
    // let's try the old fashioned way
    IWorkbenchWindow window = PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow();
    if (window != null) {
      IHandlerService handlerService = (IHandlerService) window
          .getWorkbench().getService(IHandlerService.class);
      try {
        handlerService.executeCommand(command, null);
      } catch (Exception ex) {
        StatusUtil.handleStatus(ex, StatusManager.SHOW
            | StatusManager.LOG);
      }
    }
View Full Code Here

        MenuItem exit = new MenuItem(menu, SWT.NONE);
        exit.setText("Goodbye!");
        exit.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) {
            // Lets call our command
            IHandlerService handlerService = (IHandlerService) window
                .getService(IHandlerService.class);
            try {
              handlerService.executeCommand(COMMAND_ID, null);
            } catch (Exception ex) {
              throw new RuntimeException(COMMAND_ID);
            }
          }
        });
View Full Code Here

      /* (non-Javadoc)
       * @see org.eclipse.jface.viewers.IOpenListener#open(org.eclipse.jface.viewers.OpenEvent)
       */
      @Override
      public void open(OpenEvent event) {
        IHandlerService handlerService =
          (IHandlerService) getSite().getService(IHandlerService.class);
        try {
          handlerService.executeCommand(
              "net.sf.logsaw.ui.commands.OpenLogResourceCommand", //$NON-NLS-1$
              null);
        } catch (CommandException e) {
          // log and show error
          UIPlugin.logAndShowError(new CoreException(new Status(
              IStatus.ERROR, UIPlugin.PLUGIN_ID,
              Messages.Generic_errorExecutingCommand, e)), false);
        }
      }
    });
    ViewerDropAdapter dropAdapter = new ViewerDropAdapter(viewer) {

      /* (non-Javadoc)
       * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object)
       */
      @Override
      public boolean performDrop(final Object target) {
        Display.getDefault().asyncExec(new Runnable() {

          /* (non-Javadoc)
           * @see java.lang.Runnable#run()
           */
          @Override
          public void run() {
            IHandlerService handlerService =
              (IHandlerService) getSite().getService(IHandlerService.class);
            ICommandService commandService =
              (ICommandService) getSite().getService(ICommandService.class);
            Command cmd = commandService.getCommand("net.sf.logsaw.ui.commands.AddLogResourceCommand"); //$NON-NLS-1$
            try {
              Parameterization param = new Parameterization(
                  cmd.getParameter("net.sf.logsaw.ui.commands.AddLogResourceCommand.filename"), ((String[]) target)[0]); //$NON-NLS-1$
              ParameterizedCommand paraCmd = new ParameterizedCommand(cmd, new Parameterization[] {param});
              handlerService.executeCommand(paraCmd, null);
            } catch (CommandException e) {
              // log and show error
              UIPlugin.logAndShowError(new CoreException(new Status(
                  IStatus.ERROR, UIPlugin.PLUGIN_ID,
                  Messages.Generic_errorExecutingCommand, e)), false);
View Full Code Here

      @Override
      public void keyReleased(KeyEvent e) {
        if (e.keyCode == SWT.CR) {
          try {
            int pageNumber = Integer.valueOf(text.getText().trim());
            IHandlerService service =
              (IHandlerService) getWorkbenchWindow().getService(IHandlerService.class);
            Parameterization param = new Parameterization(
                cmd.getParameter("net.sf.logsaw.ui.commands.GoToPageCommand.pageNumber"), Integer.toString(pageNumber)); //$NON-NLS-1$
            ParameterizedCommand paraCmd = new ParameterizedCommand(cmd, new Parameterization[] {param});
            service.executeCommand(paraCmd, null);
          } catch (NumberFormatException e1) {
            // nadda
          } catch (CommandException e1) {
            // Log and show error
            UIPlugin.logAndShowError(new CoreException(
View Full Code Here

TOP

Related Classes of org.eclipse.ui.handlers.IHandlerService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.