Search in sources :

Example 1 with TableDataContainer

use of com.haulmont.cuba.web.gui.components.table.TableDataContainer in project cuba by cuba-platform.

the class WebGroupTable method formatGroupPropertyValue.

protected String formatGroupPropertyValue(GroupInfo<MetaPropertyPath> groupId, @Nullable Object value) {
    if (value == null) {
        return "";
    }
    MetaPropertyPath propertyPath = groupId.getProperty();
    Table.Column<E> column = columns.get(propertyPath);
    if (column != null) {
        if (column.getFormatter() != null) {
            return column.getFormatter().apply(value);
        } else if (column.getXmlDescriptor() != null) {
            // vaadin8 move to Column
            String captionProperty = column.getXmlDescriptor().attributeValue("captionProperty");
            if (StringUtils.isNotEmpty(captionProperty)) {
                Collection<?> children = component.getGroupItemIds(groupId);
                if (children.isEmpty()) {
                    return null;
                }
                Object itemId = children.iterator().next();
                TableDataContainer container = (TableDataContainer) component.getContainerDataSource();
                Instance item = (Instance) container.getInternalItem(itemId);
                Object captionValue = item.getValueEx(captionProperty);
                // vaadin8 use metadataTools format with metaproperty
                return metadataTools.format(captionValue);
            }
        }
    }
    return metadataTools.format(value, propertyPath.getMetaProperty());
}
Also used : TableDataContainer(com.haulmont.cuba.web.gui.components.table.TableDataContainer) GroupTableDataContainer(com.haulmont.cuba.web.gui.components.table.GroupTableDataContainer) GroupTable(com.haulmont.cuba.gui.components.GroupTable) Table(com.haulmont.cuba.gui.components.Table) CubaGroupTable(com.haulmont.cuba.web.widgets.CubaGroupTable) Instance(com.haulmont.chile.core.model.Instance) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Aggregations

Instance (com.haulmont.chile.core.model.Instance)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 GroupTable (com.haulmont.cuba.gui.components.GroupTable)1 Table (com.haulmont.cuba.gui.components.Table)1 GroupTableDataContainer (com.haulmont.cuba.web.gui.components.table.GroupTableDataContainer)1 TableDataContainer (com.haulmont.cuba.web.gui.components.table.TableDataContainer)1 CubaGroupTable (com.haulmont.cuba.web.widgets.CubaGroupTable)1