use of org.eclipse.che.ide.ui.smartTree.event.StoreRemoveEvent in project che by eclipse.
the class NodeStorage method remove.
public boolean remove(Node node) {
NodeDescriptor nodeDescriptor = idToNodeMap.get(getKeyProvider().getKey(node));
if (nodeDescriptor != null) {
Node parent = getParent(node);
List<Node> children = getAllChildren(node);
int visibleIndex = nodeDescriptor.getParent().getChildren().indexOf(nodeDescriptor);
nodeDescriptor.getParent().remove(nodeDescriptor);
if (visibleIndex != -1) {
fireEvent(new StoreRemoveEvent(visibleIndex, node, parent, children));
} else {
List<NodeDescriptor> descriptors = new LinkedList<>();
descriptors.add(nodeDescriptor);
for (int i = 0; i < descriptors.size(); i++) {
nodeDescriptor = descriptors.get(i);
descriptors.addAll(nodeDescriptor.getChildren());
idToNodeMap.remove(getKeyProvider().getKey(nodeDescriptor.getNode()));
}
}
return true;
}
return false;
}
use of org.eclipse.che.ide.ui.smartTree.event.StoreRemoveEvent in project che by eclipse.
the class NodeStorage method removeChildren.
private void removeChildren(NodeDescriptor parent) {
if (parent.getChildren().size() != 0) {
List<NodeDescriptor> models = new LinkedList<>();
models.addAll(parent.getChildren());
parent.clear();
for (int i = 0; i < models.size(); i++) {
NodeDescriptor wrapper = models.get(i);
models.addAll(wrapper.getChildren());
List<Node> children = getAllChildren(wrapper.getNode());
idToNodeMap.remove(getKeyProvider().getKey(wrapper.getNode()));
if (wrapper.getParent() == parent) {
fireEvent(new StoreRemoveEvent(0, wrapper.getNode(), parent.getNode(), children));
}
}
}
}
Aggregations