}
private LayeredPane getLayeredPane(TimePeriodSwitcher switcher) {
FacesContext context = FacesContext.getCurrentInstance();
LayeredPane layeredPane = Components.getChildWithClass(switcher, LayeredPane.class, "layeredPane");
layeredPane.setStyleClass("o_timetablePeriodSwitcher_lp");
layeredPane.setId(switcher.getId() + LAYERED_PANE_SUFFIX);
layeredPane.setLoadingMode(LoadingMode.CLIENT);
if (layeredPane.getChildCount() == 0) {
List<UIComponent> children = layeredPane.getChildren();
children.add(new SubPanel(null, switcher.getMonthSwitcher()));
children.add(new SubPanel(null, switcher.getWeekSwitcher()));
children.add(new SubPanel(null, switcher.getDaySwitcher()));
}
Timetable timetable = switcher.getTimetableView();
Timetable.ViewType currentViewType = timetable.getViewType();
List<UIComponent> children = layeredPane.getChildren();
int viewIndex = 0;
for (int i = 0, count = children.size(); i < count; i++) {
SubPanel subPanel = (SubPanel) children.get(i);
if (subPanel.getChildCount() != 1)
throw new IllegalArgumentException("One child component expected, but was " + subPanel.getChildCount() + "; panel index: " + i);
AbstractSwitcher viewInThisPanel = (AbstractSwitcher) subPanel.getChildren().get(0);
Timetable.ViewType viewType = viewInThisPanel.getApplicableViewType();
TimetableView appropriateView = timetable.getViewByType(viewType);
viewInThisPanel.setFor(":" + appropriateView.getClientId(context));
if (viewType == currentViewType) {
viewIndex = i;
}
}
layeredPane.setSelectedIndex(viewIndex);
return layeredPane;
}