Reputation: 28757
I have an IProject that is also an IJavaProject. I need to find all other projects in the workspace that refer to this IProject.
One simple and inefficient way of calculating this is to trawl through all projects in the workspace and keep track of references to the current project. Something like this:
IProject currentProject = ...;
IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
List<IProject> interestingProjects = ...;
for (IProject project : allProjects) {
if (refersToCurrentProject(project)) {
interestingProjects.add(project);
}
}
doSomething(interestingProjects);
Note- I haven't compiled this code and I wrote it from memory, so it may not work exactly, I am only trying to give an idea of what I want to do.
Another possibility is to calculate the dependencies only once and then update the dependencies through an IResourceChangedListener. But, this is messy too and I need to write my own (error-prone) logic for that.
Any suggestions would be appreciated.
Upvotes: 0
Views: 421
Reputation: 3178
I know that there is a context menu option to close unrelated projects when you right click a particular project. Have you looked at that?
Upvotes: 1