Examples of StartupRunnable


Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

            final int myLeft = left, myRight= right, myRelationship = relationship;
            final float myRatio = ratio;
            final LayoutPart myPart = part;
           
            StartupThreading.runWithoutExceptions(new StartupRunnable() {

        public void runWithException() throws Throwable {
          // Add the part to the layout
                if (relativeID == null) {
                    add(myPart);
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

    /**
     * Creates the client composite.
     */
    private void createClientComposite() {
        final Composite parent = window.getPageComposite();
        StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        composite = new Composite(parent, SWT.NONE);
        composite.setVisible(false); // Make visible on activate.
        // force the client composite to be layed out
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

     * perspective for that descriptor. If activeDescriptor is null active the
     * old perspective.
     */
    public IStatus restoreState(IMemento memento,
            final IPerspectiveDescriptor activeDescriptor) {
        StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() throws Throwable {
        deferUpdates(true);
      }});
       
        try {
            // Restore working set
            String pageName = memento.getString(IWorkbenchConstants.TAG_LABEL);
           
            String label = null; // debugging only
            if (UIStats.isDebugging(UIStats.RESTORE_WORKBENCH)) {
                label = pageName == null ? "" : "::" + pageName; //$NON-NLS-1$ //$NON-NLS-2$
            }
   
            try {
                UIStats.start(UIStats.RESTORE_WORKBENCH, "WorkbenchPage" + label); //$NON-NLS-1$
                if (pageName == null) {
          pageName = ""; //$NON-NLS-1$
        }
                final MultiStatus result = new MultiStatus(
                        PlatformUI.PLUGIN_ID,
                        IStatus.OK,
                        NLS.bind(WorkbenchMessages.WorkbenchPage_unableToRestorePerspective, pageName ),
                        null);
   
                String workingSetName = memento
                        .getString(IWorkbenchConstants.TAG_WORKING_SET);
                if (workingSetName != null) {
                    AbstractWorkingSetManager workingSetManager = (AbstractWorkingSetManager) getWorkbenchWindow()
                            .getWorkbench().getWorkingSetManager();
                    setWorkingSet(workingSetManager.getWorkingSet(workingSetName));
                }
               
              IMemento workingSetMem = memento
            .getChild(IWorkbenchConstants.TAG_WORKING_SETS);
              if (workingSetMem != null) {
          IMemento[] workingSetChildren = workingSetMem
              .getChildren(IWorkbenchConstants.TAG_WORKING_SET);
          List workingSetList = new ArrayList(
              workingSetChildren.length);
          for (int i = 0; i < workingSetChildren.length; i++) {
            IWorkingSet set = getWorkbenchWindow().getWorkbench()
                .getWorkingSetManager().getWorkingSet(
                    workingSetChildren[i].getID());
            if (set != null) {
              workingSetList.add(set);
            }
          }

          workingSets = (IWorkingSet[]) workingSetList
              .toArray(new IWorkingSet[workingSetList.size()]);
        }
             
              aggregateWorkingSetId = memento.getString(ATT_AGGREGATE_WORKING_SET_ID);
             
              IWorkingSet setWithId = window.getWorkbench().getWorkingSetManager().getWorkingSet(aggregateWorkingSetId);
             
              // check to see if the set has already been made and assign it if it has
              if (setWithId instanceof AggregateWorkingSet) {
          aggregateWorkingSet = (AggregateWorkingSet) setWithId;
        }
                // Restore editor manager.
                IMemento childMem = memento
                        .getChild(IWorkbenchConstants.TAG_EDITORS);
                result.merge(getEditorManager().restoreState(childMem));
   
                childMem = memento.getChild(IWorkbenchConstants.TAG_VIEWS);
                if (childMem != null) {
          result.merge(getViewFactory().restoreState(childMem));
        }
   
                // Get persp block.
                childMem = memento.getChild(IWorkbenchConstants.TAG_PERSPECTIVES);
                String activePartID = childMem
                        .getString(IWorkbenchConstants.TAG_ACTIVE_PART);
                String activePartSecondaryID = null;
                if (activePartID != null) {
                    activePartSecondaryID = ViewFactory
                            .extractSecondaryId(activePartID);
                    if (activePartSecondaryID != null) {
                        activePartID = ViewFactory.extractPrimaryId(activePartID);
                    }
                }
                final String activePerspectiveID = childMem
                        .getString(IWorkbenchConstants.TAG_ACTIVE_PERSPECTIVE);
   
                // Restore perspectives.
                final IMemento perspMems[] = childMem
                        .getChildren(IWorkbenchConstants.TAG_PERSPECTIVE);
                final Perspective activePerspectiveArray [] = new Perspective[1];
               
                for (int i = 0; i < perspMems.length; i++) {
                   
                        final IMemento current = perspMems[i];
          StartupThreading
              .runWithoutExceptions(new StartupRunnable() {

                public void runWithException() throws Throwable {
                  Perspective persp = new Perspective(null,
                      WorkbenchPage.this);
                  result.merge(persp.restoreState(current));
                  final IPerspectiveDescriptor desc = persp
                      .getDesc();
                  if (desc.equals(activeDescriptor)) {
                    activePerspectiveArray[0] = persp;
                  } else if ((activePerspectiveArray[0] == null)
                      && desc.getId().equals(
                          activePerspectiveID)) {
                    activePerspectiveArray[0] = persp;
                  }
                  perspList.add(persp);
                  window.firePerspectiveOpened(
                      WorkbenchPage.this, desc);
                }
              });
                }
                Perspective activePerspective = activePerspectiveArray[0];
                boolean restoreActivePerspective = false;
                if (activeDescriptor == null) {
          restoreActivePerspective = true;

                } else if (activePerspective != null
                        && activePerspective.getDesc().equals(activeDescriptor)) {
                    restoreActivePerspective = true;
                } else {
                    restoreActivePerspective = false;
                    activePerspective = createPerspective((PerspectiveDescriptor) activeDescriptor, true);
                    if (activePerspective == null) {
                        result
                                .merge(new Status(
                                        IStatus.ERROR,
                                        PlatformUI.PLUGIN_ID,
                                        0,
                                        NLS.bind(WorkbenchMessages.Workbench_showPerspectiveError, activeDescriptor.getId() ),
                                        null));
                    }
                }
   
                perspList.setActive(activePerspective);
   
                // Make sure we have a valid perspective to work with,
                // otherwise return.
                activePerspective = perspList.getActive();
                if (activePerspective == null) {
                    activePerspective = perspList.getNextActive();
                    perspList.setActive(activePerspective);
                }
                if (activePerspective != null && restoreActivePerspective) {
          result.merge(activePerspective.restoreState());
        }
   
                if (activePerspective != null) {
                  final Perspective myPerspective = activePerspective;
                  final String myActivePartId = activePartID, mySecondaryId = activePartSecondaryID;
                  StartupThreading.runWithoutExceptions(new StartupRunnable() {

            public void runWithException() throws Throwable {
              window.firePerspectiveActivated(WorkbenchPage.this, myPerspective
                                .getDesc());
       
                        // Restore active part.
                        if (myActivePartId != null) {
                            IViewReference ref = myPerspective.findView(
                                myActivePartId, mySecondaryId);
                           
                            if (ref != null) {
                                activationList.setActive(ref);
                            }
                        }
            }});
                   
                }
   
                childMem = memento
                        .getChild(IWorkbenchConstants.TAG_NAVIGATION_HISTORY);
                if (childMem != null) {
          navigationHistory.restoreState(childMem);
        } else if (getActiveEditor() != null) {
          navigationHistory.markEditor(getActiveEditor());
        }
               
                // restore sticky view state
                stickyViewMan.restore(memento);
                   
                return result;
            } finally {
              String blame = activeDescriptor == null ? pageName : activeDescriptor.getId();
                UIStats.end(UIStats.RESTORE_WORKBENCH, blame, "WorkbenchPage" + label); //$NON-NLS-1$
            }
        } finally {
          StartupThreading.runWithoutExceptions(new StartupRunnable() {

        public void runWithException() throws Throwable {
          deferUpdates(false);
        }
      });
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

            r.y = boundsMem.getInteger(IWorkbenchConstants.TAG_Y).intValue();
            r.height = boundsMem.getInteger(IWorkbenchConstants.TAG_HEIGHT)
                    .intValue();
            r.width = boundsMem.getInteger(IWorkbenchConstants.TAG_WIDTH)
                    .intValue();
          StartupThreading.runWithoutExceptions(new StartupRunnable() {

        public void runWithException() throws Throwable {
          if (page.getWorkbenchWindow().getPages().length == 0) {
                    page.getWorkbenchWindow().getShell().setBounds(r);
                }
        }
      });

        }

        // Create an empty presentation..
        final PerspectiveHelper [] presArray = new PerspectiveHelper[1];
        StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() throws Throwable {
        ViewSashContainer mainLayout = new ViewSashContainer(page, getClientComposite());
        presArray[0] = new PerspectiveHelper(page, mainLayout, Perspective.this);
      }});
        final PerspectiveHelper pres = presArray[0];

        // Read the layout.
        result.merge(pres.restoreState(memento
                .getChild(IWorkbenchConstants.TAG_LAYOUT)));

        StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() throws Throwable {
        // Add the editor workbook. Do not hide it now.
            pres.replacePlaceholderWithPart(editorArea);
      }});

        // Add the visible views.
        IMemento[] views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);

        for (int x = 0; x < views.length; x++) {
            // Get the view details.
            IMemento childMem = views[x];
            String id = childMem.getString(IWorkbenchConstants.TAG_ID);
            String secondaryId = ViewFactory.extractSecondaryId(id);
            if (secondaryId != null) {
                id = ViewFactory.extractPrimaryId(id);
            }

            // skip the intro as it is restored higher up in workbench.
            if (id.equals(IIntroConstants.INTRO_VIEW_ID)) {
        continue;
      }
           
            // Create and open the view.
            IViewReference viewRef = viewFactory.getView(id, secondaryId);
            WorkbenchPartReference ref = (WorkbenchPartReference) viewRef;

            // report error
            if (ref == null) {
                String key = ViewFactory.getKey(id, secondaryId);
                result.add(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0,
                        NLS.bind(WorkbenchMessages.Perspective_couldNotFind,  key ), null));
                continue;
            }
            boolean willPartBeVisible = pres.willPartBeVisible(ref.getId(),
                    secondaryId);
            if (willPartBeVisible) {
                IViewPart view = (IViewPart) ref.getPart(true);
                if (view != null) {
                    ViewSite site = (ViewSite) view.getSite();
                    ViewPane pane = (ViewPane) site.getPane();
                    pres.replacePlaceholderWithPart(pane);
                }
            } else {
                pres.replacePlaceholderWithPart(ref.getPane());
            }
        }

        // Load the fast views
        if (fastViewManager != null)
          fastViewManager.restoreState(memento, result);

        // Load the view layout recs
        IMemento[] recMementos = memento
                .getChildren(IWorkbenchConstants.TAG_VIEW_LAYOUT_REC);
        for (int i = 0; i < recMementos.length; i++) {
            IMemento recMemento = recMementos[i];
            String compoundId = recMemento
                    .getString(IWorkbenchConstants.TAG_ID);
            if (compoundId != null) {
                ViewLayoutRec rec = getViewLayoutRec(compoundId, true);
                if (IWorkbenchConstants.FALSE.equals(recMemento
                        .getString(IWorkbenchConstants.TAG_CLOSEABLE))) {
                    rec.isCloseable = false;
                }
                if (IWorkbenchConstants.FALSE.equals(recMemento
                        .getString(IWorkbenchConstants.TAG_MOVEABLE))) {
                    rec.isMoveable = false;
                }
                if (IWorkbenchConstants.TRUE.equals(recMemento
                        .getString(IWorkbenchConstants.TAG_STANDALONE))) {
                    rec.isStandalone = true;
                    rec.showTitle = !IWorkbenchConstants.FALSE
                            .equals(recMemento
                                    .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

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

    // restore the presentation
    if (areaMem != null) {
      result.add(editorPresentation.restorePresentationState(areaMem));
    }
    try {
      StartupThreading.runWithThrowable(new StartupRunnable(){

        public void runWithException() throws Throwable {
          // Update each workbook with its visible editor.
          for (int i = 0; i < visibleEditors.size(); i++) {
            setVisibleEditor((IEditorReference) visibleEditors.get(i),
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

    final String workbookID = editorMem
        .getString(IWorkbenchConstants.TAG_WORKBOOK);

    try {
      StartupThreading.runWithPartInitExceptions(new StartupRunnable () {

        public void runWithException() throws Throwable {
          createEditorTab(e, workbookID);
        }});
     
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

   */
  private IWorkbenchWindow busyOpenWorkbenchWindow(final String perspID,
      final IAdaptable input) throws WorkbenchException {
    // Create a workbench window (becomes active window)
    final WorkbenchWindow newWindowArray[] = new WorkbenchWindow[1];
    StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {
      public void runWithException() {
        newWindowArray[0] = newWorkbenchWindow();
      }
    });

    final WorkbenchWindow newWindow = newWindowArray[0];
   
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        newWindow.create(); // must be created before adding to window
                  // manager
      }
    });
    windowManager.add(newWindow);

    final WorkbenchException [] exceptions = new WorkbenchException[1];
    // Create the initial page.
    if (perspID != null) {
      StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {

        public void runWithException() throws WorkbenchException {
          try {
            newWindow.busyOpenPage(perspID, input);
          } catch (WorkbenchException e) {
            windowManager.remove(newWindow);
            exceptions[0] = e;
          }
        }})
    }
    if (exceptions[0] != null)
      throw exceptions[0];

    // Open window after opening page, to avoid flicker.
    StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {

      public void runWithException() {
        newWindow.open();
      }
    });
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

    initializeColors();
    initializeApplicationColors();

    // now that the workbench is sufficiently initialized, let the advisor
    // have a turn.
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        advisor.internalBasicInitialize(getWorkbenchConfigurer());
      }
    });
   
    // configure use of color icons in toolbars
    boolean useColorIcons = PrefUtil.getInternalPreferenceStore()
        .getBoolean(IPreferenceConstants.COLOR_ICONS);
    ActionContributionItem.setUseColorIconsInToolbars(useColorIcons);

    // initialize workbench single-click vs double-click behavior
    initializeSingleClickOption();
   
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        ((GrabFocus) Tweaklets.get(GrabFocus.KEY))
            .init(getDisplay());
      }
    });
   

    // attempt to restore a previous workbench state
    try {
      UIStats.start(UIStats.RESTORE_WORKBENCH, "Workbench"); //$NON-NLS-1$

      final boolean bail [] = new boolean[1];
      StartupThreading.runWithoutExceptions(new StartupRunnable() {

        public void runWithException() throws Throwable {
          advisor.preStartup();
         
          if (!advisor.openWindows()) {
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

   * Note this will be rolled into initializeColors() at some point.
   *
   * @since 3.0
   */
  private void initializeApplicationColors() {
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        ColorDefinition[] colorDefinitions = WorkbenchPlugin
            .getDefault().getThemeRegistry().getColors();
        ThemeElementHelper.populateRegistry(getThemeManager().getTheme(
View Full Code Here

Examples of org.eclipse.ui.internal.StartupThreading.StartupRunnable

  /*
   * Initializes the workbench fonts with the stored values.
   */
  private void initializeFonts() {
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

      public void runWithException() {
        FontDefinition[] fontDefinitions = WorkbenchPlugin.getDefault()
            .getThemeRegistry().getFonts();

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.