Search in sources :

Example 1 with FlipPanelWidget

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

the class FlipPanelWidgetBuilder method Build.

public static FlipPanelWidget Build(FrameworkNode masterNode, String widgetDefFilename) {
    FlipPanelWidget _panel = new FlipPanelWidget();
    for (FrameworkNode node : masterNode.getChildNodes()) {
        if (BaseWidget.HandleCommonDefinitionFileConfig(_panel, node)) {
            continue;
        }
        if (node.getNodeName().equalsIgnoreCase("AnimationDuration")) {
            String str = node.getTextContent();
            try {
                _panel.setAnimationDuration(Double.parseDouble(str));
            } catch (Exception ex) {
                LOGGER.severe("Invlid value for <AnimationDuration> tag for FlipPanel Widget");
                return null;
            }
        } else if (node.getNodeName().equalsIgnoreCase("RotationDirection")) {
            String str = node.getTextContent();
            if (0 == str.compareToIgnoreCase("Horizontal")) {
                _panel.setOrientation(Orientation.HORIZONTAL);
            } else if (0 == str.compareToIgnoreCase("Vertical")) {
                _panel.setOrientation(Orientation.VERTICAL);
            } else {
                LOGGER.severe("Invalid Orientation in FlipPanel Widget Definition File. Should be Horizontal or Vertical, not : " + str);
                return null;
            }
        } else if (node.getNodeName().equalsIgnoreCase("FrontButton") || node.getNodeName().equalsIgnoreCase("BackButton")) {
            String BtnText = null;
            String StyleFile = null;
            String StyleID = null;
            String Location = null;
            if (node.hasAttribute("Text")) {
                BtnText = node.getAttribute("Text");
            }
            if (node.hasAttribute("Position")) {
                Location = node.getAttribute("Position");
            } else {
                LOGGER.severe("No Position set for FlipPanel Button");
                return null;
            }
            for (FrameworkNode iNode : node.getChildNodes()) {
                if (iNode.getNodeName().equalsIgnoreCase("#text") || iNode.getNodeName().equalsIgnoreCase("#comment")) {
                    continue;
                }
                if (iNode.getNodeName().equalsIgnoreCase("Style")) {
                    StyleFile = iNode.getTextContent();
                    if (iNode.hasAttribute("ID")) {
                        StyleID = iNode.getAttribute("ID");
                    }
                }
            }
            if (null == Location || null == StyleFile) {
                LOGGER.severe("Invalid Flip Panel side definition :" + node.getNodeName());
                return null;
            }
            PanelSideInfo panel = new PanelSideInfo(Location, BtnText, StyleID, StyleFile);
            if (node.getNodeName().equalsIgnoreCase("FrontButton")) {
                _panel.setFrontInfo(panel);
            } else {
                _panel.setBackInfo(panel);
            }
        } else {
            LOGGER.severe("Invalid FlipPanel Widget Definition File.  Unknown Tag: " + node.getNodeName());
            return null;
        }
    }
    return _panel;
}
Also used : FlipPanelWidget(kutch.biff.marvin.widget.FlipPanelWidget) PanelSideInfo(kutch.biff.marvin.utility.PanelSideInfo) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Aggregations

FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)1 PanelSideInfo (kutch.biff.marvin.utility.PanelSideInfo)1 FlipPanelWidget (kutch.biff.marvin.widget.FlipPanelWidget)1