use of io.jmix.ui.model.InstanceContainer 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)));
}
use of io.jmix.ui.model.InstanceContainer 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.InstanceContainer in project jmix by jmix-framework.
the class WebTable method clearFieldDatasources.
@Override
protected void clearFieldDatasources() {
if (fieldDatasources == null) {
return;
}
// detach instance containers from entities explicitly
for (Map.Entry<Object, Object> entry : fieldDatasources.entrySet()) {
if (entry.getValue() instanceof InstanceContainer) {
InstanceContainer container = (InstanceContainer) entry.getValue();
container.setItem(null);
} else if (entry.getValue() instanceof Datasource) {
Datasource datasource = (Datasource) entry.getValue();
datasource.setItem(null);
}
}
fieldDatasources.clear();
}
use of io.jmix.ui.model.InstanceContainer in project jmix by jmix-framework.
the class WebGroupTable method clearFieldDatasources.
@Override
protected void clearFieldDatasources() {
if (fieldDatasources == null) {
return;
}
// detach instance containers from entities explicitly
for (Map.Entry<Object, Object> entry : fieldDatasources.entrySet()) {
if (entry.getValue() instanceof InstanceContainer) {
InstanceContainer container = (InstanceContainer) entry.getValue();
container.setItem(null);
} else if (entry.getValue() instanceof Datasource) {
Datasource datasource = (Datasource) entry.getValue();
datasource.setItem(null);
}
}
fieldDatasources.clear();
}
use of io.jmix.ui.model.InstanceContainer 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);
}
Aggregations