Examples of IHandlerService


Examples of org.eclipse.ui.handlers.IHandlerService

                editor.getAction(ITextEditorActionConstants.UNDO));
        actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO,
                editor.getAction(ITextEditorActionConstants.REDO));
        fActionGroups.fillActionBars(actionBars);
        registerToolbarActions(actionBars);
        final IHandlerService handlerService = (IHandlerService) site
                .getService(IHandlerService.class);
        handlerService.activateHandler(
                IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR,
                new ActionHandler(fToggleLinkingAction));
        fPartListener = new IPartListener() {

            @Override
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

   */
  private void initializeDefaultServices() {
    final Expression defaultExpression = new ActivePartExpression(
        multiPageEditor);

    final IHandlerService parentService = (IHandlerService) serviceLocator
        .getService(IHandlerService.class);
    final IHandlerService slave = new NestableHandlerService(parentService,
        defaultExpression);
    serviceLocator.registerService(IHandlerService.class, slave);

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

Examples of org.eclipse.ui.handlers.IHandlerService

  private void initializeDefaultServices() {
    final IWorkbenchPart parentPart = parentSite.getPart();
    final Expression defaultExpression = new ActivePartExpression(
        parentPart);

    final IHandlerService parentService = (IHandlerService) parentSite
        .getService(IHandlerService.class);
    final IHandlerService slave = new NestableHandlerService(parentService,
        defaultExpression);
    serviceLocator.registerService(IHandlerService.class, slave);

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

Examples of org.eclipse.ui.handlers.IHandlerService

        Tracing.printTrace("KEYS", "    not enabled"); //$NON-NLS-1$ //$NON-NLS-2$
      }
    }

    try {
      final IHandlerService handlerService = (IHandlerService) workbench
          .getService(IHandlerService.class);
      handlerService.executeCommand(parameterizedCommand, trigger);
    } catch (final NotDefinedException e) {
      // The command is not defined. Forwarded to the IExecutionListener.
    } catch (final NotEnabledException e) {
      // The command is not enabled. Forwarded to the IExecutionListener.
    } catch (final NotHandledException e) {
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

  /**
   * Deactivates all of the activations made by this class, and then clears
   * the collection. This should be called before every read.
   */
  private final void clearActivations() {
    final IHandlerService service = (IHandlerService) window
        .getService(IHandlerService.class);
    service.deactivateHandlers(handlerActivations);
    final Iterator activationItr = handlerActivations.iterator();
    while (activationItr.hasNext()) {
      final IHandlerActivation activation = (IHandlerActivation) activationItr
          .next();
      final IHandler handler = activation.getHandler();
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

      commandService.setHelpContextId(handler, helpContextId);
    }

    // Activate the handler.
    final String commandId = command.getId();
    final IHandlerService service = (IHandlerService) window
        .getService(IHandlerService.class);
    final IHandlerActivation handlerActivation;
    if (activeWhenExpression == null) {
      handlerActivation = service.activateHandler(commandId, handler);
    } else {
      handlerActivation = service.activateHandler(commandId, handler,
          activeWhenExpression);
    }
    handlerActivations.add(handlerActivation);
  }
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

  private void updateSiteAssociations(IWorkbenchPartSite site,
      String commandId, String actionId, IConfigurationElement element) {
    IWorkbench workbench = (IWorkbench) site.getService(IWorkbench.class);
    IWorkbenchWindow window = (IWorkbenchWindow) site
        .getService(IWorkbenchWindow.class);
    IHandlerService serv = (IHandlerService) workbench
        .getService(IHandlerService.class);
    appContext = new EvaluationContext(serv.getCurrentState(),
        Collections.EMPTY_LIST);

    // set up the appContext as we would want it.
    appContext.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME,
        StructuredSelection.EMPTY);
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

    SafeRunner.run(runnable);
    return true;
  }

  public final boolean isEnabled() {
    final IHandlerService service = (IHandlerService) window
        .getService(IHandlerService.class);
    IEvaluationContext context = service.getCurrentState();
    return isEnabled(context);
  }
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

          .entrySet().iterator();
      while (activationItr.hasNext()) {
        final Map.Entry value = (Map.Entry) activationItr.next();
        final IServiceLocator locator = (IServiceLocator) value
            .getKey();
        final IHandlerService service = (IHandlerService) locator
            .getService(IHandlerService.class);
        final Map activationsByActionId = (Map) value.getValue();
        final Iterator iterator = activationsByActionId.values()
            .iterator();
        while (iterator.hasNext()) {
          final IHandlerActivation activation = (IHandlerActivation) iterator
              .next();
          service.deactivateHandler(activation);
          activation.getHandler().dispose();
        }
      }
      activationsByActionIdByServiceLocator.clear();
    }
