Search in sources :

Example 1 with ContainerTreeItems

use of io.jmix.ui.component.data.tree.ContainerTreeItems in project jmix by jmix-framework.

the class TreeLoader method loadDataContainer.

protected void loadDataContainer(Tree resultComponent, Element element) {
    String containerId = element.attributeValue("dataContainer");
    if (containerId != null) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        InstanceContainer container = screenData.getContainer(containerId);
        CollectionContainer collectionContainer;
        if (container instanceof CollectionContainer) {
            collectionContainer = (CollectionContainer) container;
        } else {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
        }
        String hierarchyProperty = loadHierarchyProperty(element);
        if (Strings.isNullOrEmpty(hierarchyProperty)) {
            throw new GuiDevelopmentException("Tree doesn't have 'hierarchyProperty' attribute of the 'treechildren' element", context, "Tree ID", element.attributeValue("id"));
        }
        String showOrphansAttr = element.attributeValue("showOrphans");
        boolean showOrphans = showOrphansAttr == null || Boolean.parseBoolean(showOrphansAttr);
        resultComponent.setItems(new ContainerTreeItems(collectionContainer, hierarchyProperty, showOrphans));
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) InstanceContainer(io.jmix.ui.model.InstanceContainer) CollectionContainer(io.jmix.ui.model.CollectionContainer) ScreenData(io.jmix.ui.model.ScreenData) ContainerTreeItems(io.jmix.ui.component.data.tree.ContainerTreeItems)

Aggregations

GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)1 ContainerTreeItems (io.jmix.ui.component.data.tree.ContainerTreeItems)1 CollectionContainer (io.jmix.ui.model.CollectionContainer)1 InstanceContainer (io.jmix.ui.model.InstanceContainer)1 ScreenData (io.jmix.ui.model.ScreenData)1 FrameOwner (io.jmix.ui.screen.FrameOwner)1