<分区>
我们想在删除一个项目(IProject)的时候关闭它在eclipse中所有打开的文件。我可以通过项目的成员方法访问 IFiles。我想关闭已删除项目的所有文件。
<分区>
我们想在删除一个项目(IProject)的时候关闭它在eclipse中所有打开的文件。我可以通过项目的成员方法访问 IFiles。我想关闭已删除项目的所有文件。
最佳答案
您可以通过以下方式获取对页面上打开的编辑器的引用:
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);
关于eclipse - 如何在 Eclipse 中以编程方式关闭编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37374791/
相关文章:
java - 安卓初学者 : ListView with Images and CheckBoxes
java - eUML 和 Eclipse 开普勒 : Has someone been able to make it work?
java - 当我将鼠标悬停在自定义编辑器中的错误上时,如何显示快速修复
java - 在eclipse Juno中的所有MPerspective中添加MPart
java - Eclipse RCP 和 RAP 可定制表控件
eclipse - eclipse中动态web项目打不开欢迎页
java - ERROR : Cannot load this JVM TI agent twice, 检查您的 java 命令行是否有重复的 jdwp 选项
eclipse-plugin - 序列图中的 Action 执行规范用法
android - Eclipse 说需要更新的 ADT 版本,但找不到更新
eclipse-rcp - 如何让 tycho materialize-product 和 archive-product 为我的 RCP 应用程序存档文件使用目录前缀