Search in sources :

Example 1 with Widget

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

the class WidgetBuilder method BuildRepeatList.

public static List<Widget> BuildRepeatList(FrameworkNode repeatNode) {
    ArrayList<Widget> objWidgetList = new ArrayList<>();
    int count, start;
    String strCountAlias = "";
    String strValueAlias = "";
    AliasMgr.getAliasMgr().PushAliasList(false);
    AliasMgr.getAliasMgr().AddAliasFromAttibuteList(repeatNode, new // can define an alias list in <repeat>
    String[] { "Count", "startvlaue", "currentCountAlias", "currentvalueAlias" });
    if (!repeatNode.hasAttribute("Count")) {
        LOGGER.severe("For did not have Count attribute.");
        return null;
    }
    count = repeatNode.getIntegerAttribute("Count", -1);
    if (count < 1) {
        LOGGER.warning("For Count value invalid: " + repeatNode.getAttribute("Count"));
        return objWidgetList;
    }
    start = repeatNode.getIntegerAttribute("StartValue", 0);
    if (start < 0) {
        LOGGER.severe("For Start value invalid: " + repeatNode.getAttribute("startValue"));
        return null;
    }
    if (repeatNode.hasAttribute("CurrentCountAlias")) {
        strCountAlias = repeatNode.getAttribute("CurrentCountAlias");
    }
    if (repeatNode.hasAttribute("CurrentValueAlias")) {
        strValueAlias = repeatNode.getAttribute("CurrentValueAlias");
    }
    for (int iLoop = 0; iLoop < count; iLoop++) {
        AliasMgr.getAliasMgr().PushAliasList(false);
        if (!strCountAlias.isEmpty()) {
            AliasMgr.getAliasMgr().AddAlias(strCountAlias, Integer.toString(iLoop));
        }
        if (!strValueAlias.isEmpty()) {
            AliasMgr.getAliasMgr().AddAlias(strValueAlias, Integer.toString(iLoop + start));
        }
        // Always have these aliases
        AliasMgr.getAliasMgr().AddAlias("CurrentValueAlias", Integer.toString(iLoop + start));
        AliasMgr.getAliasMgr().AddAlias("CurrentCountAlias", Integer.toString(iLoop));
        for (FrameworkNode node : repeatNode.getChildNodes()) {
            if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
                continue;
            }
            if (node.getNodeName().equalsIgnoreCase("Widget") || node.getNodeName().equalsIgnoreCase("Grid") || node.getNodeName().equalsIgnoreCase("DynamicGrid")) {
                Widget widget = WidgetBuilder.Build(node);
                if (null != widget) {
                    objWidgetList.add(widget);
                } else {
                    LOGGER.severe("Error creating " + node.getNodeName() + " in <Repeat>");
                    return null;
                }
            } else if (node.getNodeName().equalsIgnoreCase("GridMacro") || node.getNodeName().equalsIgnoreCase("MacroGrid")) {
                ReadGridMacro(node);
            } else if (// embedded <Repeat>s - kewl!
            node.getNodeName().equalsIgnoreCase("For")) {
                objWidgetList.addAll(BuildRepeatList(node));
            } else {
                LOGGER.warning("Unknown item in <For> :" + node.getNodeName() + " ignoring");
            }
        }
        AliasMgr.getAliasMgr().PopAliasList();
    }
    AliasMgr.getAliasMgr().PopAliasList();
    return objWidgetList;
}
Also used : BaseWidget(kutch.biff.marvin.widget.BaseWidget) OnDemandGridWidget(kutch.biff.marvin.widget.OnDemandGridWidget) Widget(kutch.biff.marvin.widget.Widget) GridWidget(kutch.biff.marvin.widget.GridWidget) DynamicGridWidget(kutch.biff.marvin.widget.DynamicGridWidget) ArrayList(java.util.ArrayList) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 2 with Widget

use of kutch.biff.marvin.widget.Widget 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;
    }
    if (!ConfigurationReader.GetConfigReader().ReadConditionals(gridNode)) {
        return null;
    }
    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 (node.getNodeName().contentEquals("Conditional")) {
        // already taken care of
        } 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) OnDemandGridWidget(kutch.biff.marvin.widget.OnDemandGridWidget) 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 3 with Widget

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

the class OnDemandGridBuilder method Build.

@Override
public boolean Build(String Namespace, String ID, String Value, String sortStr) {
    LOGGER.info("Creating OnDemand Grid for namespace: " + Namespace + " and ID: " + ID);
    __builtCount += 1;
    AliasMgr.getAliasMgr().PushAliasList(true);
    __containerGrid.getCriterea().putAliasListSnapshot();
    // __containerGrid.AddAliasListSnapshot();
    AliasMgr.getAliasMgr().PushAliasList(true);
    // So tab knows namespace
    AliasMgr.getAliasMgr().AddAlias("TriggeredNamespace", Namespace);
    AliasMgr.getAliasMgr().AddAlias("TriggeredID", ID);
    AliasMgr.getAliasMgr().AddAlias("TriggeredValue", Value);
    AliasMgr.getAliasMgr().AddAlias("TriggeredIndex", Integer.toString(__builtCount));
    __containerGrid.getCriterea().tokenizeAndCreateAlias(ID);
    // Let's throw in if it is odd or even :-)
    if (__builtCount % 2 == 0) {
        AliasMgr.getAliasMgr().AddAlias("TriggeredEVEN", "TRUE");
    } else {
        AliasMgr.getAliasMgr().AddAlias("TriggeredEVEN", "FALSE");
    }
    Widget objWidget = WidgetBuilder.Build(__containerGrid.getCriterea().getNode());
    if (null == objWidget) {
        return false;
    }
    if (!(objWidget instanceof GridWidget)) {
        LOGGER.severe("Tried to build something that was not a Grid " + objWidget.getClass().toString());
        return false;
    }
    // once for this grid's aliases and another for the 'super set' stored
    AliasMgr.getAliasMgr().PopAliasList();
    AliasMgr.getAliasMgr().PopAliasList();
    GridWidget objGridWidget = (GridWidget) objWidget;
    if (null != objGridWidget.getOnDemandTask()) {
        TaskManager.getTaskManager().AddDeferredTask(objGridWidget.getOnDemandTask());
    }
    return __containerGrid.AddOnDemandWidget(objGridWidget, sortStr);
}
Also used : OnDemandGridWidget(kutch.biff.marvin.widget.OnDemandGridWidget) GridWidget(kutch.biff.marvin.widget.GridWidget) Widget(kutch.biff.marvin.widget.Widget) OnDemandGridWidget(kutch.biff.marvin.widget.OnDemandGridWidget) GridWidget(kutch.biff.marvin.widget.GridWidget)

Aggregations

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