Search in sources :

Example 1 with RadioButtonGroup

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);
}
Also used : ListDataProvider(com.vaadin.data.provider.ListDataProvider) TextField(com.vaadin.ui.TextField) AbstractOkCancelDialog(de.catma.ui.dialog.AbstractOkCancelDialog) Project(de.catma.project.Project) Collection(java.util.Collection) Alignment(com.vaadin.ui.Alignment) ComponentContainer(com.vaadin.ui.ComponentContainer) ArrayList(java.util.ArrayList) List(java.util.List) Type(com.vaadin.ui.Notification.Type) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Notification(com.vaadin.ui.Notification) RadioButtonGroup(com.vaadin.ui.RadioButtonGroup) TagsetDefinition(de.catma.tag.TagsetDefinition) Version(de.catma.tag.Version) IDGenerator(de.catma.util.IDGenerator) SaveCancelListener(de.catma.ui.dialog.SaveCancelListener) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) Collections(java.util.Collections) Grid(com.vaadin.ui.Grid) TagsetDefinition(de.catma.tag.TagsetDefinition) ListDataProvider(com.vaadin.data.provider.ListDataProvider) TextField(com.vaadin.ui.TextField) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with RadioButtonGroup

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);
}
Also used : Arrays(java.util.Arrays) TextField(com.vaadin.ui.TextField) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EpiWeek(de.symeda.sormas.api.utils.EpiWeek) IntegerRange(de.symeda.sormas.api.IntegerRange) Alignment(com.vaadin.ui.Alignment) ReferenceDto(de.symeda.sormas.api.ReferenceDto) AgeGroup(de.symeda.sormas.api.AgeGroup) QuarterOfYear(de.symeda.sormas.api.QuarterOfYear) BigDecimal(java.math.BigDecimal) CaseOutcome(de.symeda.sormas.api.caze.CaseOutcome) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) StatisticsCaseAttribute(de.symeda.sormas.api.statistics.StatisticsCaseAttribute) CheckBox(com.vaadin.ui.CheckBox) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Page(com.vaadin.server.Page) Quarter(de.symeda.sormas.api.Quarter) Year(de.symeda.sormas.api.Year) GeoLatLon(de.symeda.sormas.api.geo.GeoLatLon) VaadinIcons(com.vaadin.icons.VaadinIcons) LeafletMap(de.symeda.sormas.ui.map.LeafletMap) UserRole(de.symeda.sormas.api.user.UserRole) LeafletMapUtil(de.symeda.sormas.ui.map.LeafletMapUtil) RoundingMode(java.math.RoundingMode) ValoTheme(com.vaadin.ui.themes.ValoTheme) DownloadUtil(de.symeda.sormas.ui.utils.DownloadUtil) StatisticsGroupingKey(de.symeda.sormas.api.statistics.StatisticsGroupingKey) StatisticsKeyComparator(de.symeda.sormas.api.statistics.StatisticsHelper.StatisticsKeyComparator) Sex(de.symeda.sormas.api.person.Sex) HtmlHelper(de.symeda.sormas.api.utils.HtmlHelper) HighChart(de.symeda.sormas.ui.highcharts.HighChart) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TokenizableValue(de.symeda.sormas.ui.statistics.StatisticsFilterElement.TokenizableValue) RadioButtonGroup(com.vaadin.ui.RadioButtonGroup) Descriptions(de.symeda.sormas.api.i18n.Descriptions) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) StreamResource(com.vaadin.server.StreamResource) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) CaseMeasure(de.symeda.sormas.api.CaseMeasure) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) LeafletPolygon(de.symeda.sormas.ui.map.LeafletPolygon) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Calendar(java.util.Calendar) CollectionUtils(org.apache.commons.collections.CollectionUtils) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) StatisticsCaseCriteria(de.symeda.sormas.api.statistics.StatisticsCaseCriteria) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) StatisticsVisualizationChartType(de.symeda.sormas.ui.statistics.StatisticsVisualizationType.StatisticsVisualizationChartType) Month(de.symeda.sormas.api.Month) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Validations(de.symeda.sormas.api.i18n.Validations) DataHelper(de.symeda.sormas.api.utils.DataHelper) DashboardMapComponent(de.symeda.sormas.ui.dashboard.map.DashboardMapComponent) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Captions(de.symeda.sormas.api.i18n.Captions) StatisticsCaseCountDto(de.symeda.sormas.api.statistics.StatisticsCaseCountDto) Button(com.vaadin.ui.Button) StatisticsCaseSubAttribute(de.symeda.sormas.api.statistics.StatisticsCaseSubAttribute) Disease(de.symeda.sormas.api.Disease) TreeMap(java.util.TreeMap) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FileDownloader(com.vaadin.server.FileDownloader) StatisticsHelper(de.symeda.sormas.api.statistics.StatisticsHelper) MonthOfYear(de.symeda.sormas.api.MonthOfYear) Comparator(java.util.Comparator) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) CheckBox(com.vaadin.ui.CheckBox) Label(com.vaadin.ui.Label) RadioButtonGroup(com.vaadin.ui.RadioButtonGroup) TextField(com.vaadin.ui.TextField) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)2 Alignment (com.vaadin.ui.Alignment)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Notification (com.vaadin.ui.Notification)2 Type (com.vaadin.ui.Notification.Type)2 RadioButtonGroup (com.vaadin.ui.RadioButtonGroup)2 TextField (com.vaadin.ui.TextField)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 ListDataProvider (com.vaadin.data.provider.ListDataProvider)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 FileDownloader (com.vaadin.server.FileDownloader)1 Page (com.vaadin.server.Page)1 StreamResource (com.vaadin.server.StreamResource)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 Button (com.vaadin.ui.Button)1 CheckBox (com.vaadin.ui.CheckBox)1 ComponentContainer (com.vaadin.ui.ComponentContainer)1 Grid (com.vaadin.ui.Grid)1