Search in sources :

Example 36 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class ResizableTextAreaWrapper method wrap.

@Override
public ComponentContainer wrap(T textField, String caption, boolean withMargin) {
    this.textField = textField;
    this.caption = caption;
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(false);
    layout.setMargin(false);
    layout.setWidth(100, Sizeable.Unit.PERCENTAGE);
    if (withMargin) {
        layout.addStyleName(CssStyles.FIELD_WRAPPER);
    }
    textField.setWidth(100, Sizeable.Unit.PERCENTAGE);
    textField.addStyleName(CssStyles.RESIZABLE);
    textField.setNullRepresentation("");
    textField.setTextChangeTimeout(200);
    Stream<Validator> maxLengthValidatorStream = textField.getValidators().stream().filter(v -> v instanceof MaxLengthValidator);
    if (withMaxLength) {
        maxLengthValidatorStream.findFirst().map(v -> ((MaxLengthValidator) v).getMaxLength()).ifPresent(textField::setMaxLength);
        labelField = new Label(buildLabelMessage(textField.getValue(), textField, caption));
        labelField.setId(textField.getId() + "_label");
        labelField.setWidth(100, Sizeable.Unit.PERCENTAGE);
        labelField.addStyleNames(CssStyles.ALIGN_RIGHT, CssStyles.FIELD_EXTRA_INFO, CssStyles.LABEL_ITALIC);
        layout.addComponents(labelField);
    } else {
        maxLengthValidatorStream.iterator().forEachRemaining(v -> textField.removeValidator(v));
    }
    textField.addTextChangeListener(e -> {
        updateTextfieldAppearance();
    });
    textField.addValueChangeListener(e -> {
        updateTextfieldAppearance();
    });
    layout.addComponents(textField);
    if (withMaxLength) {
        layout.addComponents(labelField);
    }
    return layout;
}
Also used : Strings(com.google.common.base.Strings) Stream(java.util.stream.Stream) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) Validator(com.vaadin.v7.data.Validator) TextArea(com.vaadin.v7.ui.TextArea) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) CharMatcher(com.google.common.base.CharMatcher) AbstractTextField(com.vaadin.v7.ui.AbstractTextField) Sizeable(com.vaadin.server.Sizeable) ComponentContainer(com.vaadin.ui.ComponentContainer) Label(com.vaadin.v7.ui.Label) Label(com.vaadin.v7.ui.Label) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) Validator(com.vaadin.v7.data.Validator)

Example 37 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class MultiSelect method initContent.

@Override
protected Component initContent() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(new MarginInfo(false, false, true, false));
    selectComponent.setWidth("100%");
    selectComponent.addValueChangeListener((ValueChangeListener) event -> {
        T item = (T) selectComponent.getValue();
        if (item == null) {
            return;
        }
        String caption = selectComponent.getItemCaption(item);
        selectedItemsWithCaption.put(item, caption);
        setValue(new HashSet<>(selectedItemsWithCaption.keySet()));
        selectComponent.setValue(null);
        listSelectedItems();
    });
    verticalLayout.addComponent(selectComponent);
    if (isReadOnly()) {
        selectComponent.setVisible(false);
        selectComponent.setReadOnly(true);
    }
    labelLayout.setMargin(false);
    verticalLayout.addComponent(labelLayout);
    initFromCurrentValue();
    listSelectedItems();
    return verticalLayout;
}
Also used : ValoTheme(com.vaadin.ui.themes.ValoTheme) VerticalLayout(com.vaadin.ui.VerticalLayout) Set(java.util.Set) HashMap(java.util.HashMap) Converter(com.vaadin.v7.data.util.converter.Converter) MarginInfo(com.vaadin.shared.ui.MarginInfo) Select(com.vaadin.v7.ui.Select) HashSet(java.util.HashSet) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Map(java.util.Map) Label(com.vaadin.ui.Label) CustomField(com.vaadin.v7.ui.CustomField) VaadinIcons(com.vaadin.icons.VaadinIcons) Component(com.vaadin.ui.Component) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) MarginInfo(com.vaadin.shared.ui.MarginInfo) VerticalLayout(com.vaadin.ui.VerticalLayout) HashSet(java.util.HashSet)

Example 38 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class ExposuresField method showMultipleInfectionEnvironmentsPopup.

