use of org.eclipse.che.ide.ui.smartTree.event.PostLoadEvent.PostLoadHandler in project che by eclipse.
the class TreeResourceRevealer method expand.
protected void expand(final ResourceNode parent, final Path segment, final boolean select, final AsyncCallback<ResourceNode> callback) {
if (parent.getData().getLocation().equals(segment)) {
if (select) {
if (toSelect == null) {
toSelect = new Node[] { parent };
} else {
final int index = toSelect.length;
toSelect = copyOf(toSelect, index + 1);
toSelect[index] = parent;
}
selectTask.delay(200);
}
callback.onSuccess(parent);
return;
}
final HandlerRegistration[] handler = new HandlerRegistration[1];
handler[0] = tree.getNodeLoader().addPostLoadHandler(new PostLoadHandler() {
@Override
public void onPostLoad(PostLoadEvent event) {
if (!event.getRequestedNode().equals(parent)) {
return;
}
if (handler[0] != null) {
handler[0].removeHandler();
}
final List<Node> children = tree.getNodeStorage().getChildren(event.getRequestedNode());
for (Node child : children) {
if (child instanceof ResourceNode && ((ResourceNode) child).getData().getLocation().isPrefixOf(segment)) {
expand((ResourceNode) child, segment, select, callback);
return;
}
}
callback.onFailure(new IllegalStateException("Not found"));
}
});
tree.getNodeLoader().loadChildren(parent);
}
Aggregations