use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.
the class CmsSourceEditor method initUI.
/**
* @see org.opencms.ui.editors.I_CmsEditor#initUI(org.opencms.ui.apps.I_CmsAppUIContext, org.opencms.file.CmsResource, java.lang.String, java.util.Map)
*/
public void initUI(I_CmsAppUIContext context, CmsResource resource, String backLink, Map<String, String> params) {
CmsMessages messages = Messages.get().getBundle(UI.getCurrent().getLocale());
context.showInfoArea(false);
context.setAppTitle(messages.key(Messages.GUI_SOURCE_EDITOR_TITLE_0));
CmsAppWorkplaceUi.setWindowTitle(CmsVaadinUtils.getMessageText(org.opencms.ui.apps.Messages.GUI_CONTENT_EDITOR_TITLE_2, resource.getName(), CmsResource.getParentFolder(A_CmsUI.getCmsObject().getSitePath(resource))));
m_backLink = backLink;
m_codeMirror = new CmsCodeMirror();
m_codeMirror.setSizeFull();
context.setAppContent(m_codeMirror);
context.enableDefaultToolbarButtons(false);
m_saveAndExit = CmsToolBar.createButton(FontOpenCms.SAVE_EXIT, messages.key(Messages.GUI_BUTTON_SAVE_AND_EXIT_0), true);
m_saveAndExit.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
saveAndExit();
}
});
m_saveAndExit.setEnabled(false);
context.addToolbarButton(m_saveAndExit);
m_save = CmsToolBar.createButton(FontOpenCms.SAVE, messages.key(Messages.GUI_BUTTON_SAVE_0), true);
m_save.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
save();
}
});
m_save.setEnabled(false);
context.addToolbarButton(m_save);
Button undo = CmsToolBar.createButton(FontOpenCms.UNDO, messages.key(Messages.GUI_BUTTON_UNDO_0), true);
context.addToolbarButton(undo);
Button redo = CmsToolBar.createButton(FontOpenCms.REDO, messages.key(Messages.GUI_BUTTON_REDO_0), true);
context.addToolbarButton(redo);
m_codeMirror.registerUndoRedo(undo, redo);
Button search = CmsToolBar.createButton(FontOpenCms.SEARCH, messages.key(Messages.GUI_BUTTON_SEARCH_0), true);
context.addToolbarButton(search);
Button replace = CmsToolBar.createButton(FontOpenCms.SEARCH_REPLACE, messages.key(Messages.GUI_BUTTON_REPLACE_0), true);
context.addToolbarButton(replace);
m_codeMirror.registerSearchReplace(search, replace);
EditorSettings settings;
try {
settings = OpenCms.getWorkplaceAppManager().getAppSettings(A_CmsUI.getCmsObject(), EditorSettings.class);
} catch (Exception e) {
settings = new EditorSettings();
}
final Button toggleHighlight = CmsToolBar.createButton(FontOpenCms.HIGHLIGHT, messages.key(Messages.GUI_BUTTON_TOGGLE_HIGHLIGHTING_0));
toggleHighlight.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
Button b = event.getButton();
boolean pressed = b.getStyleName().contains(OpenCmsTheme.BUTTON_PRESSED);
if (pressed) {
b.removeStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
b.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
}
m_codeMirror.setHighlighting(!pressed);
}
});
if (settings.m_highlighting) {
m_codeMirror.setHighlighting(true);
toggleHighlight.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
m_codeMirror.setHighlighting(false);
}
context.addToolbarButtonRight(toggleHighlight);
final Button toggleLineWrap = CmsToolBar.createButton(FontOpenCms.WRAP_LINES, messages.key(Messages.GUI_BUTTON_TOGGLE_LINE_WRAPPING_0));
toggleLineWrap.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
Button b = event.getButton();
boolean pressed = b.getStyleName().contains(OpenCmsTheme.BUTTON_PRESSED);
if (pressed) {
b.removeStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
b.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
}
m_codeMirror.setLineWrapping(!pressed);
}
});
if (settings.m_lineWrapping) {
m_codeMirror.setLineWrapping(true);
toggleLineWrap.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
m_codeMirror.setLineWrapping(false);
}
context.addToolbarButtonRight(toggleLineWrap);
final Button toggleBrackets = CmsToolBar.createButton(FontOpenCms.BRACKETS, messages.key(Messages.GUI_BUTTON_TOBBLE_BRACKET_AUTOCLOSE_0));
toggleBrackets.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
Button b = event.getButton();
boolean pressed = b.getStyleName().contains(OpenCmsTheme.BUTTON_PRESSED);
if (pressed) {
b.removeStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
b.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
}
m_codeMirror.setCloseBrackets(!pressed);
}
});
if (settings.m_closeBrackets) {
m_codeMirror.setCloseBrackets(true);
toggleBrackets.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
m_codeMirror.setCloseBrackets(false);
}
context.addToolbarButtonRight(toggleBrackets);
final Button toggleTabs = CmsToolBar.createButton(FontOpenCms.INVISIBLE_CHARS, messages.key(Messages.GUI_BUTTON_TOGGLE_TAB_VISIBILITY_0));
toggleTabs.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
Button b = event.getButton();
boolean pressed = b.getStyleName().contains(OpenCmsTheme.BUTTON_PRESSED);
if (pressed) {
b.removeStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
b.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
}
m_codeMirror.setTabsVisible(!pressed);
}
});
if (settings.m_tabsVisible) {
m_codeMirror.setTabsVisible(true);
toggleTabs.addStyleName(OpenCmsTheme.BUTTON_PRESSED);
} else {
m_codeMirror.setTabsVisible(false);
}
context.addToolbarButtonRight(toggleTabs);
ComboBox modeSelect = new ComboBox();
modeSelect.setWidth("115px");
modeSelect.addStyleName(OpenCmsTheme.TOOLBAR_FIELD);
modeSelect.addStyleName(OpenCmsTheme.REQUIRED_BUTTON);
modeSelect.setNullSelectionAllowed(false);
modeSelect.setImmediate(true);
modeSelect.setNewItemsAllowed(false);
for (CodeMirrorLanguage lang : CodeMirrorLanguage.values()) {
modeSelect.addItem(lang);
modeSelect.setItemCaption(lang, lang.name());
}
CodeMirrorLanguage lang = getHighlightMode(resource);
modeSelect.setValue(lang);
m_codeMirror.setLanguage(lang);
modeSelect.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
m_codeMirror.setLanguage((CodeMirrorLanguage) event.getProperty().getValue());
}
});
context.addToolbarButtonRight(modeSelect);
ComboBox fontSizeSelect = new ComboBox();
fontSizeSelect.setWidth("75px");
fontSizeSelect.addStyleName(OpenCmsTheme.TOOLBAR_FIELD);
fontSizeSelect.addStyleName(OpenCmsTheme.REQUIRED_BUTTON);
fontSizeSelect.setNullSelectionAllowed(false);
fontSizeSelect.setImmediate(true);
fontSizeSelect.setNewItemsAllowed(false);
for (int i = 0; i < FONT_SIZES.length; i++) {
fontSizeSelect.addItem(FONT_SIZES[i]);
}
fontSizeSelect.setValue(settings.m_fontSize);
fontSizeSelect.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
m_codeMirror.setFontSize((String) event.getProperty().getValue());
}
});
context.addToolbarButtonRight(fontSizeSelect);
m_codeMirror.setFontSize(settings.m_fontSize);
m_exit = CmsToolBar.createButton(FontOpenCms.EXIT, messages.key(Messages.GUI_BUTTON_CANCEL_0), true);
m_exit.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
exit();
}
});
context.addToolbarButtonRight(m_exit);
try {
m_file = LockedFile.lockResource(A_CmsUI.getCmsObject(), resource);
String content = new String(m_file.getFile().getContents(), m_file.getEncoding());
m_codeMirror.setValue(content);
} catch (Exception e) {
CmsErrorDialog.showErrorDialog(e);
}
m_codeMirror.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
onChange((String) event.getProperty().getValue());
}
});
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project SORMAS-Project by hzi-braunschweig.
the class CaseCreateForm method addFields.
@Override
protected void addFields() {
NullableOptionGroup ogCaseOrigin = addField(CaseDataDto.CASE_ORIGIN, NullableOptionGroup.class);
ogCaseOrigin.setRequired(true);
TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class);
epidField.setInvalidCommitted(true);
style(epidField, ERROR_COLOR_PRIMARY);
if (!FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()) {
TextField externalIdField = addField(CaseDataDto.EXTERNAL_ID, TextField.class);
style(externalIdField, ERROR_COLOR_PRIMARY);
} else {
CheckBox dontShareCheckbox = addField(CaseDataDto.DONT_SHARE_WITH_REPORTING_TOOL, CheckBox.class);
CaseFormHelper.addDontShareWithReportingTool(getContent(), () -> dontShareCheckbox, DONT_SHARE_WARNING_LOC);
}
addField(CaseDataDto.REPORT_DATE, DateField.class);
ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false, true);
diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class);
diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
diseaseVariantField.setNullSelectionAllowed(true);
diseaseVariantField.setVisible(false);
addField(CaseDataDto.DISEASE_DETAILS, TextField.class);
NullableOptionGroup plagueType = addField(CaseDataDto.PLAGUE_TYPE, NullableOptionGroup.class);
addField(CaseDataDto.DENGUE_FEVER_TYPE, NullableOptionGroup.class);
addField(CaseDataDto.RABIES_TYPE, NullableOptionGroup.class);
personCreateForm = new PersonCreateForm(showHomeAddressForm, true, true, showPersonSearchButton);
personCreateForm.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(personCreateForm, CaseDataDto.PERSON);
differentPlaceOfStayJurisdiction = addCustomField(DIFFERENT_PLACE_OF_STAY_JURISDICTION, Boolean.class, CheckBox.class);
differentPlaceOfStayJurisdiction.addStyleName(VSPACE_3);
Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.casePlaceOfStay));
placeOfStayHeadingLabel.addStyleName(H3);
getContent().addComponent(placeOfStayHeadingLabel, PLACE_OF_STAY_HEADING_LOC);
ComboBox region = addInfrastructureField(CaseDataDto.REGION);
districtCombo = addInfrastructureField(CaseDataDto.DISTRICT);
communityCombo = addInfrastructureField(CaseDataDto.COMMUNITY);
communityCombo.setNullSelectionAllowed(true);
// jurisdictionfields
Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingCaseResponsibleJurisidction));
jurisdictionHeadingLabel.addStyleName(H3);
getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
ComboBox responsibleRegion = addInfrastructureField(CaseDataDto.RESPONSIBLE_REGION);
responsibleRegion.setRequired(true);
responsibleDistrictCombo = addInfrastructureField(CaseDataDto.RESPONSIBLE_DISTRICT);
responsibleDistrictCombo.setRequired(true);
responsibleCommunityCombo = addInfrastructureField(CaseDataDto.RESPONSIBLE_COMMUNITY);
responsibleCommunityCombo.setNullSelectionAllowed(true);
responsibleCommunityCombo.addStyleName(SOFT_REQUIRED);
InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrictCombo, responsibleCommunityCombo);
differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
ComboBox pointOfEntryRegionCombo = addCustomField(POINT_OF_ENTRY_REGION, RegionReferenceDto.class, ComboBox.class);
pointOfEntryDistrictCombo = addCustomField(POINT_OF_ENTRY_DISTRICT, DistrictReferenceDto.class, ComboBox.class);
InfrastructureFieldsHelper.initInfrastructureFields(pointOfEntryRegionCombo, pointOfEntryDistrictCombo, null);
pointOfEntryDistrictCombo.addValueChangeListener(e -> updatePOEs());
FieldHelper.setVisibleWhen(differentPlaceOfStayJurisdiction, Arrays.asList(region, districtCombo, communityCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(pointOfEntryRegionCombo, pointOfEntryDistrictCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setRequiredWhen(differentPlaceOfStayJurisdiction, Arrays.asList(region, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
ogCaseOrigin.addValueChangeListener(e -> {
boolean pointOfEntryRegionDistrictVisible = CaseOrigin.POINT_OF_ENTRY.equals(ogCaseOrigin.getValue()) && Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue());
pointOfEntryRegionCombo.setVisible(pointOfEntryRegionDistrictVisible);
pointOfEntryDistrictCombo.setVisible(pointOfEntryRegionDistrictVisible);
});
facilityOrHome = addCustomField(FACILITY_OR_HOME_LOC, TypeOfPlace.class, NullableOptionGroup.class, I18nProperties.getCaption(Captions.casePlaceOfStay));
facilityOrHome.removeAllItems();
for (TypeOfPlace place : TypeOfPlace.FOR_CASES) {
facilityOrHome.addItem(place);
facilityOrHome.setItemCaption(place, I18nProperties.getEnumCaption(place));
}
facilityOrHome.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
facilityOrHome.setId("facilityOrHome");
facilityOrHome.setWidth(100, Unit.PERCENTAGE);
CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
facilityTypeGroup.setId("typeGroup");
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
facilityType = ComboBoxHelper.createComboBoxV7();
facilityType.setId("type");
facilityType.setCaption(I18nProperties.getCaption(Captions.facilityType));
facilityType.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(facilityType, CaseDataDto.FACILITY_TYPE);
facilityCombo = addInfrastructureField(CaseDataDto.HEALTH_FACILITY);
facilityCombo.setImmediate(true);
TextField facilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
facilityDetails.setVisible(false);
ComboBox cbPointOfEntry = addInfrastructureField(CaseDataDto.POINT_OF_ENTRY);
cbPointOfEntry.setImmediate(true);
TextField tfPointOfEntryDetails = addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class);
tfPointOfEntryDetails.setVisible(false);
if (convertedTravelEntry != null) {
differentPointOfEntryJurisdiction.setValue(true);
RegionReferenceDto regionReferenceDto = convertedTravelEntry.getPointOfEntryRegion() != null ? convertedTravelEntry.getPointOfEntryRegion() : convertedTravelEntry.getResponsibleRegion();
pointOfEntryRegionCombo.setValue(regionReferenceDto);
DistrictReferenceDto districtReferenceDto = convertedTravelEntry.getPointOfEntryDistrict() != null ? convertedTravelEntry.getPointOfEntryDistrict() : convertedTravelEntry.getResponsibleDistrict();
pointOfEntryDistrictCombo.setValue(districtReferenceDto);
differentPointOfEntryJurisdiction.setReadOnly(true);
pointOfEntryRegionCombo.setReadOnly(true);
pointOfEntryDistrictCombo.setReadOnly(true);
updatePOEs();
cbPointOfEntry.setReadOnly(true);
tfPointOfEntryDetails.setReadOnly(true);
ogCaseOrigin.setReadOnly(true);
}
region.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
districtCombo.addValueChangeListener(e -> {
FieldHelper.removeItems(communityCombo);
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(communityCombo, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
updateFacility();
if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
updatePOEs();
}
});
communityCombo.addValueChangeListener(e -> {
updateFacility();
});
facilityOrHome.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue()) || ((facilityOrHome.getValue() instanceof java.util.Set) && TypeOfPlace.FACILITY.equals(facilityOrHome.getNullableValue()))) {
if (facilityTypeGroup.getValue() == null) {
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
}
if (facilityType.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue())) {
facilityType.setValue(FacilityType.HOSPITAL);
}
if (facilityType.getValue() != null) {
updateFacility();
}
if (CaseOrigin.IN_COUNTRY.equals(ogCaseOrigin.getValue())) {
facilityCombo.setRequired(true);
}
updateFacilityFields(facilityCombo, facilityDetails);
} else if (TypeOfPlace.HOME.equals(facilityOrHome.getValue()) || ((facilityOrHome.getValue() instanceof java.util.Set) && TypeOfPlace.HOME.equals(facilityOrHome.getNullableValue()))) {
setNoneFacility();
} else {
facilityCombo.removeAllItems();
facilityCombo.setValue(null);
updateFacilityFields(facilityCombo, facilityDetails);
}
});
facilityTypeGroup.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
});
facilityType.addValueChangeListener(e -> updateFacility());
region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
region.setReadOnly(true);
responsibleRegion.setReadOnly(true);
districtCombo.setReadOnly(true);
responsibleDistrictCombo.setReadOnly(true);
communityCombo.setReadOnly(true);
responsibleCommunityCombo.setReadOnly(true);
differentPlaceOfStayJurisdiction.setVisible(false);
differentPlaceOfStayJurisdiction.setEnabled(false);
facilityOrHome.setImmediate(true);
// [FACILITY]
facilityOrHome.setValue(Sets.newHashSet(TypeOfPlace.FACILITY));
facilityOrHome.setReadOnly(true);
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
facilityTypeGroup.setReadOnly(true);
facilityType.setValue(FacilityType.HOSPITAL);
facilityType.setReadOnly(true);
facilityCombo.setValue(UserProvider.getCurrent().getUser().getHealthFacility());
facilityCombo.setReadOnly(true);
}
if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
ogCaseOrigin.addValueChangeListener(ev -> {
if (ev.getProperty().getValue() == CaseOrigin.IN_COUNTRY) {
setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS);
differentPointOfEntryJurisdiction.setVisible(false);
setRequired(true, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY);
setRequired(false, CaseDataDto.POINT_OF_ENTRY);
updateFacilityFields(facilityCombo, facilityDetails);
} else {
setVisible(true, CaseDataDto.POINT_OF_ENTRY);
differentPointOfEntryJurisdiction.setVisible(true);
setRequired(true, CaseDataDto.POINT_OF_ENTRY);
if (userJurisdictionLevel != JurisdictionLevel.HEALTH_FACILITY) {
facilityOrHome.clear();
setRequired(false, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY);
}
updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails);
}
});
}
// jurisdiction field valuechangelisteners
responsibleDistrictCombo.addValueChangeListener(e -> {
Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
if (!Boolean.TRUE.equals(differentPlaceOfStay)) {
updateFacility();
if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
updatePOEs();
}
}
});
responsibleCommunityCombo.addValueChangeListener((e) -> {
Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
updateFacility();
}
});
differentPlaceOfStayJurisdiction.addValueChangeListener(e -> {
updateFacility();
if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
updatePOEs();
}
});
// Set initial visibilities & accesses
initializeVisibilitiesAndAllowedVisibilities();
setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.DISEASE, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE);
FieldHelper.addSoftRequiredStyle(plagueType, communityCombo, facilityDetails);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DISEASE_DETAILS), CaseDataDto.DISEASE, Arrays.asList(Disease.OTHER), true);
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.DISEASE, Arrays.asList(CaseDataDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.CASE_ORIGIN, Arrays.asList(CaseDataDto.HEALTH_FACILITY), Arrays.asList(CaseOrigin.IN_COUNTRY));
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.CASE_ORIGIN, Arrays.asList(CaseDataDto.POINT_OF_ENTRY), Arrays.asList(CaseOrigin.POINT_OF_ENTRY));
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.PLAGUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DENGUE_FEVER_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.DENGUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.RABIES_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.RABIES), true);
FieldHelper.setVisibleWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false);
FieldHelper.setRequiredWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false, null);
facilityCombo.addValueChangeListener(e -> {
updateFacilityFields(facilityCombo, facilityDetails);
this.getValue().setFacilityType((FacilityType) facilityType.getValue());
});
cbPointOfEntry.addValueChangeListener(e -> {
updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails);
});
addValueChangeListener(e -> {
if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
setVisible(false, CaseDataDto.CASE_ORIGIN, CaseDataDto.DISEASE, CaseDataDto.COMMUNITY, CaseDataDto.HEALTH_FACILITY);
setVisible(true, CaseDataDto.POINT_OF_ENTRY);
}
});
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
updateDiseaseVariant((Disease) valueChangeEvent.getProperty().getValue());
personCreateForm.updatePresentConditionEnum((Disease) valueChangeEvent.getProperty().getValue());
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
if (diseaseField.getValue() != null) {
Disease disease = (Disease) diseaseField.getValue();
updateDiseaseVariant(disease);
personCreateForm.updatePresentConditionEnum(disease);
}
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project SORMAS-Project by hzi-braunschweig.
the class LocationEditForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
addressType = addField(LocationDto.ADDRESS_TYPE, ComboBox.class);
addressType.setVisible(false);
final PersonAddressType[] personAddressTypeValues = PersonAddressType.getValues(FacadeProvider.getConfigFacade().getCountryCode());
if (!isConfiguredServer("ch")) {
addressType.removeAllItems();
addressType.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ID);
addressType.addItems(personAddressTypeValues);
}
TextField addressTypeDetails = addField(LocationDto.ADDRESS_TYPE_DETAILS, TextField.class);
addressTypeDetails.setVisible(false);
FieldHelper.setVisibleWhen(getFieldGroup(), LocationDto.ADDRESS_TYPE_DETAILS, addressType, Arrays.stream(personAddressTypeValues).filter(pat -> !pat.equals(PersonAddressType.HOME)).collect(Collectors.toList()), true);
FieldHelper.setRequiredWhen(getFieldGroup(), addressType, Arrays.asList(LocationDto.ADDRESS_TYPE_DETAILS), Arrays.asList(PersonAddressType.OTHER_ADDRESS));
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
;
facilityTypeGroup.setId("typeGroup");
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
facilityTypeGroup.addItems(FacilityTypeGroup.values());
getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
facilityType = addField(LocationDto.FACILITY_TYPE);
facility = addInfrastructureField(LocationDto.FACILITY);
facility.setImmediate(true);
facilityDetails = addField(LocationDto.FACILITY_DETAILS, TextField.class);
facilityDetails.setVisible(false);
addressType.addValueChangeListener(e -> {
FacilityTypeGroup oldGroup = (FacilityTypeGroup) facilityTypeGroup.getValue();
FacilityType oldType = (FacilityType) facilityType.getValue();
FacilityReferenceDto oldFacility = (FacilityReferenceDto) facility.getValue();
String oldDetails = facilityDetails.getValue();
if (PersonAddressType.HOME.equals(addressType.getValue())) {
facilityTypeGroup.removeAllItems();
facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
setOldFacilityValuesIfPossible(oldGroup, oldType, oldFacility, oldDetails);
} else {
facilityTypeGroup.removeAllItems();
facilityTypeGroup.addItems(FacilityTypeGroup.values());
setOldFacilityValuesIfPossible(oldGroup, oldType, oldFacility, oldDetails);
}
});
TextField streetField = addField(LocationDto.STREET, TextField.class);
TextField houseNumberField = addField(LocationDto.HOUSE_NUMBER, TextField.class);
TextField additionalInformationField = addField(LocationDto.ADDITIONAL_INFORMATION, TextField.class);
addField(LocationDto.DETAILS, TextField.class);
TextField cityField = addField(LocationDto.CITY, TextField.class);
TextField postalCodeField = addField(LocationDto.POSTAL_CODE, TextField.class);
ComboBox areaType = addField(LocationDto.AREA_TYPE, ComboBox.class);
areaType.setDescription(I18nProperties.getDescription(getPropertyI18nPrefix() + "." + LocationDto.AREA_TYPE));
contactPersonFirstName = addField(LocationDto.CONTACT_PERSON_FIRST_NAME, TextField.class);
contactPersonLastName = addField(LocationDto.CONTACT_PERSON_LAST_NAME, TextField.class);
contactPersonPhone = addField(LocationDto.CONTACT_PERSON_PHONE, TextField.class);
contactPersonPhone.addValidator(new PhoneNumberValidator(I18nProperties.getValidationError(Validations.validPhoneNumber, contactPersonPhone.getCaption())));
contactPersonEmail = addField(LocationDto.CONTACT_PERSON_EMAIL, TextField.class);
contactPersonEmail.addValidator(new EmailValidator(I18nProperties.getValidationError(Validations.validEmailAddress, contactPersonEmail.getCaption())));
final AccessibleTextField tfLatitude = addField(LocationDto.LATITUDE, AccessibleTextField.class);
final AccessibleTextField tfLongitude = addField(LocationDto.LONGITUDE, AccessibleTextField.class);
final AccessibleTextField tfAccuracy = addField(LocationDto.LAT_LON_ACCURACY, AccessibleTextField.class);
final StringToAngularLocationConverter stringToAngularLocationConverter = new StringToAngularLocationConverter();
tfLatitude.setConverter(stringToAngularLocationConverter);
tfLongitude.setConverter(stringToAngularLocationConverter);
tfAccuracy.setConverter(stringToAngularLocationConverter);
continent = addInfrastructureField(LocationDto.CONTINENT);
subcontinent = addInfrastructureField(LocationDto.SUB_CONTINENT);
country = addInfrastructureField(LocationDto.COUNTRY);
ComboBox region = addInfrastructureField(LocationDto.REGION);
ComboBox district = addInfrastructureField(LocationDto.DISTRICT);
ComboBox community = addInfrastructureField(LocationDto.COMMUNITY);
continent.setVisible(false);
subcontinent.setVisible(false);
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
if (!isEditableAllowed(LocationDto.COMMUNITY)) {
setEnabled(false, LocationDto.COUNTRY, LocationDto.REGION, LocationDto.DISTRICT);
}
ValueChangeListener continentValueListener = e -> {
if (continent.isVisible()) {
ContinentReferenceDto continentReferenceDto = (ContinentReferenceDto) e.getProperty().getValue();
if (subcontinent.getValue() == null) {
FieldHelper.updateItems(country, continentReferenceDto != null ? FacadeProvider.getCountryFacade().getAllActiveByContinent(continentReferenceDto.getUuid()) : FacadeProvider.getCountryFacade().getAllActiveAsReference());
country.setValue(null);
}
subcontinent.setValue(null);
FieldHelper.updateItems(subcontinent, continentReferenceDto != null ? FacadeProvider.getSubcontinentFacade().getAllActiveByContinent(continentReferenceDto.getUuid()) : FacadeProvider.getSubcontinentFacade().getAllActiveAsReference());
}
};
ValueChangeListener subContinentValueListener = e -> {
if (subcontinent.isVisible()) {
SubcontinentReferenceDto subcontinentReferenceDto = (SubcontinentReferenceDto) e.getProperty().getValue();
if (subcontinentReferenceDto != null) {
continent.removeValueChangeListener(continentValueListener);
continent.setValue(FacadeProvider.getContinentFacade().getBySubcontinent(subcontinentReferenceDto));
continent.addValueChangeListener(continentValueListener);
}
country.setValue(null);
ContinentReferenceDto continentValue = (ContinentReferenceDto) continent.getValue();
FieldHelper.updateItems(country, subcontinentReferenceDto != null ? FacadeProvider.getCountryFacade().getAllActiveBySubcontinent(subcontinentReferenceDto.getUuid()) : continentValue == null ? FacadeProvider.getCountryFacade().getAllActiveAsReference() : FacadeProvider.getCountryFacade().getAllActiveByContinent(continentValue.getUuid()));
}
};
continent.addValueChangeListener(continentValueListener);
subcontinent.addValueChangeListener(subContinentValueListener);
skipCountryValueChange = false;
country.addValueChangeListener(e -> {
if (!skipCountryValueChange) {
CountryReferenceDto countryDto = (CountryReferenceDto) e.getProperty().getValue();
if (countryDto != null) {
final ContinentReferenceDto countryContinent = FacadeProvider.getContinentFacade().getByCountry(countryDto);
final SubcontinentReferenceDto countrySubcontinent = FacadeProvider.getSubcontinentFacade().getByCountry(countryDto);
if (countryContinent != null) {
continent.removeValueChangeListener(continentValueListener);
if (continent.isVisible()) {
skipCountryValueChange = true;
FieldHelper.updateItems(country, FacadeProvider.getCountryFacade().getAllActiveByContinent(countryContinent.getUuid()));
skipCountryValueChange = false;
}
continent.setValue(countryContinent);
continent.addValueChangeListener(continentValueListener);
}
if (countrySubcontinent != null) {
subcontinent.removeValueChangeListener(subContinentValueListener);
if (subcontinent.isVisible()) {
skipCountryValueChange = true;
if (countryContinent != null) {
FieldHelper.updateItems(subcontinent, FacadeProvider.getSubcontinentFacade().getAllActiveByContinent(countryContinent.getUuid()));
}
FieldHelper.updateItems(country, FacadeProvider.getCountryFacade().getAllActiveBySubcontinent(countrySubcontinent.getUuid()));
skipCountryValueChange = false;
}
subcontinent.setValue(countrySubcontinent);
subcontinent.addValueChangeListener(subContinentValueListener);
}
}
}
});
region.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
district.addValueChangeListener(e -> {
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(community, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
if (districtDto == null) {
FieldHelper.removeItems(facility);
// Add a visual indictator reminding the user to select a district
facility.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getString(Strings.infoFacilityNeedsDistrict);
}
});
} else if (facilityType.getValue() != null) {
facility.setComponentError(null);
facility.markAsDirty();
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(districtDto, (FacilityType) facilityType.getValue(), true, false));
}
});
community.addValueChangeListener(e -> {
CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue();
if (facilityType.getValue() != null) {
FieldHelper.updateItems(facility, communityDto != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(communityDto, (FacilityType) facilityType.getValue(), true, true) : district.getValue() != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) district.getValue(), (FacilityType) facilityType.getValue(), true, false) : null);
}
});
skipFacilityTypeUpdate = false;
facilityTypeGroup.addValueChangeListener(e -> {
if (!skipFacilityTypeUpdate) {
FieldHelper.removeItems(facility);
FieldHelper.updateEnumData(facilityType, FacilityType.getTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
facilityType.setRequired(facilityTypeGroup.getValue() != null);
}
});
facilityType.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
facility.setComponentError(null);
facility.markAsDirty();
if (facilityType.getValue() != null && facilityTypeGroup.getValue() == null) {
facilityTypeGroup.setValue(((FacilityType) facilityType.getValue()).getFacilityTypeGroup());
}
if (facilityType.getValue() != null && district.getValue() != null) {
if (community.getValue() != null) {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType((CommunityReferenceDto) community.getValue(), (FacilityType) facilityType.getValue(), true, false));
} else {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) district.getValue(), (FacilityType) facilityType.getValue(), true, false));
}
} else if (facilityType.getValue() != null && district.getValue() == null) {
// Add a visual indictator reminding the user to select a district
facility.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getString(Strings.infoFacilityNeedsDistrict);
}
});
}
// Only show contactperson-details if at least a faciltytype has been set
if (facilityType.getValue() != null) {
setFacilityContactPersonFieldsVisible(true, true);
} else {
setFacilityContactPersonFieldsVisible(false, true);
}
});
facility.addValueChangeListener(e -> {
if (facility.getValue() != null) {
boolean visibleAndRequired = areFacilityDetailsRequired();
facilityDetails.setVisible(visibleAndRequired);
facilityDetails.setRequired(visibleAndRequired);
if (!visibleAndRequired) {
facilityDetails.clear();
} else {
String facilityDetailsValue = getValue() != null ? getValue().getFacilityDetails() : null;
facilityDetails.setValue(facilityDetailsValue);
}
} else {
facilityDetails.setVisible(false);
facilityDetails.setRequired(false);
facilityDetails.clear();
}
// value because of this field dependencies to other fields and the way updateEnumValues works
if (facility.isAttached() && !disableFacilityAddressCheck) {
if (facility.getValue() != null) {
FacilityDto facilityDto = FacadeProvider.getFacilityFacade().getByUuid(((FacilityReferenceDto) getField(LocationDto.FACILITY).getValue()).getUuid());
// Only if the facility's address is set
if (StringUtils.isNotEmpty(facilityDto.getCity()) || StringUtils.isNotEmpty(facilityDto.getPostalCode()) || StringUtils.isNotEmpty(facilityDto.getStreet()) || StringUtils.isNotEmpty(facilityDto.getHouseNumber()) || StringUtils.isNotEmpty(facilityDto.getAdditionalInformation()) || facilityDto.getAreaType() != null || facilityDto.getLatitude() != null || facilityDto.getLongitude() != null || (StringUtils.isNotEmpty(facilityDto.getContactPersonFirstName()) && StringUtils.isNotEmpty(facilityDto.getContactPersonLastName()))) {
// Show a confirmation popup if the location's address is already set and different from the facility one
if ((StringUtils.isNotEmpty(cityField.getValue()) && !cityField.getValue().equals(facilityDto.getCity())) || (StringUtils.isNotEmpty(postalCodeField.getValue()) && !postalCodeField.getValue().equals(facilityDto.getPostalCode())) || (StringUtils.isNotEmpty(streetField.getValue()) && !streetField.getValue().equals(facilityDto.getStreet())) || (StringUtils.isNotEmpty(houseNumberField.getValue()) && !houseNumberField.getValue().equals(facilityDto.getHouseNumber())) || (StringUtils.isNotEmpty(additionalInformationField.getValue()) && !additionalInformationField.getValue().equals(facilityDto.getAdditionalInformation())) || (areaType.getValue() != null && areaType.getValue() != facilityDto.getAreaType()) || (StringUtils.isNotEmpty(contactPersonFirstName.getValue()) && StringUtils.isNotEmpty(contactPersonLastName.getValue())) || (tfLatitude.getConvertedValue() != null && Double.compare((Double) tfLatitude.getConvertedValue(), facilityDto.getLatitude()) != 0) || (tfLongitude.getConvertedValue() != null && Double.compare((Double) tfLongitude.getConvertedValue(), facilityDto.getLongitude()) != 0)) {
VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingLocation), new Label(I18nProperties.getString(Strings.confirmationLocationFacilityAddressOverride)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 640, confirmationEvent -> {
if (confirmationEvent) {
overrideLocationDetailsWithFacilityOnes(facilityDto);
}
});
} else {
overrideLocationDetailsWithFacilityOnes(facilityDto);
}
}
}
}
});
final List<ContinentReferenceDto> continents = FacadeProvider.getContinentFacade().getAllActiveAsReference();
if (continents.isEmpty()) {
continent.setVisible(false);
continent.clear();
} else {
continent.addItems(continents);
}
final List<SubcontinentReferenceDto> subcontinents = FacadeProvider.getSubcontinentFacade().getAllActiveAsReference();
if (subcontinents.isEmpty()) {
subcontinent.setVisible(false);
subcontinent.clear();
} else {
subcontinent.addItems(subcontinents);
}
country.addItems(FacadeProvider.getCountryFacade().getAllActiveAsReference());
updateRegionCombo(region, country);
country.addValueChangeListener(e -> {
updateRegionCombo(region, country);
region.setValue(null);
});
Stream.of(LocationDto.LATITUDE, LocationDto.LONGITUDE).<Field<?>>map(this::getField).forEach(f -> f.addValueChangeListener(e -> this.updateLeafletMapContent()));
// Set initial visiblity of facility-contactperson-details (should only be visible if at least a facilityType has been selected)
setFacilityContactPersonFieldsVisible(facilityType.getValue() != null, true);
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project SORMAS-Project by hzi-braunschweig.
the class SymptomsForm method addSoftRequiredStyleWhenSymptomaticAndCooperative.
/**
* Sets the fields defined by the ids contained in sourceValues to required when the person is symptomatic
* and - if a visit is processed - cooperative. When this method is called from within a case, it needs to
* be called with visitStatusField set to null in order to ignore the visit status requirement.
*/
@SuppressWarnings("rawtypes")
private void addSoftRequiredStyleWhenSymptomaticAndCooperative(FieldGroup fieldGroup, Object targetPropertyId, List<String> sourcePropertyIds, List<Object> sourceValues, NullableOptionGroup visitStatusField) {
for (Object sourcePropertyId : sourcePropertyIds) {
Field sourceField = fieldGroup.getField(sourcePropertyId);
if (sourceField instanceof AbstractField<?>) {
((AbstractField) sourceField).setImmediate(true);
}
}
// Initialize
final Field targetField = fieldGroup.getField(targetPropertyId);
if (!targetField.isVisible()) {
return;
}
if (visitStatusField != null) {
if (isAnySymptomSetToYes(fieldGroup, sourcePropertyIds, sourceValues) && visitStatusField.getNullableValue() == VisitStatus.COOPERATIVE) {
FieldHelper.addSoftRequiredStyle(targetField);
} else {
FieldHelper.removeSoftRequiredStyle(targetField);
}
} else {
if (isAnySymptomSetToYes(fieldGroup, sourcePropertyIds, sourceValues)) {
FieldHelper.addSoftRequiredStyle(targetField);
} else {
FieldHelper.removeSoftRequiredStyle(targetField);
}
}
// Add listeners
for (Object sourcePropertyId : sourcePropertyIds) {
Field sourceField = fieldGroup.getField(sourcePropertyId);
sourceField.addValueChangeListener(event -> {
if (visitStatusField != null) {
if (isAnySymptomSetToYes(fieldGroup, sourcePropertyIds, sourceValues) && visitStatusField.getValue() == VisitStatus.COOPERATIVE) {
FieldHelper.addSoftRequiredStyle(targetField);
} else {
FieldHelper.removeSoftRequiredStyle(targetField);
}
} else {
if (isAnySymptomSetToYes(fieldGroup, sourcePropertyIds, sourceValues)) {
FieldHelper.addSoftRequiredStyle(targetField);
} else {
FieldHelper.removeSoftRequiredStyle(targetField);
}
}
});
}
if (visitStatusField != null) {
visitStatusField.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(com.vaadin.v7.data.Property.ValueChangeEvent event) {
if (isAnySymptomSetToYes(fieldGroup, sourcePropertyIds, sourceValues) && visitStatusField.getValue() == VisitStatus.COOPERATIVE) {
FieldHelper.addSoftRequiredStyle(targetField);
} else {
FieldHelper.removeSoftRequiredStyle(targetField);
}
}
});
}
}
use of com.vaadin.v7.data.Property.ValueChangeListener in project SORMAS-Project by hzi-braunschweig.
the class MultiSelect method initContent.
@Override
protected Component initContent() {
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setMargin(new MarginInfo(false, false, true, false));
selectComponent.setWidth("100%");
selectComponent.addValueChangeListener((ValueChangeListener) event -> {
T item = (T) selectComponent.getValue();
if (item == null) {
return;
}
String caption = selectComponent.getItemCaption(item);
selectedItemsWithCaption.put(item, caption);
setValue(new HashSet<>(selectedItemsWithCaption.keySet()));
selectComponent.setValue(null);
listSelectedItems();
});
verticalLayout.addComponent(selectComponent);
if (isReadOnly()) {
selectComponent.setVisible(false);
selectComponent.setReadOnly(true);
}
labelLayout.setMargin(false);
verticalLayout.addComponent(labelLayout);
initFromCurrentValue();
listSelectedItems();
return verticalLayout;
}
Aggregations