Search in sources :

Example 6 with Select

use of com.vaadin.v7.ui.Select in project SORMAS-Project by hzi-braunschweig.

the class FieldHelper method updateEnumData.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static void updateEnumData(AbstractSelect select, Iterable<? extends Enum> enumData) {
    boolean readOnly = select.isReadOnly();
    select.setReadOnly(false);
    Object value = select.getValue();
    select.removeAllItems();
    select.addContainerProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID, String.class, "");
    select.setItemCaptionPropertyId((SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID));
    if (enumData != null) {
        for (Object r : enumData) {
            Item newItem = select.addItem(r);
            newItem.getItemProperty(DefaultFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(r.toString());
        }
    }
    select.setValue(value);
    select.setReadOnly(readOnly);
}
Also used : Item(com.vaadin.v7.data.Item)

Example 7 with Select

use of com.vaadin.v7.ui.Select in project ANNIS by korpling.

the class FlatQueryBuilderTest method setup.

@BeforeEach
public void setup() {
    UIScopeImpl.setBeanStoreRetrievalStrategy(new SingletonBeanStoreRetrievalStrategy());
    this.ui = beanFactory.getBean(AnnisUI.class);
    MockVaadin.setup(() -> this.ui);
    ui.getQueryState().setSelectedCorpora(Sets.newSet("pcc2"));
    // Click on the query builder button and select the flat query builder
    _click(_get(Button.class, spec -> spec.withCaption("Query<br />Builder")));
    ComboBox queryBuilderChooser = _get(_get(QueryBuilderChooser.class), ComboBox.class);
    queryBuilderChooser.select("Word sequences and meta information");
    this.queryBuilder = _get(FlatQueryBuilder.class);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) MenuItem(com.vaadin.ui.MenuBar.MenuItem) CheckBox(com.vaadin.v7.ui.CheckBox) EdgeBox(org.corpus_tools.annis.gui.flatquerybuilder.EdgeBox) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) QueryBuilderChooser(org.corpus_tools.annis.gui.querybuilder.QueryBuilderChooser) Autowired(org.springframework.beans.factory.annotation.Autowired) FlatQueryBuilder(org.corpus_tools.annis.gui.flatquerybuilder.FlatQueryBuilder) ActiveProfiles(org.springframework.test.context.ActiveProfiles) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) ArrayList(java.util.ArrayList) SpanBox(org.corpus_tools.annis.gui.flatquerybuilder.SpanBox) SingletonBeanStoreRetrievalStrategy(org.corpus_tools.annis.gui.SingletonBeanStoreRetrievalStrategy) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) Sets(org.mockito.internal.util.collections.Sets) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) MetaBox(org.corpus_tools.annis.gui.flatquerybuilder.MetaBox) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) SearchBox(org.corpus_tools.annis.gui.flatquerybuilder.SearchBox) MenuBar(com.vaadin.ui.MenuBar) TextChangeEvent(com.vaadin.v7.event.FieldEvents.TextChangeEvent) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) ComboBox(com.vaadin.v7.ui.ComboBox) Collection(java.util.Collection) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) Mockito.when(org.mockito.Mockito.when) ValueField(org.corpus_tools.annis.gui.flatquerybuilder.ValueField) SensitiveComboBox(org.corpus_tools.annis.gui.flatquerybuilder.SensitiveComboBox) Test(org.junit.jupiter.api.Test) Button(com.vaadin.ui.Button) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) VerticalNode(org.corpus_tools.annis.gui.flatquerybuilder.VerticalNode) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BeanFactory(org.springframework.beans.factory.BeanFactory) Mockito.mock(org.mockito.Mockito.mock) QueryBuilderChooser(org.corpus_tools.annis.gui.querybuilder.QueryBuilderChooser) Button(com.vaadin.ui.Button) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) ComboBox(com.vaadin.v7.ui.ComboBox) SensitiveComboBox(org.corpus_tools.annis.gui.flatquerybuilder.SensitiveComboBox) FlatQueryBuilder(org.corpus_tools.annis.gui.flatquerybuilder.FlatQueryBuilder) SingletonBeanStoreRetrievalStrategy(org.corpus_tools.annis.gui.SingletonBeanStoreRetrievalStrategy) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with Select

