for (IResource resource : resources) {
treeObjectMap.put(resource, new OOResourceTreeObject(resource));
IResource current = resource;
while (current != null) {
IResource parent = current.getParent();
ResourceTreeObject parentTreeObject = treeObjectMap.get(parent);
if (parentTreeObject != null) {
parentTreeObject.getChildren().add(
treeObjectMap.get(current));
break;
}
if (parent.getProject().equals(parent)) {
parentTreeObject = new ProjectTreeObject(parent);
invisibleRoot.getChildren().add(parentTreeObject);
parentTreeObject.getChildren().add(
treeObjectMap.get(current));
treeObjectMap.put(parent, parentTreeObject);
break;
}
parentTreeObject = new DirectoryTreeObject(parent);
parentTreeObject.getChildren().add(treeObjectMap.get(current));
treeObjectMap.put(parent, parentTreeObject);
current = parent;
}
}