How can the Eclipse plugin access the project directory?

Is there a way to get the project directory in Eclipse? We are writing a plugin that will allow the user to select files and then run some processes in these files. Ideally, I would like to get all files with a specific extension, but this is not necessary.

+7
java eclipse plugins workspace
source share
2 answers

what:

ResourcesPlugin.getWorkspace().getRoot().getProjects() 

will provide you with a list of all projects in the workspace. You can easily iterate to find the one you need. At this point, you can search for specific files using extensions, etc.

+7
source share

If you want your users to select files inside the eclipse workspace with a specific extension, you can look at the org.eclipse.ui.dialogs.ElementTreeSelectionDialog class (org.eclipse.ui. Dialogs) as a launch.

Then, to have an example of how to do this filter extension, you can look at the class org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog (org.eclipse.jdt. Ui plugin) to see how they do it, and then override the material.

This should give you a higher level of action than collecting files inside projects manually and redefining dialogs.

+1
source share

All Articles