private void getAllChildren(TreeNode<?> parent, List<TreeNode<?>> children) { List<TreeNode<?>> childrenForCurrentDeep = parent.getChildren(); if (childrenForCurrentDeep.isEmpty()) { return; } children.addAll(childrenForCurrentDeep); for (TreeNode<?> node : childrenForCurrentDeep) { getAllChildren(node, children); } }
private void updateDataTreeNode( final StorableNode parent, final String renamedNodeNewPath, final Iterator<TreeNode<?>> children) { if (!children.hasNext()) { eventBus.fireEvent(NodeChangedEvent.createNodeRenamedEvent(parent.getParent())); return; } TreeNode treeNode = children.next(); if (treeNode instanceof UpdateTreeNodeDataIterable && treeNode instanceof StorableNode) { String newPath = solveNewPath(renamedNodeNewPath, ((StorableNode) treeNode).getPath()); if (treeNode.equals(parent)) { newPath = renamedNodeNewPath; } ((UpdateTreeNodeDataIterable) treeNode) .updateData( new AsyncCallback<Void>() { @Override public void onSuccess(Void aVoid) { updateDataTreeNode(parent, renamedNodeNewPath, children); } @Override public void onFailure(Throwable throwable) { Log.error(getClass(), "Error update treeNode data " + throwable); // eventBus.fireEvent(new RefreshProjectTreeEvent()); } }, newPath); return; } updateDataTreeNode(parent, renamedNodeNewPath, children); }
/** {@inheritDoc} */ @Override public void onNodeExpanded(@NotNull final TreeNode<?> node) { if (node.getChildren().isEmpty()) { // If children is empty then node may be not refreshed yet? node.refreshChildren( new AsyncCallback<TreeNode<?>>() { @Override public void onSuccess(TreeNode<?> result) { if (node instanceof Openable) { ((Openable) node).open(); } if (!result.getChildren().isEmpty()) { updateNode(result); } } @Override public void onFailure(Throwable caught) { Log.error(ProjectExplorerPartPresenter.class, caught); } }); } }
public void refreshNode(TreeNode<?> node, final AsyncCallback<TreeNode<?>> callback) { node.refreshChildren( new AsyncCallback<TreeNode<?>>() { @Override public void onSuccess(TreeNode<?> result) { updateNode(result); callback.onSuccess(result); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); }
/** {@inheritDoc} */ @Override public void onNodeSelected(final TreeNode<?> node, final SelectionModel<?> model) { final List<?> allSelected = model.getSelectedNodes(); final List<Object> newSelection = new ArrayList<>(); for (final Object item : allSelected) { newSelection.add(item); } if (newSelection.contains(node)) { setSelection(new Selection<>(newSelection, node)); } else { setSelection(new Selection<>(newSelection)); } if (node != null && node instanceof StorableNode && appContext.getCurrentProject() != null) { appContext .getCurrentProject() .setProjectDescription(node.getProject().getProjectDescriptor()); } }
/** {@inheritDoc} */ @Override public void onNodeAction(@NotNull TreeNode<?> node) { node.processNodeAction(); }