use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class DbPartnerEditor method onAdd.
// public void onSelectionChanged(PartnerDTO selectedItem) {
// this.view.setActionEnabled(UIActions.delete, selectedItem != null);
// }
@Override
protected void onAdd() {
final PartnerDTO newPartner = new PartnerDTO();
this.view.showAddDialog(newPartner, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddPartner(db.getId(), newPartner), 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) {
Log.debug("DbPartnerEditor tried to add partner '" + newPartner.getName() + "' to database " + db.getId() + " but it already exists");
MessageBox.alert(I18N.CONSTANTS.newPartner(), I18N.CONSTANTS.duplicatePartner(), null);
} else {
Log.debug("DbPartnerEditor added new partner '" + newPartner.getName() + "' to database " + db.getId());
newPartner.setId(result.getNewId());
store.add(newPartner);
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
}
});
}
});
}
use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class LockedPeriodGrid method startCreate.
@Override
public void startCreate() {
addLockedPeriod.startCreate();
form = new FormDialogImpl<AddLockedPeriodDialog>(addLockedPeriod);
form.setHeading(I18N.CONSTANTS.addTimeLock());
form.setWidth(400);
form.setHeight(350);
form.show(new FormDialogCallback() {
@Override
public void onValidated() {
super.onValidated();
}
@Override
public void onValidated(FormDialogTether dlg) {
LockedPeriodGrid.this.lockedPeriod = addLockedPeriod.getValue();
eventBus.fireEvent(new CreateEvent());
}
@Override
public void onCancelled() {
eventBus.fireEvent(new CancelCreateEvent());
}
});
}
use of org.activityinfo.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.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class DesignPresenter method createEntity.
private void createEntity(final ModelData parent, final EntityDTO newEntity) {
view.showNewForm(newEntity, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether tether) {
service.execute(new CreateEntity(newEntity), tether, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
GWT.log(caught.getMessage());
}
@Override
public void onSuccess(CreateResult result) {
// todo add
newEntity.set("id", result.getNewId());
if (parent == null) {
treeStore.add(newEntity, false);
} else {
treeStore.add(parent, newEntity, false);
}
if (newEntity instanceof ActivityDTO) {
treeStore.add(newEntity, new AttributeGroupFolder(messages.attributes()), false);
treeStore.add(newEntity, new IndicatorFolder(messages.indicators()), false);
}
tether.hide();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
}
});
}
});
}
use of org.activityinfo.client.page.common.dialog.FormDialogTether in project activityinfo by bedatadriven.
the class DbProjectEditor method onAdd.
@Override
protected void onAdd() {
final ProjectDTO newProject = new ProjectDTO();
this.view.showAddDialog(newProject, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddProject(db.getId(), newProject), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof DuplicatePartnerException) {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
} else {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
}
}
@Override
public void onSuccess(CreateResult result) {
newProject.setId(result.getNewId());
store.add(newProject);
db.getProjects().add(newProject);
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
Aggregations