本文整理汇总了Java中com.vaadin.ui.Grid.Column类的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于com.vaadin.ui.Grid包,在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatHeaders
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private Grid<HeaderGridRow> formatHeaders(String title, Map<String, List<String>> headers) {
Grid<HeaderGridRow> grid = new Grid<>(HeaderGridRow.class);
grid.removeAllColumns();
Column<HeaderGridRow, String> headerColumn = grid.addColumn(HeaderGridRow::getHeader)
.setCaption("Header")
.setExpandRatio(1);
Column<HeaderGridRow, String> valuesColumn = grid.addColumn(HeaderGridRow::getValues)
.setCaption("Values")
.setDescriptionGenerator(HeaderGridRow::getValues)
.setExpandRatio(1);
grid.setItems(headers.entrySet().stream().map(HeaderGridRow::new));
grid.sort(headerColumn);
HeaderRow titleRow = grid.prependHeaderRow();
titleRow.join(headerColumn, valuesColumn).setHtml(title);
return grid;
}
示例2: setupRendererAndConverter
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
/**
* Setup {@link Renderer}s and {@link Converter}s for given <code>property</code> column, using
* {@link PropertyColumn} definition and falling back to defaults.
* @param property Property to which the column is bound
* @param column Column to setup
*/
protected void setupRendererAndConverter(P property, Column column) {
PropertyColumn<T, P> propertyColumn = getPropertyColumn(property);
if (propertyColumn != null) {
// Converter
if (propertyColumn.getConverter() != null) {
column.setConverter(propertyColumn.getConverter());
} else {
// ue default, if available
getDefaultPropertyConverter(property).ifPresent((c) -> column.setConverter(c));
}
// Renderer
if (propertyColumn.getRenderer() != null) {
column.setRenderer(propertyColumn.getRenderer());
} else {
// use default
getDefaultPropertyRenderer(property).ifPresent(r -> column.setRenderer(r));
}
}
}
示例3: initApplicationsGrid
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private void initApplicationsGrid() {
grid = new Grid<>();
// Columns
grid.removeAllColumns();
Column<Application, String> appColumn = grid.addColumn(Application::getName).setCaption("Application").setExpandRatio(0);
Column<Application, String> envColumn = grid.addColumn(Application::getEnvironment).setCaption("Environment").setExpandRatio(0);
Column<Application, String> urlColumn = grid.addColumn(Application::getUrl).setCaption("URL").setExpandRatio(1);
// Items
grid.setItems(applications);
// Header filter row
initFilterRow(appColumn, envColumn, urlColumn);
// Style
grid.setStyleGenerator(app -> app.isUp() ? null : "app-down");
grid.addItemClickListener(applicationOnClick());
grid.setSizeFull();
grid.setHeightByRows(applications.size());
grid.sort(appColumn);
grid.setRowHeight(40);
}
示例4: setEditorBinding
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private void setEditorBinding(P property, Column column, HasValue editor, boolean readOnly,
PropertyColumn<?, ?> pc) {
BindingBuilder builder = getGrid().getEditor().getBinder().forField(editor);
if (pc.isRequired()) {
final Localizable requiredMessage = (pc.getRequiredMessage() != null) ? pc.getRequiredMessage()
: RequiredInputValidator.DEFAULT_REQUIRED_ERROR;
builder.asRequired(context -> {
return LocalizationContext.translate(requiredMessage, true);
});
}
// default validators
getDefaultPropertyValidators(property).forEach(v -> builder.withValidator(new ValidatorWrapper<>(v)));
// validators
pc.getValidators().forEach(v -> builder.withValidator(v));
// bind
column.setEditorBinding(builder.bind(getColumnId(property)));
// set editable if not read-only
column.setEditable(!readOnly);
}
示例5: getRenderer
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
protected Renderer<?> getRenderer(final String propId) {
// Grid.Column (as of 8.0.3) does not expose its renderer, we have to get it from extensions
final Column<T, ?> column = getColumn(propId);
if (column != null) {
for (Extension each : column.getExtensions()) {
if (each instanceof Renderer<?>) {
return (Renderer<?>) each;
}
}
}
return null;
}
示例6: getAllMetricsGrid
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private Grid<MetricsGridRow> getAllMetricsGrid(Map<String, Number> metrics) {
allMetricsRows = metrics.entrySet().stream()
.map(MetricsGridRow::new)
.collect(Collectors.toList());
Grid<MetricsGridRow> grid = new Grid<>(MetricsGridRow.class);
grid.removeAllColumns();
Column<MetricsGridRow, String> nameColumn = grid.addColumn(MetricsGridRow::getName)
.setCaption("Name")
.setExpandRatio(1);
grid.addColumn(MetricsGridRow::getValue).setCaption("Value");
grid.setItems(allMetricsRows);
grid.sort(nameColumn);
grid.setSizeFull();
grid.setRowHeight(40);
TextField filterInput = new TextField();
filterInput.setPlaceholder("filter by metric...");
filterInput.addValueChangeListener(e -> updateMetrics(e.getValue()));
filterInput.setValueChangeMode(ValueChangeMode.LAZY);
filterInput.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(nameColumn).setComponent(filterInput);
return grid;
}
示例7: initFilterRow
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private void initFilterRow(Column<Application, String> appColumn, Column<Application, String> envColumn, Column<Application, String> urlColumn) {
TextField filterApp = new TextField();
TextField filterEnv = new TextField();
TextField filterUrl = new TextField();
filterApp.setPlaceholder("filter by application...");
filterApp.addValueChangeListener(e -> updateApplications(e.getValue(), filterEnv.getValue(), filterUrl.getValue()));
filterApp.setValueChangeMode(ValueChangeMode.LAZY);
filterApp.focus();
filterApp.setSizeFull();
filterEnv.setPlaceholder("filter by environment...");
filterEnv.addValueChangeListener(e -> updateApplications(filterApp.getValue(), e.getValue(), filterUrl.getValue()));
filterEnv.setValueChangeMode(ValueChangeMode.LAZY);
filterEnv.setSizeFull();
filterUrl.setPlaceholder("filter by URL...");
filterUrl.addValueChangeListener(e -> updateApplications(filterApp.getValue(), filterEnv.getValue(), e.getValue()));
filterUrl.setValueChangeMode(ValueChangeMode.LAZY);
filterUrl.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(appColumn).setComponent(filterApp);
filterRow.getCell(envColumn).setComponent(filterEnv);
filterRow.getCell(urlColumn).setComponent(filterUrl);
}
示例8: getPropertyColumns
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
@Override
public List<P> getPropertyColumns() {
List<Column<T, ?>> columns = getGrid().getColumns();
if (columns != null && !columns.isEmpty()) {
List<P> properties = new ArrayList<>(columns.size());
for (Column<T, ?> column : columns) {
properties.add(getColumnProperty(column.getId()));
}
return properties;
}
return Collections.emptyList();
}
示例9: setPropertyColumnVisible
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
@Override
public void setPropertyColumnVisible(P property, boolean visible) {
ObjectUtils.argumentNotNull(property, "Property must be not null");
String id = getColumnId(property);
if (id != null) {
Column<T, ?> column = getGrid().getColumn(id);
if (column != null) {
column.setHidden(!visible);
}
}
}
示例10: hackDateColumnWidth
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private void hackDateColumnWidth(Grid grid) {
List<Column> columns = grid.getColumns();
if (columns.isEmpty()) {
return;
}
Column lastCol = columns.get(columns.size() - 1);
if (!"orderTime".equals(lastCol.getPropertyId())) {
return;
}
lastCol.setWidth(174);
}
示例11: initSelectionMode
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
/**
* Init selection mode
*/
private void initSelectionMode() {
final CheckBox checkBox = new CheckBox("Multi Select");
addComponent(checkBox);
checkBox.setImmediate(true);
checkBox.setValue(false);
checkBox.addValueChangeListener(new ValueChangeListener() {
/**
*
*/
private static final long serialVersionUID = -1261311232228188664L;
@Override
public void valueChange(ValueChangeEvent event) {
if (checkBox.getValue()) {
grid.setSelectionMode(SelectionMode.MULTI);
grid.recalculateColumnWidths();
// Seems to be some bug in Vaadin Grid when expand ration is
// not given the column shrinks and this is visible when
// selection mode is single
for (Column column : grid.getColumns()) {
column.setExpandRatio(1);
}
} else {
grid.setSelectionMode(SelectionMode.SINGLE);
}
}
});
}
示例12: initGridProperties
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
/**
* Initializes basic properties of the grid
*/
private void initGridProperties() {
grid.setHeightMode(HeightMode.ROW);
grid.setWidth(100, Unit.PERCENTAGE);
grid.setColumnOrder(new Object[] { "customerName", "city", "pincode",
"gender" });
// Hiding is not supported by Grid, in order to remove/hide a column use
// this API
grid.removeColumn("customerID");
Column dob = grid.getColumn("dob");
dob.setRenderer(new DateRenderer(DateFormat
.getDateInstance(DateFormat.MEDIUM)));
}
示例13: initGridColumns
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private void initGridColumns() {
Column customerName = grid.getColumn("customerName");
Column city = grid.getColumn("city");
Column pincode = grid.getColumn("pincode");
Column gender = grid.getColumn("gender");
Column dob = grid.getColumn("dob");
customerName.setHeaderCaption("Customer Name");
city.setHeaderCaption("City");
pincode.setHeaderCaption("Pin Code");
gender.setHeaderCaption("Gender");
dob.setHeaderCaption("Date of Birth");
// Set Column order of Grid
grid.setColumnOrder("customerName", "dob", "city", "gender", "pincode");
}
示例14: setDefaultGridProperties
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
/**
* Sets the default properties of grid
*/
protected void setDefaultGridProperties() {
grid.setSelectionMode(SelectionMode.SINGLE);
grid.removeColumn("id");
grid.removeColumn("sales2012.totalSales");
grid.removeColumn("sales2013.totalSales");
grid.removeColumn("sales2014.totalSales");
grid.setImmediate(true);
grid.setHeightMode(HeightMode.CSS);
for (Column column : grid.getColumns()) {
column.setExpandRatio(1);
}
}
示例15: createNestedProperties
import com.vaadin.ui.Grid.Column; //导入依赖的package包/类
private <T extends Serializable> void createNestedProperties(final Grid<T> grid, final String[] nestedProperties) {
if (nestedProperties != null) {
for (final String property : nestedProperties) {
final Column<T, ?> addColumn = grid.addColumn(new BeanNestedPropertyValueProvider<T>(property));
addColumn.setId(property);
}
}
}