moveFormItem(drag, x, y);
}
}
private void addMenuItem(Widget drag, int x, int y) {
FBMenuItem menuItem = (FBMenuItem) drag;
FBFormItem formItem = menuItem.buildWidget();
formItem.setDesiredPosition(x, y);
Map<String, Object> dataSnapshot = new HashMap<String, Object>();
dataSnapshot.put("formItem", formItem);
dataSnapshot.put("menuItem", menuItem);
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));
}
@Override
public void doAction(UndoableEvent event) {
FBFormItem formItem = (FBFormItem) event.getData("formItem");
FBMenuItem menuItem = (FBMenuItem) event.getData("menuItem");
Integer x = (Integer) event.getData("x");
Integer y = (Integer) event.getData("y");
if (formItem != null) {
HasWidgets panel = layoutView.getUnderlyingLayout(x, y);
if (panel instanceof FBForm) {