Search in sources :

Example 1 with FormatterLoadFactory

use of io.jmix.ui.component.formatter.FormatterLoadFactory in project jmix by jmix-framework.

the class AbstractComponentLoader method loadFormatter.

@Nullable
protected Formatter<?> loadFormatter(Element element) {
    Element formatterElement = element.element("formatter");
    if (formatterElement == null) {
        return null;
    }
    int size = formatterElement.elements().size();
    if (size != 1) {
        throw new GuiDevelopmentException("Only one formatter needs to be defined. " + "The current number of formatters is " + size, getContext(), "Component ID", resultComponent.getId());
    }
    Element childElement = formatterElement.elements().get(0);
    FormatterLoadFactory loadFactory = applicationContext.getBean(FormatterLoadFactory.class);
    if (loadFactory.isFormatter(childElement)) {
        return loadFactory.createFormatter(childElement);
    }
    return null;
}
Also used : Element(org.dom4j.Element) FormatterLoadFactory(io.jmix.ui.component.formatter.FormatterLoadFactory) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Nullable(javax.annotation.Nullable)

Aggregations

GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)1 FormatterLoadFactory (io.jmix.ui.component.formatter.FormatterLoadFactory)1 Nullable (javax.annotation.Nullable)1 Element (org.dom4j.Element)1