Search in sources :

Example 1 with OnDemandTabBuilder

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

the class ConfigurationReader method ReadAppSettings.

private boolean ReadAppSettings(Document doc, boolean basicInfoOnly) {
    NodeList appStuff = doc.getElementsByTagName("Application");
    if (appStuff.getLength() < 1) {
        LOGGER.severe("No <Application> section of config file");
        return false;
    }
    if (appStuff.getLength() > 1) {
        LOGGER.warning("More than one <Application> section found, only using first.");
    }
    boolean NetworkSettingsRead = false;
    FrameworkNode baseNode = new FrameworkNode(appStuff.item(0));
    FetchDimenstions(baseNode);
    boolean currErrorBool = Configuration.getConfig().DoNotReportAliasErrors();
    Configuration.getConfig().SetDoNotReportAliasErrors(basicInfoOnly);
    AliasMgr.getAliasMgr().addMarvinInfo();
    AliasMgr.ReadAliasFromRootDocument(doc);
    ReadAppAttributes(baseNode);
    Configuration.getConfig().SetDoNotReportAliasErrors(currErrorBool);
    ArrayList<String> DeclaredTabList = new ArrayList<>();
    for (FrameworkNode node : baseNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#Comment")) {
            continue;
        } else if (node.getNodeName().equalsIgnoreCase("Title")) {
            _Configuration.setAppTitle(node.getTextContent());
            LOGGER.config("Application Title = " + _Configuration.getAppTitle());
        } else if (node.getNodeName().equalsIgnoreCase("Heartbeat")) {
            if (node.hasAttribute("rate")) {
                _Configuration.setHeartbeatInterval(node.getIntegerAttribute("rate", _Configuration.getHeartbeatInterval()));
            }
        } else if (node.getNodeName().equalsIgnoreCase("StyleSheet")) {
            _Configuration.setCSSFile(node.getTextContent());
            LOGGER.config("Setting application CSS to " + _Configuration.getCSSFile());
        } else if (node.getNodeName().equalsIgnoreCase("IgnoreWebCerts")) {
            _Configuration.setIgnoreWebCerts(node.getBooleanValue());
            LOGGER.config("Ignoring Web Certifications");
        } else if (node.getNodeName().equalsIgnoreCase("MonitorNumber")) {
            if (false == basicInfoOnly) {
                continue;
            }
            int count = Screen.getScreens().size();
            if (count == 1) {
                continue;
            }
            try {
                int monitorNum = Integer.parseInt(node.getTextContent());
                if (monitorNum < 1) {
                    LOGGER.warning("<MonitorNumber> set to " + node.getTextContent() + " smallest valid value is 1.Ignoring");
                    continue;
                }
                if (monitorNum <= count) {
                    Screen primary = Screen.getScreens().get(monitorNum - 1);
                    _Configuration.setPrimaryScreen(primary);
                    if (false == basicInfoOnly) {
                        LOGGER.config("Setting Primary Screen to monitor #" + node.getTextContent());
                    }
                } else if (false == basicInfoOnly) {
                    LOGGER.warning("<MonitorNumber> set to " + node.getTextContent() + " however there are only " + Integer.toHexString(count) + " monitors. Ignoring");
                }
            } catch (Exception Ex) {
                LOGGER.severe("Invalid MonitorNumber specified.  Ignoring.");
            // return false;
            }
        } else if (node.getNodeName().equalsIgnoreCase("CreationSize")) {
            Utility.ValidateAttributes(new String[] { "Height", "Width" }, node);
            if (node.hasAttribute("Height") && node.hasAttribute("Width")) {
                _Configuration.setCreationWidth(node.getIntegerAttribute("Width", 0));
                _Configuration.setCreationHeight(node.getIntegerAttribute("Height", 0));
            } else if (false == basicInfoOnly) {
                LOGGER.severe("Invalid CreationSize specified");
            }
        } else if (node.getNodeName().equalsIgnoreCase("Tasks")) {
            if (basicInfoOnly) {
                continue;
            }
            Utility.ValidateAttributes(new String[] { "Enabled" }, node);
            if (node.hasAttribute("Enabled")) {
                String str = node.getAttribute("Enabled");
                if (str.equalsIgnoreCase("True")) {
                    _Configuration.setAllowTasks(true);
                    LOGGER.config("Tasks Enabled");
                } else {
                    _Configuration.setAllowTasks(false);
                    LOGGER.config("Tasks Disabled");
                }
            }
        } else if (node.getNodeName().equalsIgnoreCase("Network")) {
            if (basicInfoOnly) {
                continue;
            }
            Utility.ValidateAttributes(new String[] { "IP", "Port" }, node);
            boolean fPort = false;
            if (node.hasAttribute("IP")) {
                String str = node.getAttribute("IP");
                _Configuration.setAddress(str);
            } else {
                LOGGER.config("No IP specified in <Network> settings. Will listen on all interfaces");
                _Configuration.setAddress("0.0.0.0");
            }
            if (node.hasAttribute("Port")) {
                String str = node.getAttribute("Port");
                try {
                    _Configuration.setPort(Integer.parseInt(str));
                    fPort = true;
                } catch (Exception ex) {
                    LOGGER.severe("Invalid Network port: " + str);
                }
            } else {
                LOGGER.info("Port not attribute for <Network> settings.");
            }
            if (fPort) {
                NetworkSettingsRead = true;
            } else {
                return false;
            }
            for (FrameworkNode oscarNode : node.getChildNodes()) {
                if (oscarNode.getNodeName().equalsIgnoreCase("#Text") || oscarNode.getNodeName().equalsIgnoreCase("#Comment")) {
                    continue;
                } else if (oscarNode.getNodeName().equalsIgnoreCase("Oscar")) {
                    if (false == ReadOscarConnection(oscarNode)) {
                        return false;
                    }
                }
            }
        } else if (node.getNodeName().equalsIgnoreCase("Padding")) {
            if (basicInfoOnly) {
                continue;
            }
            Utility.ValidateAttributes(new String[] { "top", "bottom", "left", "right", "legacymode" }, node);
            String strTop = "-1";
            String strBottom = "-1";
            String strLeft = "-1";
            String strRight = "-1";
            if (node.hasAttribute("top")) {
                strTop = node.getAttribute("top");
            }
            if (node.hasAttribute("bottom")) {
                strBottom = node.getAttribute("bottom");
            }
            if (node.hasAttribute("left")) {
                strLeft = node.getAttribute("left");
            }
            if (node.hasAttribute("right")) {
                strRight = node.getAttribute("right");
            }
            try {
                _Configuration.setInsetTop(Integer.parseInt(strTop));
                _Configuration.setInsetBottom(Integer.parseInt(strBottom));
                _Configuration.setInsetLeft(Integer.parseInt(strLeft));
                _Configuration.setInsetRight(Integer.parseInt(strRight));
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid Application <Inset> configuration.");
                return false;
            }
            if (node.hasAttribute("legacymode")) {
                _Configuration.setLegacyInsetMode(node.getBooleanAttribute("legacymode"));
                if (_Configuration.getLegacyInsetMode()) {
                    LOGGER.config("Using LEGACY mode of padding.");
                }
            }
        } else if (node.getNodeName().equalsIgnoreCase("MainMenu")) {
            if (false == ReadAppMenu(node, basicInfoOnly)) {
                return false;
            }
        } else if (node.getNodeName().equalsIgnoreCase("UnregisteredData")) {
            if (basicInfoOnly) {
                continue;
            }
            if (false == ReadUnregisteredDataInfo(node)) {
                return false;
            }
        } else if (node.getNodeName().equalsIgnoreCase("Tabs")) {
            Utility.ValidateAttributes(new String[] { "side" }, node);
            if (// where the tabs should be located.
            node.hasAttribute("Side")) {
                String sideStr = node.getAttribute("Side");
                if (sideStr.equalsIgnoreCase("Top")) {
                    _Configuration.setSide(Side.TOP);
                } else if (sideStr.equalsIgnoreCase("Bottom")) {
                    _Configuration.setSide(Side.BOTTOM);
                } else if (sideStr.equalsIgnoreCase("Left")) {
                    _Configuration.setSide(Side.LEFT);
                } else if (sideStr.equalsIgnoreCase("Right")) {
                    _Configuration.setSide(Side.RIGHT);
                } else {
                    LOGGER.warning("Invalid <Tabs Side=> attribute: " + sideStr + ". Ignoring");
                }
            }
            if (basicInfoOnly) {
                continue;
            }
            int tabCount = 0;
            for (FrameworkNode tabNode : node.getChildNodes(true)) {
                if (tabNode.getNodeName().equalsIgnoreCase("#Text")) {
                    continue;
                }
                if (tabNode.getNodeName().equalsIgnoreCase("Tab")) {
                    if (tabNode.hasAttributes()) {
                        String ID = tabNode.getAttribute("ID");
                        if (ID != null && ID.length() > 0) {
                            if (tabNode.hasChild("OnDemand")) {
                                DynamicItemInfoContainer dynaInfo = ReadOnDemandInfo(tabNode.getChild("OnDemand"));
                                if (null != dynaInfo) {
                                    OnDemandTabBuilder objBuilder = new OnDemandTabBuilder(ID, tabCount, dynaInfo);
                                    DataManager.getDataManager().AddOnDemandWidgetCriterea(dynaInfo, objBuilder);
                                    _OnDemandID_List.add(ID.toUpperCase());
                                }
                            } else {
                                DeclaredTabList.add(ID);
                            }
                            tabCount++;
                        } else {
                            LOGGER.warning("Tab defined in <Tabs> without an ID");
                        }
                    }
                }
            }
        } else if (node.getNodeName().equalsIgnoreCase("RefreshInterval")) {
            if (basicInfoOnly) {
                continue;
            }
            String strInterval = node.getTextContent();
            try {
                _Configuration.setTimerInterval(Long.parseLong(strInterval));
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid Application <RefreshInterval> configuration.");
                return false;
            }
        } else {
            LOGGER.warning("Unexpected section in <Application>: " + node.getNodeName());
        }
    }
    if (basicInfoOnly) {
        return true;
    }
    if (DeclaredTabList.isEmpty() && !DataManager.getDataManager().DynamicTabRegistered()) {
        LOGGER.severe("No Tabs defined in <Application> section of configuration file.");
        return false;
    }
    _Configuration.setPrimaryScreenDetermined(true);
    if (VerifyTabList(DeclaredTabList)) {
        _tabs = ReadTabs(doc, DeclaredTabList);
        if (null == _tabs) {
            return false;
        }
    }
    if (DataManager.getDataManager().DynamicTabRegistered()) {
        ReadOnDemandTabs(doc);
    }
    if (false == NetworkSettingsRead) {
        LOGGER.severe("No <Network> section found in Application.xml");
    }
    return NetworkSettingsRead;
}
Also used : DynamicItemInfoContainer(kutch.biff.marvin.utility.DynamicItemInfoContainer) Screen(javafx.stage.Screen) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) OnDemandTabBuilder(kutch.biff.marvin.widget.widgetbuilder.OnDemandTabBuilder) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 2 with OnDemandTabBuilder

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

