use of com.haulmont.cuba.web.toolkit.ui.converters.FormatterBasedConverter in project cuba by cuba-platform.
the class WebDataGrid method setupGridColumnProperties.
protected void setupGridColumnProperties(Grid.Column gridColumn, Column column) {
gridColumn.setHeaderCaption(column.getCaption());
gridColumn.setHidingToggleCaption(column.getCollapsingToggleCaption());
if (column.isWidthAuto()) {
gridColumn.setWidthUndefined();
} else {
gridColumn.setWidth(column.getWidth());
}
gridColumn.setExpandRatio(column.getExpandRatio());
gridColumn.setMinimumWidth(column.getMinimumWidth());
gridColumn.setMaximumWidth(column.getMaximumWidth());
gridColumn.setHidden(column.isCollapsed());
gridColumn.setHidable(column.isCollapsible() && column.getOwner().isColumnsCollapsingAllowed());
gridColumn.setResizable(column.isResizable());
gridColumn.setEditable(column.isEditable());
AppUI current = AppUI.getCurrent();
if (current != null && current.isTestMode()) {
addColumnId(gridColumn, column);
}
// workaround to prevent exception from GridColumn while Grid is using default IndexedContainer
if (getContainerDataSource() instanceof SortableDataGridIndexedCollectionDsWrapper) {
gridColumn.setSortable(column.isSortable() && column.getOwner().isSortable());
}
((ColumnImpl) column).setGridColumn(gridColumn);
if (column.getFormatter() != null) {
FormatterBasedConverter converter = new FormatterBasedConverter(column.getFormatter());
gridColumn.setConverter(converter);
} else {
MetaProperty metaProperty = column.getPropertyPath() != null ? column.getPropertyPath().getMetaProperty() : null;
if (metaProperty != null && Collection.class.isAssignableFrom(metaProperty.getJavaType())) {
final FormatterBasedConverter converter = new FormatterBasedConverter(new CollectionFormatter());
gridColumn.setConverter(converter);
} else {
setDefaultConverter(gridColumn, metaProperty, column.getType());
setDefaultRenderer(gridColumn, metaProperty, column.getType());
}
}
}
Aggregations