Search in sources :

Example 1 with VoidResult

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();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) UpdateEntity(org.activityinfo.legacy.shared.command.UpdateEntity) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether) Record(com.extjs.gxt.ui.client.store.Record)

Example 2 with VoidResult

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);
        }
    });
}
Also used : VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO)

Example 3 with VoidResult

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());
        }
    });
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) LinkIndicators(org.activityinfo.legacy.shared.command.LinkIndicators)

Example 4 with VoidResult

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;
}
Also used : UpdateMonthlyReports(org.activityinfo.legacy.shared.command.UpdateMonthlyReports) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) ArrayList(java.util.ArrayList) Promise(org.activityinfo.promise.Promise) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) Record(com.extjs.gxt.ui.client.store.Record)

Example 5 with VoidResult

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);
        }
    });
}
Also used : VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) UpdateReportModel(org.activityinfo.legacy.shared.command.UpdateReportModel)

Aggregations

VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)22 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)4 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)4 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)3 Record (com.extjs.gxt.ui.client.store.Record)2 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)2 UpdateMonthlyReports (org.activityinfo.legacy.shared.command.UpdateMonthlyReports)2 UpdateReportSubscription (org.activityinfo.legacy.shared.command.UpdateReportSubscription)2 UpdateSite (org.activityinfo.legacy.shared.command.UpdateSite)2 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)2 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)2 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)2 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 SafeHtmlUtils.fromString (com.google.gwt.safehtml.shared.SafeHtmlUtils.fromString)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 CreateLocation (org.activityinfo.legacy.shared.command.CreateLocation)1 DeleteReport (org.activityinfo.legacy.shared.command.DeleteReport)1