/** * Propagates the changes on the target node to the next level above of * the hierarchy. If the updated node is no longer defined, it can even * be removed from its parent. Otherwise, it is just replaced. * * @param target the target node for this operation * @param node the resulting node after applying all operations * @param level the level of the target node */ private void propagateChange(final ImmutableNode target, final ImmutableNode node, final int level) { final ImmutableNode parent = getParent(target); final ChildrenUpdateOperation co = new ChildrenUpdateOperation(); if (InMemoryNodeModel.checkIfNodeDefined(node)) { co.addNodeToReplace(target, node); } else { co.addNodeToRemove(target); } fetchOperations(parent, level - 1).addChildrenOperation(co); }
/** * Adds an operation for adding a number of new children to a given parent * node. * * @param parent the parent node * @param newNodes the collection of new child nodes */ public void addAddNodesOperation(final ImmutableNode parent, final Collection<? extends ImmutableNode> newNodes) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNewNodes(newNodes); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * Adds an operation for removing a child node of a given node. * * @param parent the parent node * @param node the child node to be removed */ public void addRemoveNodeOperation(final ImmutableNode parent, final ImmutableNode node) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNodeToRemove(node); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * Adds an operation for adding a new child to a given parent node. * * @param parent the parent node * @param newChild the new child to be added */ public void addAddNodeOperation(final ImmutableNode parent, final ImmutableNode newChild) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNewNode(newChild); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }