Package org.eclipse.ui.contexts

Examples of org.eclipse.ui.contexts.IContextService


        // create actions
        this.actionGroup = new EntryEditorWidgetActionGroup( this.mainWidget, this.configuration );
        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
        IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
            IContextService.class );
        contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_DIALOGS );
        actionGroup.activateGlobalActionHandlers();       

        // create the listener
        this.universalListener = new MultiValuedEntryEditorUniversalListener( this.mainWidget.getViewer(),
            this.actionGroup.getOpenDefaultEditorAction() );
View Full Code Here


            configuration.dispose();
            configuration = null;

            if ( contextActivation != null )
            {
                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
                    IContextService.class );
                contextService.deactivateContext( contextActivation );
                contextActivation = null;
            }
        }
        super.dispose();
    }
View Full Code Here

        // create actions
        actionGroup = new EntryEditorWidgetActionGroupWithAttribute( mainWidget, configuration );
        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
        actionGroup.fillMenu( mainWidget.getMenuManager() );
        actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
        IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
            IContextService.class );
        contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_DIALOGS );
        actionGroup.activateGlobalActionHandlers();

        // create the listener
        universalListener = new EntryEditorWidgetUniversalListener( mainWidget.getViewer(), actionGroup
            .getOpenDefaultEditorAction() );
View Full Code Here

        // Create action sets.
        List temp = new ArrayList();
        createInitialActionSets(temp, layout.getActionSets());

        IContextService service = null;
        if (page != null) {
      service = (IContextService) page.getWorkbenchWindow().getService(
          IContextService.class);
    }
        try {
          if (service!=null) {
            service.activateContext(ContextAuthority.DEFER_EVENTS);
          }
      for (Iterator iter = temp.iterator(); iter.hasNext();) {
        IActionSetDescriptor descriptor = (IActionSetDescriptor) iter
            .next();
        addAlwaysOn(descriptor);
      }
    } finally {
      if (service!=null) {
        service.activateContext(ContextAuthority.SEND_EVENTS);
      }
        }
        newWizardShortcuts = layout.getNewWizardShortcuts();
        showViewShortcuts = layout.getShowViewShortcuts();
        perspectiveShortcuts = layout.getPerspectiveShortcuts();