the class DataManager method ChangeValue.

public void ChangeValue(String ID, String Namespace, String Value) {
    boolean OnDemandItemFound = false;
    boolean OnDemandTabFound = false;
    synchronized (this) {
        for (Pair<DynamicItemInfoContainer, OnDemandWidgetBuilder> entry : _OnDemandQueue) {
            if (entry.getKey().Matches(Namespace, ID, Value)) {
                LateCreateTask objTask = new LateCreateTask(entry.getValue(), Namespace, ID, Value, entry.getKey().getLastMatchedSortStr());
                TaskManager.getTaskManager().AddDeferredTaskObject(objTask);
                OnDemandItemFound = true;
                if (entry.getValue() instanceof OnDemandTabBuilder) {
                    OnDemandTabFound = true;
                }
            }
        }
        if (OnDemandItemFound) {
            Configuration.getConfig().setCursorToWait();
        }
        // go and handle any GenerateDatapoint stuff
        for (GenerateDatapointInfo info : __GenerateDatapointList) {
            if (info.Matches(Namespace, ID)) {
                info.BuildDatapoint(Namespace, ID);
            }
        }
    }
    synchronized (this) {
        String Key = Utility.generateKey(Namespace, ID);
        _UpdateCount++;
        boolean inWildcard = HandleWildcardChangeValue(ID, Namespace, Value);
        if (false == _DataMap.containsKey(Key)) {
            _DataMap.put(Key, new DataSet());
            if (false == inWildcard) {
                _UnassignedDataPoints++;
                // nifty stuff to dynamically add a tab to show 'unregistered' data points.
                if (kutch.biff.marvin.widget.DynamicTabWidget.isEnabled()) {
                    DynamicDebugWidgetTask objTask = new DynamicDebugWidgetTask(Namespace, ID, Value);
                    TaskManager.getTaskManager().AddPostponedTask(objTask, 0);
                }
            }
        }
        if (// if didn't exist, is created above
        _DataMap.containsKey(Key)) {
            _DataMap.get(Key).setLatestValue(Value);
        }
    }
    if (true == OnDemandTabFound) {
    // ApplyOnDemandTabStyle objTask = new ApplyOnDemandTabStyle();
    // TaskManager.getTaskManager().AddPostponedTask(objTask, 1000);
    }
}
Also used : DynamicItemInfoContainer(kutch.biff.marvin.utility.DynamicItemInfoContainer) OnDemandWidgetBuilder(kutch.biff.marvin.widget.widgetbuilder.OnDemandWidgetBuilder) GenerateDatapointInfo(kutch.biff.marvin.utility.GenerateDatapointInfo) LateCreateTask(kutch.biff.marvin.task.LateCreateTask) OnDemandTabBuilder(kutch.biff.marvin.widget.widgetbuilder.OnDemandTabBuilder) DynamicDebugWidgetTask(kutch.biff.marvin.task.DynamicDebugWidgetTask)

