Search in sources :

Example 1 with KeyValueCollectionContainer

use of io.jmix.ui.model.KeyValueCollectionContainer in project jmix by jmix-framework.

the class ShowReportTableScreen method drawTables.

protected void drawTables(JmixTableData dto) {
    Map<String, List<KeyValueEntity>> data = dto.getData();
    Map<String, Set<JmixTableData.ColumnInfo>> headerMap = dto.getHeaders();
    tablesVBoxLayout.removeAll();
    if (data == null || data.isEmpty())
        return;
    data.forEach((dataSetName, keyValueEntities) -> {
        if (CollectionUtils.isNotEmpty(keyValueEntities)) {
            KeyValueCollectionContainer container = createContainer(dataSetName, keyValueEntities, headerMap);
            Table table = createTable(dataSetName, container, headerMap);
            GroupBoxLayout groupBox = uiComponents.create(GroupBoxLayout.class);
            groupBox.setCaption(dataSetName);
            groupBox.add(table);
            groupBox.expand(table);
            tablesVBoxLayout.add(groupBox);
            tablesVBoxLayout.expand(groupBox);
        }
    });
}
Also used : Set(java.util.Set) JmixTableData(io.jmix.reports.entity.JmixTableData) KeyValueCollectionContainer(io.jmix.ui.model.KeyValueCollectionContainer) List(java.util.List)

Example 2 with KeyValueCollectionContainer

use of io.jmix.ui.model.KeyValueCollectionContainer in project jmix by jmix-framework.

the class ShowReportTableScreen method createContainer.

protected KeyValueCollectionContainer createContainer(String dataSetName, List<KeyValueEntity> keyValueEntities, Map<String, Set<JmixTableData.ColumnInfo>> headerMap) {
    KeyValueCollectionContainer collectionContainer = dataComponents.createKeyValueCollectionContainer();
    collectionContainer.setIdName(dataSetName + "Dc");
    collectionContainer.setItems(keyValueEntities);
    Set<JmixTableData.ColumnInfo> columnInfos = headerMap.get(dataSetName);
    columnInfos.forEach(columnInfo -> {
        Class javaClass = columnInfo.getColumnClass();
        if (Entity.class.isAssignableFrom(javaClass) || EnumClass.class.isAssignableFrom(javaClass) || datatypeRegistry.find(javaClass) != null) {
            collectionContainer.addProperty(columnInfo.getKey(), javaClass);
        }
    });
    return collectionContainer;
}
Also used : KeyValueCollectionContainer(io.jmix.ui.model.KeyValueCollectionContainer) EnumClass(io.jmix.core.metamodel.datatype.impl.EnumClass)

Aggregations

KeyValueCollectionContainer (io.jmix.ui.model.KeyValueCollectionContainer)2 EnumClass (io.jmix.core.metamodel.datatype.impl.EnumClass)1 JmixTableData (io.jmix.reports.entity.JmixTableData)1 List (java.util.List)1 Set (java.util.Set)1