use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class ComboBoxDemoPage method createComboBoxUsingComponentRenderer.
private void createComboBoxUsingComponentRenderer() {
Div message = createMessageDiv("component-selection-message");
ComboBox<Song> comboBox = new ComboBox<>();
List<Song> listOfSongs = createListOfSongs();
/*
* Providing a custom item filter allows filtering based on all of the
* rendered properties:
*/
ItemFilter<Song> filter = (song, filterString) -> song.getName().toLowerCase().contains(filterString.toLowerCase()) || song.getArtist().toLowerCase().contains(filterString.toLowerCase());
comboBox.setItems(filter, listOfSongs);
comboBox.setItemLabelGenerator(Song::getName);
comboBox.setRenderer(new ComponentRenderer<>(item -> {
VerticalLayout container = new VerticalLayout();
Label song = new Label(item.getName());
container.add(song);
Label artist = new Label(item.getArtist());
artist.getStyle().set("fontSize", "smaller");
container.add(artist);
return container;
}));
comboBox.addValueChangeListener(event -> {
if (event.getSource().isEmpty()) {
message.setText("No artist selected");
} else if (event.getOldValue() == null) {
message.setText("Selected artist: " + event.getValue().getArtist());
} else {
message.setText("Selected artist: " + event.getValue().getArtist() + "\nThe old selection was: " + event.getOldValue().getArtist());
}
});
comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
comboBox.setId("component-selection-box");
add(new Div(new H2("Using components"), new H2("Rendering items using ComponentTemplateRenderer"), comboBox, message));
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class ContextMenuView method addCard.
private void addCard(String title, Component... components) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.add(new H2(title));
layout.add(components);
add(layout);
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class IronListView method addCard.
private void addCard(String title, String description, Component... components) {
if (description != null) {
title = title + ": " + description;
}
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.add(new H2(title));
layout.add(components);
add(layout);
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class RadioButtonGroupDemoPage method addCard.
private Component addCard(String title, Component... components) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.add(new H2(title));
layout.add(components);
add(layout);
return layout;
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class CheckboxDemoPage method addCard.
private void addCard(String title, Component... components) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.add(new H2(title));
layout.add(components);
add(layout);
}
Aggregations