private void showMultipleInfectionEnvironmentsPopup(ExposureDto entry) {
    VerticalLayout warningLayout = VaadinUiUtil.createWarningLayout();
    Window popupWindow = VaadinUiUtil.showPopupWindow(warningLayout);
    com.vaadin.ui.Label infoLabel = new com.vaadin.ui.Label(I18nProperties.getValidationError(Validations.caseMultipleInfectionEnvironments));
    CssStyles.style(infoLabel, CssStyles.LABEL_LARGE, CssStyles.LABEL_WHITE_SPACE_NORMAL);
    warningLayout.addComponent(infoLabel);
    ConfirmationComponent yesNo = VaadinUiUtil.buildYesNoConfirmationComponent();
    yesNo.getConfirmButton().addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popupWindow.close();
            for (ExposureDto exposure : getValue()) {
                if (exposure.isProbableInfectionEnvironment() && !exposure.getUuid().equals(entry.getUuid())) {
                    exposure.setProbableInfectionEnvironment(false);
                }
            }
            getTable().refreshRowCache();
        }
    });
    yesNo.getCancelButton().addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popupWindow.close();
            entry.setProbableInfectionEnvironment(false);
            getTable().refreshRowCache();
        }
    });
    warningLayout.addComponent(yesNo);
    popupWindow.setWidth(800, Sizeable.Unit.PIXELS);
    popupWindow.setClosable(false);
}
Also used : Window(com.vaadin.ui.Window) Label(com.vaadin.v7.ui.Label) Button(com.vaadin.ui.Button) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) VerticalLayout(com.vaadin.ui.VerticalLayout) ConfirmationComponent(de.symeda.sormas.ui.utils.ConfirmationComponent)

Example 39 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project charts by vaadin.

the class ChartsDemoUI method init.

