use of com.vaadin.ui.RadioButtonGroup in project catma by forTEXT.
the class ChangeImportActionDialog method addContent.
@Override
protected void addContent(ComponentContainer content) {
HorizontalLayout choicePanel = new HorizontalLayout();
ListDataProvider<TagsetDefinition> tagsetGridDataProvider = new ListDataProvider<TagsetDefinition>(tagsets);
this.tagsetGrid = new Grid<>("Available Tagsets", tagsetGridDataProvider);
this.tagsetGrid.setHeight("200px");
tagsetGrid.addColumn(tagset -> tagset.getName()).setCaption("Name");
this.tagsetNameInput = new TextField("Enter the name of the new Tagset");
this.choices = new RadioButtonGroup<String>("Your choices are");
this.choices.setItems(choice1, choice2, choice3);
this.choices.addValueChangeListener(event -> {
choicePanel.removeAllComponents();
if (event.getValue().equals(choice1)) {
choicePanel.addComponent(this.tagsetNameInput);
} else if (event.getValue().equals(choice2)) {
choicePanel.addComponent(this.tagsetGrid);
}
});
content.addComponent(this.choices);
content.addComponent(choicePanel);
if (content instanceof AbstractOrderedLayout) {
((AbstractOrderedLayout) content).setComponentAlignment(choices, Alignment.TOP_CENTER);
((AbstractOrderedLayout) content).setComponentAlignment(choicePanel, Alignment.TOP_CENTER);
}
this.choices.setValue(choice2);
}
use of com.vaadin.ui.RadioButtonGroup in project SORMAS-Project by hzi-braunschweig.
the class StatisticsView method addOptionsLayout.
private void addOptionsLayout(VerticalLayout statisticsLayout) {
Label optionsTitle = new Label(I18nProperties.getCaption(Captions.options));
optionsTitle.setWidthUndefined();
CssStyles.style(optionsTitle, CssStyles.STATISTICS_TITLE);
statisticsLayout.addComponent(optionsTitle);
HorizontalLayout optionsLayout = new HorizontalLayout();
optionsLayout.setWidth(100, Unit.PERCENTAGE);
optionsLayout.setSpacing(true);
CssStyles.style(optionsLayout, CssStyles.STATISTICS_TITLE_BOX);
{
ogCaseCountOrIncidence = new RadioButtonGroup<CaseCountOrIncidence>(I18nProperties.getCaption(Captions.statisticsDataDisplayed), Arrays.asList(CaseCountOrIncidence.values()));
ogCaseCountOrIncidence.setId(Captions.statisticsDataDisplayed);
ogCaseCountOrIncidence.setValue(CaseCountOrIncidence.CASE_COUNT);
ogCaseCountOrIncidence.addValueChangeListener(e -> {
showCaseIncidence = e.getValue() == CaseCountOrIncidence.CASE_INCIDENCE;
tfIncidenceDivisor.setVisible(showCaseIncidence);
visualizationComponent.setStackedColumnAndPieEnabled(!showCaseIncidence);
});
CssStyles.style(ogCaseCountOrIncidence, CssStyles.VSPACE_NONE, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.SOFT_REQUIRED);
optionsLayout.addComponent(ogCaseCountOrIncidence);
tfIncidenceDivisor = new TextField(I18nProperties.getCaption(Captions.statisticsIncidenceDivisor));
tfIncidenceDivisor.setId("incidenceDivisor");
tfIncidenceDivisor.setValue("100000");
tfIncidenceDivisor.addValueChangeListener(e -> {
try {
// Store value in a temporary variable to trigger possible exception
int newDivisor = Integer.valueOf(e.getValue());
incidenceDivisor = newDivisor;
} catch (NumberFormatException ex) {
tfIncidenceDivisor.setValue(String.valueOf(incidenceDivisor));
new Notification(null, I18nProperties.getValidationError(Validations.statisticsIncidenceOnlyNumbersAllowed), Type.ERROR_MESSAGE, false).show(Page.getCurrent());
}
});
optionsLayout.addComponent(tfIncidenceDivisor);
tfIncidenceDivisor.setVisible(false);
cbShowZeroValues = new CheckBox(I18nProperties.getCaption(Captions.statisticsShowZeroValues));
cbShowZeroValues.setId(Captions.statisticsShowZeroValues);
cbShowZeroValues.setValue(false);
CssStyles.style(cbShowZeroValues, CssStyles.FORCE_CAPTION_CHECKBOX);
optionsLayout.addComponent(cbShowZeroValues);
cbHideOtherCountries = new CheckBox(I18nProperties.getCaption(Captions.dashboardHideOtherCountries));
cbHideOtherCountries.setId(Captions.dashboardHideOtherCountries);
cbHideOtherCountries.setValue(false);
CssStyles.style(cbHideOtherCountries, CssStyles.FORCE_CAPTION_CHECKBOX);
optionsLayout.addComponent(cbHideOtherCountries);
cbHideOtherCountries.setVisible(StatisticsVisualizationType.MAP.equals(visualizationComponent.getVisualizationType()));
Label expandedDummy = new Label();
optionsLayout.addComponent(expandedDummy);
optionsLayout.setExpandRatio(expandedDummy, 1);
}
statisticsLayout.addComponent(optionsLayout);
}
Aggregations