Eclipse:按ID创建IEditorPart

时间:2017-02-27 18:26:01

标签: eclipse-plugin

如何通过ID在eclipse插件中创建IEditorPart?

注意,我知道我可以做到:

    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    page.openEditor(
                input,
                "the-editor-id);

但是,这不是我想要的。我想创建一个IEditorPart,以便我可以将它嵌入到多页面编辑器中。我没有直接访问编辑器类,所以我无法直接用“new”实例化。

感谢。

1 个答案:

答案 0 :(得分:0)

作为参考,这就是我所做的。 注意,它使用非API。似乎没有使用官方API进行此操作的机制:

    EditorDescriptor d = (EditorDescriptor)PlatformUI
            .getWorkbench()
            .getEditorRegistry()
            .findEditor("my.editor.id");
    IEditorPart editor = d.createEditor();

EditorDescriptor类和createEditor方法都是非api。 IEditorDescriptor接口没有声明createrEditor方法。