Search in sources :

Example 1 with RibbonImpl

use of com.qcadoo.view.internal.ribbon.model.RibbonImpl in project qcadoo by qcadoo.

the class RibbonParserService method parseRibbon.

public InternalRibbon parseRibbon(final Node ribbonNode, final ViewDefinitionParser parser, final ViewDefinition viewDefinition) throws ViewDefinitionParserNodeException {
    InternalRibbon ribbon = new RibbonImpl();
    NodeList childNodes = ribbonNode.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.item(i);
        if (Node.ELEMENT_NODE != child.getNodeType()) {
            continue;
        }
        if ("group".equals(child.getNodeName())) {
            ribbon.addGroupsPack(new SingleRibbonGroupPack(parseRibbonGroup(child, parser, viewDefinition)));
        } else if ("template".equals(child.getNodeName())) {
            applyTemplate(child, ribbon, parser, viewDefinition);
        } else {
            throw new ViewDefinitionParserNodeException(child, "Wrong node type - 'group' or 'template' expected");
        }
    }
    ribbon.setAlignment(parser.getStringAttribute(ribbonNode, ALIGNMENT));
    return ribbon;
}
Also used : InternalRibbon(com.qcadoo.view.internal.ribbon.model.InternalRibbon) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) SingleRibbonGroupPack(com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException) RibbonImpl(com.qcadoo.view.internal.ribbon.model.RibbonImpl)

Aggregations

InternalRibbon (com.qcadoo.view.internal.ribbon.model.InternalRibbon)1 RibbonImpl (com.qcadoo.view.internal.ribbon.model.RibbonImpl)1 SingleRibbonGroupPack (com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack)1 ViewDefinitionParserNodeException (com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1