View Full Code Here

                                    .getString(IWorkbenchConstants.TAG_SHOW_TITLE));
                }
            }
        }

        final IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
        try { // one big try block, don't kill me here
      // defer context events
      if (service != null) {
        service.activateContext(ContextAuthority.DEFER_EVENTS);
      }

      HashSet knownActionSetIds = new HashSet();

      // Load the always on action sets.
      IMemento[] actions = memento
          .getChildren(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
      for (int x = 0; x < actions.length; x++) {
        String actionSetID = actions[x]
            .getString(IWorkbenchConstants.TAG_ID);
        final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
            .getActionSetRegistry().findActionSet(actionSetID);
        if (d != null) {
          StartupThreading
              .runWithoutExceptions(new StartupRunnable() {
                public void runWithException() throws Throwable {
                  addAlwaysOn(d);
                }
              });

          knownActionSetIds.add(actionSetID);
        }
      }

      // Load the always off action sets.
      actions = memento
          .getChildren(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
      for (int x = 0; x < actions.length; x++) {
        String actionSetID = actions[x]
            .getString(IWorkbenchConstants.TAG_ID);
        final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
            .getActionSetRegistry().findActionSet(actionSetID);
        if (d != null) {
          StartupThreading
              .runWithoutExceptions(new StartupRunnable() {
                public void runWithException() throws Throwable {
                  addAlwaysOff(d);
                }
              });
          knownActionSetIds.add(actionSetID);
        }
      }

      // Load "show view actions".
      actions = memento
          .getChildren(IWorkbenchConstants.TAG_SHOW_VIEW_ACTION);
      showViewShortcuts = new ArrayList(actions.length);
      for (int x = 0; x < actions.length; x++) {
        String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
        showViewShortcuts.add(id);
      }

      // Load "show in times".
      actions = memento.getChildren(IWorkbenchConstants.TAG_SHOW_IN_TIME);
      for (int x = 0; x < actions.length; x++) {
        String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
        String timeStr = actions[x]
            .getString(IWorkbenchConstants.TAG_TIME);
        if (id != null && timeStr != null) {
          try {
            long time = Long.parseLong(timeStr);
            showInTimes.put(id, new Long(time));
          } catch (NumberFormatException e) {
            // skip this one
          }
        }
      }

      // Load "show in parts" from registry, not memento
      showInPartIds = getShowInIdsFromRegistry();

      // Load "new wizard actions".
      actions = memento
          .getChildren(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
      newWizardShortcuts = new ArrayList(actions.length);
      for (int x = 0; x < actions.length; x++) {
        String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
        newWizardShortcuts.add(id);
      }

      // Load "perspective actions".
      actions = memento
          .getChildren(IWorkbenchConstants.TAG_PERSPECTIVE_ACTION);
      perspectiveShortcuts = new ArrayList(actions.length);
      for (int x = 0; x < actions.length; x++) {
        String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
        perspectiveShortcuts.add(id);
      }

      ArrayList extActionSets = getPerspectiveExtensionActionSets();
      for (int i = 0; i < extActionSets.size(); i++) {
        String actionSetID = (String) extActionSets.get(i);
        if (knownActionSetIds.contains(actionSetID)) {
          continue;
        }
        final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
            .getActionSetRegistry().findActionSet(actionSetID);
        if (d != null) {
          StartupThreading
              .runWithoutExceptions(new StartupRunnable() {
                public void runWithException() throws Throwable {
                  addAlwaysOn(d);
                }
              });
          knownActionSetIds.add(d.getId());
        }
      }

      // Add the visible set of action sets to our knownActionSetIds
      // Now go through the registry to ensure we pick up any new action
      // sets
      // that have been added but not yet considered by this perspective.
      ActionSetRegistry reg = WorkbenchPlugin.getDefault()
          .getActionSetRegistry();
      IActionSetDescriptor[] array = reg.getActionSets();
      int count = array.length;
      for (int i = 0; i < count; i++) {
        IActionSetDescriptor desc = array[i];
        if ((!knownActionSetIds.contains(desc.getId()))
            && (desc.isInitiallyVisible())) {
          addActionSet(desc);
        }
      }
    } finally {
          // restart context changes
          if (service != null) {
        StartupThreading.runWithoutExceptions(new StartupRunnable() {
          public void runWithException() throws Throwable {
            service.activateContext(ContextAuthority.SEND_EVENTS);
          }
        });
      }
        }
View Full Code Here

        this.oldPartRef = oldPartRef;
    }

    //for dynamic UI
    /* package */void addActionSet(IActionSetDescriptor newDesc) {
      IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
      try {
      service.activateContext(ContextAuthority.DEFER_EVENTS);
      for (int i = 0; i < alwaysOnActionSets.size(); i++) {
        IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
            .get(i);
        if (desc.getId().equals(newDesc.getId())) {
          removeAlwaysOn(desc);
          removeAlwaysOff(desc);
          break;
        }
      }
      addAlwaysOn(newDesc);
    } finally {
        service.activateContext(ContextAuthority.SEND_EVENTS);
      }
    }
View Full Code Here

      }
    }

    // for dynamic UI
    /* package */void removeActionSet(String id) {
      IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
      try {
      service.activateContext(ContextAuthority.DEFER_EVENTS);
      for (int i = 0; i < alwaysOnActionSets.size(); i++) {
        IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
            .get(i);
        if (desc.getId().equals(id)) {
          removeAlwaysOn(desc);
          break;
        }
      }

      for (int i = 0; i < alwaysOffActionSets.size(); i++) {
        IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOffActionSets
            .get(i);
        if (desc.getId().equals(id)) {
          removeAlwaysOff(desc);
          break;
        }
      }
    } finally {
        service.activateContext(ContextAuthority.SEND_EVENTS);
      }
    }
