private int calculateLayoutHeight(
FacesContext facesContext, UIComponent component, boolean minimum) {
UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
final List<UIGridLayout.Row> rows = layout.ensureRows();
LayoutTokens layoutTokens = layout.getRowLayout();
if (layoutTokens == null && !minimum && LOG.isDebugEnabled()) {
LOG.debug("No rowLayout found using " + (minimum ? "'minimum'" : "'fixed'")
+ " for all " + rows.size() + " rows."
+ " (clientId='" + layout.getClientId(facesContext) + "')");
}
if (rows.size() != layoutTokens.getSize()) {
LOG.warn("Unbalanced layout: rows.size()=" + rows.size()
+ " != layoutTokens.length=" + layoutTokens.getSize()
+ " rowLayout='" + layoutTokens + "'"
+ " (clientId='" + layout.getClientId(facesContext) + "')");
layoutTokens.ensureSize(rows.size(), new RelativeLayoutToken(1));
}
// TODO alternative? rows.size() == 1 ? new RelativeLayoutToken(1) : new FixedLayoutToken()
//new FixedLayoutToken() );
//String[] layoutTokens
// = LayoutInfo.createLayoutTokens(rowLayout, rows.size(),
// minimum ? "minimum" : "fixed");
int size = Math.min(rows.size(), layoutTokens.getSize());
int height = 0;
height += getMarginAsInt(layout.getMarginTop());
height += getMarginAsInt(layout.getMarginBottom());
boolean first = true;
for (int i = 0; i < size; i++) {
if (!rowIsRendered(rows.get(i))) {
continue;
}
height += getCellPadding(facesContext, layout, first);
first = false;
LayoutToken token = layoutTokens.get(i);
if (token instanceof PixelLayoutToken) {
height += ((PixelLayoutToken) token).getPixel();
} else if (token instanceof FixedLayoutToken) {
height += getMaxHeight(facesContext, rows.get(i), false);
} else if (token instanceof MinimumLayoutToken) {