}));
}
private void moveFormItem(Widget drag, int x, int y) {
MovablePanel movable = (MovablePanel) drag;
FBFormItem formItem = (FBFormItem) movable.getOldContainer();
formItem.setDesiredPosition(x, y);
Map<String, Object> dataSnapshot = new HashMap<String, Object>();
dataSnapshot.put("formItem", formItem);
dataSnapshot.put("movable", movable);
dataSnapshot.put("oldMovableX", movable.getAbsoluteLeft());
dataSnapshot.put("oldMovableY", movable.getAbsoluteTop());
dataSnapshot.put("x", x);
dataSnapshot.put("y", y);
this.bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
@Override
public void onEvent(UndoableEvent event) { }
@Override
public void undoAction(UndoableEvent event) {
FBFormItem formItem = (FBFormItem) event.getData("formItem");
Integer x = (Integer) event.getData("x");
Integer y = (Integer) event.getData("y");
HasWidgets panel = layoutView.getUnderlyingLayout(x, y);
panel.remove(formItem);
bus.fireEvent(new FormItemRemovedEvent(formItem));
Integer oldX = (Integer) event.getData("oldMovableX");
Integer oldY = (Integer) event.getData("oldMovableY");
HasWidgets panel2 = layoutView.getUnderlyingLayout(oldX, oldY);
panel2.add(formItem);
bus.fireEvent(new FormItemAddedEvent(formItem, (Widget) panel2));
}
@Override
public void doAction(UndoableEvent event) {
FBFormItem formItem = (FBFormItem) event.getData("formItem");
MovablePanel movable = (MovablePanel) event.getData("movable");
Integer x = (Integer) event.getData("x");
Integer y = (Integer) event.getData("y");
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 {