@Override
public void commitChildChanges(ValueNode oldChild, ValueNode newChild) {
// Get the copy of the current value node, type switched if necessary.
NTupleValueNode oldValueNode = (NTupleValueNode)getValueNode();
NTupleValueNode newValueNode;
if (!oldChild.getTypeExpr().sameType(newChild.getTypeExpr())) {
Map<ValueNode, TypeExpr> valueNodeToUnconstrainedTypeMap = getValueNodeToUnconstrainedTypeMap();
Map<ValueNode, ValueNode> commitValueMap = valueEditorManager.getValueNodeCommitHelper().getCommitValues(oldChild, newChild, valueNodeToUnconstrainedTypeMap);
newValueNode = (NTupleValueNode)commitValueMap.get(oldValueNode);
} else {
newValueNode = (NTupleValueNode)oldValueNode.copyValueNode();
}
// Modify the new value node so that the old child is replaced by the new child.
// Note that the cell editor may now be editing a different column so we have to search for the row that changed
// This can happen if one clicks from an editor for one cell to another cell
// (eg. in a list of colours, from a colour value editor for one cell, onto the cell editor for another cell.)
List<ValueNode> currentChildrenList = oldValueNode.getValue();
for (int i = 0, listSize = newValueNode.getTupleSize(); i < listSize; i++) {
if (currentChildrenList.get(i) == oldChild) {
TypeExpr childType = newValueNode.getValueAt(i).getTypeExpr();
newValueNode.setValueNodeAt(i, newChild.copyValueNode(childType));
break;
}
}
// Set the value node