Map<String, Object> dataSnapshot = new HashMap<String, Object>();
dataSnapshot.put("form", form);
bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() {
@Override
public void undoAction(UndoableEvent event) {
FormRepresentation form = (FormRepresentation) event.getData("form");
if (form != null) {
try {
service.saveForm(form);
} catch (FormBuilderException e) {
bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.ProblemRestoringForm(), e));
}
}
}
@Override
public void onEvent(UndoableEvent event) { }
@Override
public void doAction(UndoableEvent event) {
FormRepresentation form = (FormRepresentation) event.getData("form");
try {
service.deleteForm(form);
} catch (FormBuilderException e) {
event.setData("form", null);
bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.ProblemDeletingForm(), e));