Tas
Tas

Reputation: 285

Finding currently open files in Eclipse plugin

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?

Upvotes: 1

Views: 1356

Answers (1)

codejammer
codejammer

Reputation: 1686

//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);
    }
}

Upvotes: 5

Related Questions