Search in sources :

Example 1 with FormDialogCallback

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

the class DbListPresenter method onAdd.

public void onAdd() {
    final UserDatabaseDTO db = new UserDatabaseDTO();
    DatabaseForm form = new DatabaseForm(dispatcher);
    form.getBinding().bind(db);
    final FormDialogImpl dialog = new FormDialogImpl(form);
    dialog.setWidth(400);
    dialog.setHeight(200);
    dialog.setHeading(I18N.CONSTANTS.newDatabase());
    dialog.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            save(db, dialog);
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) DatabaseForm(org.activityinfo.client.page.config.form.DatabaseForm)

Example 2 with FormDialogCallback

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

the class DbPartnerEditor method onAdd.

// public void onSelectionChanged(PartnerDTO selectedItem) {
// this.view.setActionEnabled(UIActions.delete, selectedItem != null);
// }
@Override
protected void onAdd() {
    final PartnerDTO newPartner = new PartnerDTO();
    this.view.showAddDialog(newPartner, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            service.execute(new AddPartner(db.getId(), newPartner), dlg, new AsyncCallback<CreateResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    Log.debug("DbPartnerEditor caught exception while executing command AddPartner: ", caught);
                }

                @Override
                public void onSuccess(CreateResult result) {
                    if (result instanceof DuplicateCreateResult) {
                        Log.debug("DbPartnerEditor tried to add partner '" + newPartner.getName() + "' to database " + db.getId() + " but it already exists");
                        MessageBox.alert(I18N.CONSTANTS.newPartner(), I18N.CONSTANTS.duplicatePartner(), null);
                    } else {
                        Log.debug("DbPartnerEditor added new partner '" + newPartner.getName() + "' to database " + db.getId());
                        newPartner.setId(result.getNewId());
                        store.add(newPartner);
                        eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                        dlg.hide();
                    }
                }
            });
        }
    });
}
Also used : DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) AddPartner(org.activityinfo.shared.command.AddPartner)

Example 3 with FormDialogCallback

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

the class LockedPeriodGrid method startCreate.

@Override
public void startCreate() {
    addLockedPeriod.startCreate();
    form = new FormDialogImpl<AddLockedPeriodDialog>(addLockedPeriod);
    form.setHeading(I18N.CONSTANTS.addTimeLock());
    form.setWidth(400);
    form.setHeight(350);
    form.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            super.onValidated();
        }

        @Override
        public void onValidated(FormDialogTether dlg) {
            LockedPeriodGrid.this.lockedPeriod = addLockedPeriod.getValue();
            eventBus.fireEvent(new CreateEvent());
        }

        @Override
        public void onCancelled() {
            eventBus.fireEvent(new CancelCreateEvent());
        }
    });
}
Also used : FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether)

Example 4 with FormDialogCallback

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

the class DbProjectEditor method onEdit.

@Override
protected void onEdit(final ProjectDTO model) {
    final FormDialogImpl<ProjectForm> dialog = new FormDialogImpl<ProjectForm>(new ProjectForm());
    dialog.setWidth(450);
    dialog.setHeight(300);
    dialog.getForm().getBinding().bind(model);
    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 : ProjectForm(org.activityinfo.client.page.config.form.ProjectForm) FormDialogImpl(org.activityinfo.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.shared.command.result.VoidResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback)

Example 5 with FormDialogCallback

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

the class DbUserEditor method add.

private void add() {
    final UserForm form = new UserForm(db);
    final FormDialogImpl dlg = new FormDialogImpl(form);
    dlg.setHeading(I18N.CONSTANTS.newUser());
    dlg.setWidth(400);
    dlg.setHeight(300);
    final String host = Window.Location.getHostName();
    dlg.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            dispatcher.execute(new UpdateUserPermissions(db, form.getUser(), host), dlg, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                }

                @Override
                public void onSuccess(VoidResult result) {
                    loader.load();
                    dlg.hide();
                }
            });
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.shared.command.result.VoidResult) UpdateUserPermissions(org.activityinfo.shared.command.UpdateUserPermissions) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) UserForm(org.activityinfo.client.page.config.form.UserForm)

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