I am trying to use the DragDropLayout Addon. Using the grid layout demo from John Ahlroos, I find that when you drop a component on another component it gets deleted from the layout. I would have thought that the other components on the layout would have gotten reordered.
In the addon, I was just using the DefaultGridLayoutDropHandler(). I ended up just creating my own drop handler that would not allow a drop ontop of another component.
grid.setDropHandler(new DropHandler()
{
private static final long serialVersionUID = 1L;
/*
* Don't allow a drop onto another component
*
*/
@Override
public void drop(DragAndDropEvent event)
{
GridLayoutTargetDetails details = (GridLayoutTargetDetails) event.getTargetDetails();
// If there is no component there already drop it there or else don't do anything
if (((DDGridLayout)details.getTarget()).getComponent(details.getOverColumn(), details.getOverRow()) == null)
{
LayoutBoundTransferable transferable = (LayoutBoundTransferable)event.getTransferable();
Component c = transferable.getComponent();
((ComponentContainer)c.getParent()).removeComponent(c);
((DDGridLayout)details.getTarget()).addComponent(c,details.getOverColumn(),details.getOverRow());
}
}
@Override
public AcceptCriterion getAcceptCriterion()
{
return AcceptAll.get();
}
});
It can be taken much further where the components are then shifted to allow for the drop if a component is aready present.