Search in sources :

Example 6 with FormDialogCallback

use of org.activityinfo.ui.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) {
                    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();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) AddProject(org.activityinfo.legacy.shared.command.AddProject) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether)

Example 7 with FormDialogCallback

use of org.activityinfo.ui.client.page.common.dialog.FormDialogCallback in project activityinfo by bedatadriven.

the class DbProjectEditor method onEdit.

@Override
protected void onEdit(final ProjectDTO model) {
    final ProjectDTO copy = new ProjectDTO();
    copy.setProperties(model.getProperties());
    final FormDialogImpl<ProjectForm> dialog = new FormDialogImpl<ProjectForm>(new ProjectForm()) {

        @Override
        public void onCancel() {
            model.setProperties(copy.getProperties());
        }
    };
    dialog.setWidth(450);
    dialog.setHeight(300);
    dialog.getForm().getBinding().bind(model);
    List<ProjectDTO> allowed = Lists.newArrayList(store.getModels());
    allowed.remove(model);
    dialog.getForm().getNameField().setValidator(new UniqueNameValidator(allowed));
    dialog.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            service.execute(RequestChange.update(model, "name", "description"), dialog, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                // handled by monitor
                }

                @Override
                public void onSuccess(VoidResult result) {
                    dialog.hide();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    view.refresh();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ProjectForm(org.activityinfo.ui.client.page.config.form.ProjectForm) FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) UniqueNameValidator(org.activityinfo.ui.client.page.config.design.UniqueNameValidator)

Example 8 with FormDialogCallback

use of org.activityinfo.ui.client.page.common.dialog.FormDialogCallback 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);
            }
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) PermissionAssignmentException(org.activityinfo.ui.client.page.config.form.PermissionAssignmentException) UserExistsException(org.activityinfo.legacy.shared.command.result.UserExistsException) FolderAssignmentException(org.activityinfo.ui.client.page.config.form.FolderAssignmentException) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

Example 9 with FormDialogCallback

use of org.activityinfo.ui.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.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());
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) FormEvent(com.extjs.gxt.ui.client.event.FormEvent) HiddenField(com.extjs.gxt.ui.client.widget.form.HiddenField)

Aggregations

FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)9 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)6 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)5 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)5 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)3 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)2 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 FormEvent (com.extjs.gxt.ui.client.event.FormEvent)1 Record (com.extjs.gxt.ui.client.store.Record)1 HiddenField (com.extjs.gxt.ui.client.widget.form.HiddenField)1 AddProject (org.activityinfo.legacy.shared.command.AddProject)1 AddTarget (org.activityinfo.legacy.shared.command.AddTarget)1 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)1 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)1 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)1 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)1 UserExistsException (org.activityinfo.legacy.shared.command.result.UserExistsException)1 TargetDTO (org.activityinfo.legacy.shared.model.TargetDTO)1