import com.vaadin.ui.Table; //导入方法依赖的package包/类
/**
* Setup column configuration for given property
using its {@link PropertyColumn} definition.
* @param property Property to which the column is bound
* @param table Table to setup
*/
protected void setupTablePropertyColumn(P property, Table table) {
PropertyColumn propertyColumn = getPropertyColumn(property);
if (propertyColumn != null) {
// header
if (propertyColumn.getCaption() != null) {
String header = LocalizationContext.translate(propertyColumn.getCaption(), true);
if (header != null) {
table.setColumnHeader(property, header);
}
}
// alignment
if (propertyColumn.getAlignment() != null) {
switch (propertyColumn.getAlignment()) {
case CENTER:
table.setColumnAlignment(property, Align.CENTER);
break;
case LEFT:
table.setColumnAlignment(property, Align.LEFT);
break;
case RIGHT:
table.setColumnAlignment(property, Align.RIGHT);
break;
default:
break;
}
}
// width
if (propertyColumn.getWidth() > -1) {
table.setColumnWidth(property, propertyColumn.getWidth());
}
// expand
if (propertyColumn.getTableExpandRatio() > -1) {
table.setColumnExpandRatio(property, propertyColumn.getTableExpandRatio());
}
// hiding
if (propertyColumn.isHidable()) {
table.setColumnCollapsible(property, true);
if (propertyColumn.isHidden()) {
table.setColumnCollapsed(property, true);
}
} else {
table.setColumnCollapsible(property, false);
}
// icon
if (propertyColumn.getIcon() != null) {
table.setColumnIcon(property, propertyColumn.getIcon());
}
}
}