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();
}
}
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));
}
}
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();
}
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();
}
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));
}
}
Aggregations