Search in sources :

Example 31 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class ConfigurationReader method ReadTaskAndConditionals.

private static boolean ReadTaskAndConditionals(Document doc) {
    TaskManager TASKMAN = TaskManager.getTaskManager();
    boolean retVal = true;
    List<FrameworkNode> taskListNodes = FrameworkNode.GetChildNodes(doc, "TaskList");
    if (taskListNodes.size() < 1) {
        // LOGGER.info("No Tasks defined in config file.");
        return true;
    }
    for (FrameworkNode taskNode : taskListNodes) {
        retVal = ConfigurationReader.ReadTaskList(taskNode);
        if (!retVal) {
            break;
        }
    }
    if (true == retVal) {
        retVal = ReadConditionals(doc);
    }
    return retVal;
}
Also used : TaskManager(kutch.biff.marvin.task.TaskManager) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 32 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class ConfigurationReader method ReadMenu.

private Menu ReadMenu(String Title, FrameworkNode menuNode) {
    Menu objMenu = new Menu(Title);
    for (FrameworkNode node : menuNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("MenuItem")) {
            Utility.ValidateAttributes(new String[] { "Text", "Task" }, node);
            if (node.hasAttribute("Text") && node.hasAttribute("Task")) {
                MenuItem objItem = new MenuItem(node.getAttribute("Text"));
                if (true == _Configuration.getAllowTasks()) {
                    objItem.setOnAction(new EventHandler<ActionEvent>() {

                        @Override
                        public void handle(ActionEvent t) {
                            TASKMAN.PerformTask(node.getAttribute("Task"));
                        }
                    });
                }
                objMenu.getItems().add(objItem);
            } else {
                LOGGER.severe("Invalid Menu with Title of " + Title + " defined");
                return null;
            }
        }
    }
    return objMenu;
}
Also used : ActionEvent(javafx.event.ActionEvent) MenuItem(javafx.scene.control.MenuItem) Menu(javafx.scene.control.Menu) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 33 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class ConfigurationReader method ReadAppMenu.

private boolean ReadAppMenu(FrameworkNode menuNode, boolean basicInfoOnly) {
    if (null != _Configuration.getMenuBar()) {
        return true;
    }
    if (menuNode.hasAttribute("Show")) {
        String strVal = menuNode.getAttribute("Show");
        if (strVal.equalsIgnoreCase("True")) {
            _Configuration.setShowMenuBar(true);
            if (!basicInfoOnly) {
                LOGGER.config("Show Menu Bar = TRUE");
            }
        } else {
            _Configuration.setShowMenuBar(false);
            if (!basicInfoOnly) {
                LOGGER.config("Show Menu Bar = FALSE");
            }
        }
    }
    if (basicInfoOnly) {
        return true;
    }
    MenuBar objMenuBar = new MenuBar();
    for (FrameworkNode node : menuNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("Menu")) {
            Utility.ValidateAttributes(new String[] { "Title" }, node);
            if (node.hasAttribute("Title")) {
                Menu objMenu = ReadMenu(node.getAttribute("Title"), node);
                if (null != objMenu) {
                    objMenuBar.getMenus().add(objMenu);
                } else {
                    return false;
                }
            } else {
                LOGGER.severe("Invalid Menu defined, no Title");
                return false;
            }
        }
    }
    _Configuration.setMenuBar(objMenuBar);
    return true;
}
Also used : MenuBar(javafx.scene.control.MenuBar) Menu(javafx.scene.control.Menu) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 34 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class ConfigurationReader method ReadConditionals.

private static boolean ReadConditionals(Document doc) {
    /*
         <Conditional type='IF_EQ' CaseSensitive="True">
         <MinionSrc ID="myID" Namespace="myNS"/>
         <Value>
         <MinionSrc ID="myID" Namespace="myNS"/>
         </Value>
         or
         <Value>44</Value>
        
         <Then>Task12</Then>
         <Else>Task3</Else>
         </Conditional>
         */
    TaskManager TASKMAN = TaskManager.getTaskManager();
    boolean retVal = true;
    NodeList conditionals = doc.getElementsByTagName("Conditional");
    if (conditionals.getLength() < 1) {
        return true;
    }
    for (int iLoop = 0; iLoop < conditionals.getLength(); iLoop++) {
        FrameworkNode condNode = new FrameworkNode(conditionals.item(iLoop));
        Conditional objCond = ReadConditional(condNode);
        if (null == objCond) {
            retVal = false;
        } else {
            if (_conditionalMap.containsKey(objCond)) {
                LOGGER.config("Duplicate conditional found.  Might want to check for multiple inclusions of same conditional. Conditional Information: " + objCond.toString());
            } else {
                _conditionalMap.put(objCond, objCond);
            }
            objCond.Enable();
        }
    }
    return retVal;
}
Also used : TaskManager(kutch.biff.marvin.task.TaskManager) NodeList(org.w3c.dom.NodeList) Conditional(kutch.biff.marvin.utility.Conditional) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 35 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class ReceiveThreadMgr method HandleIncomingOscarPacket.

private void HandleIncomingOscarPacket(Node objNode, InetAddress address) {
    FrameworkNode node = new FrameworkNode(objNode);
    if (!node.hasAttribute("Type")) {
        LOGGER.severe("Received Oscar Packet with not Type attribute");
        return;
    }
    String type = node.getAttribute("Type");
    if (type.equalsIgnoreCase("Data")) {
        HandleIncomingDatapoint(objNode);
    } else if (type.equalsIgnoreCase("ConnectionInformation")) {
        HandleIncomingOscarConnectionInfoPacket(objNode, address);
    } else {
        LOGGER.severe("Received Oscar Packet with unknown Type: " + type);
    }
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Aggregations

FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)52 NodeList (org.w3c.dom.NodeList)7 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 SAXException (org.xml.sax.SAXException)5 BaseWidget (kutch.biff.marvin.widget.BaseWidget)4 Document (org.w3c.dom.Document)4 TaskManager (kutch.biff.marvin.task.TaskManager)3 DynamicGridWidget (kutch.biff.marvin.widget.DynamicGridWidget)3 GridWidget (kutch.biff.marvin.widget.GridWidget)3 Node (org.w3c.dom.Node)3 File (java.io.File)2 Menu (javafx.scene.control.Menu)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 SeriesDataSet (kutch.biff.marvin.utility.SeriesDataSet)2 Widget (kutch.biff.marvin.widget.Widget)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 List (java.util.List)1