return AcceptAll.get();
}
@Override
public void drop(DragAndDropEvent event) {
WrapperTargetDetails ed = (WrapperTargetDetails) event
.getTargetDetails();
Transferable transferable = event.getTransferable();
TransferableImpl ctr = (TransferableImpl) transferable;
Component component = ctr.getSourceComponent();
if (component == wrapper) {
// if the drag source was wrapper we are interested about
// the dragged component
WrapperTransferable tr = (WrapperTransferable) transferable;
component = tr.getDraggedComponent();
// html5 drag created by wrapper set component null
}
if (component != null) {
if (component.getParent() != layout) {
if (transferable instanceof DataBoundTransferable) {
// Item has been dragged, construct a Label from
// Item id
Label l = new Label();
l.setSizeUndefined();
l.setValue("ItemId : "
+ ((DataBoundTransferable) transferable)
.getItemId());
layout.addComponent(l);
component = l;
} else {
// we have a component that is been dragged, add
// it to this
layout.addComponent(component);
}
Integer left = ed.getAbsoluteLeft();
Integer top = ed.getAbsoluteTop();
MouseEventDetails eventDetails = ed.getMouseEvent();
int clientX = eventDetails.getClientX();
int clientY = eventDetails.getClientY();
try {
layout.getPosition(component).setTopValue(
Float.valueOf(clientY - top));
layout.getPosition(component).setLeftValue(
Float.valueOf(clientX - left));
} catch (Exception e) {
// TODO: handle exception
}
} else {
WrapperTransferable tr = (WrapperTransferable) transferable;
// drag ended inside the this Pane
MouseEventDetails start = tr.getMouseDownEvent();
MouseEventDetails eventDetails = ed.getMouseEvent();
int deltaX = eventDetails.getClientX()
- start.getClientX();
int deltaY = eventDetails.getClientY()
- start.getClientY();