Package org.eclipse.ui

Examples of org.eclipse.ui.IPersistableElement


    // Phase 3: check unmaterialized editors for input equality,
    // delaying plug-in activation further by only restoring the editor
    // input
    // if the editor reference's factory id and name match.
    String name = input.getName();
    IPersistableElement persistable = input.getPersistable();
    if (name == null || persistable == null) {
      return;
    }
    String id = persistable.getFactoryId();
    if (id == null) {
      return;
    }
    for (Iterator i = editorList.iterator(); i.hasNext();) {
      EditorReference editor = (EditorReference) i.next();
View Full Code Here


    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);
View Full Code Here

      }

      // Get the input.
      IAdaptable input = page.getInput();
      if (input != null) {
        IPersistableElement persistable = (IPersistableElement) Util
            .getAdapter(input, IPersistableElement.class);
        if (persistable == null) {
          WorkbenchPlugin
              .log("Unable to save page input: " //$NON-NLS-1$
                  + input
                  + ", because it does not adapt to IPersistableElement"); //$NON-NLS-1$

        } else {
          // Save input.
          IMemento inputMem = pageMem
              .createChild(IWorkbenchConstants.TAG_INPUT);
          inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
              persistable.getFactoryId());
          persistable.saveState(inputMem);
        }
      }
    }

    return result;
View Full Code Here

      }

      // Get the input.
      IAdaptable input = page.getInput();
      if (input != null) {
        IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input,
            IPersistableElement.class);
        if (persistable == null) {
          WorkbenchPlugin
              .log("Unable to save page input: " //$NON-NLS-1$
                  + input
                  + ", because it does not adapt to IPersistableElement"); //$NON-NLS-1$
        } else {
          // Save input.
          IMemento inputMem = pageMem
              .createChild(IWorkbenchConstants.TAG_INPUT);
          inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
              persistable.getFactoryId());
          persistable.saveState(inputMem);
        }
      }
    }

    // Save window advisor state.
View Full Code Here

      return false;
    }
        if (!getToolTipText().equals(input.getToolTipText())) {
      return false;
    }
        IPersistableElement persistable = input.getPersistable();
        String inputId = persistable == null ? null : persistable
                .getFactoryId();
        String myId = getFactoryId();
        return myId == null ? inputId == null : myId.equals(inputId);
    }
View Full Code Here

     * Returns <code>null</code> if there is no factory id.
     */
    public String getFactoryId() {
        if (isRestored()) {
            if (input != null) {
                IPersistableElement persistable = input.getPersistable();
                if (persistable != null) {
                    return persistable.getFactoryId();
                }
            }
        } else if (memento != null) {
            return memento.getString(IWorkbenchConstants.TAG_FACTORY_ID);
        }
View Full Code Here

    public IStatus saveState(IMemento memento) {
        if (!isRestored()) {
            memento.putMemento(this.memento);
        } else if (input != null) {

            IPersistableElement persistable = input.getPersistable();
            if (persistable != null) {
                /*
                 * Store IPersistable of the IEditorInput in a separate section
                 * since it could potentially use a tag already used in the parent
                 * memento and thus overwrite data.
                 */
                IMemento persistableMemento = memento
                        .createChild(IWorkbenchConstants.TAG_PERSISTABLE);
                persistable.saveState(persistableMemento);
                memento.putString(IWorkbenchConstants.TAG_FACTORY_ID,
                        persistable.getFactoryId());
                if (descriptor != null && descriptor.getId() != null) {
                    memento.putString(IWorkbenchConstants.TAG_ID, descriptor
                            .getId());
                }
                // save the name and tooltip separately so they can be restored
View Full Code Here

        "The editor input must have a non-null name"); //$NON-NLS-1$
    Assert.isNotNull(input.getToolTipText(),
        "The editor input must have a non-null tool tip"); //$NON-NLS-1$

    // Persistable element may be null
    IPersistableElement persistableElement = input.getPersistable();
    if (persistableElement != null) {
      Assert
          .isNotNull(persistableElement.getFactoryId(),
              "The persistable element for the editor input must have a non-null factory id"); //$NON-NLS-1$
        }
    }
View Full Code Here

    return "CamelContext: " + contextNode.getContextId();
  }

  @Override
  public IPersistableElement getPersistable() {
    return new IPersistableElement() {

      @Override
      public void saveState(IMemento memento) {
        // TODO how to get the document input...
      }
View Full Code Here

  public IPersistableElement getPersistable() {
    boolean restore = Platform.getPreferencesService().getBoolean(RESTORE_QUALIFIER, RESTORE_KEY, true, null);
    if (!restore)
      return null;

    return new IPersistableElement() {
      public String getFactoryId() {
        return FACTORY_ID;
      }

      public void saveState(IMemento memento) {
View Full Code Here

TOP

Related Classes of org.eclipse.ui.IPersistableElement

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.