View Full Code Here

    /*
     * We will fallback to the workbench window, but only if a dialog is not
     * open.
     */
    final IContextService contextService = (IContextService) workbench
        .getService(IContextService.class);   
    final int shellType = contextService.getShellType(newActiveShell);
    if (shellType != IContextService.TYPE_DIALOG) {
      final IWorkbenchWindow newActiveWorkbenchWindow = workbench
          .getActiveWorkbenchWindow();
      final Shell newActiveWorkbenchWindowShell;
      if (newActiveWorkbenchWindow == null) {
View Full Code Here

    final Expression defaultExpression = new ActivePartExpression(part);
    final IHandlerService slave = new SlaveHandlerService(parentService,
        defaultExpression);
    serviceLocator.registerService(IHandlerService.class, slave);

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

    final ICommandService parentCommandService = (ICommandService) serviceLocator
        .getService(ICommandService.class);
View Full Code Here

      public void runWithException() {
        ContextManager.DEBUG = Policy.DEBUG_CONTEXTS;
        contextManager = new ContextManager();
        }});
   
    final IContextService contextService = new ContextService(
        contextManager);
   
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        contextService.readRegistry();
        }});
   
    serviceLocator.registerService(IContextService.class, contextService);
 
   
    final IHandlerService [] handlerService = new IHandlerService[1];
 
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        handlerService[0] = new HandlerService(
            commandService[0], evaluationService);
        handlerService[0].readRegistry();
      }});
   
    serviceLocator.registerService(IHandlerService.class, handlerService[0]);

    final IBindingService [] bindingService = new BindingService[1];
   
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        BindingManager.DEBUG = Policy.DEBUG_KEY_BINDINGS;
        bindingManager = new BindingManager(contextManager, commandManager);
        bindingService[0] = new BindingService(
            bindingManager, commandService[0], Workbench.this);
       
      }});
   
    bindingService[0].readRegistryAndPreferences(commandService[0]);
    serviceLocator.registerService(IBindingService.class, bindingService[0]);

    final CommandImageManager commandImageManager = new CommandImageManager();
    final CommandImageService commandImageService = new CommandImageService(
        commandImageManager, commandService[0]);
    commandImageService.readRegistry();
    serviceLocator.registerService(ICommandImageService.class,
        commandImageService);
   
    final WorkbenchMenuService menuService = new WorkbenchMenuService(serviceLocator);
   
    serviceLocator.registerService(IMenuService.class, menuService);
    // the service must be registered before it is initialized - its
    // initialization uses the service locator to address a dependency on
    // the menu service
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        menuService.readRegistry();
      }});

    /*
     * Phase 2 of the initialization of commands. The source providers that
     * the workbench provides are creating and registered with the above
     * services. These source providers notify the services when particular
     * pieces of workbench state change.
     */
    final ISourceProviderService sourceProviderService = new SourceProviderService();
    serviceLocator.registerService(ISourceProviderService.class,
        sourceProviderService);
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        final ActiveShellSourceProvider activeShellSourceProvider = new ActiveShellSourceProvider(
            Workbench.this);
        evaluationService.addSourceProvider(activeShellSourceProvider);
        handlerService[0].addSourceProvider(activeShellSourceProvider);
        contextService.addSourceProvider(activeShellSourceProvider);
        menuService.addSourceProvider(activeShellSourceProvider);
        sourceProviderService.registerProvider(activeShellSourceProvider);   
      }});
   
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        final ActivePartSourceProvider activePartSourceProvider = new ActivePartSourceProvider(
            Workbench.this);
        evaluationService.addSourceProvider(activePartSourceProvider);
        handlerService[0].addSourceProvider(activePartSourceProvider);
        contextService.addSourceProvider(activePartSourceProvider);
        menuService.addSourceProvider(activePartSourceProvider);
        sourceProviderService.registerProvider(activePartSourceProvider);
      }});
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        final ActiveContextSourceProvider activeContextSourceProvider = new ActiveContextSourceProvider(
            contextService);
        evaluationService.addSourceProvider(activeContextSourceProvider);
        handlerService[0].addSourceProvider(activeContextSourceProvider);
        menuService.addSourceProvider(activeContextSourceProvider);
        sourceProviderService.registerProvider(activeContextSourceProvider);
      }});
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        final CurrentSelectionSourceProvider currentSelectionSourceProvider = new CurrentSelectionSourceProvider(
            Workbench.this);
        evaluationService.addSourceProvider(currentSelectionSourceProvider);
        handlerService[0].addSourceProvider(currentSelectionSourceProvider);
        contextService.addSourceProvider(currentSelectionSourceProvider);
        menuService.addSourceProvider(currentSelectionSourceProvider);
        sourceProviderService.registerProvider(currentSelectionSourceProvider);
       
        actionSetSourceProvider = new ActionSetSourceProvider();
        evaluationService.addSourceProvider(actionSetSourceProvider);
        handlerService[0].addSourceProvider(actionSetSourceProvider);
        contextService.addSourceProvider(actionSetSourceProvider);
        menuService.addSourceProvider(actionSetSourceProvider);
        sourceProviderService.registerProvider(actionSetSourceProvider);
       
        FocusControlSourceProvider focusControl = new FocusControlSourceProvider();
        serviceLocator.registerService(IFocusService.class, focusControl);
        evaluationService.addSourceProvider(focusControl);
        handlerService[0].addSourceProvider(focusControl);
        contextService.addSourceProvider(focusControl);
        menuService.addSourceProvider(focusControl);
        sourceProviderService.registerProvider(focusControl);
       
       
        menuSourceProvider = new MenuSourceProvider();
        evaluationService.addSourceProvider(menuSourceProvider);
        handlerService[0].addSourceProvider(menuSourceProvider);
        contextService.addSourceProvider(menuSourceProvider);
        menuService.addSourceProvider(menuSourceProvider);
        sourceProviderService.registerProvider(menuSourceProvider);
      }});
   
    /*
 
View Full Code Here

TOP

Related Classes of org.eclipse.ui.contexts.IContextService

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.