/** {@inheritDoc} */ @Override public String convert(Node node) { return node.getName(); } }
/** Returns {@code true} if given node is nested in given parent. */ private boolean nestedNodeOf(Node node, Node parent) { while (node != null) { node = node.getParent(); if (parent.equals(node)) { return true; } } return false; }
@Override public boolean isNodeValid(Node node) { return !node.isLeaf(); }
private boolean isNodeSupportGoInto(Object node) { return node instanceof Node && ((Node) node).supportGoInto(); } }
/** * Check if node has children. This method make a request to server to read children count. * * @param node node * @return true if node has children, otherwise false */ public Promise<Boolean> hasChildren(@NotNull Node node) { return node.getChildren(false).thenPromise(children -> Promises.resolve(!children.isEmpty())); }
@Override public List<Node> apply(List<Node> children) throws FunctionException { if (children == null) { setChildren(Collections.<Node>emptyList()); return Collections.emptyList(); } for (Node node : children) { node.setParent(AbstractTreeNode.this); } setChildren(children); return children; } };
getTransitFolderName(allFolders, path), Path.valueOf(path), nodesResources); if (currentChildNodes.keySet().contains(path)) { folder.setChildren(currentChildNodes.get(path)); return nodesToNest; } else { preparedNodes.get(parentPath).setChildren(nodesToNest);
public boolean isLeaf() { return node.isLeaf(); }
/** {@inheritDoc} */ public boolean activate(Node node) { if (!node.supportGoInto()) { return false; } // save node this.node = node; // save root nodes rootNodes = tree.getRootNodes(); // reset selection tree.getSelectionModel().deselectAll(); Element rootContainer = tree.getContainer(null); rootContainer.setInnerHTML(""); rootContainer.appendChild(tree.getNodeDescriptor(node).getRootContainer()); // if go into node is collapsed - then we need to expand it if (!tree.getNodeDescriptor(node).isExpanded()) { tree.setExpanded(node, true); } // then select go into node tree.getSelectionModel().select(node, false); tree.update(); fireEvent(new GoIntoStateEvent(ACTIVATED, node)); return active = true; }
/** * Initiates a load request for the parent's children. Also fire {@link * org.eclipse.che.ide.ui.smartTree.event.BeforeLoadEvent} event. * * @param parent parent node * @return true if load was requested, otherwise false */ private boolean doLoad(@NotNull final Node parent) { if (fireEvent(new BeforeLoadEvent(parent))) { lastRequest = parent; parent .getChildren(!useCaching) .then(interceptChildren(parent)) .catchError(onLoadFailure(parent)); return true; } return false; }
private void iterate( final LinkedList<NodeInterceptor> deque, final Node parent, final List<Node> children) { if (deque.isEmpty()) { for (Node child : children) { child.setParent(parent); } onLoadSuccess(parent, children); return; } NodeInterceptor interceptor = deque.poll(); interceptor .intercept(parent, children) .then( childrenList -> { iterate(deque, parent, childrenList); }); }
/** * Returns true if checked node is leaf. * * @param node node to check * @return true if node is leaf, otherwise false */ public boolean isLeaf(Node node) { checkNotNull(node, NULL_NODE_MSG); return node.isLeaf(); }
@Override public boolean isNodeValid(Node node) { return node.getName().endsWith(JAR); }
if (!parent.isLeaf() && event.getReceivedNodes().isEmpty()) { tree.getView().onJointChange(tree.getNodeDescriptor(parent), Joint.EXPANDED); for (NodeDescriptor removed : removedNodes) { if (!tree.getNodeStorage().remove(removed.getNode())) { Log.info(this.getClass(), "Failed to remove node: " + removed.getNode().getName());
/** * Checks whether node has children or not. This method may allow tree to determine whether to * show expand control near non-leaf node. * * @param parent node * @return true if node has children, otherwise false */ public boolean mayHaveChildren(@NotNull Node parent) { return !parent.isLeaf(); }
private void updateSavedNodes(Node parent, List<Node> children) { List<Node> savedChildren = savedNodes .stream() .filter(node -> node.getParent() != null && node.getParent().equals(parent)) .collect(toList()); if (savedChildren.size() == children.size()) { savedChildren.forEach( node -> { int i = savedNodes.indexOf(node); savedNodes.remove(node); savedNodes.add(i, children.get(savedChildren.indexOf(node))); }); } }