Search in sources :

Example 21 with ScreenData

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

the class AbstractChartLoader method loadDataContainer.

protected void loadDataContainer(Chart chart, 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);
        }
        chart.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)

Example 22 with ScreenData

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

the class UiDataFilterSupport method registerConfigurationDc.

protected void registerConfigurationDc(FilterConfiguration configurationModel, FrameOwner owner) {
    InstanceContainer<FilterConfiguration> configurationDc = dataComponents.createInstanceContainer(FilterConfiguration.class);
    configurationDc.setItem(configurationModel);
    ScreenData screenData = UiControllerUtils.getScreenData(owner);
    screenData.registerContainer(CONFIGURATION_CONTAINER_ID, configurationDc);
}
Also used : FilterConfiguration(io.jmix.uidata.entity.FilterConfiguration) ScreenData(io.jmix.ui.model.ScreenData)

Example 23 with ScreenData

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

the class UiDataFilterSupport method getFragmentFilterConfigurationModel.

protected FilterConfiguration getFragmentFilterConfigurationModel(Filter.Configuration configuration, ScreenFragment configurationFragment) {
    Filter filter = configuration.getOwner();
    FilterConfiguration configurationModel;
    if (configurationFragment instanceof UiDataFilterConfigurationModelFragment) {
        ScreenData screenData = UiControllerUtils.getScreenData(configurationFragment.getHostController());
        InstanceContainer<FilterConfiguration> configurationDc = screenData.getContainer(CONFIGURATION_CONTAINER_ID);
        configurationModel = configurationDc.getItem();
        if (filter.getId() != null && filter.getFrame() != null && ((UiDataFilterConfigurationModelFragment) configurationFragment).getDefaultForMeFieldVisible()) {
            ScreenSettingsFacet settingsFacet = UiControllerUtils.getFacet(filter.getFrame(), ScreenSettingsFacet.class);
            if (settingsFacet != null) {
                saveFilterSettings(settingsFacet, filter.getId(), configurationModel);
            }
        }
    } else {
        configurationModel = loadFilterConfigurationModel(filter, configuration.getId());
    }
    if (configurationModel == null) {
        configurationModel = createFilterConfigurationModel(configuration);
    }
    return configurationModel;
}
Also used : ScreenSettingsFacet(io.jmix.ui.settings.facet.ScreenSettingsFacet) Filter(io.jmix.ui.component.Filter) FilterConfiguration(io.jmix.uidata.entity.FilterConfiguration) UiDataFilterConfigurationModelFragment(io.jmix.uidata.app.filter.configuration.UiDataFilterConfigurationModelFragment) ScreenData(io.jmix.ui.model.ScreenData)

Example 24 with ScreenData

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

the class DataLoadCoordinatorImpl method configureAutomatically.

@Override
public void configureAutomatically() {
    FrameOwner frameOwner = getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    getUnconfiguredLoaders(screenData).forEach(loader -> configureAutomatically(loader, frameOwner));
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) ScreenData(io.jmix.ui.model.ScreenData)

Example 25 with ScreenData

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

the class TokenListLoader method loadOptionsContainer.

protected void loadOptionsContainer(TokenList component, 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);
        }
        // noinspection unchecked
        component.setOptions(new ContainerOptions((CollectionContainer) container));
    }
    if (component.getOptions() == null) {
        DatasourceLoaderHelper.loadOptionsDatasource(element, (ComponentLoaderContext) getComponentContext()).ifPresent(component::setOptions);
    }
}
Also used : ContainerOptions(io.jmix.ui.component.data.options.ContainerOptions) 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)

Aggregations

ScreenData (io.jmix.ui.model.ScreenData)26 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)5 ContainerDataProvider (io.jmix.ui.data.impl.ContainerDataProvider)3 ContainerOptions (io.jmix.ui.component.data.options.ContainerOptions)2 HasLoader (io.jmix.ui.model.HasLoader)2 ScreenDataXmlLoader (io.jmix.ui.model.impl.ScreenDataXmlLoader)2 Screen (io.jmix.ui.screen.Screen)2 Subscribe (io.jmix.ui.screen.Subscribe)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 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 Nullable (javax.annotation.Nullable)2 Element (org.dom4j.Element)2 LoadDataBeforeShow (com.haulmont.cuba.gui.screen.LoadDataBeforeShow)1