答案 0 :(得分:3)
您可以在页面上获得对开放式编辑器的引用:
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
从参考资料中获取实际的编辑部分:
IEditorPart editor = editorRefs[index].getEditor(true);
获取编辑器输入:
IEditorInput input = editor.getEditorInput();
获取编辑器正在编辑的文件:
IFile file = (IFile)input.getAdapter(IFile.class);
关闭编辑器:
page.closeEditor(editor, true);