Search in sources :

Example 11 with ViewDefinitionParserNodeException

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();
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)

Aggregations

ViewDefinitionParserNodeException (com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)11 Node (org.w3c.dom.Node)10 NodeList (org.w3c.dom.NodeList)8 ModuleException (com.qcadoo.plugin.api.ModuleException)2 ComponentDefinition (com.qcadoo.view.internal.ComponentDefinition)2 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)2 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)2 InternalRibbonGroup (com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)2 SingleRibbonGroupPack (com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack)2 ViewDefinitionParserException (com.qcadoo.view.internal.xml.ViewDefinitionParserException)2 IOException (java.io.IOException)2 SecurityRole (com.qcadoo.security.api.SecurityRole)1 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)1 RibbonComboBox (com.qcadoo.view.api.ribbon.RibbonComboBox)1 RibbonComboItem (com.qcadoo.view.api.ribbon.RibbonComboItem)1 ComponentPattern (com.qcadoo.view.internal.api.ComponentPattern)1 WindowTabComponentPattern (com.qcadoo.view.internal.components.window.WindowTabComponentPattern)1 InternalRibbon (com.qcadoo.view.internal.ribbon.model.InternalRibbon)1 InternalRibbonActionItem (com.qcadoo.view.internal.ribbon.model.InternalRibbonActionItem)1 InternalRibbonComboItem (com.qcadoo.view.internal.ribbon.model.InternalRibbonComboItem)1