在Eclipse插件中查找当前打开的文件 [英] Finding currently open files in Eclipse plugin

查看:282
本文介绍了在Eclipse插件中查找当前打开的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个基于外部输出注释eclipse java项目的插件。目前,我正在遍历所有基于本教程的开放项目: http:// www .vogella.de / articles / EclipseJDT / article.html 但是,我正在寻找一种方法来获取目前仅在java编辑器中打开的文件的完整列表。有没有办法或命令我得到这个?

I'm trying to create a plugin that annotates eclipse java projects based on external output. Currently, I'm traversing all of the open projects based on this tutorial: http://www.vogella.de/articles/EclipseJDT/article.html However, I'm looking for a way to get a full list of only the files that are currently open in the java editor. Is there a way or command for me to get that?

推荐答案

//get all active editor references,check if reference is of type java editor    
IEditorReference[] ref = PlatformUI.getWorkbench()
    .getActiveWorkbenchWindow().getActivePage()
    .getEditorReferences();
List<IEditorReference> javaEditors = new ArrayList<IEditorReference>();
for (IEditorReference reference : ref) {
    if ("org.eclipse.jdt.ui.CompilationUnitEditor".equals(reference.getId())){
        javaEditors.add(reference);
    }
}

这篇关于在Eclipse插件中查找当前打开的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