Search in sources :

Example 1 with InternalRibbon

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

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

the class WindowComponentState method renderContent.

@Override
protected JSONObject renderContent() throws JSONException {
    JSONObject json = new JSONObject();
    List<String> errorTabs = new LinkedList<String>();
    for (Map.Entry<String, InternalComponentState> child : getChildren().entrySet()) {
        if (child.getValue().isHasError()) {
            errorTabs.add(child.getKey());
        }
    }
    JSONArray errors = new JSONArray();
    for (String tabName : errorTabs) {
        errors.put(tabName);
    }
    json.put("errors", errors);
    json.put(JSON_TABS_SELECTION_STATE, tabsSelectionState.toJson());
    if (pattern.getContextualHelpUrl() != null) {
        json.put("contextualHelpUrl", pattern.getContextualHelpUrl());
    }
    if (ribbon != null) {
        InternalRibbon diffrenceRibbon = ribbon.getUpdate();
        if (diffrenceRibbon != null) {
            json.put("ribbon", RibbonUtils.translateRibbon(diffrenceRibbon, getLocale(), pattern));
        }
    }
    if (activeMenu != null) {
        json.put(JSON_ACTIVE_MENU, activeMenu);
    }
    return json;
}
Also used : JSONObject(org.json.JSONObject) InternalRibbon(com.qcadoo.view.internal.ribbon.model.InternalRibbon) JSONArray(org.json.JSONArray) Map(java.util.Map) LinkedList(java.util.LinkedList) InternalComponentState(com.qcadoo.view.internal.api.InternalComponentState)

Aggregations

InternalRibbon (com.qcadoo.view.internal.ribbon.model.InternalRibbon)2 InternalComponentState (com.qcadoo.view.internal.api.InternalComponentState)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 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1