Search in sources :

Example 6 with FormDialogCallback

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);
                }
            });
        }
    });
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 7 with FormDialogCallback

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

Example 8 with FormDialogCallback

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();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) VoidResult(org.activityinfo.shared.command.result.VoidResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) Record(com.extjs.gxt.ui.client.store.Record)

Example 9 with FormDialogCallback

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();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) AddTarget(org.activityinfo.shared.command.AddTarget) TargetDTO(org.activityinfo.shared.dto.TargetDTO)

Example 10 with FormDialogCallback

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());
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.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.client.page.common.dialog.FormDialogCallback)10 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)7 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)6 FormDialogImpl (org.activityinfo.client.page.common.dialog.FormDialogImpl)4 CreateResult (org.activityinfo.shared.command.result.CreateResult)4 VoidResult (org.activityinfo.shared.command.result.VoidResult)3 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)3 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)3 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 DatabaseForm (org.activityinfo.client.page.config.form.DatabaseForm)1 ProjectForm (org.activityinfo.client.page.config.form.ProjectForm)1 UserForm (org.activityinfo.client.page.config.form.UserForm)1 AddPartner (org.activityinfo.shared.command.AddPartner)1 AddProject (org.activityinfo.shared.command.AddProject)1 AddTarget (org.activityinfo.shared.command.AddTarget)1 CreateEntity (org.activityinfo.shared.command.CreateEntity)1 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)1 UpdateUserPermissions (org.activityinfo.shared.command.UpdateUserPermissions)1