One thing I can think of (at least I didn’t see it in your code) is that you are not detaching the custom component from the grid layout before attaching it to the horizontal layout. At least for me this example works:
DDGridLayout grid = new DDGridLayout();
grid.setDragMode(LayoutDragMode.CLONE);
DDHorizontalLayout horizontal = new DDHorizontalLayout();
horizontal.setDropHandler(new DropHandler() {
public AcceptCriterion getAcceptCriterion() {
return AcceptAll.get();
}
public void drop(DragAndDropEvent event) {
LayoutBoundTransferable transferable = (LayoutBoundTransferable)event.getTransferable();
HorizontalLayoutTargetDetails details = (HorizontalLayoutTargetDetails) event.getTargetDetails();
Component c = transferable.getComponent();
// Detach from parent layout
((ComponentContainer)c.getParent()).removeComponent(c);
// Add to target layout (ignores position)
((DDHorizontalLayout)details.getTarget()).addComponent(c);
}
});
With the addon comes a default implementation of a DDHorizontalLayout drophandler,
DefaultHorizontalLayoutDropHandler , which does this and also takes into consideration the drop location and special cases. Take a look at it for an example.
Note: The released version of DefaultHorizontalLayoutDropHandler.java (0.6.3) contains a couple of typos which has been fixed after the release so don’t use it directly, instead use the version in the repository. The fixed version will be included in the next release (0.6.4)
DragDroplayouts contains client side GWT code that needs to be compiled into the widgetset. If you want to use it you need to replace DefaultWidgetset with your own widgetset.