Search in sources :

Example 1 with ComponentLoader

use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.

the class TabSheetLoader method createComponent.

@Override
public void createComponent() {
    resultComponent = createComponentInternal();
    loadId(resultComponent, element);
    LayoutLoader layoutLoader = getLayoutLoader();
    List<Element> tabElements = element.elements("tab");
    for (Element tabElement : tabElements) {
        final String name = tabElement.attributeValue("id");
        boolean lazy = Boolean.parseBoolean(tabElement.attributeValue("lazy"));
        ComponentLoader tabComponentLoader = layoutLoader.getLoader(tabElement, TabComponentLoader.class);
        TabSheet.Tab tab;
        if (lazy) {
            tab = resultComponent.addLazyTab(name, tabElement, tabComponentLoader);
        } else {
            tabComponentLoader.createComponent();
            Component tabComponent = tabComponentLoader.getResultComponent();
            tab = resultComponent.addTab(name, tabComponent);
            pendingLoadComponents.add(tabComponentLoader);
        }
        pendingLoadTabs.put(tabElement, tab);
    }
}
Also used : TabSheet(io.jmix.ui.component.TabSheet) Element(org.dom4j.Element) Component(io.jmix.ui.component.Component) ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader)

Example 2 with ComponentLoader

use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.

the class JpqlFilterLoader method createValueComponent.

@SuppressWarnings("rawtypes")
@Override
protected Component createValueComponent(List<Element> elements) {
    return elements.stream().filter(valueComponentElement -> !"condition".equals(valueComponentElement.getName())).map(valueComponentElement -> {
        ComponentLoader valueComponentLoader = getLayoutLoader().createComponent(valueComponentElement);
        valueComponentLoader.loadComponent();
        return valueComponentLoader.getResultComponent();
    }).findFirst().orElseGet(this::generateValueComponent);
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Component(io.jmix.ui.component.Component) HasValue(io.jmix.ui.component.HasValue) MetaClass(io.jmix.core.metamodel.model.MetaClass) List(java.util.List) JpqlFilter(io.jmix.ui.component.JpqlFilter) ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader) JpqlFilterSupport(io.jmix.ui.component.jpqlfilter.JpqlFilterSupport) Element(org.dom4j.Element) ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader)

Example 3 with ComponentLoader

use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.

the class LayoutLoader method initLoader.

protected ComponentLoader initLoader(Element element, Class<? extends ComponentLoader> loaderClass) {
    ComponentLoader loader;
    Constructor<? extends ComponentLoader> constructor;
    try {
        constructor = loaderClass.getConstructor();
    } catch (NoSuchMethodException e) {
        throw new GuiDevelopmentException("Unable to get constructor for loader: " + e, context);
    }
    try {
        loader = constructor.newInstance();
    } catch (InvocationTargetException | IllegalAccessException | InstantiationException e) {
        throw new GuiDevelopmentException("Loader instantiation error: " + e, context);
    }
    loader.setApplicationContext(applicationContext);
    loader.setEnvironment(environment);
    loader.setContext(context);
    loader.setLayoutLoaderConfig(config);
    loader.setLoaderResolver(loaderResolver);
    loader.setLoaderSupport(loaderSupport);
    loader.setFactory(factory);
    loader.setElement(element);
    return loader;
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader)

Example 4 with ComponentLoader

use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.

the class CompositeComponentLayoutLoader method initLoader.

protected ComponentLoader initLoader(Element element, Class<? extends ComponentLoader> loaderClass) {
    ComponentLoader loader;
    Constructor<? extends ComponentLoader> constructor;
    try {
        constructor = loaderClass.getConstructor();
    } catch (NoSuchMethodException e) {
        throw new GuiDevelopmentException("Unable to get constructor for loader: " + e, context);
    }
    try {
        loader = constructor.newInstance();
    } catch (InvocationTargetException | IllegalAccessException | InstantiationException e) {
        throw new GuiDevelopmentException("Loader instantiation error: " + e, context);
    }
    loader.setApplicationContext(applicationContext);
    loader.setContext(context);
    loader.setLoaderResolver(loaderResolver);
    loader.setLoaderSupport(loaderSupport);
    loader.setFactory(factory);
    loader.setElement(element);
    return loader;
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader)

Example 5 with ComponentLoader

use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.

the class CompositeComponentLayoutLoader method createComponent.

public Component createComponent(Element element) {
    ComponentLoader loader = getLoader(element);
    loader.createComponent();
    loader.loadComponent();
    return loader.getResultComponent();
}
Also used : ComponentLoader(io.jmix.ui.xml.layout.ComponentLoader)

Aggregations

ComponentLoader (io.jmix.ui.xml.layout.ComponentLoader)12 Element (org.dom4j.Element)7 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)6 Component (io.jmix.ui.component.Component)5 MetaClass (io.jmix.core.metamodel.model.MetaClass)3 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Nullable (javax.annotation.Nullable)2 Strings (com.google.common.base.Strings)1 Iterables (com.google.common.collect.Iterables)1 Security (com.haulmont.cuba.core.global.Security)1 UiComponents (com.haulmont.cuba.gui.UiComponents)1 FieldGroup (com.haulmont.cuba.gui.components.FieldGroup)1 FieldCaptionAlignment (com.haulmont.cuba.gui.components.FieldGroup.FieldCaptionAlignment)1 FieldGroupFieldFactory (com.haulmont.cuba.gui.components.FieldGroupFieldFactory)1 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)1 Datasource (com.haulmont.cuba.gui.data.Datasource)1 DsContext (com.haulmont.cuba.gui.data.DsContext)1 EmbeddedDatasource (com.haulmont.cuba.gui.data.EmbeddedDatasource)1 DynamicAttributesGuiTools (com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools)1