use of io.jmix.ui.app.inputdialog.InputParameter in project jmix by jmix-framework.
the class InputDialogFacetProvider method loadEntityParameter.
@SuppressWarnings("unchecked")
protected InputParameter loadEntityParameter(Element paramEl, ComponentLoader.ComponentContext context) {
String paramId = paramEl.attributeValue("id");
String classFqn = paramEl.attributeValue("entityClass");
InputParameter parameter;
Class clazz = loadParamClass(paramEl, classFqn, context);
MetaClass entityClass = metadata.findClass(clazz);
if (entityClass != null) {
parameter = InputParameter.entityParameter(paramId, clazz).withCaption(loadParamCaption(paramEl, context)).withRequired(loadParamRequired(paramEl)).withRequiredMessage(loadRequiredMessage(paramEl, context));
Field<?> field = loadField(paramId, paramEl, context);
if (field != null) {
parameter.withField(() -> field);
}
} else {
throw new GuiDevelopmentException(String.format("Unable to create InputDialog parameter '%s'. Class '%s' is not entity class", paramId, classFqn), context);
}
return parameter;
}
use of io.jmix.ui.app.inputdialog.InputParameter in project jmix by jmix-framework.
the class InputDialogFacetProvider method loadEnumParameter.
@SuppressWarnings("unchecked")
protected InputParameter loadEnumParameter(Element paramEl, ComponentLoader.ComponentContext context) {
String paramId = paramEl.attributeValue("id");
String classFqn = paramEl.attributeValue("enumClass");
InputParameter parameter;
Class clazz = loadParamClass(paramEl, classFqn, context);
if (EnumClass.class.isAssignableFrom(clazz)) {
parameter = InputParameter.enumParameter(paramId, clazz).withCaption(loadParamCaption(paramEl, context)).withRequired(loadParamRequired(paramEl)).withRequiredMessage(loadRequiredMessage(paramEl, context));
Field<?> field = loadField(paramId, paramEl, context);
if (field != null) {
parameter.withField(() -> field);
}
} else {
throw new GuiDevelopmentException(String.format("Unable to create InputDialog parameter '%s'. Class '%s' is not enum class", paramId, classFqn), context);
}
return parameter;
}
use of io.jmix.ui.app.inputdialog.InputParameter in project jmix by jmix-framework.
the class InputDialogFacetProvider method loadPrimitiveParameter.
protected InputParameter loadPrimitiveParameter(Element paramEl, ComponentLoader.ComponentContext context) {
String paramId = paramEl.attributeValue("id");
String paramName = paramEl.getName();
InputParameter inputParameter;
if ("bigDecimalParameter".equals(paramName)) {
// Handle BigDecimal explicitly because its datatype id doesn't match with pattern "typeParameter"
inputParameter = InputParameter.bigDecimalParameter(paramId).withCaption(loadParamCaption(paramEl, context)).withRequired(loadParamRequired(paramEl)).withRequiredMessage(loadRequiredMessage(paramEl, context)).withDefaultValue(loadDefaultValue(paramEl, datatypeRegistry.get(BigDecimal.class), context));
} else {
Datatype datatype = loadDatatype(paramEl, context);
inputParameter = InputParameter.parameter(paramId).withCaption(loadParamCaption(paramEl, context)).withRequired(loadParamRequired(paramEl)).withRequiredMessage(loadRequiredMessage(paramEl, context)).withUseUserTimeZone(loadUseUserTimeZone(paramEl)).withTimeZone(loadTimeZone(paramEl, context)).withDatatype(datatype).withDefaultValue(loadDefaultValue(paramEl, datatype, context));
}
Field<?> field = loadField(paramId, paramEl, context);
if (field != null) {
inputParameter.withField(() -> field);
}
return inputParameter;
}
use of io.jmix.ui.app.inputdialog.InputParameter in project jmix by jmix-framework.
the class InputDialogFacetProvider method loadInputParameters.
protected void loadInputParameters(InputDialogFacet facet, Element element, ComponentLoader.ComponentContext context) {
List<InputParameter> inputParameters = new ArrayList<>();
Set<String> paramIds = new HashSet<>();
Element paramsEl = element.element("parameters");
if (paramsEl == null) {
return;
}
for (Element paramEl : paramsEl.elements()) {
String paramId = paramEl.attributeValue("id");
if (!paramIds.contains(paramId)) {
inputParameters.add(loadInputParameter(paramEl, context));
paramIds.add(paramId);
} else {
throw new GuiDevelopmentException("InputDialog parameters should have unique ids", context);
}
}
if (inputParameters.isEmpty()) {
throw new GuiDevelopmentException("InputDialog Facet cannot be used without parameters", context);
}
facet.setParameters(inputParameters.toArray(new InputParameter[] {}));
}
Aggregations