PDA

View Full Version : Async Tree Drag and drop bug



dhruv.shukla
31 Mar 2011, 2:19 PM
Hello I have an Async Tree ... with a BaseTreeReader and RPCProxy to load the tree nodes.

I am having troubles using drag drop since.. on drop the childrens are getting reloaded again. .. on the drop of a loaded parent.

Any help will be greatly appreciated. Please let me know . if further info is required.

My Drag Drop on tree code is as follows
final TreePanelDropTarget target = new TreePanelDropTarget(tree) {
@Override
protected void showFeedback(DNDEvent event) {
final TreePanel<ModelData>.TreeNode target = tree.findNode(event.getTarget());
if (target != null) {
TreeModel targetData = (TreeModel)target.getModel();
TreeModel sourceData = selectionModel.getSelectedItem();
TreeModel storeSource = store.getParent(sourceData);
TreeModel storeTarget =store.getParent(targetData);
if(storeTarget == null && storeSource == null) {
super.showFeedback(event);
return;
} else {
if(storeSource !=null && storeTarget !=null && storeTarget.equals(storeSource)) {
super.showFeedback(event);
return;
}
}
}
event.getStatus().setStatus(false);
event.setCancelled(true);
Insert.get().hide();
}
@Override
protected void handleInsert(DNDEvent event, final TreeNode item) {
int height = item.getElement().getOffsetHeight();
int mid = height / 2;
int top = item.getElement().getAbsoluteTop();
mid += top;
int y = event.getClientY();
boolean before = y < mid;

if (!item.isLeaf() || isAllowDropOnLeaf()) {
if ((before && y > top + 4) || (!before && y < top + height - 4)) {
event.getStatus().setStatus(false);
event.setCancelled(true);
return;
}
}
super.handleInsert(event, item);
}
};