if (formItem != null) {
bus.fireEvent(new FormItemRemovedEvent(formItem));
HasWidgets dropContainer = layoutView.getUnderlyingLayout(x, y);
Widget previousContainer = formItem.getParent();
if (previousContainer instanceof FBForm) {
FBForm formDisplay = (FBForm) previousContainer;
formDisplay.remove(movable);
formDisplay.remove(formItem);
} else {
LayoutFormItem layoutItem = (LayoutFormItem) ((Widget) previousContainer).getParent();
layoutItem.remove(movable);
layoutItem.remove(formItem);
}
if (dropContainer instanceof FBForm) {
FBForm formDisplay = (FBForm) dropContainer;
formDisplay.replacePhantom(formItem);
} else {
LayoutFormItem layoutItem = (LayoutFormItem) ((Widget) dropContainer).getParent();
layoutItem.replacePhantom(formItem);
}
bus.fireEvent(new FormItemAddedEvent(formItem, (Widget) dropContainer));