String clientId = tree.getClientId(context);
String dragNodeRowKey = params.get(clientId + "_dragNode");
String dropNodeRowKey = params.get(clientId + "_dropNode");
String dragSource = params.get(clientId + "_dragSource");
int dndIndex = Integer.parseInt(params.get(clientId + "_dndIndex"));
TreeNode dragNode;
TreeNode dropNode;
if(dragSource.equals(clientId)) {
tree.setRowKey(dragNodeRowKey);
dragNode = tree.getRowNode();
}
else {
Tree otherTree = (Tree) tree.findComponent(":" + dragSource);
otherTree.setRowKey(dragNodeRowKey);
dragNode = otherTree.getRowNode();
}
if(isValueBlank(dropNodeRowKey)) {
dropNode = tree.getValue();
}
else {
tree.setRowKey(dropNodeRowKey);
dropNode = tree.getRowNode();
}
tree.setDragNode(dragNode);
tree.setDropNode(dropNode);
if(dndIndex >= 0 && dndIndex < dropNode.getChildCount())
dropNode.getChildren().add(dndIndex, dragNode);
else
dropNode.getChildren().add(dragNode);
}