use of de.symeda.sormas.ui.utils.CssStyles.VSPACE_2 in project SORMAS-Project by hzi-braunschweig.
the class OutbreakRegionConfigurationForm method createHeader.
private HorizontalLayout createHeader() {
HorizontalLayout headerLayout = new HorizontalLayout();
headerLayout.setWidth(100, Unit.PERCENTAGE);
headerLayout.setSpacing(true);
style(headerLayout, VSPACE_2);
// Headline and info text
Label infoTextLabel = new Label(I18nProperties.getString(Strings.headingDefineOutbreakDistricts));
infoTextLabel.setWidthUndefined();
style(infoTextLabel, VSPACE_TOP_4);
headerLayout.addComponent(infoTextLabel);
// Number of affected districts and options to toggle outbreak mode for all districts
HorizontalLayout allDistrictsLayout = new HorizontalLayout();
allDistrictsLayout.setWidthUndefined();
allDistrictsLayout.setSpacing(true);
{
Label allDistrictsLabel = new Label(I18nProperties.getString(Strings.headingSetOutbreakStatus));
allDistrictsLabel.setWidthUndefined();
style(allDistrictsLabel, VSPACE_TOP_4);
allDistrictsLayout.addComponent(allDistrictsLabel);
OptionGroup outbreakToggle = new OptionGroup();
style(outbreakToggle, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.OPTIONGROUP_HORIZONTAL_SWITCH_CRITICAL);
outbreakToggle.addItem(OUTBREAK);
outbreakToggle.addItem(NORMAL);
if (affectedDistricts.isEmpty()) {
outbreakToggle.setValue(NORMAL);
} else if (affectedDistricts.size() == totalDistricts) {
outbreakToggle.setValue(OUTBREAK);
}
outbreakToggle.addValueChangeListener(e -> {
for (OptionGroup districtOutbreakToggle : outbreakToggles) {
districtOutbreakToggle.setValue(e.getProperty().getValue());
}
});
outbreakToggle.setWidthUndefined();
allDistrictsLayout.addComponent(outbreakToggle);
affectedDistrictsNumberLabel = new Label();
affectedDistrictsNumberLabel.setWidthUndefined();
allDistrictsLayout.addComponent(affectedDistrictsNumberLabel);
}
headerLayout.addComponent(allDistrictsLayout);
headerLayout.setComponentAlignment(allDistrictsLayout, Alignment.TOP_RIGHT);
headerLayout.setExpandRatio(infoTextLabel, 1);
return headerLayout;
}
Aggregations