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);
}
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);
}
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();
}
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;
}
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);
}
Aggregations