use of org.activityinfo.ui.client.page.common.dialog.FormDialogImpl in project activityinfo by bedatadriven.
the class DbUserEditorActions method showDialog.
private void showDialog(final UserForm form, final boolean newUser) {
final FormDialogImpl dlg = new FormDialogImpl(form);
dlg.setHeadingText(newUser ? I18N.CONSTANTS.newUser() : I18N.CONSTANTS.editUser());
dlg.setWidth(400);
dlg.setHeight(300);
dlg.getCancelButton().addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent buttonEvent) {
panel.setModified(false);
}
});
final String host = Window.Location.getHostName();
dlg.show(new FormDialogCallback() {
@Override
public void onValidated() {
try {
UpdateUserPermissions command = new UpdateUserPermissions(db, form.getUser(), host);
command.setNewUser(newUser);
dispatcher.execute(command, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof UserExistsException) {
MessageBox.alert(I18N.CONSTANTS.userExistsTitle(), I18N.CONSTANTS.userExistsMessage(), null);
} else {
MessageBox.alert(I18N.CONSTANTS.serverError(), I18N.CONSTANTS.errorUnexpectedOccured(), null);
}
}
@Override
public void onSuccess(VoidResult result) {
loader.load();
panel.setModified(false);
dlg.hide();
}
});
} catch (FolderAssignmentException excp) {
MessageBox.alert(I18N.CONSTANTS.noFolderAssignmentTitle(), excp.getMessage(), null);
} catch (PermissionAssignmentException excp) {
MessageBox.alert(I18N.CONSTANTS.permissionAssignmentErrorTitle(), excp.getMessage(), null);
}
}
});
}
use of org.activityinfo.ui.client.page.common.dialog.FormDialogImpl 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.setHeadingText(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