Search in sources :

Example 16 with ComboBox

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();
}
Also used : DeleteRendererClickListener(org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickListener) Random(java.util.Random) ComboBox(com.vaadin.ui.ComboBox) DeleteButtonRenderer(org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer) DeleteRendererClickEvent(org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickEvent) Date(java.util.Date)

Example 17 with ComboBox

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;
}
Also used : PageMode(com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode) Panel(com.vaadin.ui.Panel) Arrays(java.util.Arrays) ApplicationEventGroup(com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) UI(com.vaadin.ui.UI) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Secured(org.springframework.security.access.annotation.Secured) SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ViewAction(com.hack23.cia.web.impl.ui.application.action.ViewAction) Locale(java.util.Locale) Map(java.util.Map) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee) ContentRatio(com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio) MenuBar(com.vaadin.ui.MenuBar) Collectors(java.util.stream.Collectors) DecisionFlowChartManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionFlowChartManager) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Component(org.springframework.stereotype.Component) ChartIndicators(com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators) Layout(com.vaadin.ui.Layout) Collections(java.util.Collections) SankeyChart(com.hack23.cia.web.widgets.charts.SankeyChart) ComboBox(com.vaadin.ui.ComboBox) VerticalLayout(com.vaadin.ui.VerticalLayout) List(java.util.List) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee) Secured(org.springframework.security.access.annotation.Secured)

Example 18 with ComboBox

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));
}
Also used : LinkkiComboBox(org.linkki.core.ui.components.LinkkiComboBox) ComboBox(com.vaadin.ui.ComboBox) Test(org.junit.Test)

Example 19 with ComboBox

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()));
}
Also used : LinkkiComboBox(org.linkki.core.ui.components.LinkkiComboBox) ComboBox(com.vaadin.ui.ComboBox) ArrayList(java.util.ArrayList) TestEnum(org.linkki.core.binding.TestEnum) Test(org.junit.Test)

Example 20 with ComboBox

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));
}
Also used : LinkkiComboBox(org.linkki.core.ui.components.LinkkiComboBox) ComboBox(com.vaadin.ui.ComboBox) Test(org.junit.Test)

Aggregations

ComboBox (com.vaadin.ui.ComboBox)41 HorizontalLayout (com.vaadin.ui.HorizontalLayout)7 TextField (com.vaadin.ui.TextField)7 Button (com.vaadin.ui.Button)6 SplitComboBox (au.com.vaadinutils.crud.splitFields.SplitComboBox)5 LegacySplitComboBox (au.com.vaadinutils.crud.splitFields.legacy.LegacySplitComboBox)5 Item (com.vaadin.data.Item)5 Label (com.vaadin.ui.Label)5 VerticalLayout (com.vaadin.ui.VerticalLayout)5 Test (org.junit.Test)4 LegacyComboBox (org.vaadin.ui.LegacyComboBox)4 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 Panel (com.vaadin.ui.Panel)3 UI (com.vaadin.ui.UI)3 LinkkiComboBox (org.linkki.core.ui.components.LinkkiComboBox)3 TimePicker (au.com.vaadinutils.layout.TimePicker)2 ViewRiksdagenCommittee (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)2 ApplicationEventGroup (com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup)2 DataContainer (com.hack23.cia.service.api.DataContainer)2