Java 类com.vaadin.ui.renderers.NumberRenderer 实例源码

项目:holon-vaadin    文件:ExampleListing.java   
public void listing5() {
    // tag::listing5[]
    PropertyListing listing = Components.listing.properties(PROPERTIES) //
            .render(ID, new NumberRenderer(Locale.US)) // <1>
            .render(ID, value -> String.valueOf(value), new TextRenderer()) // <2>
            .build();
    // end::listing5[]
}
项目:bean-grid    文件:BeanGridNumberValueProvider.java   
@Override
public NumberRenderer getRenderer(ColumnDefinition definition) {
    if (definition.getFormat().isPresent()) {
        return new NumberRenderer(new DecimalFormat(definition.getFormat().get()));
    }

    return new NumberRenderer();
}
项目:cuba    文件:WebNumberRenderer.java   
@Override
protected Renderer<Number> createImplementation() {
    if (numberFormat != null) {
        return new NumberRenderer(numberFormat, getNullRepresentation());
    } else {
        checkNotNullArgument(formatString, "Format string may not be null");
        checkNotNullArgument(locale, "Locale may not be null");
        return new NumberRenderer(formatString, locale, getNullRepresentation());
    }
}
项目:cuba    文件:WebNumberRenderer.java   
@Override
public NumberRenderer getImplementation() {
    return (NumberRenderer) super.getImplementation();
}
项目:GridExtensionPack    文件:DemoContentLayout.java   
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);
    }
}