Search in sources :

Example 6 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether 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 7 with FormDialogTether

use of org.activityinfo.client.page.common.dialog.FormDialogTether 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 8 with FormDialogTether

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

the class MockDesignTree method showNewForm.

@Override
public FormDialogTether showNewForm(EntityDTO entity, FormDialogCallback callback) {
    for (String property : newEntityProperties.keySet()) {
        ((ModelData) entity).set(property, newEntityProperties.get(property));
    }
    FormDialogTether tether = createNiceMock(FormDialogTether.class);
    replay(tether);
    callback.onValidated(tether);
    return tether;
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether)

Aggregations

FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)8 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)6 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)5 CreateResult (org.activityinfo.shared.command.result.CreateResult)4 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)3 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)3 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 Record (com.extjs.gxt.ui.client.store.Record)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 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)1 TargetDTO (org.activityinfo.shared.dto.TargetDTO)1 DuplicatePartnerException (org.activityinfo.shared.exception.DuplicatePartnerException)1