我正在寻找使用平台API启动编辑器的方法。 有没有办法从IFile获得IEditorPart?
谢谢
答案 0 :(得分:0)
我找到了解决方案,我想与可能遇到同样问题的人分享。
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
EditorManager manager = ((WorkbenchPage) page).getEditorManager();
//the magic is here
IEditorDescriptor desc = editorRegistry.findEditor("com.Editor.ID");
EditorReference result = new EditorReference(manager, new FileEditorInput(iFile), (EditorDescriptor)desc, null);
IEditorPart editor = result.getEditor(true);