Examples of IPerspectiveDescriptor


Examples of org.eclipse.ui.IPerspectiveDescriptor

        ArrayList getCheckedItemIds() {
            ArrayList ids = new ArrayList();
            if (getMenuId() == ID_PERSP) {
                for (int i = 0; i < checkedItems.size(); i++) {
                    IPerspectiveDescriptor item = (IPerspectiveDescriptor) checkedItems
                            .get(i);
                    ids.add(item.getId());
                }
            } else if (getMenuId() == ID_VIEW) {
                for (int i = 0; i < checkedItems.size(); i++) {
                    IViewDescriptor item = (IViewDescriptor) checkedItems
                            .get(i);
                    ids.add(item.getId());
                }
            } else if (getMenuId() == ID_WIZARD) {
                for (int i = 0; i < checkedItems.size(); i++) {
                    WorkbenchWizardElement item = (WorkbenchWizardElement) checkedItems
                            .get(i);
                    ids.add(item.getId());
                }
            }
            for (int i = 0; i < children.size(); i++) {
                ShortcutMenu menu = (ShortcutMenu) children.get(i);
                ids.addAll(menu.getCheckedItemIds());
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

        XMLMemento memento = XMLMemento.createReadRoot(reader);
        PerspectiveDescriptor newPersp = new PerspectiveDescriptor(
            null, null, null);
        newPersp.restoreState(memento);
        String id = newPersp.getId();
        IPerspectiveDescriptor oldPersp = findPerspectiveWithId(id);
        if (oldPersp == null) {
          add(newPersp);
        }
        reader.close();
      } catch (IOException e) {
        unableToLoadPerspective(null);
      } catch (WorkbenchException e) {
        unableToLoadPerspective(e.getStatus());
      }
    }

    // Get the entries from files, if any
    // if -data @noDefault specified the state location may not be
    // initialized
    IPath path = WorkbenchPlugin.getDefault().getDataLocation();
    if (path == null) {
      return;
    }

    File folder = path.toFile();

    if (folder.isDirectory()) {
      File[] fileList = folder.listFiles();
      int nSize = fileList.length;
      for (int nX = 0; nX < nSize; nX++) {
        File file = fileList[nX];
        if (file.getName().endsWith(EXT)) {
          // get the memento
          InputStream stream = null;
          try {
            stream = new FileInputStream(file);
            reader = new BufferedReader(new InputStreamReader(
                stream, "utf-8")); //$NON-NLS-1$

            // Restore the layout state.
            XMLMemento memento = XMLMemento.createReadRoot(reader);
            PerspectiveDescriptor newPersp = new PerspectiveDescriptor(
                null, null, null);
            newPersp.restoreState(memento);
            IPerspectiveDescriptor oldPersp = findPerspectiveWithId(newPersp
                .getId());
            if (oldPersp == null) {
              add(newPersp);
            }
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

  /**
   * @see IPerspectiveRegistry#setDefaultPerspective(String)
   */
  public void setDefaultPerspective(String id) {
    IPerspectiveDescriptor desc = findPerspectiveWithId(id);
    if (desc != null) {
      defaultPerspID = id;
      PrefUtil.getAPIPreferenceStore().setValue(
          IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID, id);
    }
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

   * Verifies the id of the default perspective. If the default perspective is
   * invalid use the workbench default.
   */
  private void verifyDefaultPerspective() {
    // Step 1: Try current defPerspId value.
    IPerspectiveDescriptor desc = null;
    if (defaultPerspID != null) {
      desc = findPerspectiveWithId(defaultPerspID);
    }
    if (desc != null) {
      return;
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

    if (label == null || !(label.trim().length() > 0)) {
      throw new IllegalArgumentException();
    }

    // Check for duplicates
    IPerspectiveDescriptor desc = findPerspectiveWithId(id);
    if (desc != null) {
      throw new IllegalArgumentException();
    }

    // Create descriptor.
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

  public IPerspectiveFactory createFactory() throws CoreException {
    // if there is an originalId, then use that descriptor instead
    if (originalId != null) {
      // Get the original descriptor to create the factory. If the
      // original is gone then nothing can be done.
      IPerspectiveDescriptor target = ((PerspectiveRegistry) WorkbenchPlugin
          .getDefault().getPerspectiveRegistry())
          .findPerspectiveWithId(originalId);

      return target == null ? null : ((PerspectiveDescriptor) target)
          .createFactory();
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

      label = childMem.getString(IWorkbenchConstants.TAG_LABEL);
      className = childMem.getString(IWorkbenchConstants.TAG_CLASS);
      singleton = (childMem.getInteger(IWorkbenchConstants.TAG_SINGLETON) != null);

      // Find a descriptor in the registry.
      IPerspectiveDescriptor descriptor = WorkbenchPlugin.getDefault()
          .getPerspectiveRegistry().findPerspectiveWithId(
              getOriginalId());

      if (descriptor != null) {
        // Copy the state from the registred descriptor.
        image = descriptor.getImageDescriptor();
      }
    }
    return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
  }
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

     * Determines the active perspective in the window
     * and calls <code>update(IPerspectiveDescriptor)</code>.
     */
    private void update() {
        if (window != null) {
            IPerspectiveDescriptor persp = null;
            IWorkbenchPage page = window.getActivePage();
            if (page != null) {
                persp = page.getPerspective();
            }
            update(persp);
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

      }
    }
    if (perspId == null) {
      return;
    }
    IPerspectiveDescriptor desc = getPerspectiveRegistry()
        .findPerspectiveWithId(perspId);
    if (desc == null) {
      return;
    }
View Full Code Here

Examples of org.eclipse.ui.IPerspectiveDescriptor

    // ignored.
    WorkbenchWindow win = (WorkbenchWindow) window;
    if (win != null) {
      WorkbenchPage page = win.getActiveWorkbenchPage();
      if (page != null) {
        IPerspectiveDescriptor perspectives[] = page
            .getOpenPerspectives();
        for (int i = 0; i < perspectives.length; i++) {
          IPerspectiveDescriptor persp = perspectives[i];
          if (perspectiveId.equals(persp.getId())) {
            win.makeVisible();
            page.setPerspective(persp);
            return page;
          }
        }
      }
    }

    // If another window that has the workspace root as input and the
    // requested
    // perpective open and active, then the window is given focus.
    IAdaptable input = getDefaultPageInput();
    IWorkbenchWindow[] windows = getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
      win = (WorkbenchWindow) windows[i];
      if (window != win) {
        WorkbenchPage page = win.getActiveWorkbenchPage();
        if (page != null) {
          boolean inputSame = false;
          if (input == null) {
            inputSame = (page.getInput() == null);
          } else {
            inputSame = input.equals(page.getInput());
          }
          if (inputSame) {
            Perspective persp = page.getActivePerspective();
            if (persp != null) {
              IPerspectiveDescriptor desc = persp.getDesc();
              if (desc != null) {
                if (perspectiveId.equals(desc.getId())) {
                  Shell shell = win.getShell();
                  shell.open();
                  if (shell.getMinimized()) {
                    shell.setMinimized(false);
                  }
                  return page;
                }
              }
            }
          }
        }
      }
    }

    // Otherwise the requested perspective is opened and shown in the
    // specified
    // window or in a new window depending on the current user preference
    // for opening
    // perspectives, and that window is given focus.
    win = (WorkbenchWindow) window;
    if (win != null) {
      IPreferenceStore store = WorkbenchPlugin.getDefault()
          .getPreferenceStore();
      int mode = store.getInt(IPreferenceConstants.OPEN_PERSP_MODE);
      IWorkbenchPage page = win.getActiveWorkbenchPage();
      IPerspectiveDescriptor persp = null;
      if (page != null) {
        persp = page.getPerspective();
      }

      // Only open a new window if user preference is set and the window
      // has an active perspective.
      if (IPreferenceConstants.OPM_NEW_WINDOW == mode && persp != null) {
        IWorkbenchWindow newWindow = openWorkbenchWindow(perspectiveId,
            input);
        return newWindow.getActivePage();
      }

      IPerspectiveDescriptor desc = getPerspectiveRegistry()
          .findPerspectiveWithId(perspectiveId);
      if (desc == null) {
        throw new WorkbenchException(
            NLS
                .bind(
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.