private void handleLoadDetail(final MapItem mi) { String filter = "id = " + mi.getId(); mDataService.get( MapItem.class.getName(), filter, true, new AsyncCallback<List<?>>() { @Override public void onSuccess(List<?> result) { if (result.size() == 1) { // onStartEditing((MapItem) result.get(0)); showMapItemEdit((MapItem) result.get(0)); } else { mMapController.finishWorking(true); NotificationDialog.show( "Should return only 1 record!", NotificationDialog.NotificationType.Warning); } } @Override public void onFailure(Throwable caught) { NotificationDialog.show(caught); mMapController.finishWorking(true); } }); }
public void onFinishAddingStar(final Star s) { setStarButton(false); mDataService.processStar( s, DataService.ADD, new AsyncCallback<Star>() { @Override public void onSuccess(Star result) { onAddedStar(result); } @Override public void onFailure(Throwable caught) { NotificationDialog.show(caught); } }); }
/** * Called only if data model is valid * * @throws ValidationException */ public void onSavingItem() throws ValidationException { if (!mDisplay.validate()) throw new ValidationException("Map Item validation"); MapItem item = mDisplay.getDataModel().getValue(); setLeftButton(false, "save", DrifMaps.Words.Saving()); int operation = (item.getId() == 0) ? DataService.ADD : DataService.UPDATE; mDataService.processMapItem( item, operation, new AsyncCallback<MapItem>() { @Override public void onSuccess(MapItem result) { onSavedItem(result); } @Override public void onFailure(Throwable caught) { setLeftButton(true, "save", DrifMaps.Words.Save()); NotificationDialog.show(caught); } }); }