Search in sources :

Example 6 with ScreenData

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

the class StockChartLoader method loadDataSet.

protected void loadDataSet(DataSet dataSet, Element dataSetElement) {
    loadFieldMappings(dataSet, dataSetElement);
    loadStockEvents(dataSet, dataSetElement);
    String id = dataSetElement.attributeValue("id");
    if (StringUtils.isNotEmpty(id)) {
        dataSet.setId(id);
    }
    checkMultipleDatasources(dataSetElement);
    String categoryField = dataSetElement.attributeValue("categoryField");
    if (StringUtils.isNotEmpty(categoryField)) {
        dataSet.setCategoryField(categoryField);
    }
    String color = dataSetElement.attributeValue("color");
    if (StringUtils.isNotEmpty(color)) {
        dataSet.setColor(Color.valueOf(color));
    }
    String compared = dataSetElement.attributeValue("compared");
    if (StringUtils.isNotEmpty(compared)) {
        dataSet.setCompared(Boolean.valueOf(compared));
    }
    String dataContainerId = dataSetElement.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);
        }
        dataSet.setDataProvider(new ContainerDataProvider(dataContainer));
    }
    String showInCompare = dataSetElement.attributeValue("showInCompare");
    if (StringUtils.isNotEmpty(showInCompare)) {
        dataSet.setShowInCompare(Boolean.valueOf(showInCompare));
    }
    String showInSelect = dataSetElement.attributeValue("showInSelect");
    if (StringUtils.isNotEmpty(showInSelect)) {
        dataSet.setShowInSelect(Boolean.valueOf(showInSelect));
    }
    String title = dataSetElement.attributeValue("title");
    if (StringUtils.isNotEmpty(title)) {
        dataSet.setTitle(title);
    }
}
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)

Example 7 with ScreenData

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

the class FormLoader method loadDataContainer.

protected void loadDataContainer(Form resultComponent, Element element) {
    String containerId = element.attributeValue("dataContainer");
    if (!Strings.isNullOrEmpty(containerId)) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        InstanceContainer container = screenData.getContainer(containerId);
        // noinspection unchecked
        resultComponent.setValueSourceProvider(new ContainerValueSourceProvider(container));
    }
}
Also used : ContainerValueSourceProvider(io.jmix.ui.component.data.value.ContainerValueSourceProvider) FrameOwner(io.jmix.ui.screen.FrameOwner) InstanceContainer(io.jmix.ui.model.InstanceContainer) ScreenData(io.jmix.ui.model.ScreenData)

Example 8 with ScreenData

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

the class FragmentLoader method loadDataElement.

protected void loadDataElement(Element element) {
    Element dataEl = element.element("data");
    if (dataEl == null) {
        return;
    }
    ScreenData hostScreenData = null;
    ComponentContext parent = getComponentContext().getParent();
    while (hostScreenData == null && parent != null) {
        hostScreenData = parent.getScreenData();
        parent = parent.getParent();
    }
    ScreenDataXmlLoader screenDataXmlLoader = applicationContext.getBean(ScreenDataXmlLoader.class);
    ScreenData screenData = UiControllerUtils.getScreenData(resultComponent.getFrameOwner());
    screenDataXmlLoader.load(screenData, dataEl, hostScreenData);
    ((ComponentLoaderContext) context).setScreenData(screenData);
}
Also used : Element(org.dom4j.Element) ScreenDataXmlLoader(io.jmix.ui.model.impl.ScreenDataXmlLoader) ScreenData(io.jmix.ui.model.ScreenData)

Example 9 with ScreenData

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

the class CalendarLoader method loadDataContainer.

@SuppressWarnings("unchecked")
protected void loadDataContainer(Calendar component, Element element) {
    String containerId = element.attributeValue("dataContainer");
    if (Strings.isNullOrEmpty(containerId)) {
        return;
    }
    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);
    }
    component.setEventProvider(new ContainerCalendarEventProvider<>(((CollectionContainer) container)));
}
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 10 with ScreenData

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

the class WindowLoader method loadScreenData.

protected void loadScreenData(Window window, Element element) {
    Element dataEl = element.element("data");
    if (dataEl != null) {
        ScreenDataXmlLoader screenDataXmlLoader = applicationContext.getBean(ScreenDataXmlLoader.class);
        ScreenData screenData = UiControllerUtils.getScreenData(window.getFrameOwner());
        screenDataXmlLoader.load(screenData, dataEl, null);
        ((ComponentLoaderContext) context).setScreenData(screenData);
    }
}
Also used : Element(org.dom4j.Element) ScreenDataXmlLoader(io.jmix.ui.model.impl.ScreenDataXmlLoader) 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