View Full Code Here

Examples of org.eclipse.ui.handlers.IHandlerService

        final IActionCommandMappingService mappingService = (IActionCommandMappingService) serviceLocator
            .getService(IActionCommandMappingService.class);
        final String commandId = mappingService.getCommandId(actionID);

        // Update the handler activations.
        final IHandlerService service = (IHandlerService) serviceLocator
            .getService(IHandlerService.class);
        Map activationsByActionId = null;
        if (activationsByActionIdByServiceLocator == null) {
          activationsByActionIdByServiceLocator = new WeakHashMap();
          activationsByActionId = new HashMap();
          activationsByActionIdByServiceLocator.put(serviceLocator,
              activationsByActionId);
        } else {
          activationsByActionId = (Map) activationsByActionIdByServiceLocator
              .get(serviceLocator);
          if (activationsByActionId == null) {
            activationsByActionId = new HashMap();
            activationsByActionIdByServiceLocator.put(
                serviceLocator, activationsByActionId);
          } else if (activationsByActionId.containsKey(actionID)) {
            final Object value = activationsByActionId
                .remove(actionID);
            if (value instanceof IHandlerActivation) {
              final IHandlerActivation activation = (IHandlerActivation) value;
              actionIdByCommandId.remove(activation.getCommandId());
              service.deactivateHandler(activation);
              activation.getHandler().dispose();
            }
          } else if (commandId != null
              && actionIdByCommandId.containsKey(commandId)) {
            final Object value = activationsByActionId
                .remove(actionIdByCommandId.remove(commandId));
            if (value instanceof IHandlerActivation) {
              final IHandlerActivation activation = (IHandlerActivation) value;
              service.deactivateHandler(activation);
              activation.getHandler().dispose();
            }
          }
        }

        if (commandId != null) {
          actionIdByCommandId.put(commandId, actionID);
          // Register this as a handler with the given definition id.
          // the expression gives the setGlobalActionHandler() a
          // priority.
          final IHandler actionHandler = new ActionHandler(handler);
          Expression handlerExpression = EXPRESSION;
          //XXX add new API in next release to avoid down-casting (bug 137091)
          if (this instanceof EditorActionBars) {
            handlerExpression = ((EditorActionBars)this).getHandlerExpression();
          }
          final IHandlerActivation activation = service
              .activateHandler(commandId, actionHandler,
                  handlerExpression);
          activationsByActionId.put(actionID, activation);
        }
      }

    } else {
      if (actionHandlers != null) {
        actionHandlers.remove(actionID);
      }

      // Remove the handler activation.
      if (serviceLocator != null) {
        final IHandlerService service = (IHandlerService) serviceLocator
            .getService(IHandlerService.class);
        if (activationsByActionIdByServiceLocator != null) {
          final Map activationsByActionId = (Map) activationsByActionIdByServiceLocator
              .get(serviceLocator);
          if ((activationsByActionId != null)
              && (activationsByActionId.containsKey(actionID))) {
            final Object value = activationsByActionId
                .remove(actionID);
            if (value instanceof IHandlerActivation) {
              final IHandlerActivation activation = (IHandlerActivation) value;
              actionIdByCommandId.remove(activation.getCommandId());
              service.deactivateHandler(activation);
              activation.getHandler().dispose();
            }
          }
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.