use of com.haulmont.cuba.gui.model.impl.KeyValueContainerImpl in project cuba by cuba-platform.
the class WebAbstractDataGrid method createInstanceContainer.
protected InstanceContainer<E> createInstanceContainer(E item) {
if (itemDatasources == null) {
itemDatasources = new WeakHashMap<>();
}
Object container = itemDatasources.get(item);
if (container instanceof InstanceContainer) {
// noinspection unchecked
return (InstanceContainer<E>) container;
}
EntityDataGridItems<E> items = getEntityDataGridItemsNN();
DataComponents factory = beanLocator.get(DataComponents.class);
ViewRepository viewRepository = beanLocator.get(ViewRepository.NAME);
MetaClass metaClass = items.getEntityMetaClass();
InstanceContainer<E> instanceContainer;
if (metaClass instanceof KeyValueMetaClass) {
// noinspection unchecked
instanceContainer = (InstanceContainer<E>) new KeyValueContainerImpl((KeyValueMetaClass) metaClass);
} else {
instanceContainer = factory.createInstanceContainer(metaClass.getJavaClass());
}
instanceContainer.setView(viewRepository.getView(metaClass, View.LOCAL));
instanceContainer.setItem(item);
itemDatasources.put(item, instanceContainer);
return instanceContainer;
}
use of com.haulmont.cuba.gui.model.impl.KeyValueContainerImpl in project cuba by cuba-platform.
the class WebAbstractTable method getInstanceContainer.
@SuppressWarnings("unchecked")
@Override
public InstanceContainer<E> getInstanceContainer(E item) {
if (fieldDatasources == null) {
fieldDatasources = new WeakHashMap<>();
}
Object fieldDatasource = fieldDatasources.get(item);
if (fieldDatasource instanceof InstanceContainer) {
return (InstanceContainer<E>) fieldDatasource;
}
EntityTableItems containerTableItems = (EntityTableItems) getItems();
if (containerTableItems == null) {
throw new IllegalStateException("Table is not bound to items");
}
InstanceContainer<E> instanceContainer;
MetaClass metaClass = containerTableItems.getEntityMetaClass();
if (metaClass instanceof KeyValueMetaClass) {
instanceContainer = (InstanceContainer<E>) new KeyValueContainerImpl((KeyValueMetaClass) metaClass);
} else {
instanceContainer = dataComponents.createInstanceContainer(metaClass.getJavaClass());
}
View view = viewRepository.getView(metaClass, View.LOCAL);
instanceContainer.setView(view);
instanceContainer.setItem(item);
fieldDatasources.put(item, instanceContainer);
return instanceContainer;
}
Aggregations