use of io.jmix.ui.component.data.meta.EntityTableItems in project jmix by jmix-framework.
the class WebTable method getItemDatasource.
@SuppressWarnings("unchecked")
@Override
public Datasource getItemDatasource(Entity item) {
if (fieldDatasources == null) {
fieldDatasources = new WeakHashMap<>();
}
Object fieldDatasource = fieldDatasources.get(item);
if (fieldDatasource instanceof Datasource) {
return (Datasource) fieldDatasource;
}
EntityTableItems containerTableItems = (EntityTableItems) getItems();
Datasource datasource = DsBuilder.create().setAllowCommit(false).setMetaClass(containerTableItems.getEntityMetaClass()).setRefreshMode(CollectionDatasource.RefreshMode.NEVER).setViewName(View.LOCAL).buildDatasource();
((DatasourceImplementation) datasource).valid();
datasource.setItem(item);
fieldDatasources.put(item, datasource);
return datasource;
}
use of io.jmix.ui.component.data.meta.EntityTableItems in project jmix by jmix-framework.
the class WebGroupTable method getItemDatasource.
@SuppressWarnings("unchecked")
@Override
public Datasource getItemDatasource(Entity item) {
if (fieldDatasources == null) {
fieldDatasources = new WeakHashMap<>();
}
Object fieldDatasource = fieldDatasources.get(item);
if (fieldDatasource instanceof Datasource) {
return (Datasource) fieldDatasource;
}
EntityTableItems containerTableItems = (EntityTableItems) getItems();
Datasource datasource = DsBuilder.create().setAllowCommit(false).setMetaClass(containerTableItems.getEntityMetaClass()).setRefreshMode(CollectionDatasource.RefreshMode.NEVER).setViewName(View.LOCAL).buildDatasource();
((DatasourceImplementation) datasource).valid();
datasource.setItem(item);
fieldDatasources.put(item, datasource);
return datasource;
}
use of io.jmix.ui.component.data.meta.EntityTableItems in project jmix by jmix-framework.
the class WebTreeTable method getItemDatasource.
@SuppressWarnings("unchecked")
@Override
public Datasource getItemDatasource(Entity item) {
if (fieldDatasources == null) {
fieldDatasources = new WeakHashMap<>();
}
Object fieldDatasource = fieldDatasources.get(item);
if (fieldDatasource instanceof Datasource) {
return (Datasource) fieldDatasource;
}
EntityTableItems containerTableItems = (EntityTableItems) getItems();
Datasource datasource = DsBuilder.create().setAllowCommit(false).setMetaClass(containerTableItems.getEntityMetaClass()).setRefreshMode(CollectionDatasource.RefreshMode.NEVER).setViewName(View.LOCAL).buildDatasource();
((DatasourceImplementation) datasource).valid();
datasource.setItem(item);
fieldDatasources.put(item, datasource);
return datasource;
}
use of io.jmix.ui.component.data.meta.EntityTableItems in project jmix by jmix-framework.
the class GroupTableSettingsBinder method applyColumnSettings.
@Override
protected void applyColumnSettings(TableSettings tableSettings, Table table) {
super.applyColumnSettings(tableSettings, table);
GroupTableSettings groupTableSettings = (GroupTableSettings) tableSettings;
List<String> groupProperties = groupTableSettings.getGroupProperties();
if (groupProperties != null) {
MetaClass metaClass = ((EntityTableItems) table.getItems()).getEntityMetaClass();
List<MetaPropertyPath> properties = new ArrayList<>(groupProperties.size());
for (String id : groupProperties) {
MetaPropertyPath property = metadataTools.resolveMetaPropertyPathOrNull(metaClass, id);
if (property != null) {
properties.add(property);
} else {
log.warn("Ignored group property '{}'", id);
}
}
((GroupTable) table).groupBy(properties.toArray());
} else {
((GroupTable) table).ungroup();
}
}
use of io.jmix.ui.component.data.meta.EntityTableItems in project jmix by jmix-framework.
the class AbstractTable method tableSourceItemSetChanged.
@Override
public void tableSourceItemSetChanged(TableItems.ItemSetChangeEvent<E> event) {
// replacement for collectionChangeSelectionListener
// #PL-2035, reload selection from ds
Set<Object> selectedItemIds = getSelectedItemIds();
if (selectedItemIds == null) {
selectedItemIds = Collections.emptySet();
}
Set<Object> newSelection = new LinkedHashSet<>();
TableItems<E> tableItems = event.getSource();
for (Object entityId : selectedItemIds) {
if (tableItems.getItem(entityId) != null) {
newSelection.add(entityId);
}
}
if (tableItems.getState() == BindingState.ACTIVE && tableItems instanceof EntityTableItems) {
EntityTableItems entityTableSource = (EntityTableItems) tableItems;
if (entityTableSource.getSelectedItem() != null) {
newSelection.add(EntityValues.getId(entityTableSource.getSelectedItem()));
}
}
if (newSelection.isEmpty()) {
setSelected((E) null);
} else {
setSelectedIds(newSelection);
}
refreshActionsState();
}
Aggregations