use of org.activityinfo.client.page.common.dialog.FormDialogCallback 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.FormDialogCallback 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();
}
});
}
});
}
use of org.activityinfo.client.page.common.dialog.FormDialogCallback 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.client.page.common.dialog.FormDialogCallback in project activityinfo by bedatadriven.
the class DbTargetEditor method onAdd.
@Override
protected void onAdd() {
final TargetDTO newTarget = new TargetDTO();
this.view.showAddDialog(newTarget, db, 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());
PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
newTarget.setPartner(partner);
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.client.page.common.dialog.FormDialogCallback in project activityinfo by bedatadriven.
the class AttachmentsPresenter method onUpload.
public void onUpload() {
form = new AttachmentForm();
form.setEncoding(Encoding.MULTIPART);
form.setMethod(Method.POST);
HiddenField<String> blobField = new HiddenField<String>();
blobField.setName("blobId");
blobid = UUID.uuid();
blobField.setValue(blobid);
form.add(blobField);
final FormDialogImpl dialog = new FormDialogImpl(form);
dialog.setWidth(400);
dialog.setHeight(200);
dialog.setHeading(I18N.CONSTANTS.newAttachment());
dialog.show(new FormDialogCallback() {
@Override
public void onValidated() {
form.setAction("/ActivityInfo/attachment?blobId=" + blobid + "&siteId=" + currentSite.getId());
form.submit();
dialog.getSaveButton().setEnabled(false);
}
});
form.addListener(Events.Submit, new Listener<FormEvent>() {
@Override
public void handleEvent(FormEvent event) {
dialog.hide();
view.setAttachmentStore(currentSite.getId());
}
});
}
Aggregations