use of com.vaadin.ui.ComboBox in project GridFastNavigation by TatuLund.
the class DemoUI method initGrid.
private void initGrid(final Grid grid) {
// Add some columns
DeleteButtonRenderer deleteButton = new DeleteButtonRenderer(new DeleteRendererClickListener() {
@Override
public void click(DeleteRendererClickEvent event) {
grid.getContainerDataSource().removeItem(event.getItem());
}
}, FontAwesome.TRASH.getHtml() + " Delete", FontAwesome.CHECK.getHtml() + " Confirm");
deleteButton.setHtmlContentAllowed(true);
grid.addColumn("action", Boolean.class);
grid.getColumn("action").setEditable(false);
grid.getColumn("action").setRenderer(deleteButton);
grid.addColumn("col1", String.class);
grid.addColumn("col2", String.class);
for (int i = 0; i < 5; ++i) {
grid.addColumn("col" + (i + 3), Integer.class);
}
grid.addColumn("col8", Date.class);
grid.addColumn("col10", Boolean.class);
grid.addColumn("col11", String.class);
ComboBox comboBox = new ComboBox();
comboBox.addItems("Soft", "Medium", "Hard");
grid.getColumn("col11").setEditorField(comboBox);
// Make column 2 read only to test statically read only columns
grid.getColumn("col2").setEditable(false);
Random rand = new Random();
for (int i = 0; i < 100; ++i) {
grid.addRow(true, "string 1 " + i, "string 2 " + i, rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), new Date(), false, "Medium");
}
grid.setSelectionMode(SelectionMode.SINGLE);
grid.setSizeFull();
}
use of com.vaadin.ui.ComboBox in project cia by Hack23.
the class CommitteeDecisionFlowPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);
final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenCommittee.class);
final ViewRiksdagenCommittee viewRiksdagenCommittee = dataContainer.load(pageId);
if (viewRiksdagenCommittee != null) {
String selectedYear = "2017/18";
if (parameters != null && parameters.contains("[") && parameters.contains("]")) {
selectedYear = parameters.substring(parameters.indexOf('[') + 1, parameters.lastIndexOf(']'));
}
ComboBox<String> comboBox = new ComboBox<>("Select year", Collections.unmodifiableList(Arrays.asList("2017/18", "2016/17", "2015/16", "2014/15", "2013/14", "2012/13", "2011/12", "2010/11")));
panelContent.addComponent(comboBox);
panelContent.setExpandRatio(comboBox, ContentRatio.SMALL2);
comboBox.setSelectedItem(selectedYear);
comboBox.addValueChangeListener(event -> {
if (!event.getSource().isEmpty()) {
UI.getCurrent().getNavigator().navigateTo(NAME + "/" + PageMode.CHARTS.toString() + "/" + ChartIndicators.DECISION_FLOW_CHART.toString() + "/" + pageId + "[" + event.getValue() + "]");
}
});
final Map<String, List<ViewRiksdagenCommittee>> committeeMap = dataContainer.getAll().stream().collect(Collectors.groupingBy(c -> c.getEmbeddedId().getOrgCode().toUpperCase(Locale.ENGLISH)));
SankeyChart chart = decisionFlowChartManager.createCommitteeDecisionFlow(viewRiksdagenCommittee, committeeMap, comboBox.getSelectedItem().orElse(selectedYear));
panelContent.addComponent(chart);
panelContent.setExpandRatio(chart, ContentRatio.LARGE);
}
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
panel.setCaption(new StringBuilder().append(NAME).append("::").append(COMMITTEE_DECISION_FLOW).toString());
return panelContent;
}
use of com.vaadin.ui.ComboBox in project linkki by linkki-framework.
the class UIComboBoxIntegrationTest method testStaticAvailableValues.
@Test
public void testStaticAvailableValues() {
ComboBox staticComboBox = getStaticComponent();
assertThat(staticComboBox.getItemIds(), contains(TestEnum.ONE, TestEnum.TWO, TestEnum.THREE));
}
use of com.vaadin.ui.ComboBox in project linkki by linkki-framework.
the class UIComboBoxIntegrationTest method testNullSelection.
@Test
public void testNullSelection() {
assertThat(getStaticComponent().isNullSelectionAllowed(), is(false));
List<TestEnum> availableValues = new ArrayList<>(getDefaultPmo().getValueAvailableValues());
ComboBox comboBox = getDynamicComponent();
assertThat(availableValues.contains(null), is(false));
assertThat(comboBox.isNullSelectionAllowed(), is(false));
availableValues.add(null);
assertThat(availableValues.contains(null), is(true));
getDefaultPmo().setValueAvailableValues(availableValues);
updateUi();
assertThat(comboBox.getItemIds(), contains(TestEnum.ONE, TestEnum.TWO, TestEnum.THREE, comboBox.getNullSelectionItemId()));
}
use of com.vaadin.ui.ComboBox in project linkki by linkki-framework.
the class UIYesNoComboBoxIntegrationTest method testNullSelection.
@Test
public void testNullSelection() {
assertThat(getStaticComponent().isNullSelectionAllowed(), is(false));
ComboBox comboBox = getDynamicComponent();
assertThat(comboBox.isNullSelectionAllowed(), is(false));
assertThat(getDynamicComponent().getItemIds(), contains(null, true, false));
comboBox.setValue(null);
assertThat(getDefaultModelObject().value, is(nullValue()));
comboBox.setValue(false);
getDefaultModelObject().value = true;
updateUi();
assertThat(comboBox.getValue(), is(true));
}
Aggregations