use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class SchemaAttributesImportVM method openParentEntitySelectionButton.
@Command
public void openParentEntitySelectionButton() {
Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {
public boolean evaluate(SurveyObject item) {
return item instanceof UITab || item instanceof EntityDefinition;
}
};
Predicate<SurveyObject> selectableNodePredicate = new Predicate<SurveyObject>() {
public boolean evaluate(SurveyObject item) {
return item instanceof EntityDefinition;
}
};
String title = Labels.getLabel("survey.schema.attributes_import.select_entity.popup.title");
// calculate parent item (tab or entity)
final Window popup = SchemaTreePopUpVM.openPopup(title, parentEntityDefinition.getRootEntity(), null, includedNodePredicate, true, true, null, selectableNodePredicate, parentEntityDefinition, false);
popup.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {
public void onEvent(NodeSelectedEvent event) throws Exception {
SurveyObject selectedParent = event.getSelectedItem();
parentEntityDefinition = (EntityDefinition) selectedParent;
notifyChange("parentEntityDefinitionPath");
closePopUp(popup);
}
});
}
use of org.zkoss.bind.annotation.Command 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);
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class AttributeVM method addAttributeDefault.
@Command
@NotifyChange("attributeDefaults")
public void addAttributeDefault() {
if (checkCanInsertAttributeDefault()) {
editingNewAttributeDefault = true;
editedAttributeDefault = new AttributeDefault();
openAttributeDefaultEditPopUp();
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class AttributeVM method addCheck.
@Command
public void addCheck(@BindingParam("checkType") String checkType) {
if (checkCanAddCheck()) {
CheckType type = CheckType.valueOf(checkType.toUpperCase());
editingNewCheck = true;
editedCheck = CheckType.createCheck(type);
openCheckEditPopUp();
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class AttributeVM method openReferencedAttributeSelector.
@Command
public void openReferencedAttributeSelector(@ContextParam(ContextType.BINDER) final Binder binder) {
ReferenceableKeyAttributeHelper referenceableKeyAttributeHelper = new ReferenceableKeyAttributeHelper(editedItem);
final Set<EntityDefinition> referenceableEntityDefinitions = referenceableKeyAttributeHelper.determineReferenceableEntities();
final Set<AttributeDefinition> selectableAttributes = referenceableKeyAttributeHelper.determineReferenceableAttributes();
if (selectableAttributes.isEmpty()) {
MessageUtil.showWarning("survey.schema.attribute.no_referenceable_attributes_available");
} else {
Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {
public boolean evaluate(SurveyObject item) {
EntityDefinition parentEntity;
if (item instanceof UITab) {
parentEntity = survey.getUIOptions().getParentEntityForAssignedNodes((UITab) item);
} else {
parentEntity = ((NodeDefinition) item).getParentEntityDefinition();
}
for (EntityDefinition entityDef : referenceableEntityDefinitions) {
if (parentEntity == entityDef || parentEntity.isAncestorOf(entityDef)) {
return true;
}
}
return false;
}
};
Predicate<SurveyObject> disabledNodePredicate = new Predicate<SurveyObject>() {
public boolean evaluate(SurveyObject item) {
return !selectableAttributes.contains(item);
}
};
String title = Labels.getLabel("survey.schema.attribute.select_attribute_referenced_by", new String[] { editedItem.getName() });
final Window parentSelectorPopUp = SchemaTreePopUpVM.openPopup(title, editedItem.getRootEntity(), null, includedNodePredicate, false, false, disabledNodePredicate, null, editedItem.getReferencedAttribute(), true);
parentSelectorPopUp.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {
public void onEvent(NodeSelectedEvent event) throws Exception {
AttributeDefinition referencedAttribute = (AttributeDefinition) event.getSelectedItem();
AttributeDefinitionFormObject<?> fo = (AttributeDefinitionFormObject<?>) formObject;
fo.setReferencedAttributePath(referencedAttribute == null ? null : referencedAttribute.getPath());
notifyChange("formObject");
dispatchApplyChangesCommand(binder);
closePopUp(parentSelectorPopUp);
}
});
}
}
Aggregations