use of com.vaadin.v7.ui.Select in project SORMAS-Project by hzi-braunschweig.

the class AbstractSampleForm method initializeRequestedTestFields.

protected void initializeRequestedTestFields() {
    // Information texts for users that can edit the requested tests
    Label requestedPathogenInfoLabel = new Label(I18nProperties.getString(Strings.infoSamplePathogenTesting));
    getContent().addComponent(requestedPathogenInfoLabel, PATHOGEN_TESTING_INFO_LOC);
    Label requestedAdditionalInfoLabel = new Label(I18nProperties.getString(Strings.infoSampleAdditionalTesting));
    getContent().addComponent(requestedAdditionalInfoLabel, ADDITIONAL_TESTING_INFO_LOC);
    // Yes/No fields for requesting pathogen/additional tests
    CheckBox pathogenTestingRequestedField = addField(SampleDto.PATHOGEN_TESTING_REQUESTED, CheckBox.class);
    pathogenTestingRequestedField.setWidthUndefined();
    pathogenTestingRequestedField.addValueChangeListener(e -> updateRequestedTestFields());
    CheckBox additionalTestingRequestedField = addField(SampleDto.ADDITIONAL_TESTING_REQUESTED, CheckBox.class);
    additionalTestingRequestedField.setWidthUndefined();
    additionalTestingRequestedField.addValueChangeListener(e -> updateRequestedTestFields());
    // CheckBox groups to select the requested pathogen/additional tests
    OptionGroup requestedPathogenTestsField = addField(SampleDto.REQUESTED_PATHOGEN_TESTS, OptionGroup.class);
    CssStyles.style(requestedPathogenTestsField, CssStyles.OPTIONGROUP_CHECKBOXES_HORIZONTAL);
    requestedPathogenTestsField.setMultiSelect(true);
    requestedPathogenTestsField.addItems(Arrays.stream(PathogenTestType.values()).filter(c -> fieldVisibilityCheckers.isVisible(PathogenTestType.class, c.name())).collect(Collectors.toList()));
    requestedPathogenTestsField.removeItem(PathogenTestType.OTHER);
    requestedPathogenTestsField.setCaption(null);
    OptionGroup requestedAdditionalTestsField = addField(SampleDto.REQUESTED_ADDITIONAL_TESTS, OptionGroup.class);
    CssStyles.style(requestedAdditionalTestsField, CssStyles.OPTIONGROUP_CHECKBOXES_HORIZONTAL);
    requestedAdditionalTestsField.setMultiSelect(true);
    requestedAdditionalTestsField.addItems((Object[]) AdditionalTestType.values());
    requestedAdditionalTestsField.setCaption(null);
    // Text fields to type in other tests
    TextField requestedOtherPathogenTests = addField(SampleDto.REQUESTED_OTHER_PATHOGEN_TESTS, TextField.class);
    TextField requestedOtherAdditionalTests = addField(SampleDto.REQUESTED_OTHER_ADDITIONAL_TESTS, TextField.class);
    // header for read view
    Label pathogenTestsHeading = new Label(I18nProperties.getString(Strings.headingRequestedPathogenTests));
    CssStyles.style(pathogenTestsHeading, CssStyles.LABEL_BOLD, CssStyles.LABEL_SECONDARY, VSPACE_4);
    getContent().addComponent(pathogenTestsHeading, PATHOGEN_TESTING_READ_HEADLINE_LOC);
    Label additionalTestsHeading = new Label(I18nProperties.getString(Strings.headingRequestedAdditionalTests));
    CssStyles.style(additionalTestsHeading, CssStyles.LABEL_BOLD, CssStyles.LABEL_SECONDARY, VSPACE_4);
    getContent().addComponent(additionalTestsHeading, ADDITIONAL_TESTING_READ_HEADLINE_LOC);
    updateRequestedTestFields();
}
Also used : OptionGroup(com.vaadin.v7.ui.OptionGroup) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) TextField(com.vaadin.v7.ui.TextField) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType)

