Search in sources :

Example 1 with SingleRibbonGroupPack

use of com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack 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)

Example 2 with SingleRibbonGroupPack

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

the class ViewRibbonModule method enable.

@Override
public void enable() {
    addedGroups = new HashMap<WindowComponentPattern, RibbonGroupsPack>();
    InternalViewDefinition viewDefinition = viewDefinitionService.getWithoutSession(viewExtension.getPluginName(), viewExtension.getViewName());
    if (viewDefinition == null) {
        throw new ModuleException(pluginIdentifier, "view", "reference to view which not exists");
    }
    try {
        for (Node groupNode : viewDefinitionParser.geElementChildren(viewExtension.getExtesionNode())) {
            try {
                InternalRibbonGroup group = viewDefinitionParser.parseRibbonGroup(groupNode, viewDefinition);
                group.setExtensionPluginIdentifier(pluginIdentifier);
                RibbonGroupsPack groupsPack = new SingleRibbonGroupPack(group);
                WindowComponentPattern window = viewDefinition.getRootWindow();
                window.getRibbon().addGroupsPack(groupsPack);
                addedGroups.put(window, groupsPack);
            } catch (ViewDefinitionParserNodeException e) {
                throw ViewDefinitionParserException.forFileAndNode(fileName, e);
            }
        }
    } catch (Exception e) {
        throw new ModuleException(pluginIdentifier, "view-ribbon-group", e);
    }
}
Also used : WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) InternalViewDefinition(com.qcadoo.view.internal.api.InternalViewDefinition) Node(org.w3c.dom.Node) SingleRibbonGroupPack(com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException) RibbonGroupsPack(com.qcadoo.view.internal.ribbon.model.RibbonGroupsPack) ModuleException(com.qcadoo.plugin.api.ModuleException) InternalRibbonGroup(com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup) ViewDefinitionParserNodeException(com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException) IOException(java.io.IOException) ModuleException(com.qcadoo.plugin.api.ModuleException) ViewDefinitionParserException(com.qcadoo.view.internal.xml.ViewDefinitionParserException)

Aggregations

SingleRibbonGroupPack (com.qcadoo.view.internal.ribbon.model.SingleRibbonGroupPack)2 ViewDefinitionParserNodeException (com.qcadoo.view.internal.xml.ViewDefinitionParserNodeException)2 Node (org.w3c.dom.Node)2 ModuleException (com.qcadoo.plugin.api.ModuleException)1 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)1 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)1 InternalRibbon (com.qcadoo.view.internal.ribbon.model.InternalRibbon)1 InternalRibbonGroup (com.qcadoo.view.internal.ribbon.model.InternalRibbonGroup)1 RibbonGroupsPack (com.qcadoo.view.internal.ribbon.model.RibbonGroupsPack)1 RibbonImpl (com.qcadoo.view.internal.ribbon.model.RibbonImpl)1 ViewDefinitionParserException (com.qcadoo.view.internal.xml.ViewDefinitionParserException)1 IOException (java.io.IOException)1 NodeList (org.w3c.dom.NodeList)1