Search in sources :

Example 16 with VoidResult

use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.

the class ReportGridPanel method delete.

private void delete() {
    final ReportMetadataDTO report = grid.getSelectionModel().getSelectedItem();
    MessageBox.confirm(I18N.CONSTANTS.delete(), I18N.MESSAGES.confirmDeleteReport(report.getTitle()), new Listener<MessageBoxEvent>() {

        @Override
        public void handleEvent(MessageBoxEvent be) {
            if (be.getButtonClicked().getItemId().equals(Dialog.YES)) {
                dispatcher.execute(new DeleteReport(report.getId()), new MaskingAsyncMonitor(ReportGridPanel.this, I18N.CONSTANTS.delete()), new AsyncCallback<VoidResult>() {

                    @Override
                    public void onFailure(Throwable caught) {
                    // handled by monitor
                    }

                    @Override
                    public void onSuccess(VoidResult result) {
                        grid.getStore().remove(report);
                    }
                });
            }
        }
    });
}
Also used : VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) DeleteReport(org.activityinfo.legacy.shared.command.DeleteReport) ReportMetadataDTO(org.activityinfo.legacy.shared.model.ReportMetadataDTO)

Example 17 with VoidResult

use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.

the class BoundLocationSection method save.

@Override
public void save(final AsyncCallback<Void> callback) {
    if (isDirty()) {
        newLocation();
        dispatcher.execute(new CreateLocation(location), new AsyncCallback<VoidResult>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(VoidResult result) {
                callback.onSuccess(null);
            }
        });
    } else {
        callback.onSuccess(null);
    }
}
Also used : CreateLocation(org.activityinfo.legacy.shared.command.CreateLocation) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult)

Example 18 with VoidResult

use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.

the class UpdateTargetValueHandler method execute.

@Override
public CommandResult execute(UpdateTargetValue cmd, User user) throws CommandException {
    Double newValue = cmd.getChanges().get("value");
    TargetValue targetValue = entityManager().find(TargetValue.class, new TargetValueId(cmd.getTargetId(), cmd.getIndicatorId()));
    if (targetValue == null) {
        if (newValue != null) {
            // Need a new record
            Target target = entityManager().find(Target.class, cmd.getTargetId());
            Indicator indicator = entityManager().find(Indicator.class, cmd.getIndicatorId());
            targetValue = new TargetValue();
            targetValue.setId(new TargetValueId(cmd.getTargetId(), cmd.getIndicatorId()));
            targetValue.setValue(cmd.getChanges().get("value"));
            targetValue.setTarget(target);
            targetValue.setIndicator(indicator);
            entityManager().persist(targetValue);
        }
    } else {
        targetValue.setValue(newValue);
    }
    return new VoidResult();
}
Also used : UpdateTargetValue(org.activityinfo.legacy.shared.command.UpdateTargetValue) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult)

Example 19 with VoidResult

use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.

the class DbProjectEditor method onEdit.

@Override
protected void onEdit(final ProjectDTO model) {
    final ProjectDTO copy = new ProjectDTO();
    copy.setProperties(model.getProperties());
    final FormDialogImpl<ProjectForm> dialog = new FormDialogImpl<ProjectForm>(new ProjectForm()) {

        @Override
        public void onCancel() {
            model.setProperties(copy.getProperties());
        }
    };
    dialog.setWidth(450);
    dialog.setHeight(300);
    dialog.getForm().getBinding().bind(model);
    List<ProjectDTO> allowed = Lists.newArrayList(store.getModels());
    allowed.remove(model);
    dialog.getForm().getNameField().setValidator(new UniqueNameValidator(allowed));
    dialog.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            service.execute(RequestChange.update(model, "name", "description"), dialog, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                // handled by monitor
                }

                @Override
                public void onSuccess(VoidResult result) {
                    dialog.hide();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    view.refresh();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ProjectForm(org.activityinfo.ui.client.page.config.form.ProjectForm) FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) UniqueNameValidator(org.activityinfo.ui.client.page.config.design.UniqueNameValidator)

Example 20 with VoidResult

use of org.activityinfo.legacy.shared.command.result.VoidResult in project activityinfo by bedatadriven.

the class DbUserEditorActions method showDialog.

private void showDialog(final UserForm form, final boolean newUser) {
    final FormDialogImpl dlg = new FormDialogImpl(form);
    dlg.setHeadingText(newUser ? I18N.CONSTANTS.newUser() : I18N.CONSTANTS.editUser());
    dlg.setWidth(400);
    dlg.setHeight(300);
    dlg.getCancelButton().addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent buttonEvent) {
            panel.setModified(false);
        }
    });
    final String host = Window.Location.getHostName();
    dlg.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            try {
                UpdateUserPermissions command = new UpdateUserPermissions(db, form.getUser(), host);
                command.setNewUser(newUser);
                dispatcher.execute(command, new AsyncCallback<VoidResult>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        if (caught instanceof UserExistsException) {
                            MessageBox.alert(I18N.CONSTANTS.userExistsTitle(), I18N.CONSTANTS.userExistsMessage(), null);
                        } else {
                            MessageBox.alert(I18N.CONSTANTS.serverError(), I18N.CONSTANTS.errorUnexpectedOccured(), null);
                        }
                    }

                    @Override
                    public void onSuccess(VoidResult result) {
                        loader.load();
                        panel.setModified(false);
                        dlg.hide();
                    }
                });
            } catch (FolderAssignmentException excp) {
                MessageBox.alert(I18N.CONSTANTS.noFolderAssignmentTitle(), excp.getMessage(), null);
            } catch (PermissionAssignmentException excp) {
                MessageBox.alert(I18N.CONSTANTS.permissionAssignmentErrorTitle(), excp.getMessage(), null);
            }
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) PermissionAssignmentException(org.activityinfo.ui.client.page.config.form.PermissionAssignmentException) UserExistsException(org.activityinfo.legacy.shared.command.result.UserExistsException) FolderAssignmentException(org.activityinfo.ui.client.page.config.form.FolderAssignmentException) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

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