EditorManager manager, EditorAreaHelper editorPresentation,
EditorDescriptor desc, IEditorInput input,
IEditorReference reusableEditorRef) {
IEditorPart reusableEditor = reusableEditorRef.getEditor(false);
if (reusableEditor == null) {
IEditorReference result = new EditorReference(manager, input, desc);
page.closeEditor(reusableEditorRef, false);
return result;
}
EditorSite site = (EditorSite) reusableEditor.getEditorSite();
EditorDescriptor oldDesc = site.getEditorDescriptor();
if ((desc.getId().equals(oldDesc.getId()))
&& (reusableEditor instanceof IReusableEditor)) {
Workbench wb = (Workbench) page.getWorkbenchWindow().getWorkbench();
editorPresentation.moveEditor(reusableEditor, -1);
wb.getEditorHistory().add(reusableEditor.getEditorInput(),
site.getEditorDescriptor());
page.reuseEditor((IReusableEditor) reusableEditor, input);
return reusableEditorRef;
}
// findReusableEditor(...) checks pinned and saves editor if
// necessary, so it's OK to close "reusableEditor"
IEditorReference ref = new EditorReference(manager, input, desc);
reusableEditor.getEditorSite().getPage().closeEditor(reusableEditor,
false);
return ref;
}