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());
}
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();
}
});
}
});
}
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);
}
});
}
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);
}
});
}
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");
}
});
}
Aggregations