use of io.jmix.ui.GuiDevelopmentException in project jmix by jmix-framework.
the class AbstractScreenFacetProvider method loadProperty.
protected UiControllerProperty loadProperty(Element property, ComponentLoader.ComponentContext context) {
String name = property.attributeValue("name");
if (name == null || name.isEmpty()) {
throw new GuiDevelopmentException("Screen property cannot have empty name", context);
}
String value = property.attributeValue("value");
String ref = property.attributeValue("ref");
if (StringUtils.isNotEmpty(value) && StringUtils.isNotEmpty(ref)) {
throw new GuiDevelopmentException("Screen property can have either a value or a reference. Property: " + name, context);
}
if (StringUtils.isNotEmpty(value)) {
return new UiControllerProperty(name, value, UiControllerProperty.Type.VALUE);
} else if (StringUtils.isNotEmpty(ref)) {
return new UiControllerProperty(name, ref, UiControllerProperty.Type.REFERENCE);
} else {
throw new GuiDevelopmentException("No value or reference found for screen property: " + name, context);
}
}
use of io.jmix.ui.GuiDevelopmentException 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.GuiDevelopmentException in project jmix by jmix-framework.
the class InputDialogFacetProvider method loadDialogActions.
protected void loadDialogActions(InputDialogFacet facet, Element element, ComponentLoader.ComponentContext context) {
loadDialogActions(facet, element);
Element actions = element.element("actions");
if (actions != null) {
if (facet.getDialogActions() == null) {
loadActions(facet, element, context);
} else {
throw new GuiDevelopmentException("Predefined and custom actions cannot be used for InputDialog at the same time", context);
}
}
}
use of io.jmix.ui.GuiDevelopmentException 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.GuiDevelopmentException in project jmix by jmix-framework.
the class InputDialogFacetProvider method loadDatatype.
protected Datatype loadDatatype(Element element, ComponentLoader.ComponentContext context) {
String paramName = element.getName();
Matcher matcher = PARAM_TYPE_REGEX.matcher(paramName);
if (matcher.matches()) {
String typeName = matcher.group(1);
return datatypeRegistry.get(typeName);
} else {
throw new GuiDevelopmentException(String.format("Unsupported InputDialog parameter type: '%s'", paramName), context);
}
}
Aggregations