use of com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDFormLayout in project cuba by cuba-platform.
the class DefaultFormLayoutDropHandler method handleComponentReordering.
/*
* (non-Javadoc)
*
* @see
* com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.AbstractDefaultLayoutDropHandler
* #handleComponentReordering(com.vaadin.event.dd.DragAndDropEvent)
*/
@Override
protected void handleComponentReordering(DragAndDropEvent event) {
LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
FormLayoutTargetDetails details = (FormLayoutTargetDetails) event.getTargetDetails();
DDFormLayout layout = (DDFormLayout) details.getTarget();
Component comp = transferable.getComponent();
int idx = details.getOverIndex();
int oldIdx = layout.getComponentIndex(comp);
if (idx == oldIdx) {
// Dropping on myself
return;
}
// Detach
layout.removeComponent(comp);
if (idx > 0 && idx > oldIdx) {
idx--;
}
// Increase index if component is dropped after or above a previous
// component
VerticalDropLocation loc = details.getDropLocation();
if (loc == VerticalDropLocation.MIDDLE || loc == VerticalDropLocation.BOTTOM) {
idx++;
}
// Add component
if (idx >= 0) {
layout.addComponent(comp, idx);
} else {
layout.addComponent(comp);
}
// Add component alignment if given
if (dropAlignment != null) {
layout.setComponentAlignment(comp, dropAlignment);
}
}
Aggregations