Search in sources :

Example 1 with DynamicGridWidget

use of kutch.biff.marvin.widget.DynamicGridWidget in project Board-Instrumentation-Framework by intel.

the class WidgetBuilder method ReadGridInfo.

public static DynamicGridWidget ReadGridInfo(FrameworkNode gridNode, DynamicGridWidget retWidget) {
    if (gridNode.getChildNodes().isEmpty()) {
        return retWidget;
    }
    for (FrameworkNode node : gridNode.getChildNodes(true)) {
        if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
            continue;
        }
        if (node.getNodeName().equalsIgnoreCase("PaddingOverride") || node.getNodeName().equalsIgnoreCase("Padding")) {
            retWidget.HandleWidgetSpecificSettings(node);
        } else if (node.getNodeName().equalsIgnoreCase("Widget") || node.getNodeName().equalsIgnoreCase("Grid")) {
            Widget subWidget = WidgetBuilder.Build(node);
            if (null != subWidget) {
                retWidget.AddWidget(subWidget);
            } else {
                return null;
            }
        } else if (node.getNodeName().equalsIgnoreCase("GridMacro") || node.getNodeName().equalsIgnoreCase("MacroGrid")) {
            if (!ReadGridMacro(node)) {
                return null;
            }
        } else if (node.getNodeName().equalsIgnoreCase("For")) {
            List<Widget> repeatList = WidgetBuilder.BuildRepeatList(node);
            if (null == repeatList) {
                return null;
            }
            for (Widget objWidget : repeatList) {
                retWidget.AddWidget(objWidget);
            }
        } else if (node.getNodeName().equalsIgnoreCase("MinionSrc")) {
            if (node.hasAttributes()) {
                Utility.ValidateAttributes(new String[] { "Namespace", "ID" }, node);
                if (node.hasAttribute("ID") && node.hasAttribute("Namespace")) {
                    retWidget.setMinionID(node.getAttribute("ID"));
                    retWidget.setNamespace(node.getAttribute("Namespace"));
                    continue;
                }
            }
            LOGGER.severe("Malformed DynamicGrid Widget MinionSrc Definition in Application.XML");
            return null;
        } else if (node.getNodeName().equalsIgnoreCase("StyleOverride")) {
            HandleStyleOverride(retWidget, node);
        } else if (// for external grid files
        node.getNodeName().equalsIgnoreCase("Peekaboo")) {
            if (!HandlePeekaboo(retWidget, node)) {
                return null;
            }
        } else if (node.getNodeName().equalsIgnoreCase("ClickThroughTransparent")) {
            retWidget.SetClickThroughTransparentRegion(node.getBooleanValue());
            if (node.hasAttribute("Propagate") && node.getBooleanAttribute("Propagate")) {
                retWidget.setExplicitPropagate(true);
            }
        } else if (!retWidget.HandleWidgetSpecificSettings(node)) {
            LOGGER.severe("Unknown DynamicGrid Item in Config file: " + node.getNodeName());
            return null;
        }
    }
    return retWidget;
}
Also used : BaseWidget(kutch.biff.marvin.widget.BaseWidget) Widget(kutch.biff.marvin.widget.Widget) GridWidget(kutch.biff.marvin.widget.GridWidget) DynamicGridWidget(kutch.biff.marvin.widget.DynamicGridWidget) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 2 with DynamicGridWidget

use of kutch.biff.marvin.widget.DynamicGridWidget in project Board-Instrumentation-Framework by intel.

the class WidgetBuilder method BuildDynamicGrid.

