use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class ComboBoxDemoPage method createComboBoxWithCustomValues.
private void createComboBoxWithCustomValues() {
Div message = createMessageDiv("custom-value-message");
ComboBox<String> comboBox = new ComboBox<>("City");
comboBox.setItems("Turku", "Berlin", "San Jose");
/**
* Allow users to enter a value which doesn't exist in the data set, and
* set it as the value of the ComboBox.
*/
comboBox.addCustomValueSetListener(event -> {
comboBox.setValue(event.getDetail());
});
comboBox.addValueChangeListener(event -> {
if (event.getSource().isEmpty()) {
message.setText("No city selected");
} else {
message.setText("Selected city: " + event.getValue());
}
});
comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
comboBox.setId("custom-value-box");
add(new Div(new H2("Custom Values"), new H2("Allow users to input custom values"), comboBox, message));
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class ComboBoxDemoPage method createStringComboBox.
private void createStringComboBox() {
Div message = createMessageDiv("string-selection-message");
ComboBox<String> comboBox = new ComboBox<>("Browsers");
comboBox.setItems("Google Chrome", "Mozilla Firefox", "Opera", "Apple Safari", "Microsoft Edge");
comboBox.addValueChangeListener(event -> {
if (event.getSource().isEmpty()) {
message.setText("No browser selected");
} else {
message.setText("Selected browser: " + event.getValue());
}
});
comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
comboBox.setId("string-selection-box");
add(new Div(new H2("String selection"), comboBox, message));
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class ComboBoxDemoPage method createDisabledComboBox.
private void createDisabledComboBox() {
Div message = createMessageDiv("disabled-combobox-message");
ComboBox<String> comboBox = new ComboBox<>("Disabled ComboBox");
comboBox.setEnabled(false);
comboBox.setItems("Google Chrome", "Mozilla Firefox", "Opera", "Apple Safari", "Microsoft Edge");
comboBox.addValueChangeListener(event -> {
if (event.getSource().isEmpty()) {
message.setText("No browser selected");
} else {
message.setText("Selected browser: " + event.getValue());
}
});
comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
comboBox.setId("disabled-combo-box");
add(new Div(new H2("Disabled ComboBox"), comboBox, message));
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class GridUpdateDataProviderPage method createBasicGrid.
private void createBasicGrid() {
Grid<String> grid = new Grid<>();
grid.setId("basic-grid");
DataProvider<String, ?> orig = DataProvider.fromCallbacks(query -> IntStream.range(query.getOffset(), query.getOffset() + query.getLimit()).mapToObj(Integer::toString), query -> 10000);
DataProvider<String, ?> updated = DataProvider.ofItems("foo", "foob", "fooba", "foobar");
grid.setDataProvider(orig);
grid.addColumn(i -> i).setHeader("text");
grid.addColumn(i -> String.valueOf(i.length())).setHeader("length");
NativeButton updateProvider = new NativeButton("Use another provider", event -> swapDataProviders(grid, orig, updated));
updateProvider.setId("update-basic-provider");
add(new H2("Basic grid"), grid, updateProvider);
}
use of com.vaadin.flow.component.html.H2 in project flow-components by vaadin.
the class GridMultiSelectionColumnPage method createInMemoryGrid.
private void createInMemoryGrid() {
Grid<String> grid = new Grid<>();
grid.setItems(IntStream.range(0, ITEM_COUNT).mapToObj(Integer::toString));
setUp(grid);
grid.setId(IN_MEMORY_GRID_ID);
add(new H2("In-memory grid"), grid);
}
Aggregations