Search in sources :

Example 1 with ScreenData

use of io.jmix.ui.model.ScreenData in project jmix by jmix-framework.

the class AnnotationBasedLoaderBeforeShow method loadData.

@Override
public void loadData(Screen screen) {
    LoadDataBeforeShow annotation = screen.getClass().getAnnotation(LoadDataBeforeShow.class);
    if (annotation != null && annotation.value()) {
        ScreenData screenData = UiControllerUtils.getScreenData(screen);
        screenData.loadAll();
    }
}
Also used : LoadDataBeforeShow(com.haulmont.cuba.gui.screen.LoadDataBeforeShow) ScreenData(io.jmix.ui.model.ScreenData)

Example 2 with ScreenData

use of io.jmix.ui.model.ScreenData in project jmix by jmix-framework.

the class TableFieldFactoryImpl method findOptionsContainer.

@Nullable
protected CollectionContainer findOptionsContainer(Table.Column columnConf) {
    String optDcName = columnConf.getXmlDescriptor() != null ? columnConf.getXmlDescriptor().attributeValue("optionsContainer") : null;
    if (Strings.isNullOrEmpty(optDcName)) {
        return null;
    } else {
        ScreenData screenData = UiControllerUtils.getScreenData(webTable.getFrame().getFrameOwner());
        InstanceContainer container = screenData.getContainer(optDcName);
        if (container instanceof CollectionContainer) {
            return (CollectionContainer) container;
        }
        throw new IllegalStateException(String.format("'%s' is not an instance of CollectionContainer", optDcName));
    }
}
Also used : InstanceContainer(io.jmix.ui.model.InstanceContainer) CollectionContainer(io.jmix.ui.model.CollectionContainer) ScreenData(io.jmix.ui.model.ScreenData) Nullable(javax.annotation.Nullable)

Example 3 with ScreenData

use of io.jmix.ui.model.ScreenData in project jmix by jmix-framework.

the class AbstractComponentLoader method loadContainer.

protected Optional<InstanceContainer> loadContainer(Element element, @Nullable String property) {
    String containerId = element.attributeValue("dataContainer");
    // For instance, a component is placed within the Form component
    if (Strings.isNullOrEmpty(containerId) && property != null) {
        containerId = getParentDataContainer(element);
    }
    if (!Strings.isNullOrEmpty(containerId)) {
        if (property == null) {
            throw new GuiDevelopmentException(String.format("Can't set container '%s' for component '%s' because 'property' " + "attribute is not defined", containerId, element.attributeValue("id")), context);
        }
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        return Optional.of(screenData.getContainer(containerId));
    }
    return Optional.empty();
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) ScreenData(io.jmix.ui.model.ScreenData)

Example 4 with ScreenData

use of io.jmix.ui.model.ScreenData in project jmix by jmix-framework.

the class AbstractComponentLoader method loadOptionsContainer.

protected Optional<CollectionContainer> loadOptionsContainer(Element element) {
    String containerId = element.attributeValue("optionsContainer");
    if (containerId != null) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        InstanceContainer container = screenData.getContainer(containerId);
        if (!(container instanceof CollectionContainer)) {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
        }
        return Optional.of((CollectionContainer) container);
    }
    return Optional.empty();
}
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)

Example 5 with ScreenData

use of io.jmix.ui.model.ScreenData in project jmix by jmix-framework.

the class PivotTableLoader method loadDataContainer.

protected void loadDataContainer(PivotTable pivotTable, Element element) {
    String dataContainerId = element.attributeValue("dataContainer");
    if (StringUtils.isNotEmpty(dataContainerId)) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        CollectionContainer dataContainer;
        InstanceContainer container = screenData.getContainer(dataContainerId);
        if (container instanceof CollectionContainer) {
            dataContainer = (CollectionContainer) container;
        } else {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context);
        }
        pivotTable.setDataProvider(new ContainerDataProvider(dataContainer));
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) CollectionContainer(io.jmix.ui.model.CollectionContainer) InstanceContainer(io.jmix.ui.model.InstanceContainer) ContainerDataProvider(io.jmix.ui.data.impl.ContainerDataProvider) ScreenData(io.jmix.ui.model.ScreenData)

Aggregations

ScreenData (io.jmix.ui.model.ScreenData)25 FrameOwner (io.jmix.ui.screen.FrameOwner)16 InstanceContainer (io.jmix.ui.model.InstanceContainer)13 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)11 CollectionContainer (io.jmix.ui.model.CollectionContainer)10 DataLoader (io.jmix.ui.model.DataLoader)4 ContainerDataProvider (io.jmix.ui.data.impl.ContainerDataProvider)3 ContainerOptions (io.jmix.ui.component.data.options.ContainerOptions)2 ScreenDataXmlLoader (io.jmix.ui.model.impl.ScreenDataXmlLoader)2 UiControllerUtils.getScreenData (io.jmix.ui.screen.UiControllerUtils.getScreenData)2 AnnotatedMethod (io.jmix.ui.sys.UiControllerReflectionInspector.AnnotatedMethod)2 FilterConfiguration (io.jmix.uidata.entity.FilterConfiguration)2 Nullable (javax.annotation.Nullable)2 Element (org.dom4j.Element)2 LoadDataBeforeShow (com.haulmont.cuba.gui.screen.LoadDataBeforeShow)1 DevelopmentException (io.jmix.core.DevelopmentException)1 Action (io.jmix.ui.action.Action)1 Filter (io.jmix.ui.component.Filter)1 ContainerTreeItems (io.jmix.ui.component.data.tree.ContainerTreeItems)1 ContainerValueSourceProvider (io.jmix.ui.component.data.value.ContainerValueSourceProvider)1