public static DynamicGridWidget BuildDynamicGrid(FrameworkNode dynaGridNode) {
    DynamicGridWidget retWidget = new DynamicGridWidget();
    String rowSpan = "1";
    String colSpan = "1";
    String strRow = "0";
    String strColumn = "0";
    String WhatIsIt = "DynamicGrid";
    if (false == dynaGridNode.hasAttribute("row")) {
        LOGGER.severe("DynamicGrid with no row");
        return null;
    }
    if (dynaGridNode.hasAttribute("Task")) {
        retWidget.setTaskID(dynaGridNode.getAttribute("Task"));
    }
    if (false == dynaGridNode.hasAttribute("column")) {
        LOGGER.severe("Grid with no column");
        return null;
    }
    if (dynaGridNode.hasAttribute("rowSpan")) {
        rowSpan = dynaGridNode.getAttribute("rowSpan");
    }
    if (dynaGridNode.hasAttribute("colSpan")) {
        colSpan = dynaGridNode.getAttribute("colSpan");
    }
    if (dynaGridNode.hasAttribute("columnspan")) {
        colSpan = dynaGridNode.getAttribute("columnspan");
    }
    if (true == dynaGridNode.hasAttribute("Height")) {
        if (!retWidget.parseHeight(dynaGridNode)) {
            LOGGER.severe("Invalid Height for Grid in Application.xml");
            return null;
        }
    }
    if (true == dynaGridNode.hasAttribute("Width")) {
        if (!retWidget.parseWidth(dynaGridNode)) {
            LOGGER.severe("Invalid Width for Grid in Application.xml");
            return null;
        }
    }
    strRow = dynaGridNode.getAttribute("row");
    strColumn = dynaGridNode.getAttribute("column");
    if (strRow == null) {
        LOGGER.severe("Invalid " + WhatIsIt + " definition in Configuration file. no row defined");
        return null;
    }
    if (strColumn == null) {
        LOGGER.severe("Invalid " + WhatIsIt + " definition in Configuration file. no row defined");
        return null;
    }
    try {
        retWidget.setRow(Integer.parseInt(strRow));
        retWidget.setColumn(Integer.parseInt(strColumn));
        retWidget.setRowSpan(Integer.parseInt(rowSpan));
        retWidget.setColumnSpan(Integer.parseInt(colSpan));
        AliasMgr.getAliasMgr().UpdateCurrentColumn(Integer.parseInt(strColumn));
        AliasMgr.getAliasMgr().UpdateCurrentRow(Integer.parseInt(strRow));
        AliasMgr.getAliasMgr().PushAliasList(true);
    } catch (NumberFormatException ex) {
        LOGGER.severe("Invalid " + WhatIsIt + " definition in Configuration file. ");
        return null;
    }
    if (dynaGridNode.hasAttribute("hgap")) {
        try {
            retWidget.sethGap(Integer.parseInt(dynaGridNode.getAttribute("hgap")));
            LOGGER.config("Setting hGap for " + WhatIsIt + " :" + dynaGridNode.getAttribute("hgap"));
        } catch (NumberFormatException ex) {
            LOGGER.warning("hgap for " + WhatIsIt + "  invalid: " + dynaGridNode.getAttribute("hgap") + ".  Ignoring");
        }
    }
    if (dynaGridNode.hasAttribute("vgap")) {
        try {
            retWidget.setvGap(Integer.parseInt(dynaGridNode.getAttribute("vgap")));
            LOGGER.config("Setting vGap for " + WhatIsIt + " :" + dynaGridNode.getAttribute("vgap"));
        } catch (NumberFormatException ex) {
            LOGGER.warning("vgap for " + WhatIsIt + " invalid: " + dynaGridNode.getAttribute("vgap") + ".  Ignoring");
        }
    }
    if (true == dynaGridNode.hasAttribute("Align")) {
        String str = dynaGridNode.getAttribute("Align");
        retWidget.setAlignment(str);
    } else {
        // if not an external declaration, check for known options
        Utility.ValidateAttributes(new String[] { "row", "column", "rowSpan", "colSpan", "columnSpan", "hgap", "vgap", "Align", "Height", "Width" }, dynaGridNode);
    }
    // go read the grid contents - note that this could be a continuation from stuff already read in via file
    // so you can define most of grid in external file, but keep adding
    retWidget = ReadGridInfo(dynaGridNode, retWidget);
    AliasMgr.getAliasMgr().PopAliasList();
    return retWidget;
}
Also used : DynamicGridWidget(kutch.biff.marvin.widget.DynamicGridWidget)

Aggregations

DynamicGridWidget (kutch.biff.marvin.widget.DynamicGridWidget)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)1 BaseWidget (kutch.biff.marvin.widget.BaseWidget)1 GridWidget (kutch.biff.marvin.widget.GridWidget)1 Widget (kutch.biff.marvin.widget.Widget)1 NodeList (org.w3c.dom.NodeList)1