《eclipse插件开发学习笔记——011 get all Content of current workspace》

 

I want to make an eclipse plugin which can analyze java code in the current project and display it in the editor.

 

 

I solved the problem even better way than expected.

In the handler class's execute method , I used IWorkspace and IWorkspaceRoot from org.eclipse.core.resources package.

IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();

From above code, I had access to each and every resource of the current workspace. I fetched the project using IJavaProject and filtered java files from the resources.

 

 

How can I access which files the user currently has open from an eclipse plugin?

IWorkbenchPage[] pages = PlatformUI.getWorkbench()
    .getActiveWorkbenchWindow().getPages();

for (IWorkbenchPage page : pages) {
    IEditorReference[] references = page.getEditorReferences();

    for (IEditorReference reference : references) {
        IEditorInput input = reference.getEditorInput();
    }
}

posted on 2017-02-05 22:43  fantiejun0436  阅读(162)  评论(0)    收藏  举报

导航