use of io.jmix.ui.model.CollectionContainer 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.CollectionContainer 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.CollectionContainer 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));
}
}
use of io.jmix.ui.model.CollectionContainer in project jmix by jmix-framework.
the class EntityLinkFieldImpl method afterCommitOpenedEntity.
protected void afterCommitOpenedEntity(Object item) {
MetaProperty metaProperty = getMetaPropertyForEditedValue();
if (metaProperty != null && metaProperty.getRange().isClass()) {
if (getValueSource() != null) {
CollectionContainer ownerCollectionCont = null;
if (getCollectionContainerFromOwner() != null) {
ownerCollectionCont = ((ContainerDataUnit) owner.getItems()).getContainer();
ownerCollectionCont.mute();
}
// noinspection unchecked
setValueSilently((V) item);
if (ownerCollectionCont != null) {
ownerCollectionCont.unmute();
}
} else {
// noinspection unchecked
setValue((V) item);
}
// if we edit property with non Entity type and set ListComponent owner
} else if (owner != null) {
if (getCollectionContainerFromOwner() != null) {
// do not listen changes in collection
getCollectionContainerFromOwner().mute();
// noinspection unchecked
getCollectionContainerFromOwner().replaceItem(item);
MetaPropertyPath metaPropertyPath = ((ContainerValueSource) getValueSource()).getMetaPropertyPath();
setValueSilently(EntityValues.getValueEx(item, metaPropertyPath));
// listen changes
getCollectionContainerFromOwner().unmute();
}
if (owner instanceof Focusable) {
// focus owner
((Focusable) owner).focus();
}
// if we edit property with non Entity type
} else {
// noinspection unchecked
setValueSilently((V) item);
}
}
use of io.jmix.ui.model.CollectionContainer 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);
}
}
Aggregations