Search in sources :

Example 1 with Accordion

use of com.vaadin.ui.Accordion in project VaadinUtils by rlsutton1.

the class ReportFilterUIBuilder method buildLayout.

@Override
public List<ExpanderComponent> buildLayout(Boolean hideDateFields) {
    List<ExpanderComponent> components = new LinkedList<ExpanderComponent>();
    boolean hasExpandingComponents = false;
    Accordion accordian = null;
    if (hasFilters()) {
        for (ReportParameter<?> rparam : rparams) {
            if (rparam.showFilter()) {
                // scheduler
                if (!hideDateFields || !rparam.isDateField()) {
                    if (rparam.shouldExpand()) {
                        if (accordian == null) {
                            accordian = new Accordion();
                            accordian.setSizeFull();
                        }
                        final Tab tab = accordian.addTab(rparam.getComponent(), rparam.getLabel(""));
                        rparam.addValidateListener(new ValidateListener() {

                            @Override
                            public void setComponentError(ErrorMessage componentError) {
                                tab.setComponentError(componentError);
                            }
                        });
                        rparam.validate();
                    } else {
                        components.add(new ExpanderComponent(rparam.getComponent(), rparam.shouldExpand()));
                    }
                }
            }
        }
    }
    if (accordian != null) {
        hasExpandingComponents = true;
        components.add(new ExpanderComponent(accordian, true));
    }
    if (!hasExpandingComponents) {
        // there are no expanding components, so add an empty expanding
        // component so the fields will group together at the top
        components.add(new ExpanderComponent(new VerticalLayout(), true));
    }
    // add 15px high layout to pack up the bottom of the layout, otherwise
    // on
    // some sets of filters the last component is hidden
    VerticalLayout spacer = new VerticalLayout();
    spacer.setHeight("15");
    components.add(new ExpanderComponent(spacer, false));
    return components;
}
Also used : Accordion(com.vaadin.ui.Accordion) Tab(com.vaadin.ui.TabSheet.Tab) VerticalLayout(com.vaadin.ui.VerticalLayout) ErrorMessage(com.vaadin.server.ErrorMessage) LinkedList(java.util.LinkedList)

Aggregations

ErrorMessage (com.vaadin.server.ErrorMessage)1 Accordion (com.vaadin.ui.Accordion)1 Tab (com.vaadin.ui.TabSheet.Tab)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 LinkedList (java.util.LinkedList)1