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.
有没有办法在Eclipse中获取项目目录?我们正在编写一个插件,允许用户选择文件,然后对这些文件运行一些进程。理想情况下,我希望能够获得具有特定扩展名的所有文件,但这不是必需的。
2 个解决方案
#1
7
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.
将为您提供工作区中所有项目的列表。你可以轻松迭代找到你想要的那个。此时,您可以通过扩展等查找某些文件。
#2
1
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.
如果要使用户能够使用特定扩展名在eclipse工作区内选择文件,可以查看类org.eclipse.ui.dialogs.ElementTreeSelectionDialog(org.eclipse.ui.dialogs插件)作为开头。
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.
然后,为了有一个关于如何使其成为过滤器扩展的示例,您可以查看类org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog(org.eclipse.jdt.ui插件)以查看它们是如何执行此操作的。然后重新实现这些东西。
This should give you a higher level of action than going threw files inside projects by hand and reimplement dialogs.
这应该比手动和重新实现对话框中的文件内部文件提供更高级别的操作。
#1
7
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.
将为您提供工作区中所有项目的列表。你可以轻松迭代找到你想要的那个。此时,您可以通过扩展等查找某些文件。
#2
1
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.
如果要使用户能够使用特定扩展名在eclipse工作区内选择文件,可以查看类org.eclipse.ui.dialogs.ElementTreeSelectionDialog(org.eclipse.ui.dialogs插件)作为开头。
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.
然后,为了有一个关于如何使其成为过滤器扩展的示例,您可以查看类org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog(org.eclipse.jdt.ui插件)以查看它们是如何执行此操作的。然后重新实现这些东西。
This should give you a higher level of action than going threw files inside projects by hand and reimplement dialogs.
这应该比手动和重新实现对话框中的文件内部文件提供更高级别的操作。