Search in sources :

Example 41 with Component

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

the class AbstractSingleFilterComponentLoader method loadValueComponent.

@SuppressWarnings("unchecked")
protected void loadValueComponent(C resultComponent, Element element) {
    Component valueComponent;
    if (!element.elements().isEmpty()) {
        valueComponent = createValueComponent(element.elements());
    } else {
        valueComponent = generateValueComponent();
    }
    if (!(valueComponent instanceof HasValue)) {
        throw new GuiDevelopmentException("Value component of the PropertyFilter must implement HasValue", getComponentContext().getCurrentFrameId());
    }
    resultComponent.setValueComponent((HasValue) valueComponent);
}
Also used : GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent) Component(io.jmix.ui.component.Component) HasValue(io.jmix.ui.component.HasValue)

Example 42 with Component

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

the class RelatedEntitiesLoader method loadComponent.

@Override
public void loadComponent() {
    assignFrame(resultComponent);
    loadCaption(resultComponent, element);
    loadIcon(resultComponent, element);
    loadWidth(resultComponent, element);
    loadStyleName(resultComponent, element);
    loadEnable(resultComponent, element);
    loadVisible(resultComponent, element);
    loadAlign(resultComponent, element);
    loadCss(resultComponent, element);
    loadOpenMode(resultComponent, element);
    loadString(element, "exclude", resultComponent::setExcludePropertiesRegex);
    for (Element routeObject : element.elements("property")) {
        loadPropertyOption(routeObject);
    }
    String listComponentId = loadString(element, "for").orElseThrow(() -> new GuiDevelopmentException("'for' attribute of related entities is not specified", context, "componentId", resultComponent.getId()));
    getComponentContext().addPostInitTask((context1, window) -> {
        if (resultComponent.getListComponent() == null) {
            Component bindComponent = resultComponent.getFrame().getComponent(listComponentId);
            if (!(bindComponent instanceof ListComponent)) {
                throw new GuiDevelopmentException("Specify 'for' attribute: id of table or tree", context1, "componentId", resultComponent.getId());
            }
            resultComponent.setListComponent((ListComponent) bindComponent);
        }
    });
    loadTabIndex(resultComponent, element);
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) ListComponent(io.jmix.ui.component.ListComponent) ListComponent(io.jmix.ui.component.ListComponent) Component(io.jmix.ui.component.Component)

Example 43 with Component

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

the class ResponsiveGridLayoutLoader method loadComponent.

protected void loadComponent(Column column, Element element) {
    List<Element> elements = element.elements();
    if (elements.isEmpty()) {
        throw new GuiDevelopmentException("ResponsiveGridLayout column element can't be empty", context);
    }
    if (elements.size() > 1) {
        throw new GuiDevelopmentException("ResponsiveGridLayout column element must contain only one component", context);
    }
    Element contentElement = elements.get(0);
    LayoutLoader loader = getLayoutLoader();
    ComponentLoader<?> childComponentLoader = loader.createComponent(contentElement);
    childComponentLoader.loadComponent();
    Component component = childComponentLoader.getResultComponent();
    column.setComponent(component);
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Component(io.jmix.ui.component.Component)

Example 44 with Component

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

the class SideMenuLoader method loadSidePanelToggleButton.

protected void loadSidePanelToggleButton(SideMenu component, Element element) {
    String toggleButtonId = element.attributeValue("sidePanelToggleButton");
    if (StringUtils.isNotEmpty(toggleButtonId)) {
        Component toggleButton = resultComponent.getFrame().getComponent(toggleButtonId);
        if (!(toggleButton instanceof Button)) {
            throw new GuiDevelopmentException("Unable to find sidePanelToggleButton for SideMenu", context, "sidePanelToggleButton", toggleButtonId);
        }
        component.setSidePanelToggleButton((Button) toggleButton);
    }
}
Also used : Button(io.jmix.ui.component.Button) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Component(io.jmix.ui.component.Component)

Example 45 with Component

use of io.jmix.ui.component.Component 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)

Aggregations

Component (io.jmix.ui.component.Component)81 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)16 Datasource (com.haulmont.cuba.gui.data.Datasource)12 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)11 Test (org.junit.jupiter.api.Test)11 Element (org.dom4j.Element)10 Consumer (java.util.function.Consumer)9 ListComponent (com.haulmont.cuba.gui.components.ListComponent)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)7 Action (io.jmix.ui.action.Action)7 HasValue (io.jmix.ui.component.HasValue)7 FrameOwner (io.jmix.ui.screen.FrameOwner)7 ArrayList (java.util.ArrayList)7 DatasourceImpl (com.haulmont.cuba.gui.data.impl.DatasourceImpl)6 FetchPlan (io.jmix.core.FetchPlan)6 UUID (java.util.UUID)6 Nullable (javax.annotation.Nullable)6 User (com.haulmont.cuba.core.model.common.User)5 DsBuilder (com.haulmont.cuba.gui.data.DsBuilder)5 Entity (io.jmix.core.Entity)5