Example 9 with Select

use of com.vaadin.v7.ui.Select in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method createFooter.

private HorizontalLayout createFooter() {
    HorizontalLayout mapFooterLayout = new HorizontalLayout();
    mapFooterLayout.setWidth(100, Unit.PERCENTAGE);
    mapFooterLayout.setSpacing(true);
    CssStyles.style(mapFooterLayout, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
    // Map key dropdown button
    legendDropdown = ButtonHelper.createPopupButton(Captions.dashboardMapKey, null, CssStyles.BUTTON_SUBTLE);
    legendDropdown.setContent(createLegend());
    mapFooterLayout.addComponent(legendDropdown);
    mapFooterLayout.setComponentAlignment(legendDropdown, Alignment.MIDDLE_RIGHT);
    mapFooterLayout.setExpandRatio(legendDropdown, 1);
    // Layers dropdown button
    VerticalLayout layersLayout = new VerticalLayout();
    {
        layersLayout.setMargin(true);
        layersLayout.setSpacing(false);
        layersLayout.setSizeUndefined();
        // Add check boxes and apply button
        {
            // case classifications
            OptionGroup caseClassificationOptions = new OptionGroup();
            caseClassificationOptions.addItems((Object[]) MapCaseClassificationOption.values());
            caseClassificationOptions.setValue(caseClassificationOption);
            caseClassificationOptions.addValueChangeListener(event -> {
                caseClassificationOption = (MapCaseClassificationOption) event.getProperty().getValue();
                refreshMap(true);
            });
            // Optiongroup to select what property the coordinates should be based on
            OptionGroup mapCaseDisplayModeSelect = new OptionGroup();
            mapCaseDisplayModeSelect.setWidth(100, Unit.PERCENTAGE);
            mapCaseDisplayModeSelect.addItems((Object[]) MapCaseDisplayMode.values());
            mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
            mapCaseDisplayModeSelect.addValueChangeListener(event -> {
                mapCaseDisplayMode = (MapCaseDisplayMode) event.getProperty().getValue();
                refreshMap(true);
            });
            HorizontalLayout showCasesLayout = new HorizontalLayout();
            {
                showCasesLayout.setMargin(false);
                showCasesLayout.setSpacing(false);
                CheckBox showCasesCheckBox = new CheckBox();
                showCasesCheckBox.setId(Captions.dashboardShowCases);
                showCasesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowCases));
                showCasesCheckBox.setValue(showCases);
                showCasesCheckBox.addValueChangeListener(e -> {
                    showCases = (boolean) e.getProperty().getValue();
                    mapCaseDisplayModeSelect.setEnabled(showCases);
                    mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
                    caseClassificationOptions.setEnabled(showCases);
                    refreshMap(true);
                });
                showCasesLayout.addComponent(showCasesCheckBox);
                Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseMap));
                CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3);
                infoLabel.setHeightUndefined();
                showCasesLayout.addComponent(infoLabel);
                showCasesLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
            }
            layersLayout.addComponent(showCasesLayout);
            layersLayout.addComponent(mapCaseDisplayModeSelect);
            mapCaseDisplayModeSelect.setEnabled(showCases);
            layersLayout.addComponent(caseClassificationOptions);
            caseClassificationOptions.setEnabled(showCases);
            CheckBox showConfirmedContactsCheckBox = new CheckBox();
            showConfirmedContactsCheckBox.setId(Captions.dashboardShowConfirmedContacts);
            CheckBox showUnconfirmedContactsCheckBox = new CheckBox();
            showUnconfirmedContactsCheckBox.setId(Captions.dashboardShowUnconfirmedContacts);
            CheckBox showContactsCheckBox = new CheckBox();
            showContactsCheckBox.setId(Captions.dashboardShowContacts);
            showContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowContacts));
            showContactsCheckBox.setValue(showContacts);
            showContactsCheckBox.addValueChangeListener(e -> {
                showContacts = (boolean) e.getProperty().getValue();
                showConfirmedContactsCheckBox.setEnabled(showContacts);
                showConfirmedContactsCheckBox.setValue(true);
                showUnconfirmedContactsCheckBox.setEnabled(showContacts);
                showUnconfirmedContactsCheckBox.setValue(true);
                refreshMap(true);
            });
            layersLayout.addComponent(showContactsCheckBox);
            showConfirmedContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowConfirmedContacts));
            showConfirmedContactsCheckBox.setValue(showConfirmedContacts);
            showConfirmedContactsCheckBox.addValueChangeListener(e -> {
                showConfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showConfirmedContactsCheckBox);
            CssStyles.style(showUnconfirmedContactsCheckBox, CssStyles.VSPACE_3);
            showUnconfirmedContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowUnconfirmedContacts));
            showUnconfirmedContactsCheckBox.setValue(showUnconfirmedContacts);
            showUnconfirmedContactsCheckBox.addValueChangeListener(e -> {
                showUnconfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showUnconfirmedContactsCheckBox);
            showConfirmedContactsCheckBox.setEnabled(showContacts);
            showUnconfirmedContactsCheckBox.setEnabled(showContacts);
            CheckBox showEventsCheckBox = new CheckBox();
            showEventsCheckBox.setId(Captions.dashboardShowEvents);
            CssStyles.style(showEventsCheckBox, CssStyles.VSPACE_3);
            showEventsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowEvents));
            showEventsCheckBox.setValue(showEvents);
            showEventsCheckBox.addValueChangeListener(e -> {
                showEvents = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showEventsCheckBox);
            if (nonNull(UserProvider.getCurrent()) && UserProvider.getCurrent().hasNationJurisdictionLevel()) {
                OptionGroup regionMapVisualizationSelect = new OptionGroup();
                regionMapVisualizationSelect.setWidth(100, Unit.PERCENTAGE);
                regionMapVisualizationSelect.addItems((Object[]) CaseMeasure.values());
                regionMapVisualizationSelect.setValue(caseMeasure);
                regionMapVisualizationSelect.addValueChangeListener(event -> {
                    caseMeasure = (CaseMeasure) event.getProperty().getValue();
                    refreshMap(true);
                });
                HorizontalLayout showRegionsLayout = new HorizontalLayout();
                {
                    showRegionsLayout.setMargin(false);
                    showRegionsLayout.setSpacing(false);
                    CheckBox showRegionsCheckBox = new CheckBox();
                    showRegionsCheckBox.setId(Captions.dashboardShowRegions);
                    showRegionsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowRegions));
                    showRegionsCheckBox.setValue(showRegions);
                    showRegionsCheckBox.addValueChangeListener(e -> {
                        showRegions = (boolean) e.getProperty().getValue();
                        regionMapVisualizationSelect.setEnabled(showRegions);
                        regionMapVisualizationSelect.setValue(caseMeasure);
                        refreshMap(true);
                    });
                    showRegionsLayout.addComponent(showRegionsCheckBox);
                    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                    infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseIncidence));
                    CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3);
                    infoLabel.setHeightUndefined();
                    showRegionsLayout.addComponent(infoLabel);
                    showRegionsLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
                }
                layersLayout.addComponent(showRegionsLayout);
                layersLayout.addComponent(regionMapVisualizationSelect);
                regionMapVisualizationSelect.setEnabled(showRegions);
            }
            CheckBox hideOtherCountriesCheckBox = new CheckBox();
            hideOtherCountriesCheckBox.setId(Captions.dashboardHideOtherCountries);
            hideOtherCountriesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardHideOtherCountries));
            hideOtherCountriesCheckBox.setValue(hideOtherCountries);
            hideOtherCountriesCheckBox.addValueChangeListener(e -> {
                hideOtherCountries = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            CssStyles.style(hideOtherCountriesCheckBox, CssStyles.VSPACE_3);
            layersLayout.addComponent(hideOtherCountriesCheckBox);
            CheckBox showCurrentEpiSituationCB = new CheckBox();
            showCurrentEpiSituationCB.setId(Captions.dashboardMapShowEpiSituation);
            showCurrentEpiSituationCB.setCaption(I18nProperties.getCaption(Captions.dashboardMapShowEpiSituation));
            showCurrentEpiSituationCB.setValue(false);
            showCurrentEpiSituationCB.addValueChangeListener(e -> {
                showCurrentEpiSituation = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showCurrentEpiSituationCB);
        }
    }
    PopupButton layersDropdown = ButtonHelper.createPopupButton(Captions.dashboardMapLayers, layersLayout, CssStyles.BUTTON_SUBTLE);
    mapFooterLayout.addComponent(layersDropdown);
    mapFooterLayout.setComponentAlignment(layersDropdown, Alignment.MIDDLE_RIGHT);
    return mapFooterLayout;
}
Also used : Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) Window(com.vaadin.ui.Window) LeafletMarker(de.symeda.sormas.ui.map.LeafletMarker) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GeoShapeProvider(de.symeda.sormas.api.geo.GeoShapeProvider) BigDecimal(java.math.BigDecimal) CssStyles(de.symeda.sormas.ui.utils.CssStyles) GeoLatLon(de.symeda.sormas.api.geo.GeoLatLon) VaadinIcons(com.vaadin.icons.VaadinIcons) LeafletMap(de.symeda.sormas.ui.map.LeafletMap) LeafletMapUtil(de.symeda.sormas.ui.map.LeafletMapUtil) UserProvider(de.symeda.sormas.ui.UserProvider) RoundingMode(java.math.RoundingMode) ValoTheme(com.vaadin.ui.themes.ValoTheme) InfrastructureHelper(de.symeda.sormas.api.infrastructure.InfrastructureHelper) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) DashboardCssStyles(de.symeda.sormas.ui.dashboard.DashboardCssStyles) DashboardType(de.symeda.sormas.ui.dashboard.DashboardType) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) DashboardDataProvider(de.symeda.sormas.ui.dashboard.DashboardDataProvider) List(java.util.List) ExternalResource(com.vaadin.server.ExternalResource) AbstractComponent(com.vaadin.ui.AbstractComponent) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) Optional(java.util.Optional) Objects.nonNull(java.util.Objects.nonNull) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) CaseMeasure(de.symeda.sormas.api.CaseMeasure) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) CssLayout(com.vaadin.ui.CssLayout) LeafletPolygon(de.symeda.sormas.ui.map.LeafletPolygon) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OptionGroup(com.vaadin.v7.ui.OptionGroup) Image(com.vaadin.ui.Image) Label(com.vaadin.ui.Label) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) Pair(de.symeda.sormas.api.utils.DataHelper.Pair) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) Captions(de.symeda.sormas.api.i18n.Captions) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Consumer(java.util.function.Consumer) Button(com.vaadin.ui.Button) Disease(de.symeda.sormas.api.Disease) MarkerIcon(de.symeda.sormas.ui.map.MarkerIcon) HeightMode(com.vaadin.v7.shared.ui.grid.HeightMode) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) OptionGroup(com.vaadin.v7.ui.OptionGroup) PopupButton(org.vaadin.hene.popupbutton.PopupButton) CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 10 with Select

