}
}
if (!factorList.isEmpty()) {
// find rest
LayoutContainer container = getLayoutContainer();
Measure available = LayoutUtils.getCurrentSize(orientation, container);
if (available != null) {
for (BankHead head : heads) {
available = available.subtractNotNegative(head.getCurrent());
}
available = available.subtractNotNegative(LayoutUtils.getBorderBegin(orientation, container));
available = available.subtractNotNegative(LayoutUtils.getPaddingBegin(orientation, container));
available = available.subtractNotNegative(getMarginBegin(orientation));
available = available.subtractNotNegative(computeSpacing(orientation, 0, heads.length));
available = available.subtractNotNegative(getMarginEnd(orientation));
available = available.subtractNotNegative(LayoutUtils.getPaddingEnd(orientation, container));
available = available.subtractNotNegative(LayoutUtils.getBorderEnd(orientation, container));
if (grid.isOverflow(orientation.other())) {
ClientProperties client = VariableResolverUtils.resolveClientProperties(FacesContext.getCurrentInstance());
final Measure scrollbar = orientation
== Orientation.HORIZONTAL ? client.getVerticalScrollbarWeight() : client.getHorizontalScrollbarWeight();
available = available.subtractNotNegative(scrollbar);
}
List<Measure> partition = factorList.partition(available);
// write values back into the header
int i = 0; // index of head
int j = 0; // index of partition
for (BankHead head : heads) {
if (head.getToken() instanceof RelativeLayoutToken && head.isRendered()) {
// respect the minimum
heads[i].setCurrent(Measure.max(partition.get(j), heads[i].getIntervalList().getMinimum()));
j++;
}
i++;
}
} else {
LOG.warn("No width/height set but needed for *!"); // todo: more information
}
}
// call manage sizes for all sub-layout-managers
for (int i = 0; i < heads.length; i++) {
for (int j = 0; j < heads2.length; j++) {
Cell cell = grid.getCell(i, j, orientation);
if (cell instanceof OriginCell) {
LayoutComponent component = cell.getComponent();
component.setDisplay(Display.BLOCK); // TODO: use CSS via classes and style.css
Integer span = ((OriginCell) cell).getSpan(orientation);
// compute the size of the cell
Measure size = Measure.ZERO;
for (int k = 0; k < span; k++) {
size = size.add(heads[i + k].getCurrent());
}
size = size.add(computeSpacing(orientation, i, span));
Measure current = LayoutUtils.getCurrentSize(orientation, component);
if (current == null) {
LayoutUtils.setCurrentSize(orientation, component, size);
}
// call sub layout manager
if (component instanceof LayoutContainer && (component.isRendered() || isRigid())) {
((LayoutContainer) component).getLayoutManager().mainProcessing(orientation);
}
}
}
}
Measure size = Measure.ZERO;
size = size.add(LayoutUtils.getPaddingBegin(orientation, getLayoutContainer()));
size = size.add(getMarginBegin(orientation));
size = size.add(computeSpacing(orientation, 0, heads.length));
for (BankHead head : heads) {
size = size.add(head.getCurrent());
}
size = size.add(getMarginEnd(orientation));
size = size.add(LayoutUtils.getPaddingEnd(orientation, getLayoutContainer()));
if (size.greaterThan(LayoutUtils.getCurrentSize(orientation, getLayoutContainer()))) {
grid.setOverflow(true, orientation);
}
}