Example 3 with OnDemandTabBuilder

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

the class ApplyOnDemandTabStyle method PerformTask.

@Override
public void PerformTask() {
    for (Pair<DynamicItemInfoContainer, OnDemandWidgetBuilder> entry : DataManager.getDataManager().getOnDemandList()) {
        if (entry.getValue() instanceof OnDemandTabBuilder) {
            OnDemandTabBuilder tabBuilder = (OnDemandTabBuilder) entry.getValue();
            tabBuilder.ApplyOddEvenStyle();
        }
    }
}
Also used : DynamicItemInfoContainer(kutch.biff.marvin.utility.DynamicItemInfoContainer) OnDemandWidgetBuilder(kutch.biff.marvin.widget.widgetbuilder.OnDemandWidgetBuilder) OnDemandTabBuilder(kutch.biff.marvin.widget.widgetbuilder.OnDemandTabBuilder)

Aggregations

DynamicItemInfoContainer (kutch.biff.marvin.utility.DynamicItemInfoContainer)3 OnDemandTabBuilder (kutch.biff.marvin.widget.widgetbuilder.OnDemandTabBuilder)3 OnDemandWidgetBuilder (kutch.biff.marvin.widget.widgetbuilder.OnDemandWidgetBuilder)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Screen (javafx.stage.Screen)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 DynamicDebugWidgetTask (kutch.biff.marvin.task.DynamicDebugWidgetTask)1 LateCreateTask (kutch.biff.marvin.task.LateCreateTask)1 FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)1 GenerateDatapointInfo (kutch.biff.marvin.utility.GenerateDatapointInfo)1 NodeList (org.w3c.dom.NodeList)1 SAXException (org.xml.sax.SAXException)1