use of com.vaadin.event.dd.TargetDetails in project cuba by cuba-platform.
the class AbstractDefaultLayoutDropHandler method handleDropFromAbsoluteParentLayout.
/**
* Handles a drop by a component which has an absolute layout as parent. In
* this case the component is moved.
*
* @param event
* The drag and drop event
*/
protected void handleDropFromAbsoluteParentLayout(DragAndDropEvent event) {
LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
TargetDetails details = event.getTargetDetails();
MouseEventDetails mouseDown = transferable.getMouseDownEvent();
MouseEventDetails mouseUp = MouseEventDetails.deSerialize((String) details.getData(Constants.DROP_DETAIL_MOUSE_EVENT));
int movex = mouseUp.getClientX() - mouseDown.getClientX();
int movey = mouseUp.getClientY() - mouseDown.getClientY();
Component comp = transferable.getComponent();
DDAbsoluteLayout parent = (DDAbsoluteLayout) comp.getParent();
ComponentPosition position = parent.getPosition(comp);
if (position.getLeftValue() != null) {
float x = position.getLeftValue() + movex;
position.setLeft(x, Sizeable.UNITS_PIXELS);
}
if (position.getRightValue() != null) {
float x = position.getRightValue() - movex;
position.setRight(x, Sizeable.UNITS_PIXELS);
}
if (position.getTopValue() != null) {
float y = position.getTopValue() + movey;
position.setTop(y, Sizeable.UNITS_PIXELS);
}
if (position.getBottomValue() != null) {
float y = position.getBottomValue() - movey;
position.setBottom(y, Sizeable.UNITS_PIXELS);
}
}
use of com.vaadin.event.dd.TargetDetails in project cuba by cuba-platform.
the class AbstractDefaultLayoutDropHandler method drop.
public void drop(DragAndDropEvent event) {
// Get information about the drop
TargetDetails details = event.getTargetDetails();
DropTarget layout = details.getTarget();
Component source = event.getTransferable().getSourceComponent();
if (event.getTransferable().getData("html5Data") != null) {
handleHTML5Drop(event);
} else if (layout == source) {
handleComponentReordering(event);
} else if (event.getTransferable() instanceof LayoutBoundTransferable) {
LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
Component comp = transferable.getComponent();
if (comp == layout) {
if (comp.getParent() instanceof DDAbsoluteLayout) {
handleDropFromAbsoluteParentLayout(event);
}
} else {
handleDropFromLayout(event);
}
}
}
Aggregations