use of org.activityinfo.ui.client.page.common.dialog.FormDialogTether 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.ui.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class DbTargetEditor method onAdd.
@Override
protected void onAdd() {
final TargetDTO newTarget = new TargetDTO();
this.view.showAddDialog(newTarget, db, false, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddTarget(db.getId(), newTarget), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
}
@Override
public void onSuccess(CreateResult result) {
newTarget.setId(result.getNewId());
if (newTarget.get("partnerId") != null) {
PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
newTarget.setPartner(partner);
}
if (newTarget.get("projectId") != null) {
ProjectDTO project = db.getProjectById((Integer) newTarget.get("projectId"));
newTarget.setProject(project);
}
store.add(newTarget);
store.commitChanges();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of org.activityinfo.ui.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class LockedPeriodGrid method startCreate.
@Override
public void startCreate() {
addLockedPeriod.startCreate();
form = new FormDialogImpl<>(addLockedPeriod);
form.setHeadingText(I18N.CONSTANTS.addTimeLock());
form.setWidth(400);
form.setHeight(350);
form.show(new FormDialogCallback() {
@Override
public void onValidated(FormDialogTether dlg) {
if (addLockedPeriod.isValid()) {
LockedPeriodGrid.this.lockedPeriod = addLockedPeriod.getValue();
eventBus.fireEvent(new CreateEvent());
}
}
@Override
public void onCancelled() {
eventBus.fireEvent(new CancelCreateEvent());
}
});
}
use of org.activityinfo.ui.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class DbListPresenterTest method niceFormDialogMock.
private FormDialogTether niceFormDialogMock() {
FormDialogTether mock = createNiceMock(FormDialogTether.class);
replay(mock);
return mock;
}
use of org.activityinfo.ui.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class DbPartnerEditor method showEditDialog.
private void showEditDialog(PartnerDTO partner) {
PartnerForm form = new PartnerForm(otherPartnerNames(partner));
form.getBinding().bind(partner);
FormDialogImpl<PartnerForm> dlg = new FormDialogImpl<>(form);
dlg.setWidth(450);
dlg.setHeight(300);
dlg.setHeadingText(I18N.CONSTANTS.newPartner());
dlg.show(new FormDialogCallback() {
@Override
public void onValidated(FormDialogTether dlg) {
dispatcher.execute(new UpdatePartner(db.getId(), partner), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
Log.debug("DbPartnerEditor caught exception while executing command AddPartner: ", caught);
}
@Override
public void onSuccess(CreateResult result) {
if (result instanceof DuplicateCreateResult) {
LOGGER.fine("DbPartnerEditor tried to add partner '" + partner.getName() + "' to database " + db.getId() + " but it already exists");
MessageBox.alert(I18N.CONSTANTS.newPartner(), I18N.CONSTANTS.duplicatePartner(), null);
} else {
LOGGER.fine("DbPartnerEditor added/updated new partner '" + partner.getName() + "' to database " + db.getId());
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
updateStore(partner, result);
}
}
});
}
});
}
Aggregations