如何在eclipse中的活动eclipse编辑器窗口中打开文件列表?

时间:2018-04-27 06:55:39

标签: eclipse eclipse-plugin eclipse-cdt

兴趣是在eclipse cdt编辑器中获取打开文件的列表。 让我们说aaa.c,bbb.c,ddd.c是在eclipse编辑器中打开的文件。如何获取这些文件的IFile []。

1 个答案:

答案 0 :(得分:2)

您可以使用IWorkbenchPage getEditorReferences方法获取所有公开编辑器的列表。您可以使用它来查找您感兴趣的编辑器。所以:

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

IEditorReference [] editors = page.getEditorReferences();

for (IEditorReference editor : editors) {
  String editorId = editor.getId();

  // TODO test if this is an editor you are interested in

  IEditorInput inout = editor.getEditorInput();

  IFile file = inout.getAdapter(IFile.class);

  ...
}
相关问题