在接下来的代码中,默认情况下,我从项目中获取我需要的信息 Workspace,但我需要为 Working Sets 的项目更改它。
IWorkspace workspace = ResourcesPlugin.getWorkspace();
// Get the root of the workspace
IWorkspaceRoot root = workspace.getRoot();
// Get all projects in the workspace
IProject[] projects = root.getProjects();
// Loop over all projects
for (IProject project : projects) {
try {
if (project.getName().equals("RemoteSystemsTempFiles"))
{
System.out.println("Ignored project");
//setSystemName(project.getName());
}
else
{
// Load the data model by extracting APIs declaration (Imports)
printProjectInfo(project);
}
} catch (CoreException e) {
e.printStackTrace();
}
}
所以,我找到了一个答案,但是作为循环后的返回,我收到了许多信息,例如:
- ProjectName (not open)
或者
- ProjectName
src
<default> (...)
src (...)
src.tryone (...)
C:\Program Files\Java\jre1.8.0_31\lib\resources.jar (not open)
返回该信息的代码是:
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSet [] allWorkingSets = manager.getAllWorkingSets();
for (IWorkingSet aWorkingset : allWorkingSets) {
IAdaptable[] elems = aWorkingset.getElements();
System.out.println("Working set " + aWorkingset.getName() + " has "+ elems.length + " projects.");
for (IAdaptable elem : elems) {
System.out.println("Working set " + aWorkingset.getName()+ " contains " + elem.toString());
}
}
所以,简而言之,我想知道如何以与工作区项目相同或类似的方式从工作集中获取 IProjects?