Package org.eclipse.ui

Examples of org.eclipse.ui.IMemento


        Iterator iter = parts.iterator();
        while (iter.hasNext()) {
            IPresentablePart next = (IPresentablePart) iter.next();

            IMemento childMem = memento
                    .createChild(IWorkbenchConstants.TAG_PART);
            childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next));
        }
    }
View Full Code Here


        savedPresentationState = null;
        IMemento[] presentationMementos = memento
                .getChildren(IWorkbenchConstants.TAG_PRESENTATION);

        for (int idx = 0; idx < presentationMementos.length; idx++) {
            IMemento child = presentationMementos[idx];

            String id = child.getString(IWorkbenchConstants.TAG_ID);

            if (Util.equals(id, getFactory().getId())) {
                savedPresentationState = child;
                break;
            }
View Full Code Here

        memento.putInteger(IWorkbenchConstants.TAG_APPEARANCE, appearance);

        savePresentationState();

        if (savedPresentationState != null) {
            IMemento presentationState = memento
                    .createChild(IWorkbenchConstants.TAG_PRESENTATION);
            presentationState.putMemento(savedPresentationState);
        }

        return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
    }
View Full Code Here

   *            the memento to restore from
   * @return the <code>IStatus</code> of the operation
   * @see org.eclipse.ui.IPersistableElement
   */
  public IStatus restoreState(IMemento memento) {
    IMemento childMem = memento
        .getChild(IWorkbenchConstants.TAG_DESCRIPTOR);
    if (childMem != null) {
      id = childMem.getString(IWorkbenchConstants.TAG_ID);
      originalId = childMem.getString(IWorkbenchConstants.TAG_DESCRIPTOR);
      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());
View Full Code Here

   *            the memento to restore from
   * @return the <code>IStatus</code> of the operation
   * @see org.eclipse.ui.IPersistableElement
   */
  public IStatus saveState(IMemento memento) {
    IMemento childMem = memento
        .createChild(IWorkbenchConstants.TAG_DESCRIPTOR);
    childMem.putString(IWorkbenchConstants.TAG_ID, getId());
    if (originalId != null) {
      childMem.putString(IWorkbenchConstants.TAG_DESCRIPTOR, originalId);
    }
    childMem.putString(IWorkbenchConstants.TAG_LABEL, getLabel());
    childMem.putString(IWorkbenchConstants.TAG_CLASS, getClassName());
    if (singleton) {
      childMem.putInteger(IWorkbenchConstants.TAG_SINGLETON, 1);
    }
    return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
  }
View Full Code Here

        WorkbenchMessages.EditorManager_problemsRestoringEditors, null);
    final String activeWorkbookID[] = new String[1];
    final ArrayList visibleEditors = new ArrayList(5);
    final IEditorReference activeEditor[] = new IEditorReference[1];

    IMemento areaMem = memento.getChild(IWorkbenchConstants.TAG_AREA);
    if (areaMem != null) {
      result.add(editorPresentation.restoreState(areaMem));
      activeWorkbookID[0] = areaMem
          .getString(IWorkbenchConstants.TAG_ACTIVE_WORKBOOK);
    }

    // Loop through the editors.