@Override
protected void init(VaadinRequest request) {
    initGATracker();
    tabSheet = new TabSheet();
    tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
            com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
        }
    });
    tabSheet.setSizeFull();
    tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    Link homepage = new Link("Home Page", new ExternalResource("https://vaadin.com/components/vaadin-charts"));
    Link javadoc = new Link("JavaDoc", new ExternalResource("https://vaadin.com/api/com.vaadin/vaadin-charts/" + getVersion() + "/"));
    Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/v8/charts/charts-overview.html"));
    Link pricing = new Link("Pricing", new ExternalResource("https://vaadin.com/pricing"));
    Label version = new Label("Version " + getVersion());
    version.addStyleName("version");
    HorizontalLayout links = new HorizontalLayout(homepage, pricing, javadoc, manual);
    links.setSpacing(true);
    links.addStyleName("links");
    final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSecondComponent(tabSheet);
    horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
    horizontalSplitPanel.addStyleName("main-layout");
    ChartOptions.get().setTheme(new ValoLightTheme());
    themeSelector = new ComboBox("Charts Theme:");
    themeSelector.addStyleName("theme-selector");
    themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
    themeSelector.setTextInputAllowed(false);
    com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
    Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
    com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
    mapThemes.put(themes[0], "Valo Light");
    mapThemes.put(themes[1], "Valo Dark");
    mapThemes.put(themes[2], "Vaadin");
    mapThemes.put(themes[3], "HighCharts");
    mapThemes.put(themes[4], "Grid");
    mapThemes.put(themes[5], "Gray");
    mapThemes.put(themes[6], "Skies");
    themeSelector.setEmptySelectionAllowed(false);
    themeSelector.setItems(themes);
    themeSelector.setSelectedItem(defaultTheme);
    themeSelector.setItemCaptionGenerator(mapThemes::get);
    themeSelector.addSelectionListener(e -> {
        ChartOptions.get().setTheme(e.getValue());
    });
    final HierarchicalContainer container = getContainer();
    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(false);
    Label logo = new Label("Vaadin Charts for Vaadin 8");
    logo.setWidth("100%");
    logo.addStyleName("h3");
    logo.addStyleName("logo");
    TextField filterField = new TextField();
    filterField.setPlaceholder("Filter examples");
    filterField.setIcon(FontAwesome.SEARCH);
    filterField.addStyleName("filter");
    filterField.setWidth("100%");
    filterField.addValueChangeListener(e -> {
        container.removeAllContainerFilters();
        String text = e.getValue();
        if (text != null && !text.isEmpty()) {
            expandForFiltering();
            container.addContainerFilter("searchName", text, true, false);
        } else {
            restoreExpandedStates();
        }
    });
    tree = new Tree();
    tree.setImmediate(true);
    tree.setContainerDataSource(container);
    tree.setItemCaptionPropertyId("displayName");
    tree.setNullSelectionAllowed(false);
    tree.setWidth("100%");
    tree.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value instanceof Class) {
                updateTabSheet((Class) value);
            } else {
                tree.expandItemsRecursively(value);
            }
        }
    });
    Button trial = new Button("Start Free Trial");
    trial.addStyleName(ValoTheme.BUTTON_PRIMARY);
    trial.addStyleName(ValoTheme.BUTTON_TINY);
    trial.addClickListener(e -> {
        getUI().getPage().open("https://vaadin.com/trial", "_blank");
    });
    content.addComponents(logo, links, trial, filterField, tree, version);
    content.setComponentAlignment(trial, Alignment.MIDDLE_CENTER);
    horizontalSplitPanel.setFirstComponent(content);
    selectItem();
    Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
            selectItem();
        }
    });
    setContent(new CssLayout() {

        {
            setSizeFull();
            addComponent(horizontalSplitPanel);
            addComponent(themeSelector);
        }
    });
    if (tracker != null) {
        tracker.trackPageview("/charts");
    }
}
Also used : SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) HashMap(java.util.HashMap) Label(com.vaadin.ui.Label) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) Page(com.vaadin.server.Page) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) CssLayout(com.vaadin.ui.CssLayout) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) Tree(com.vaadin.v7.ui.Tree) Property(com.vaadin.v7.data.Property) ComboBox(com.vaadin.ui.ComboBox) GridTheme(com.vaadin.addon.charts.themes.GridTheme) ExternalResource(com.vaadin.server.ExternalResource) TabSheet(com.vaadin.ui.TabSheet) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) ValoTheme(com.vaadin.ui.themes.ValoTheme) Theme(com.vaadin.annotations.Theme) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) GridTheme(com.vaadin.addon.charts.themes.GridTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HierarchicalContainer(com.vaadin.v7.data.util.HierarchicalContainer) Link(com.vaadin.ui.Link)

Example 40 with VerticalLayout

use of com.vaadin.v7.ui.VerticalLayout in project SORMAS-Project by hzi-braunschweig.

the class CampaignDashboardView method refreshDashboard.

@SuppressWarnings("deprecation")
@Override
public void refreshDashboard() {
    final Page page = Page.getCurrent();
    cleanupDashboard(page);
    final VerticalLayout tabLayout = new VerticalLayout();
    tabLayout.setSizeFull();
    tabLayout.setMargin(new MarginInfo(false, false, false, false));
    tabLayout.setSpacing(false);
    campaignDashboardTabComponents.add(tabLayout);
    dashboardLayout.addComponent(tabLayout);
    dashboardLayout.setExpandRatio(tabLayout, 1);
    final OptionGroup tabSwitcher = new OptionGroup();
    tabSwitcher.setWidthFull();
    final VerticalLayout tabSwitcherLayout = new VerticalLayout(tabSwitcher);
    tabSwitcherLayout.setWidthFull();
    tabSwitcherLayout.setMargin(new MarginInfo(false, false, false, true));
    tabSwitcherLayout.setSpacing(false);
    tabLayout.addComponent(tabSwitcherLayout);
    tabLayout.setExpandRatio(tabSwitcherLayout, 0);
    final List<String> tabs = new ArrayList<>(dataProvider.getTabIds());
    tabs.forEach(tabId -> {
        tabSwitcher.addItem(tabId);
        tabSwitcher.setItemCaption(tabId, tabId);
    });
    if (!(tabs.size() > 1)) {
        tabSwitcherLayout.setVisible(false);
    }
    final String lastTabId = lastTabIdForCampaign.get(dataProvider.getCampaign());
    tabSwitcher.setValue(tabs.isEmpty() ? StringUtils.EMPTY : lastTabId != null ? lastTabId : tabs.get(0));
    CssStyles.style(tabSwitcher, CssStyles.FORCE_CAPTION, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.OPTIONGROUP_HORIZONTAL_PRIMARY);
    final VerticalLayout subTabLayout = new VerticalLayout();
    subTabLayout.setSizeFull();
    subTabLayout.setMargin(new MarginInfo(false, false, false, false));
    subTabLayout.setSpacing(false);
    campaignDashboardTabComponents.add(subTabLayout);
    tabLayout.addComponent(subTabLayout);
    tabLayout.setExpandRatio(subTabLayout, 1);
    tabSwitcher.addValueChangeListener(e -> {
        final String tabId = (String) e.getProperty().getValue();
        subTabLayout.removeComponent(currentDiagramsWrapper);
        subTabLayout.removeComponent(currentSubTabsWrapper);
        lastTabIdForCampaign.put(dataProvider.getCampaign(), tabId);
        refreshSubTabs(page, tabId, subTabLayout);
    });
    refreshSubTabs(page, (String) tabSwitcher.getValue(), subTabLayout);
}
Also used : OptionGroup(com.vaadin.v7.ui.OptionGroup) MarginInfo(com.vaadin.shared.ui.MarginInfo) ArrayList(java.util.ArrayList) VerticalLayout(com.vaadin.ui.VerticalLayout) Page(com.vaadin.server.Page)

Aggregations

VerticalLayout (com.vaadin.v7.ui.VerticalLayout)34 VerticalLayout (com.vaadin.ui.VerticalLayout)25 Button (com.vaadin.ui.Button)22 Label (com.vaadin.ui.Label)18 Label (com.vaadin.v7.ui.Label)17 HorizontalLayout (com.vaadin.ui.HorizontalLayout)16 Window (com.vaadin.ui.Window)12 Component (com.vaadin.ui.Component)11 ValoTheme (com.vaadin.ui.themes.ValoTheme)11 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)11 VaadinIcons (com.vaadin.icons.VaadinIcons)10 Panel (com.vaadin.ui.Panel)10 TextField (com.vaadin.v7.ui.TextField)10 Strings (de.symeda.sormas.api.i18n.Strings)10 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)10 CssStyles (de.symeda.sormas.ui.utils.CssStyles)10 Captions (de.symeda.sormas.api.i18n.Captions)9 Alignment (com.vaadin.ui.Alignment)8 CheckBox (com.vaadin.v7.ui.CheckBox)8 OptionGroup (com.vaadin.v7.ui.OptionGroup)8