*/
public Node beforeDecode(mxCodec dec, Node node, Object into)
{
if (into instanceof mxChildChange)
{
mxChildChange change = (mxChildChange) into;
if (node.getFirstChild() != null
&& node.getFirstChild().getNodeType() == Node.ELEMENT_NODE)
{
// Makes sure the original node isn't modified
node = node.cloneNode(true);
Node tmp = node.getFirstChild();
change.setChild(dec.decodeCell(tmp, false));
Node tmp2 = tmp.getNextSibling();
tmp.getParentNode().removeChild(tmp);
tmp = tmp2;
while (tmp != null)
{
tmp2 = tmp.getNextSibling();
if (tmp.getNodeType() == Node.ELEMENT_NODE)
{
// Ignores all existing cells because those do not need
// to be re-inserted into the model. Since the encoded
// version of these cells contains the new parent, this
// would leave to an inconsistent state on the model
// (ie. a parent change without a call to
// parentForCellChanged).
String id = ((Element) tmp).getAttribute("id");
if (dec.lookup(id) == null)
{
dec.decodeCell(tmp, true);
}
}
tmp.getParentNode().removeChild(tmp);
tmp = tmp2;
}
}
else
{
String childRef = ((Element) node).getAttribute("child");
change.setChild((mxICell) dec.getObject(childRef));
}
}
return node;
}