View Full Code Here

    final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
        IStatus.OK,
        WorkbenchMessages.EditorManager_problemsSavingEditors, null);

    // Save the editor area workbooks layout/relationship
    IMemento editorAreaMem = memento
        .createChild(IWorkbenchConstants.TAG_AREA);
    result.add(editorPresentation.saveState(editorAreaMem));

    // Save the active workbook id
    editorAreaMem.putString(IWorkbenchConstants.TAG_ACTIVE_WORKBOOK,
        editorPresentation.getActiveEditorWorkbookID());

    // Get each workbook
    ArrayList workbooks = editorPresentation.getWorkbooks();

    for (Iterator iter = workbooks.iterator(); iter.hasNext();) {
      EditorStack workbook = (EditorStack) iter.next();

      // Use the list of editors found in EditorStack; fix for 24091
      EditorPane editorPanes[] = workbook.getEditors();

      for (int i = 0; i < editorPanes.length; i++) {
        // Save each open editor.
        IEditorReference editorReference = editorPanes[i]
            .getEditorReference();
        EditorReference e = (EditorReference) editorReference;
        final IEditorPart editor = editorReference.getEditor(false);
        if (editor == null) {
          if (e.getMemento() != null) {
            IMemento editorMem = memento
                .createChild(IWorkbenchConstants.TAG_EDITOR);
            editorMem.putMemento(e.getMemento());
          }
          continue;
        }

        // for dynamic UI - add the next line to replace the subsequent
View Full Code Here

  // for dynamic UI
  protected void saveEditorState(IMemento mem, IEditorReference ed,
      MultiStatus res) {
    final EditorReference editorRef = (EditorReference) ed;
    final IEditorPart editor = ed.getEditor(false);
    final IMemento memento = mem;
    final MultiStatus result = res;
    if (!(editor.getEditorSite() instanceof EditorSite)) {
      return;
    }
    final EditorSite site = (EditorSite) editor.getEditorSite();
    if (site.getPane() instanceof MultiEditorInnerPane) {
      return;
    }

    SafeRunner.run(new SafeRunnable() {
      public void run() {
        // Get the input.
        IEditorInput input = editor.getEditorInput();
        IPersistableElement persistable = input.getPersistable();
        if (persistable == null) {
          return;
        }

        // Save editor.
        IMemento editorMem = memento
            .createChild(IWorkbenchConstants.TAG_EDITOR);
        editorMem.putString(IWorkbenchConstants.TAG_TITLE, editorRef
            .getTitle());
        editorMem.putString(IWorkbenchConstants.TAG_NAME, editorRef
            .getName());
        editorMem.putString(IWorkbenchConstants.TAG_ID, editorRef
            .getId());
        editorMem.putString(IWorkbenchConstants.TAG_TOOLTIP, editorRef
            .getTitleToolTip());

        editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
            editorRef.getPartName());
       
        if (editor instanceof IWorkbenchPart3) {
          Map properties = ((IWorkbenchPart3) editor)
              .getPartProperties();
          if (!properties.isEmpty()) {
            IMemento propBag = editorMem
                .createChild(IWorkbenchConstants.TAG_PROPERTIES);
            Iterator i = properties.entrySet().iterator();
            while (i.hasNext()) {
              Map.Entry entry = (Map.Entry) i.next();
              IMemento p = propBag.createChild(
                  IWorkbenchConstants.TAG_PROPERTY,
                  (String) entry.getKey());
              p.putTextData((String) entry.getValue());
            }
          }
        }

        if (editorRef.isPinned()) {
          editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
        }

        EditorPane editorPane = (EditorPane) ((EditorSite) editor
            .getEditorSite()).getPane();
        editorMem.putString(IWorkbenchConstants.TAG_WORKBOOK,
            editorPane.getWorkbook().getID());

        if (editor == page.getActivePart()) {
          editorMem.putString(IWorkbenchConstants.TAG_ACTIVE_PART,
              "true"); //$NON-NLS-1$
        }

        if (editorPane == editorPane.getWorkbook().getSelection()) {
          editorMem.putString(IWorkbenchConstants.TAG_FOCUS, "true"); //$NON-NLS-1$
        }

        if (input instanceof IPathEditorInput) {
          IPath path = ((IPathEditorInput) input).getPath();
          if (path != null) {
            editorMem.putString(IWorkbenchConstants.TAG_PATH, path
                .toString());
          }
        }

        // Save input.
        IMemento inputMem = editorMem
            .createChild(IWorkbenchConstants.TAG_INPUT);
        inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
            persistable.getFactoryId());
        persistable.saveState(inputMem);
       
        // any editors that want to persist state
        if (editor instanceof IPersistableEditor) {
          IMemento editorState = editorMem
              .createChild(IWorkbenchConstants.TAG_EDITOR_STATE);
          ((IPersistableEditor) editor).saveState(editorState);
        }
      }
View Full Code Here

    private void loadCustomPersp(PerspectiveDescriptor persp) {
        //get the layout from the registry 
        PerspectiveRegistry perspRegistry = (PerspectiveRegistry) WorkbenchPlugin
                .getDefault().getPerspectiveRegistry();
        try {
            IMemento memento = perspRegistry.getCustomPersp(persp.getId());
            // Restore the layout state.
            MultiStatus status = new MultiStatus(
                    PlatformUI.PLUGIN_ID,
                    IStatus.OK,
                    NLS.bind(WorkbenchMessages.Perspective_unableToRestorePerspective, persp.getLabel()),
View Full Code Here

      descriptor = desc;
    }

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

        memento = memento.getChild(IWorkbenchConstants.TAG_FAST_VIEWS);
        if (memento != null) {
            views = memento.getChildren(IWorkbenchConstants.TAG_VIEW);
View Full Code Here

TOP

Related Classes of org.eclipse.ui.IMemento

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.