How can an Eclipse plugin access the project direc

2019-06-17 06:50发布

Is there a way to get the directory of a project in Eclipse? We are writing a plugin that will allow the user to select files, and then run some processes on those files. I would ideally like to be able to get all the files with a certain extension, but that is not necessary.

2条回答
叼着烟拽天下
2楼-- · 2019-06-17 07:37

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

Then, to have an example on how to make it filter extensions, 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 reimplement the stuff.

This should give you a higher level of action than going threw files inside projects by hand and reimplement dialogs.

查看更多
▲ chillily
3楼-- · 2019-06-17 07:41

sure:

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

will get you a list of all the projects in the workspace. you can easily iterate to find the one you want. At that point, you can look for certain files by extensions, etc.

查看更多
登录 后发表回答