use of com.vaadin.v7.ui.Select in project SORMAS-Project by hzi-braunschweig.

the class SormasFieldGroupFieldFactory method createField.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <T extends Field> T createField(Class<?> type, Class<T> fieldType) {
    if (type.isEnum()) {
        if (// no specific fieldType defined?
        fieldType.isAssignableFrom(Field.class) && (SymptomState.class.isAssignableFrom(type) || YesNoUnknown.class.isAssignableFrom(type))) {
            NullableOptionGroup field = new NullableOptionGroup();
            field.setImmediate(true);
            populateWithEnumData(field, (Class<? extends Enum>) type);
            CssStyles.style(field, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.OPTIONGROUP_CAPTION_INLINE);
            return (T) field;
        } else {
            if (Disease.class.isAssignableFrom(type)) {
                fieldType = (Class<T>) ComboBox.class;
                ComboBox field = ComboBoxHelper.createComboBoxV7();
                field.setImmediate(true);
                field.setNullSelectionAllowed(true);
                populateWithDiseaseData(field);
                return (T) field;
            } else {
                if (!AbstractSelect.class.isAssignableFrom(fieldType)) {
                    fieldType = (Class<T>) ComboBox.class;
                }
                T field = super.createField(type, fieldType);
                if (field instanceof OptionGroup) {
                    CssStyles.style(field, ValoTheme.OPTIONGROUP_HORIZONTAL);
                } else if (fieldType.isAssignableFrom(NullableOptionGroup.class)) {
                    NullableOptionGroup select = new NullableOptionGroup();
                    select.setImmediate(true);
                    populateWithEnumData(select, (Class<? extends Enum>) type);
                    CssStyles.style(select, ValoTheme.OPTIONGROUP_HORIZONTAL);
                    field = (T) select;
                } else if (field instanceof ComboBox) {
                    ((ComboBox) field).setFilteringMode(FilteringMode.CONTAINS);
                    ((ComboBox) field).setNullSelectionAllowed(true);
                }
                return field;
            }
        }
    } else if (Boolean.class.isAssignableFrom(type)) {
        fieldType = CheckBox.class.isAssignableFrom(fieldType) ? (Class<T>) CheckBox.class : (Class<T>) NullableOptionGroup.class;
        return createBooleanField(fieldType);
    } else if (ComboBox.class.isAssignableFrom(fieldType) || ComboBoxWithPlaceholder.class.isAssignableFrom(fieldType)) {
        ComboBoxWithPlaceholder combo = new ComboBoxWithPlaceholder();
        combo.setImmediate(true);
        return (T) combo;
    } else if (AbstractSelect.class.isAssignableFrom(fieldType)) {
        AbstractSelect field = createCompatibleSelect((Class<? extends AbstractSelect>) fieldType);
        field.setNullSelectionAllowed(true);
        return (T) field;
    } else if (LocationEditForm.class.isAssignableFrom(fieldType)) {
        return (T) new LocationEditForm(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (HealthConditionsForm.class.isAssignableFrom(fieldType)) {
        return (T) new HealthConditionsForm(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (DateTimeField.class.isAssignableFrom(fieldType)) {
        DateTimeField field = new DateTimeField();
        field.setConverter(new SormasDefaultConverterFactory().createDateConverter(Date.class));
        return (T) field;
    } else if (DateField.class.isAssignableFrom(fieldType)) {
        DateField field = super.createField(type, DateField.class);
        field.setDateFormat(DateFormatHelper.getDateFormatPattern());
        field.setLenient(true);
        field.setConverter(new SormasDefaultConverterFactory().createDateConverter(Date.class));
        return (T) field;
    } else if (PreviousHospitalizationsField.class.isAssignableFrom(fieldType)) {
        return (T) new PreviousHospitalizationsField(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (ExposuresField.class.isAssignableFrom(fieldType)) {
        return (T) new ExposuresField(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (ActivityAsCaseField.class.isAssignableFrom(fieldType)) {
        return (T) new ActivityAsCaseField(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (LocationsField.class.isAssignableFrom(fieldType)) {
        return (T) new LocationsField(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (PersonContactDetailsField.class.isAssignableFrom(fieldType)) {
        return (T) new PersonContactDetailsField(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (VaccinationsField.class.isAssignableFrom(fieldType)) {
        return (T) new VaccinationsField(fieldAccessCheckers);
    } else if (JsonForm.class.isAssignableFrom(fieldType)) {
        return (T) new JsonForm(fieldVisibilityCheckers, fieldAccessCheckers);
    } else if (fieldType.equals(Field.class)) {
        // no specific field type defined -> fallbacks
        if (Date.class.isAssignableFrom(type)) {
            DateField field = super.createField(type, DateField.class);
            field.setDateFormat(DateFormatHelper.getDateFormatPattern());
            field.setLenient(true);
            field.setConverter(new SormasDefaultConverterFactory().createDateConverter(Date.class));
            return (T) field;
        } else if (ReferenceDto.class.isAssignableFrom(type)) {
            return (T) ComboBoxHelper.createComboBoxV7();
        }
    } else if (MultiSelect.class.isAssignableFrom(fieldType)) {
        return (T) MultiSelect.create(type);
    }
    return super.createField(type, fieldType);
}
Also used : SymptomState(de.symeda.sormas.api.symptoms.SymptomState) AbstractSelect(com.vaadin.v7.ui.AbstractSelect) VaccinationsField(de.symeda.sormas.ui.vaccination.VaccinationsField) VaccinationsField(de.symeda.sormas.ui.vaccination.VaccinationsField) ExposuresField(de.symeda.sormas.ui.exposure.ExposuresField) DateField(com.vaadin.v7.ui.DateField) PersonContactDetailsField(de.symeda.sormas.ui.person.PersonContactDetailsField) LocationsField(de.symeda.sormas.ui.person.LocationsField) Field(com.vaadin.v7.ui.Field) AbstractTextField(com.vaadin.v7.ui.AbstractTextField) ActivityAsCaseField(de.symeda.sormas.ui.ActivityAsCase.ActivityAsCaseField) PreviousHospitalizationsField(de.symeda.sormas.ui.hospitalization.PreviousHospitalizationsField) OptionGroup(com.vaadin.v7.ui.OptionGroup) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) ExposuresField(de.symeda.sormas.ui.exposure.ExposuresField) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) ComboBox(com.vaadin.v7.ui.ComboBox) LocationsField(de.symeda.sormas.ui.person.LocationsField) Date(java.util.Date) PreviousHospitalizationsField(de.symeda.sormas.ui.hospitalization.PreviousHospitalizationsField) ActivityAsCaseField(de.symeda.sormas.ui.ActivityAsCase.ActivityAsCaseField) JsonForm(de.symeda.sormas.ui.utils.components.JsonForm) CheckBox(com.vaadin.v7.ui.CheckBox) PersonContactDetailsField(de.symeda.sormas.ui.person.PersonContactDetailsField) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) DateField(com.vaadin.v7.ui.DateField)

Aggregations

Item (com.vaadin.v7.data.Item)7 CheckBox (com.vaadin.v7.ui.CheckBox)6 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)4 ComboBox (com.vaadin.v7.ui.ComboBox)4 ArrayList (java.util.ArrayList)4 Button (com.vaadin.ui.Button)3 Label (com.vaadin.ui.Label)3 ItemClickEvent (com.vaadin.v7.event.ItemClickEvent)3 ItemClickListener (com.vaadin.v7.event.ItemClickEvent.ItemClickListener)3 OptionGroup (com.vaadin.v7.ui.OptionGroup)3 Table (com.vaadin.v7.ui.Table)3 List (java.util.List)3 CmsException (org.opencms.main.CmsException)3 VaadinIcons (com.vaadin.icons.VaadinIcons)2 ContentMode (com.vaadin.shared.ui.ContentMode)2 Alignment (com.vaadin.ui.Alignment)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 ValoTheme (com.vaadin.ui.themes.ValoTheme)2 AbstractSelect (com.vaadin.v7.ui.AbstractSelect)2 Date (java.util.Date)2