use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.
the class DbTargetEditor method onEdit.
@Override
protected void onEdit(final TargetDTO dto) {
this.view.showAddDialog(dto, db, true, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
final Record record = store.getRecord(dto);
service.execute(new UpdateEntity(dto, getChangedProperties(record)), dlg, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
Log.error("Failed to edit target. " + caught.getMessage(), caught);
}
@Override
public void onSuccess(VoidResult result) {
if (record.get("partnerId") != null) {
PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
dto.setPartner(partner);
} else {
dto.setPartner(null);
}
if (record.get("projectId") != null) {
ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
dto.setProject(project);
} else {
dto.setProject(null);
}
store.commitChanges();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.
the class DbUserEditorActions method delete.
public void delete() {
panel.setModified(true);
final UserPermissionDTO model = grid.getSelectionModel().getSelectedItem();
model.setAllowView(false);
model.setAllowViewAll(false);
model.setAllowEdit(false);
model.setAllowEditAll(false);
model.setAllowDesign(false);
model.setAllowManageAllUsers(false);
model.setAllowManageUsers(false);
dispatcher.execute(new UpdateUserPermissions(db.getId(), model), new MaskingAsyncMonitor(panel, I18N.CONSTANTS.deleting()), new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
panel.setModified(false);
}
@Override
public void onSuccess(VoidResult result) {
store.remove(model);
panel.setModified(false);
}
});
}
use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.
the class IndicatorLinkPage method onToggleLink.
protected void onToggleLink() {
IndicatorDTO source = sourceIndicatorGrid.getSelectedItem();
IndicatorDTO dest = destIndicatorGrid.getSelectedItem();
final boolean isLinked = !linkGraph.linked(source, dest);
linkButton.toggle(isLinked);
LinkIndicators updateCommand = new LinkIndicators();
updateCommand.setLink(isLinked);
updateCommand.setSourceIndicatorId(source.getId());
updateCommand.setDestIndicatorId(dest.getId());
if (isLinked) {
linkGraph.link(sourceDatabaseGrid.getSelectedItem(), source, destDatabaseGrid.getSelectedItem(), dest);
} else {
linkGraph.unlink(source, dest);
}
destDatabaseGrid.setLinked(linkGraph.destDatabases());
sourceDatabaseGrid.setLinked(linkGraph.sourceDatabases());
onDatabaseLinksChanged();
dispatcher.execute(updateCommand, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
Log.error(caught.getMessage(), caught);
}
@Override
public void onSuccess(VoidResult result) {
Info.displayText(I18N.CONSTANTS.saved(), isLinked ? I18N.CONSTANTS.linkCreated() : I18N.CONSTANTS.linkRemoved());
}
});
}
use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.
the class MonthlyReportsPanel method save.
public Promise<Void> save() {
ArrayList<UpdateMonthlyReports.Change> changes = new ArrayList<>();
for (Record record : store.getModifiedRecords()) {
IndicatorRowDTO report = (IndicatorRowDTO) record.getModel();
for (String property : record.getChanges().keySet()) {
UpdateMonthlyReports.Change change = new UpdateMonthlyReports.Change();
change.setIndicatorId(report.getIndicatorId());
change.setMonth(IndicatorRowDTO.monthForProperty(property));
change.setValue(report.get(property));
changes.add(change);
}
}
final Promise<Void> promise = new Promise<>();
service.execute(new UpdateMonthlyReports(currentSiteId, changes), new MaskingAsyncMonitor(this, I18N.CONSTANTS.saving()), new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
promise.onFailure(caught);
}
@Override
public void onSuccess(VoidResult result) {
store.commitChanges();
promise.onSuccess(null);
}
});
return promise;
}
use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.
the class ReportDesignPage method performUpdate.
private void performUpdate(final AsyncMonitor monitor, final AsyncCallback<VoidResult> callback) {
UpdateReportModel updateReport = new UpdateReportModel();
updateReport.setModel(currentModel);
dispatcher.execute(updateReport, monitor, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(final Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(final VoidResult result) {
dirty = false;
callback.onSuccess(result);
}
});
}
Aggregations