public EditorReference(
      IEclipseContext windowContext,
      IWorkbenchPage page,
      MPart part,
      IEditorInput input,
      EditorDescriptor descriptor,
      IMemento editorState) {
    super(windowContext, page, part);
    this.input = input;
    this.descriptor = descriptor;
    this.editorState = editorState;

    if (descriptor == null) {
      try {
        String memento = getModel().getPersistedState().get(MEMENTO_KEY);
        if (memento == null) {
          descriptorId = EditorRegistry.EMPTY_EDITOR_ID;
        } else {
          XMLMemento createReadRoot = XMLMemento.createReadRoot(new StringReader(memento));
          IEditorRegistry registry =
              getPage().getWorkbenchWindow().getWorkbench().getEditorRegistry();
          descriptorId = createReadRoot.getString(IWorkbenchConstants.TAG_ID);
          this.descriptor = (EditorDescriptor) registry.findEditor(descriptorId);

          boolean pinnedVal =
              "true"
                  .equals(createReadRoot.getString(IWorkbenchConstants.TAG_PINNED)); // $NON-NLS-1$
          setPinned(pinnedVal);

          String ttip = createReadRoot.getString(IWorkbenchConstants.TAG_TOOLTIP);
          part.getTransientData().put(IPresentationEngine.OVERRIDE_TITLE_TOOL_TIP_KEY, ttip);
        }
      } catch (WorkbenchException e) {
        WorkbenchPlugin.log(e);
      }
    } else {
      descriptorId = this.descriptor.getId();
    }
  }
  public EditorReference(
      IEclipseContext windowContext,
      IWorkbenchPage page,
      MPart part,
      IEditorInput input,
      EditorDescriptor descriptor,
      IMemento editorState) {
    super(windowContext, page, part);
    this.input = input;
    this.descriptor = descriptor;
    this.editorState = editorState;

    if (descriptor == null) {
      try {
        String memento = getModel().getPersistedState().get(MEMENTO_KEY);
        if (memento == null) {
          descriptorId = EditorRegistry.EMPTY_EDITOR_ID;
        } else {
          XMLMemento createReadRoot = XMLMemento.createReadRoot(new StringReader(memento));
          IEditorRegistry registry =
              getPage().getWorkbenchWindow().getWorkbench().getEditorRegistry();
          descriptorId = createReadRoot.getString(IWorkbenchConstants.TAG_ID);
          this.descriptor = (EditorDescriptor) registry.findEditor(descriptorId);
        }

        if (this.descriptor == null) {
          setImageDescriptor(ImageDescriptor.getMissingImageDescriptor());
        } else {
          setImageDescriptor(this.descriptor.getImageDescriptor());
        }
      } catch (WorkbenchException e) {
        WorkbenchPlugin.log(e);
      }
    } else {
      descriptorId = this.descriptor.getId();
      setImageDescriptor(this.descriptor.getImageDescriptor());
    }
  }