com.vaadin.ui.renderers.DateRenderer Java Examples

The following examples show how to use com.vaadin.ui.renderers.DateRenderer. 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: DemoUI.java    From vaadin-grid-util with MIT License 5 votes vote down vote up
private void setColumnRenderes(final Grid grid) {
    grid.getColumn("id")
            .setRenderer(
                    new EditDeleteButtonValueRenderer<Inhabitants>(edit -> {
                        Notification.show(edit.getItem()
                                .toString() + " want's to get edited", Type.HUMANIZED_MESSAGE);
                    }, delete -> {
                        Notification.show(delete.getItem()
                                .toString() + " want's to get deleted", Type.WARNING_MESSAGE);

                    }))
            .setWidth(160);

    grid.getColumn("bodySize")
            .setRenderer(new IndicatorRenderer(1.8, 1.1))
            .setWidth(150);
    grid.getColumn("birthday")
            .setRenderer(new DateRenderer(DateFormat.getDateInstance()))
            .setWidth(210);
    grid.getColumn("onFacebook")
            .setRenderer(new BooleanRenderer())
            .setWidth(130);

    /*
     * the icon of the editButton will get overwritten below by css styling @see DemoUI.initColumnAlignments
     */
    grid.addColumn((ValueProvider<Inhabitants, String>) value -> String.format("%s <i>(%d)</i>",
            value.getCountry()
                    .getName(),
            value.getCountry()
                    .getPopulation()), new EditButtonValueRenderer<Inhabitants>(e -> {
        Notification.show("Goto Link for " + e.getItem()
                .getCountry()
                .getName(), Type.HUMANIZED_MESSAGE);
    }));
}
 
Example #2
Source File: MyWindow.java    From java-course-ee with MIT License 5 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    mainWindow = new Window("Test Vaadin application");

    mainWindow.setWidth(800, Unit.PIXELS);
    mainWindow.setHeight(600, Unit.PIXELS);
    mainWindow.center();

    grid.setWidth("100%");
    grid.setHeight(300, Unit.PIXELS);
    grid.setSelectionMode(Grid.SelectionMode.SINGLE);

    grid.setContainerDataSource(new BeanItemContainer<Person>(Person.class, DaoImpl.getAllPersons()));
    grid.setColumns("name", "birth");
    Grid.Column bornColumn = grid.getColumn("birth");
    bornColumn.setRenderer(new DateRenderer("%1$td-%1$tm-%1$tY"));
    grid.addSelectionListener(event -> {
        Set<Object> selected = event.getSelected();
        Person o = (Person) selected.toArray()[0];
        BeanFieldGroup.bindFieldsUnbuffered(o, formLayout);
        formLayout.id.setEnabled(true);
        formLayout.name.setEnabled(true);
        formLayout.birth.setEnabled(true);
    });

    formLayout.id.setEnabled(false);
    formLayout.name.setEnabled(false);
    formLayout.birth.setEnabled(false);

    verticalLayout.setMargin(true);

    verticalLayout.addComponent(grid);
    verticalLayout.addComponent(formLayout);

    mainWindow.setContent(verticalLayout);

    addWindow(mainWindow);
}
 
Example #3
Source File: WebDateRenderer.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public DateRenderer getImplementation() {
    return (DateRenderer) super.getImplementation();
}