use of de.symeda.sormas.ui.utils.DateHelper8 in project SORMAS-Project by hzi-braunschweig.
the class LineListingConfigurationsGrid method buildGrid.
private void buildGrid() {
setSelectionMode(SelectionMode.NONE);
if (nationLevel) {
addColumn(FeatureConfigurationIndexDto::getRegionName).setCaption(I18nProperties.getPrefixCaption(FeatureConfigurationIndexDto.I18N_PREFIX, FeatureConfigurationIndexDto.REGION_NAME));
}
addColumn(FeatureConfigurationIndexDto::getDistrictName).setCaption(I18nProperties.getPrefixCaption(FeatureConfigurationIndexDto.I18N_PREFIX, FeatureConfigurationIndexDto.DISTRICT_NAME));
addComponentColumn(config -> {
CheckBox cbActive = new CheckBox();
cbActive.setValue(config.isEnabled());
cbActive.addValueChangeListener(e -> {
config.setEnabled(e.getValue());
if (Boolean.TRUE.equals(e.getValue())) {
config.setEndDate(DateHelper.addDays(new Date(), 21));
dateFieldMap.get(config).setValue(DateHelper8.toLocalDate(DateHelper.addDays(new Date(), 21)));
} else {
config.setEndDate(null);
dateFieldMap.get(config).setValue(null);
}
changedConfigurations.add(config);
});
return cbActive;
}).setCaption(I18nProperties.getPrefixCaption(FeatureConfigurationIndexDto.I18N_PREFIX, FeatureConfigurationIndexDto.ENABLED));
addComponentColumn(config -> {
DateField dfEndDate = new DateField();
dfEndDate.setValue(DateHelper8.toLocalDate(config.getEndDate()));
dfEndDate.addValueChangeListener(e -> {
if (e.getValue() != null && e.getValue().isBefore(LocalDate.now())) {
Notification errorNotification = new Notification(I18nProperties.getString(Strings.headingInvalidDateEntered), I18nProperties.getValidationError(Validations.noPastDateAllowed), Type.TRAY_NOTIFICATION);
errorNotification.setStyleName("tray notification-error");
errorNotification.show(Page.getCurrent());
} else {
config.setEndDate(DateHelper8.toDate(e.getValue()));
changedConfigurations.add(config);
}
});
dfEndDate.setRangeStart(LocalDate.now());
dateFieldMap.put(config, dfEndDate);
return dfEndDate;
}).setCaption(I18nProperties.getPrefixCaption(FeatureConfigurationIndexDto.I18N_PREFIX, FeatureConfigurationIndexDto.END_DATE));
}
Aggregations