com.vaadin.ui.Grid.Column Java Examples

The following examples show how to use com.vaadin.ui.Grid.Column. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
private static <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);
		}
	}
}
 
Example #2
Source File: GridFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the column converters.
 *
 * @param collectionPropertyConverter
 *            the collection property converter
 * @param grid
 *            the grid
 */
private static void setColumnConverters(final ListPropertyConverter[] collectionPropertyConverter,
		final Grid grid) {
	if (collectionPropertyConverter != null) {
		for (final ListPropertyConverter converter : collectionPropertyConverter) {
			grid.removeColumn(converter.getColumn());
			final Column column = grid.addColumn(converter);
			column.setCaption(WordUtils.capitalize(converter.getColumn()));
			column.setId(converter.getColumn());
		}
	}
}
 
Example #3
Source File: GridGanttLayout.java    From gantt with Apache License 2.0 5 votes vote down vote up
private Grid<Step> createGridForGantt() {

        dataProvider = new ListDataProvider<>(new ArrayList<>(gantt.getSteps()));
        Grid<Step> grid = new Grid<>(dataProvider);
        grid.setWidth(400, Unit.PIXELS);
        grid.setHeight(100, Unit.PERCENTAGE);

        Column<Step, ?> c = grid.addColumn(Step::getCaption);
        c.setSortable(false);
        c.setResizable(false);

        gantt.setVerticalScrollDelegateTarget(grid);

        return grid;
    }
 
Example #4
Source File: GridContextMenu.java    From cuba with Apache License 2.0 4 votes vote down vote up
public Column<T, ?> getColumn() {
    return column;
}
 
Example #5
Source File: DemoContentLayout.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
public DemoContentLayout() {
	final SelectGrid<TestObject> grid = new SelectGrid<>();
	grid.addColumn(TestObject::getFoo).setCaption("Foo");
	grid.addColumn(TestObject::getBar, new NumberRenderer()).setCaption("Bar");
	grid.addColumn(TestObject::getKm, new NumberRenderer()).setCaption("KM");
	grid.setHeightByRows(10);
	grid.setHeightMode(HeightMode.ROW);

	// Show it in the middle of the screen
	setStyleName("demoContentLayout");
	setSizeFull();
	addComponent(grid);
	setComponentAlignment(grid, Alignment.MIDDLE_CENTER);

	final TableSelectionModel<TestObject> tableSelect = new TableSelectionModel<>();
	grid.setSelectionModel(tableSelect);
	tableSelect.setMode(TableSelectionMode.CTRL);

	HorizontalLayout tableSelectionControls = new HorizontalLayout();
	tableSelectionControls.setCaption("Table Selection Controls");

	// Controls for testing different TableSelectionModes
	for (final TableSelectionMode t : TableSelectionMode.values()) {
		tableSelectionControls.addComponent(new Button(t.toString(), e -> tableSelect.setMode(t)));
	}

	addComponent(tableSelectionControls);

	// TODO: PagingDataProvider

	PagedDataProvider<TestObject, SerializablePredicate<TestObject>> dataProvider = new PagedDataProvider<>(
			DataProvider.ofCollection(TestObject.generateTestData(995)));
	grid.setDataProvider(dataProvider);
	PagingControls pagingControls = dataProvider.getPagingControls();

	HorizontalLayout pages = new HorizontalLayout();
	pages.setCaption("Paging controls");
	pages.addComponent(new Button("First", e -> pagingControls.setPageNumber(0)));
	pages.addComponent(new Button("Previous", e -> pagingControls.previousPage()));
	pages.addComponent(new Button("Next", e -> pagingControls.nextPage()));
	pages.addComponent(new Button("Last", e -> pagingControls.setPageNumber(pagingControls.getPageCount() - 1)));
	VerticalLayout controls = new VerticalLayout();
	controls.addComponents(tableSelectionControls, pages);
	controls.setWidth("100%");
	controls.setHeightUndefined();
	controls.setComponentAlignment(tableSelectionControls, Alignment.MIDDLE_CENTER);
	controls.setComponentAlignment(pages, Alignment.BOTTOM_CENTER);
	addComponent(controls);
	setComponentAlignment(controls, Alignment.MIDDLE_CENTER);

	grid.getEditor().setEnabled(true);
	for (Column<TestObject, ?> c : grid.getColumns()) {
		c.setHidable(true);
	}
}
 
Example #6
Source File: GridContextMenu.java    From context-menu with Apache License 2.0 4 votes vote down vote up
public Column<T, ?> getColumn() {
    return column;
}