use of io.jmix.ui.model.ScreenData in project jmix-docs by Haulmont.
the class DeclarativeLoaderParameters method onDeclarativeLoaderParametersInit.
@Subscribe
default void onDeclarativeLoaderParametersInit(Screen.InitEvent event) {
// <1>
Screen screen = event.getSource();
// <2>
ScreenData screenData = UiControllerUtils.getScreenData(screen);
Set<DataLoader> loadersToLoadBeforeShow = new HashSet<>();
for (String loaderId : screenData.getLoaderIds()) {
DataLoader loader = screenData.getLoader(loaderId);
String query = loader.getQuery();
Matcher matcher = CONTAINER_REF_PATTERN.matcher(query);
while (matcher.find()) {
// <3>
String paramName = matcher.group(1);
String containerId = matcher.group(2);
InstanceContainer<?> container = screenData.getContainer(containerId);
container.addItemChangeListener(itemChangeEvent -> {
// <4>
// <5>
loader.setParameter(paramName, itemChangeEvent.getItem());
loader.load();
});
if (container instanceof HasLoader) {
// <6>
loadersToLoadBeforeShow.add(((HasLoader) container).getLoader());
}
}
}
DeclarativeLoaderParametersState state = // <7>
new DeclarativeLoaderParametersState(loadersToLoadBeforeShow);
Extensions.register(screen, DeclarativeLoaderParametersState.class, state);
}
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);
}
}
use of io.jmix.ui.model.ScreenData in project jmix by jmix-framework.
the class DynamicAttributesPanelLoader method loadDataContainer.
protected void loadDataContainer(DynamicAttributesPanel resultComponent, Element element) {
String containerId = element.attributeValue("dataContainer");
if (Strings.isNullOrEmpty(containerId)) {
throw new GuiDevelopmentException("DynamicAttributesPanel element doesn't have 'dataContainer' attribute", context, "DynamicAttributesPanel ID", element.attributeValue("id"));
}
FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
InstanceContainer container = screenData.getContainer(containerId);
// noinspection unchecked
resultComponent.setInstanceContainer(container);
}
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));
}
}
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);
}
Aggregations