Package org.eclipse.ui.handlers

Examples of org.eclipse.ui.handlers.IHandlerService


    Command command = commandService.getCommand("io.emmet.eclipse.commands." + item.getId());
    if (!command.isDefined()) {
      command.define(item.getName(), "", commandService.getCategory("io.emmet.eclipse.commands.category"));
    }
   
    IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);
    handlerService.activateHandler(command.getId(), handlerFactory(item.getId()));
   
    CommandContributionItemParameter p = new CommandContributionItemParameter(
        serviceLocator, "", command.getId(), CommandContributionItem.STYLE_PUSH);
   
    p.label = item.getName();
View Full Code Here


        column.getColumn().setMoveable(false);
        column.setLabelProvider(new CsvCellLabelProvider());
        column.getColumn().addSelectionListener(new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent e) { 
            IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
            try {
              ColumnEvent event = new ColumnEvent();
              event.setColumn(columnHeader);
              handlerService.executeCommand("de.ambits.csvmaster.commands.renameColumn", event);
            } catch (Exception e1) {
              MessageDialog.openError(getShell(), "Error", e1.getMessage());
            }
          }
         
View Full Code Here

    activateHandler(LinkWithSelectionHandler.ID, new LinkWithSelectionHandler(
        settings, selectiontracker));
  }

  private void activateHandler(String id, IHandler handler) {
    final IHandlerService hs = (IHandlerService) getSite().getService(
        IHandlerService.class);
    hs.activateHandler(id, handler);
    handlers.add(handler);
  }
View Full Code Here

  /**
   * Create and register fHandlerSubmission.
   */
  private void activateHandler() {
    IHandlerService handlerService= (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
    if (handlerService == null)
      return;

    IHandler handler= new AbstractHandler() {
      public Object execute(ExecutionEvent event) throws ExecutionException {
        if (ContentAssistHandler.this.isEnabled()) // don't call AbstractHandler#isEnabled()!
          fContentAssistant.showPossibleCompletions();
        return null;
      }
    };
    fHandlerActivation= handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler);
  }
View Full Code Here

  /**
   * Unregister the {@link IHandlerActivation} from the shell.
   */
  private void deactivateHandler() {
    IHandlerService handlerService= (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
    if (handlerService != null)
      handlerService.deactivateHandler(fHandlerActivation);
    fHandlerActivation= null;
  }
View Full Code Here

  }
 
  @Override
  public Object function (Object[] arguments) {
    try {
      IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);
      ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
      Command showView = commandService.getCommand(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW);
      IParameter parm1 = showView.getParameter(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW_PARM_ID);
      Parameterization parmId1 = new Parameterization(parm1, HttpRequestView.ID);
      IParameter parm2 = showView.getParameter(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW_SECONDARY_ID);
      Parameterization parmId2 = new Parameterization(parm2, ScannerPerspectiveFactory.HTTP_VIEW_SECONDARY_ID);
      ParameterizedCommand parmCommand = new ParameterizedCommand(showView, new Parameterization[] { parmId1, parmId2 });
      handlerService.executeCommand(parmCommand, null);

      IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(HttpRequestView.ID, ScannerPerspectiveFactory.HTTP_VIEW_SECONDARY_ID, IWorkbenchPage.VIEW_VISIBLE);
      if(view instanceof HttpRequestView && arguments[0] instanceof String) {
        final HttpRequestView requestView = (HttpRequestView) view;
        try {
View Full Code Here

      return viewer;
    }

    private void initializeActions() {
      final ArrayList handlerActivations= new ArrayList(3);
      final IHandlerService handlerService= (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
      final Expression expression= new ActiveShellExpression(fPatternEditor.getControl().getShell());

      getShell().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
          handlerService.deactivateHandlers(handlerActivations);
        }
      });

      fPatternEditor.getTextWidget().addFocusListener(new FocusListener() {
        public void focusLost(FocusEvent e) {
          handlerService.deactivateHandlers(handlerActivations);
        }

        public void focusGained(FocusEvent e) {
          IAction action= (IAction)fGlobalActions.get(ITextEditorActionConstants.REDO);
          handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_REDO, new ActionHandler(action), expression));
          action= (IAction)fGlobalActions.get(ITextEditorActionConstants.UNDO);
          handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_UNDO, new ActionHandler(action), expression));
          action= (IAction)fGlobalActions.get(ITextEditorActionConstants.CONTENT_ASSIST);
          handlerActivations.add(handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new ActionHandler(action), expression));
        }
      });

      TextViewerAction action= new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
      action.setText(TemplatesMessages.EditTemplateDialog_undo);
View Full Code Here

    return command;
  }

  private void activateHandler(CommandConfig commandConfig, String commandId)
  {
    IHandlerService handlerService = (IHandlerService) getHandlerService(getServiceLocator());
    IHandler handler = this.createHandlerForCustomCommand(commandConfig);
    IHandlerActivation handlerActivation = handlerService.activateHandler(
        commandId, handler);
    this.setHandlerActivationInCommandConfig(commandConfig, handlerActivation);
  }
View Full Code Here

  private void deactivateHandler(IHandlerActivation handlerActivation,
      String name)
  {
    if (handlerActivation != null)
    {
      IHandlerService handlerService = this.getHandlerService(this
          .getServiceLocator());
      if (handlerService != null)
      {
        getLogFacility().logDebug("deactivating handler for: " + name);
        handlerService.deactivateHandler(handlerActivation);
        getLogFacility().logDebug("handler " + name + " deactivated.");
      }
    }
  }
View Full Code Here

    monitor.worked(1);
  }
 
  private void createSkeleton(String containerName, String projectName) throws CoreException {
    ICommandService cmdService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
   
    // get the command
    Command cmd = cmdService.getCommand("q_impress.pmi.plugin.commands.createProjectSkeleton");
    IParameter rootParm = null;
    IParameter projectNameParm = null;
    try {
      rootParm = cmd.getParameter("q_impress.pmi.plugin.commands.createProjectSkeleton.root");
      projectNameParm = cmd.getParameter("q_impress.pmi.plugin.commands.createProjectSkeleton.projectName");
    } catch (NotDefinedException e) {
      this.throwCoreException("Unable to execute command, invalid parameter :" + e.getMessage(), e);
    }

    // parametrize it
    Parameterization parmRoot = new Parameterization(rootParm, containerName);
    Parameterization parmProjectName = new Parameterization(projectNameParm, projectName);
    ParameterizedCommand parmCommand = new ParameterizedCommand(cmd, new Parameterization[] { parmRoot, parmProjectName });

    // exec the command
    try {
      handlerService.executeCommand(parmCommand, null);
    } catch (Exception e) {
      this.throwCoreException(e.getMessage(), e);
    }
  }
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.