Package org.eclipse.ui

Examples of org.eclipse.ui.IPerspectiveDescriptor


   * Switches, if necessary, the perspective of active workbench window to Fuse perspective.
   *
   * @param workbenchWindow
   */
  private void switchToFusePerspective(final IWorkbenchWindow workbenchWindow) {
    IPerspectiveDescriptor activePerspective = workbenchWindow.getActivePage().getPerspective();
    if (activePerspective == null || !activePerspective.getId().equals(FusePerspective.ID)) {
      workbenchWindow.getShell().getDisplay().syncExec(new Runnable() {
        @Override
        public void run() {
          try {
            workbenchWindow.getWorkbench().showPerspective(FusePerspective.ID, workbenchWindow);
View Full Code Here


            return;
        }

        final IWorkbenchWindow workbenchWindow = part.getSite().getPage().getWorkbenchWindow();

        IPerspectiveDescriptor activePerspective = workbenchWindow.getActivePage().getPerspective();
        final String preferredPerspectiveId = ((IPrefersPerspective) part)
                .getPreferredPerspectiveId();

        if (preferredPerspectiveId == null) {
            return;
        }

        if (activePerspective == null || !activePerspective.getId().equals(preferredPerspectiveId)) {
            // Switching of the perspective is delayed using Display.asyncExec
            // because switching the perspective while the workbench is
            // activating parts might cause conflicts.
            Display.getCurrent().asyncExec(new Runnable() {
              /*
 
View Full Code Here

    IPerspectiveRegistry reg = PlatformUI.getWorkbench()
        .getPerspectiveRegistry();

    // leave this code in - the perspective of a given project may map to
    // activities other than those that the wizard itself maps to.
    IPerspectiveDescriptor finalPersp = reg
        .findPerspectiveWithId(finalPerspId);
    if (finalPersp != null && finalPersp instanceof IPluginContribution) {
      IPluginContribution contribution = (IPluginContribution) finalPersp;
      if (contribution.getPluginId() != null) {
        IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI
            .getWorkbench().getActivitySupport();
        IActivityManager activityManager = workbenchActivitySupport
            .getActivityManager();
        IIdentifier identifier = activityManager
            .getIdentifier(WorkbenchActivityHelper
                .createUnifiedId(contribution));
        Set idActivities = identifier.getActivityIds();

        if (!idActivities.isEmpty()) {
          Set enabledIds = new HashSet(activityManager
              .getEnabledActivityIds());

          if (enabledIds.addAll(idActivities)) {
            workbenchActivitySupport
                .setEnabledActivityIds(enabledIds);
          }
        }
      }
    } else {
      IDEWorkbenchPlugin.log("Unable to find perspective " //$NON-NLS-1$
          + finalPerspId
          + " in BasicNewProjectResourceWizard.updatePerspective"); //$NON-NLS-1$
      return;
    }

    // gather the preferred perspectives
    // always consider the final perspective (and those derived from it)
    // to be preferred
    ArrayList preferredPerspIds = new ArrayList();
    addPerspectiveAndDescendants(preferredPerspIds, finalPerspId);
    String preferred = configElement.getAttribute(PREFERRED_PERSPECTIVES);
    if (preferred != null) {
      StringTokenizer tok = new StringTokenizer(preferred, " \t\n\r\f,"); //$NON-NLS-1$
      while (tok.hasMoreTokens()) {
        addPerspectiveAndDescendants(preferredPerspIds, tok.nextToken());
      }
    }

    IWorkbenchWindow window = PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow();
    if (window != null) {
      IWorkbenchPage page = window.getActivePage();
      if (page != null) {
        IPerspectiveDescriptor currentPersp = page.getPerspective();

        // don't switch if the current perspective is a preferred
        // perspective
        if (currentPersp != null
            && preferredPerspIds.contains(currentPersp.getId())) {
          return;
        }
      }

      // prompt the user to switch
View Full Code Here

 
  /**
   * @return the active perspective in the active workbench page
   */
  public SWTBotPerspective activePerspective() {
    IPerspectiveDescriptor perspective = workbenchContentsFinder.findActivePerspective();
    if (perspective == null)
      throw new WidgetNotFoundException("There is no active perspective"); //$NON-NLS-1$
    return new SWTBotPerspective(perspective, this);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.IPerspectiveDescriptor

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.