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);
}
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);
}
}
}
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());
}
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);
}
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");
}
Aggregations