Package org.eclipse.ui.commands

Examples of org.eclipse.ui.commands.ICommandService


     *
     * @param action the action
     */
    public static void deactivateActionHandler( IAction action )
    {
        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
            ICommandService.class );
        if ( commandService != null )
        {
            IHandler handler = commandService.getCommand( action.getActionDefinitionId() ).getHandler();
            if ( handler instanceof ActionHandler )
            {
                ActionHandler actionHandler = ( ActionHandler ) handler;
                if ( actionHandler != null && actionHandler.getAction() == action )
                {
                    commandService.getCommand( action.getActionDefinitionId() ).setHandler( null );
                }
            }
            else if ( handler != null )
            {
                commandService.getCommand( action.getActionDefinitionId() ).setHandler( null );
            }
        }
    }
View Full Code Here


     *
     * @param action the action
     */
    public static void activateActionHandler( IAction action )
    {
        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
            ICommandService.class );
        if ( commandService != null )
        {
            ActionHandler actionHandler = new ActionHandler( action );
            commandService.getCommand( action.getActionDefinitionId() ).setHandler( actionHandler );
        }
    }
View Full Code Here

              */
            public void partDeactivated( IWorkbenchPartReference partRef )
            {
                if ( partRef.getPart( false ) == instance && contextActivation != null )
                {
                    ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
                        ICommandService.class );
                    if ( commandService != null )
                    {
                        commandService.getCommand( newServer.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( openConfiguration.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( delete.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( rename.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( run.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( stop.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( properties.getActionDefinitionId() ).setHandler( null );
                    }

                    IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
                        IContextService.class );
                    contextService.deactivateContext( contextActivation );
                    contextActivation = null;
                }
            }


            /**
             * This implementation activates the shortcuts when the part is activated.
             */
            public void partActivated( IWorkbenchPartReference partRef )
            {
                if ( partRef.getPart( false ) == instance )
                {
                    IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
                        IContextService.class );
                    contextActivation = contextService.activateContext( ApacheDsPluginConstants.CONTEXTS_SERVERS_VIEW );

                    ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
                        ICommandService.class );
                    if ( commandService != null )
                    {
                        commandService.getCommand( newServer.getActionDefinitionId() ).setHandler(
                            new ActionHandler( newServer ) );
                        commandService.getCommand( openConfiguration.getActionDefinitionId() ).setHandler(
                            new ActionHandler( openConfiguration ) );
                        commandService.getCommand( delete.getActionDefinitionId() ).setHandler(
                            new ActionHandler( delete ) );
                        commandService.getCommand( rename.getActionDefinitionId() ).setHandler(
                            new ActionHandler( rename ) );
                        commandService.getCommand( run.getActionDefinitionId() ).setHandler( new ActionHandler( run ) );
                        commandService.getCommand( stop.getActionDefinitionId() )
                            .setHandler( new ActionHandler( stop ) );
                        commandService.getCommand( properties.getActionDefinitionId() ).setHandler(
                            new ActionHandler( properties ) );
                    }
                }
            }

View Full Code Here

              */
            public void partDeactivated( IWorkbenchPartReference partRef )
            {
                if ( partRef.getPart( false ) == view && contextActivation != null )
                {
                    ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
                        ICommandService.class );
                    if ( commandService != null )
                    {
                        commandService.getCommand( newSchema.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( newAttributeType.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( newObjectClass.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( openElement.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( openTypeHierarchy.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( deleteSchemaElement.getActionDefinitionId() ).setHandler( null );
                        commandService.getCommand( renameSchemaElement.getActionDefinitionId() ).setHandler( null );
                    }

                    IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
                        IContextService.class );
                    contextService.deactivateContext( contextActivation );
                    contextActivation = null;
                }
            }


            /**
             * This implementation activates the shortcuts when the part is activated.
             */
            public void partActivated( IWorkbenchPartReference partRef )
            {
                if ( partRef.getPart( false ) == view )
                {
                    IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
                        IContextService.class );
                    contextActivation = contextService.activateContext( PluginConstants.CONTEXT_SCHEMA_VIEW );

                    ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
                        ICommandService.class );
                    if ( commandService != null )
                    {
                        commandService.getCommand( newSchema.getActionDefinitionId() ).setHandler(
                            new ActionHandler( newSchema ) );
                        commandService.getCommand( newAttributeType.getActionDefinitionId() ).setHandler(
                            new ActionHandler( newAttributeType ) );
                        commandService.getCommand( newObjectClass.getActionDefinitionId() ).setHandler(
                            new ActionHandler( newObjectClass ) );
                        commandService.getCommand( openElement.getActionDefinitionId() ).setHandler(
                            new ActionHandler( openElement ) );
                        commandService.getCommand( openTypeHierarchy.getActionDefinitionId() ).setHandler(
                            new ActionHandler( openTypeHierarchy ) );
                        commandService.getCommand( deleteSchemaElement.getActionDefinitionId() ).setHandler(
                            new ActionHandler( deleteSchemaElement ) );
                        commandService.getCommand( renameSchemaElement.getActionDefinitionId() ).setHandler(
                            new ActionHandler( renameSchemaElement ) );
                    }
                }
            }

View Full Code Here

        .getService(IContextService.class);
    final IContextService contextService = new SlaveContextService(
        parentContextService, defaultExpression);
    serviceLocator.registerService(IContextService.class, contextService);

    final ICommandService parentCommandService = (ICommandService) serviceLocator
        .getService(ICommandService.class);
    final ICommandService commandService = new SlaveCommandService(
        parentCommandService, IServiceScopes.WINDOW_SCOPE,
        this);
    serviceLocator.registerService(ICommandService.class, commandService);

    final IMenuService menuService = new WindowMenuService(serviceLocator);
View Full Code Here

  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.CycleBaseHandler#getBackwardCommand()
   */
  protected ParameterizedCommand getBackwardCommand() {
    // TODO Auto-generated method stub
    final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class);
    final Command command = commandService.getCommand("org.eclipse.ui.window.previousView"); //$NON-NLS-1$
    ParameterizedCommand commandBack = new ParameterizedCommand(command, null);
    return commandBack;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.CycleBaseHandler#getForwardCommand()
   */
  protected ParameterizedCommand getForwardCommand() {
    // TODO Auto-generated method stub
    final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class);
    final Command command = commandService.getCommand("org.eclipse.ui.window.nextView"); //$NON-NLS-1$
    ParameterizedCommand commandF = new ParameterizedCommand(command, null);
    return commandF;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.CycleBaseHandler#getBackwardCommand()
   */
  protected ParameterizedCommand getBackwardCommand() {
    final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class);
    final Command command = commandService.getCommand("org.eclipse.ui.window.previousPerspective"); //$NON-NLS-1$
    ParameterizedCommand commandBack = new ParameterizedCommand(command, null);
    return commandBack;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.CycleBaseHandler#getForwardCommand()
   */
  protected ParameterizedCommand getForwardCommand() {
    final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class);
    final Command command = commandService.getCommand("org.eclipse.ui.window.nextPerspective"); //$NON-NLS-1$
    ParameterizedCommand commandF = new ParameterizedCommand(command, null);
    return commandF;
  }
View Full Code Here

  }

  public QuickAccessElement[] getElements() {
    if (idToElement == null) {
      idToElement = new HashMap();
      ICommandService commandService = (ICommandService) PlatformUI
          .getWorkbench().getService(ICommandService.class);
      final Collection commandIds = commandService.getDefinedCommandIds();
      final Iterator commandIdItr = commandIds.iterator();
      while (commandIdItr.hasNext()) {
        final String currentCommandId = (String) commandIdItr.next();
        final Command command = commandService
            .getCommand(currentCommandId);
        if (command != null && command.isHandled()
            && command.isEnabled()) {
          try {
            Collection combinations = ParameterizedCommand
View Full Code Here

TOP

Related Classes of org.eclipse.ui.commands.ICommandService

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.