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;
}
Aggregations