use of com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException in project qcadoo by qcadoo.
the class GridLayoutPattern method parse.
@Override
public void parse(final Node componentNode, final ViewDefinitionParser parser) throws ViewDefinitionParserNodeException {
super.parse(componentNode, parser);
Integer columns = getIntAttribute(componentNode, "columns", parser);
Integer rows = getIntAttribute(componentNode, "rows", parser);
fixedRowHeight = parser.getBooleanAttribute(componentNode, "fixedRowHeight", true);
parser.checkState(columns != null, componentNode, "columns not definied");
parser.checkState(rows != null, componentNode, "rows not definied");
// check again - because sonar is stupid
if (rows == null) {
throw new IllegalStateException("rows not definied");
}
cells = new GridLayoutCell[rows][];
for (int row = 0; row < cells.length; row++) {
cells[row] = new GridLayoutCell[columns];
for (int col = 0; col < cells[row].length; col++) {
cells[row][col] = new GridLayoutCell();
}
}
NodeList childNodes = componentNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
parser.checkState("layoutElement".equals(child.getNodeName()), child, "gridlayout can contains only layoutElements");
Integer column = getIntAttribute(child, "column", parser);
Integer row = getIntAttribute(child, "row", parser);
GridLayoutCell cell = createGridLayoutCell(child, parser);
try {
insertCell(cell, column, row);
} catch (IllegalStateException e) {
throw new ViewDefinitionParserNodeException(child, e);
}
}
if (parser.getBooleanAttribute(componentNode, "hasBorders", true)) {
updateBorders();
}
}
Aggregations