Search in sources :

Example 11 with VoidResult

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

the class DesignTest method testDelete.

@Test
public void testDelete() {
    // Dummy Data
    SchemaDTO schema = DTOs.pear();
    // Collaborator
    DispatcherStub service = new DispatcherStub();
    service.setResult(GetSchema.class, schema);
    service.setResult(Delete.class, new VoidResult());
    // Collaborator
    DesignPresenter.View view = createNiceMock(DesignPresenter.View.class);
    expect(view.getSelection()).andReturn(schema.getActivityById(91));
    view.confirmDeleteSelected(isA(ConfirmCallback.class));
    expectLastCall().andAnswer(new IAnswer<Object>() {

        @Override
        public Object answer() throws Throwable {
            ((ConfirmCallback) getCurrentArguments()[0]).confirmed();
            return null;
        }
    });
    replay(view);
    // Collaborator
    UIConstants constants = createNiceMock(UIConstants.class);
    replay(constants);
    DesignPresenter designer = new DesignPresenter(new MockEventBus(), service, new StateManagerStub(), view, constants);
    designer.go(schema.getDatabaseById(1));
    // Verify that the proper delete command executes
    designer.onUIAction(UIActions.DELETE);
    Delete cmd = service.getLastExecuted(Delete.class);
    Assert.assertEquals("Activity", cmd.getEntityName());
    Assert.assertEquals(91, cmd.getId());
}
Also used : Delete(org.activityinfo.shared.command.Delete) ConfirmCallback(org.activityinfo.client.page.common.grid.ConfirmCallback) VoidResult(org.activityinfo.shared.command.result.VoidResult) DispatcherStub(org.activityinfo.client.dispatch.DispatcherStub) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) MockEventBus(org.activityinfo.client.MockEventBus) UIConstants(org.activityinfo.client.i18n.UIConstants) StateManagerStub(org.activityinfo.client.mock.StateManagerStub) Test(org.junit.Test)

Example 12 with VoidResult

use of org.activityinfo.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, 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) {
                }

                @Override
                public void onSuccess(VoidResult result) {
                    PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
                    dto.setPartner(partner);
                    ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
                    dto.setProject(project);
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) VoidResult(org.activityinfo.shared.command.result.VoidResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) Record(com.extjs.gxt.ui.client.store.Record)

Example 13 with VoidResult

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

the class DbUserEditor method delete.

private void delete() {
    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(this, I18N.CONSTANTS.deleting()), new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(VoidResult result) {
            store.remove(model);
        }
    });
}
Also used : VoidResult(org.activityinfo.shared.command.result.VoidResult) UpdateUserPermissions(org.activityinfo.shared.command.UpdateUserPermissions) MaskingAsyncMonitor(org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor) UserPermissionDTO(org.activityinfo.shared.dto.UserPermissionDTO)

Example 14 with VoidResult

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

the class LockedPeriodsPresenter method onConfirmDelete.

@Override
public void onConfirmDelete(ConfirmDeleteEvent deleteEvent) {
    final LockedPeriodDTO lockedPeriod = view.getValue();
    service.execute(new Delete(lockedPeriod), new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
            MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer() + "\n\n" + caught.getMessage(), null);
        }

        @Override
        public void onSuccess(VoidResult result) {
            view.delete(lockedPeriod);
            parentModel.getLockedPeriods().remove(lockedPeriod);
        }
    });
}
Also used : Delete(org.activityinfo.shared.command.Delete) VoidResult(org.activityinfo.shared.command.result.VoidResult) LockedPeriodDTO(org.activityinfo.shared.dto.LockedPeriodDTO)

Example 15 with VoidResult

use of org.activityinfo.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 link = !linkGraph.linked(source, dest);
    linkButton.toggle(link);
    LinkIndicators update = new LinkIndicators();
    update.setLink(link);
    update.setSourceIndicatorId(source.getId());
    update.setDestIndicatorId(dest.getId());
    if (link) {
        linkGraph.link(sourceDatabaseGrid.getSelectedItem(), source, destDatabaseGrid.getSelectedItem(), dest);
    } else {
        linkGraph.unlink(source, dest);
    }
    destDatabaseGrid.setLinked(linkGraph.destDatabases());
    sourceDatabaseGrid.setLinked(linkGraph.sourceDatabases());
    onDatabaseLinksChanged();
    dispatcher.execute(update, new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(VoidResult result) {
            Info.display(I18N.CONSTANTS.saved(), link ? "Link created" : "Link removed");
        }
    });
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) VoidResult(org.activityinfo.shared.command.result.VoidResult) LinkIndicators(org.activityinfo.shared.command.LinkIndicators)

Aggregations

VoidResult (org.activityinfo.shared.command.result.VoidResult)26 Record (com.extjs.gxt.ui.client.store.Record)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)4 MockEventBus (org.activityinfo.client.MockEventBus)4 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)4 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 UIConstants (org.activityinfo.client.i18n.UIConstants)4 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)4 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)4 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)4 Test (org.junit.Test)4 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)3 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)2 FormDialogImpl (org.activityinfo.client.page.common.dialog.FormDialogImpl)2 Delete (org.activityinfo.shared.command.Delete)2 UpdateMonthlyReports (org.activityinfo.shared.command.UpdateMonthlyReports)2 UpdateReportSubscription (org.activityinfo.shared.command.UpdateReportSubscription)2 UpdateUserPermissions (org.activityinfo.shared.command.UpdateUserPermissions)2 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)2 CommandException (org.activityinfo.shared.exception.CommandException)2