Example usage for com.vaadin.v7.ui OptionGroup size

List of usage examples for com.vaadin.v7.ui OptionGroup size

Introduction

In this page you can find the example usage for com.vaadin.v7.ui OptionGroup size.

Prototype

@Override
public int size() 

Source Link

Document

Gets the number of items in the container.

Usage

From source file:de.symeda.sormas.ui.dashboard.AbstractDashboardView.java

License:Open Source License

protected AbstractDashboardView(String viewName, DashboardType dashboardType) {
    super(viewName);

    addStyleName(DashboardCssStyles.DASHBOARD_SCREEN);

    dashboardDataProvider = new DashboardDataProvider();
    if (dashboardDataProvider.getDashboardType() == null) {
        dashboardDataProvider.setDashboardType(dashboardType);
    }// w  ww.  j av a2s.  c om

    OptionGroup dashboardSwitcher = new OptionGroup();
    CssStyles.style(dashboardSwitcher, CssStyles.FORCE_CAPTION, ValoTheme.OPTIONGROUP_HORIZONTAL,
            CssStyles.OPTIONGROUP_HORIZONTAL_PRIMARY);
    if (UserProvider.getCurrent().hasUserRight(UserRight.DASHBOARD_SURVEILLANCE_ACCESS)) {
        dashboardSwitcher.addItem(DashboardType.SURVEILLANCE);
        dashboardSwitcher.setItemCaption(DashboardType.SURVEILLANCE,
                I18nProperties.getEnumCaption(DashboardType.SURVEILLANCE));
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.DASHBOARD_CONTACT_ACCESS)) {
        dashboardSwitcher.addItem(DashboardType.CONTACTS);
        dashboardSwitcher.setItemCaption(DashboardType.CONTACTS,
                I18nProperties.getEnumCaption(DashboardType.CONTACTS));
    }
    dashboardSwitcher.setValue(dashboardType);
    dashboardSwitcher.addValueChangeListener(e -> {
        dashboardDataProvider.setDashboardType((DashboardType) e.getProperty().getValue());
        if (e.getProperty().getValue().equals(DashboardType.SURVEILLANCE)) {
            SormasUI.get().getNavigator().navigateTo(SurveillanceDashboardView.VIEW_NAME);
        } else {
            SormasUI.get().getNavigator().navigateTo(ContactsDashboardView.VIEW_NAME);
        }
    });
    addHeaderComponent(dashboardSwitcher);

    // Hide the dashboard switcher if only one dashboard is accessible to the user
    if (dashboardSwitcher.size() <= 1) {
        dashboardSwitcher.setVisible(false);
    }

    // Dashboard layout
    dashboardLayout = new VerticalLayout();
    dashboardLayout.setMargin(false);
    dashboardLayout.setSpacing(false);
    dashboardLayout.setSizeFull();
    dashboardLayout.setStyleName("crud-main-layout");

    // Filter bar
    filterLayout = new DashboardFilterLayout(this, dashboardDataProvider);
    dashboardLayout.addComponent(filterLayout);

    addComponent(dashboardLayout);
}