Search in sources :

Example 1 with ConfirmParams

use of org.openforis.collect.designer.util.MessageUtil.ConfirmParams in project collect by openforis.

the class CodeAttributeVM method confirmCodeListChange.

private void confirmCodeListChange(final Binder binder, final CodeList list) {
    CodeList oldList = ((CodeAttributeDefinitionFormObject) getFormObject()).getList();
    ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.ConfirmHandler() {

        @Override
        public void onOk() {
            performListChange(binder, list);
        }
    }, "survey.schema.attribute.code.confirm_change_list.message");
    confirmParams.setOkLabelKey("global.change");
    confirmParams.setCancelLabelKey("global.leave_original_value");
    confirmParams.setMessageArgs(new String[] { oldList.getName(), list.getName() });
    MessageUtil.showConfirm(confirmParams);
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject) MessageUtil(org.openforis.collect.designer.util.MessageUtil)

Example 2 with ConfirmParams

use of org.openforis.collect.designer.util.MessageUtil.ConfirmParams in project collect by openforis.

the class SurveyLanguageVM method applyChanges.

@Command
public void applyChanges() {
    final SessionStatus sessionStatus = getSessionStatus();
    final CollectSurvey survey = sessionStatus.getSurvey();
    final List<String> newLanguageCodes = getSelectedLanguageCodes();
    final List<String> removedLanguages = calculateRemovedLanguages();
    if (removedLanguages.isEmpty()) {
        performLanguageUpdate(survey, newLanguageCodes);
    } else {
        ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.ConfirmHandler() {

            @Override
            public void onOk() {
                performLanguageUpdate(survey, newLanguageCodes);
            }
        }, "survey.language.remove.confirm");
        confirmParams.setOkLabelKey("global.remove_item");
        confirmParams.setMessageArgs(new String[] { StringUtils.join(removedLanguages, ", ") });
        MessageUtil.showConfirm(confirmParams);
    }
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) MessageUtil(org.openforis.collect.designer.util.MessageUtil) SessionStatus(org.openforis.collect.designer.session.SessionStatus) CollectSurvey(org.openforis.collect.model.CollectSurvey) Command(org.zkoss.bind.annotation.Command)

Example 3 with ConfirmParams

use of org.openforis.collect.designer.util.MessageUtil.ConfirmParams in project collect by openforis.

the class AttributeVM method deleteCheck.

@Command
public void deleteCheck() {
    ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {

        @Override
        public void onOk() {
            editedItem.removeCheck(selectedCheck);
            selectedCheck = null;
            initChecks();
            notifyChange("selectedCheck", "checks");
        }
    }, "survey.schema.node.check.confirm_delete");
    params.setOkLabelKey("global.delete_item");
    MessageUtil.showConfirm(params);
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) MessageUtil(org.openforis.collect.designer.util.MessageUtil) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 4 with ConfirmParams

use of org.openforis.collect.designer.util.MessageUtil.ConfirmParams in project collect by openforis.

the class AttributeVM method deleteAttributeDefault.

@Command
@NotifyChange({ "selectedAttributeDefault", "attributeDefaults" })
public void deleteAttributeDefault() {
    ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {

        @Override
        public void onOk() {
            editedItem.removeAttributeDefault(selectedAttributeDefault);
            selectedAttributeDefault = null;
            initAttributeDefaults();
            notifyChange("selectedAttributeDefault", "attributeDefaults");
        }
    }, "survey.schema.attribute.attribute_default.confirm_delete");
    params.setOkLabelKey("global.delete_item");
    MessageUtil.showConfirm(params);
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) MessageUtil(org.openforis.collect.designer.util.MessageUtil) NotifyChange(org.zkoss.bind.annotation.NotifyChange) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 5 with ConfirmParams

use of org.openforis.collect.designer.util.MessageUtil.ConfirmParams in project collect by openforis.

the class CodeAttributeVM method confirmParentCodeListChange.

private void confirmParentCodeListChange(final Binder binder, final CodeList list) {
    ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.CompleteConfirmHandler() {

        @Override
        public void onOk() {
            performListChange(binder, list);
        }

        @Override
        public void onCancel() {
            CodeList oldList = editedItem.getList();
            setFormFieldValue(binder, "list", oldList);
            setTempFormObjectFieldValue("list", oldList);
        }
    }, "survey.schema.attribute.code.confirm_change_list_on_referenced_node.message");
    confirmParams.setOkLabelKey("survey.schema.attribute.code.confirm_change_list_on_referenced_node.ok");
    confirmParams.setTitleKey("survey.schema.attribute.code.confirm_change_list_on_referenced_node.title");
    List<String> dependentAttributePaths = new ArrayList<String>();
    for (CodeAttributeDefinition codeAttributeDefinition : editedItem.getDependentCodeAttributeDefinitions()) {
        dependentAttributePaths.add(codeAttributeDefinition.getPath());
    }
    confirmParams.setMessageArgs(new String[] { StringUtils.join(dependentAttributePaths, ", ") });
    MessageUtil.showConfirm(confirmParams);
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) MessageUtil(org.openforis.collect.designer.util.MessageUtil) ArrayList(java.util.ArrayList)

Aggregations

MessageUtil (org.openforis.collect.designer.util.MessageUtil)7 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)7 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)4 CodeList (org.openforis.idm.metamodel.CodeList)2 NotifyChange (org.zkoss.bind.annotation.NotifyChange)2 ArrayList (java.util.ArrayList)1 CodeAttributeDefinitionFormObject (org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject)1 SessionStatus (org.openforis.collect.designer.session.SessionStatus)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)1