System.out.println("Memento == null:" + memento == null);
}
return;
}
PydevCommonViewer treeViewer = (PydevCommonViewer) viewer;
//we have to restore it only at the 'right' time... see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195184 for more details
if (!treeViewer.availableToRestoreMemento) {
if (DEBUG) {
System.out.println("Not available for restore");
}
return;
}
if (DEBUG) {
System.out.println("Restoring");
}
IMemento[] expanded = memento.getChildren("expanded");
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
for (IMemento m : expanded) {
Object resource = getResourceFromPath(root, m);
if (resource != null) {
if (DEBUG) {
System.out.println("Expanding:" + resource);
}
//it has to be done level by level because the children may be created
//for each expand (so, we 1st must expand the source folder in order to
//get the correct folders beneath it).
treeViewer.expandToLevel(resource, 1);
}
}
ArrayList<TreePath> paths = new ArrayList<TreePath>();
IMemento[] selected = memento.getChildren("selected");
for (IMemento m : selected) {
Object resource = getResourceFromPath(root, m);
if (resource != null) {
treeViewer.expandToLevel(resource, 1);
if (DEBUG) {
System.out.println("Selecting:" + resource);
}
paths.add(new TreePath(getCompletPath(resource).toArray()));
}
}
treeViewer.setSelection(new TreeSelection(paths.toArray(new TreePath[0])), true);
} catch (Exception e) {
Log.log(e);
}
}