Search in sources :

Example 41 with Command

use of org.zkoss.bind.annotation.Command 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 42 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeAttributeVM method onListChanged.

@Command
public void onListChanged(@ContextParam(ContextType.BINDER) Binder binder, @BindingParam("list") CodeList list) {
    CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) getFormObject();
    CodeList oldList = fo.getList();
    boolean listChanged = oldList != null && !oldList.equals(list);
    if (oldList == null) {
        performListChange(binder, list);
    } else if (listChanged) {
        if (editedItem.hasDependentCodeAttributeDefinitions()) {
            confirmParentCodeListChange(binder, list);
        } else {
            performListChange(binder, list);
        }
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 43 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class NewSurveyParametersPopUpVM method ok.

@Command
public void ok() throws IdmlParseException, SurveyValidationException, SurveyStoreException {
    String name = (String) form.get(SURVEY_NAME_FIELD);
    String langCode = ((LabelledItem) form.get(LANGUAGE_FIELD_NAME)).getCode();
    String templateCode = ((LabelledItem) form.get(TEMPLATE_FIELD_NAME)).getCode();
    TemplateType templateType = TemplateType.valueOf(templateCode);
    String userGroupName = ((LabelledItem) form.get(USER_GROUP_FIELD_NAME)).getCode();
    CollectSurvey survey;
    switch(templateType) {
        case BLANK:
            survey = createEmptySurvey(name, langCode);
            break;
        default:
            survey = createNewSurveyFromTemplate(name, langCode, templateType);
    }
    UserGroup userGroup = userGroupManager.findByName(userGroupName);
    survey.setUserGroupId(userGroup.getId());
    surveyManager.save(survey);
    SurveyEditVM.redirectToSurveyEditPage(survey.getId());
}
Also used : LabelledItem(org.openforis.collect.designer.model.LabelledItem) TemplateType(org.openforis.collect.web.controller.SurveyController.SurveyCreationParameters.TemplateType) CollectSurvey(org.openforis.collect.model.CollectSurvey) UserGroup(org.openforis.collect.model.UserGroup) Command(org.zkoss.bind.annotation.Command)

Example 44 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeListsVM method addLevel.

@Command
@NotifyChange({ "listLevels" })
public void addLevel() {
    List<CodeListLevel> levels = editedItem.getHierarchy();
    int levelPosition = levels.size() + 1;
    CodeListLevel level = new CodeListLevel();
    String generatedName = Labels.getLabel(SURVEY_CODE_LIST_GENERATED_LEVEL_NAME_LABEL_KEY, new Object[] { levelPosition });
    level.setName(generatedName);
    editedItem.addLevel(level);
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) NotifyChange(org.zkoss.bind.annotation.NotifyChange) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 45 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeListsVM method typeChanged.

@Command
public void typeChanged(@BindingParam("type") String type) {
    Type typeEnum = CodeListFormObject.Type.valueOf(type);
    switch(typeEnum) {
        case HIERARCHICAL:
            addLevel();
            break;
        default:
            editedItem.removeLevel(0);
    }
    CodeListFormObject fo = (CodeListFormObject) formObject;
    fo.setType(type);
    notifyChange("formObject", "listLevels");
}
Also used : Type(org.openforis.collect.designer.form.CodeListFormObject.Type) ContextType(org.zkoss.bind.annotation.ContextType) CodeListFormObject(org.openforis.collect.designer.form.CodeListFormObject) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

Command (org.zkoss.bind.annotation.Command)62 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)44 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 File (java.io.File)12 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 MessageUtil (org.openforis.collect.designer.util.MessageUtil)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 FileInputStream (java.io.FileInputStream)5 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)5 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 Media (org.zkoss.util.media.Media)5 Window (org.zkoss.zul.Window)5 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 IOException (java.io.IOException)4 Date (java.util.Date)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 SessionStatus (org.openforis.collect.designer.session.SessionStatus)3 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)3