use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ReceiveThreadMgr method HandleIncomingMarvinPacket.
private void HandleIncomingMarvinPacket(Node objNode) {
FrameworkNode node = new FrameworkNode(objNode);
if (!node.hasAttribute("Type")) {
LOGGER.severe("Received Marvin Packet with not Type attribute");
return;
}
String type = node.getAttribute("Type");
if (type.equalsIgnoreCase("RemoteMarvinTask")) {
HandleIncomingRemoteMarvinTaskPacket(objNode);
} else {
LOGGER.severe("Received Oscar Packet with unknown Type: " + type);
}
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class WidgetBuilder method ParseWidgetDefinitionFile.
private static BaseWidget ParseWidgetDefinitionFile(String Filename) {
BaseWidget retWidget = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
return null;
}
File file = new File(Filename);
if (file.exists()) {
Document docWidget;
try {
docWidget = db.parse(file);
} catch (SAXException | IOException ex) {
LOGGER.severe(ex.toString());
return null;
}
AliasMgr.getAliasMgr().PushAliasList(true);
if (// let's see if there are any aliases in the widget file!
!AliasMgr.ReadAliasFromRootDocument(docWidget)) {
return null;
}
FrameworkNode baseNode = new FrameworkNode(docWidget.getElementsByTagName("Widget").item(0));
if (false == baseNode.hasAttributes()) {
LOGGER.severe("Invalid Widget definition in " + Filename);
return null;
}
String strWidget = baseNode.getAttribute("Type");
if (null == strWidget) {
LOGGER.severe("Invalid Widget definition in " + Filename);
return null;
}
if (strWidget.equalsIgnoreCase("SteelGauge")) {
retWidget = SteelGaugeBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("SteelGaugeRadial")) {
retWidget = SteelGaugeRadialBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("SteelGaugeRadialSteel")) {
retWidget = SteelGaugeRadialSteelBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("Steel180Gauge")) {
retWidget = SteelGauge180Builder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("SteelSimpleGauge")) {
retWidget = SteelSimpleGaugeBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("SteelLCD")) {
retWidget = SteelLCDWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("LedBargraph")) {
retWidget = SteelLedBarGraphBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("StaticImage")) {
retWidget = StaticImageBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("DynamicImage")) {
retWidget = DynamicImageBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("Text")) {
retWidget = TextBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("ProgressBar")) {
retWidget = ProgressBarBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("ProgressIndicator")) {
retWidget = ProgressIndicatorBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("Button")) {
retWidget = ButtonWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("MultiSourceLineChart")) {
retWidget = ChartWidgetBuilder.BuildMultiSourceLineChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("LineChart")) {
retWidget = ChartWidgetBuilder.BuildLineChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("AreaChart")) {
retWidget = ChartWidgetBuilder.BuildAreaChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("MultiSourceAreaChart")) {
retWidget = ChartWidgetBuilder.BuildMultiSourceAreaChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("MultiSourceStackedAreaChart")) {
retWidget = ChartWidgetBuilder.BuildMultiSourceStackedAreaChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("StackedAreaChart")) {
retWidget = ChartWidgetBuilder.BuildStackedAreaChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("PieChart")) {
retWidget = PieChartWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("BarChart")) {
retWidget = ChartWidgetBuilder.BuildBarChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("StackedBarChart")) {
retWidget = ChartWidgetBuilder.BuildStackedlBarChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("HorizontalBarChart")) {
retWidget = ChartWidgetBuilder.BuildHorizontalBarChart(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("FlipPanel")) {
retWidget = FlipPanelWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("Spacer")) {
retWidget = SpacerWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("SVG")) {
retWidget = SVG_WidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("PDF_Reader")) {
LOGGER.severe("PDF Reader not currently supported");
retWidget = null;
// retWidget = PDF_ReaderWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("AudioPlayer")) {
retWidget = AudioPlayerWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("VideoPlayer")) {
retWidget = VideoPlayerWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("Web")) {
retWidget = WebWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("QuickView")) {
retWidget = QuickViewWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("QuickViewLCD")) {
retWidget = QuickViewLCDWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("DoubleBarGauge")) {
retWidget = DoubleBarGaugeWidgetBuilder.Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("BarGauge")) {
retWidget = BarGaugeWidgetBuilder.Build(baseNode, Filename);
} else {
LOGGER.severe("Unknown Widget type : " + strWidget + " in :" + Filename);
}
if (null != retWidget) {
retWidget.setWidgetInformation(file.getParent(), Filename, strWidget);
}
} else {
LOGGER.severe("Widget Definition file does not exist: " + Filename);
return null;
}
AliasMgr.getAliasMgr().PopAliasList();
return retWidget;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class WidgetBuilder method BuildGrid.
public static GridWidget BuildGrid(FrameworkNode gridNode, boolean isFlipPanelGrid) {
GridWidget retWidget = new GridWidget();
String rowSpan = "1";
String colSpan = "1";
String strRow = "0";
String strColumn = "0";
String WhatIsIt = "Grid";
if (true == isFlipPanelGrid) {
WhatIsIt = "FlipPanel";
}
if (false == gridNode.hasAttribute("row") && false == isFlipPanelGrid) {
LOGGER.severe("Grid with no row");
return null;
}
if (false == gridNode.hasAttribute("column") && false == isFlipPanelGrid) {
LOGGER.severe("Grid with no column");
return null;
}
if (gridNode.hasAttribute("rowSpan")) {
rowSpan = gridNode.getAttribute("rowSpan");
}
if (gridNode.hasAttribute("colSpan")) {
colSpan = gridNode.getAttribute("colSpan");
}
if (gridNode.hasAttribute("columnspan")) {
colSpan = gridNode.getAttribute("columnspan");
}
if (true == gridNode.hasAttribute("Height")) {
if (!retWidget.parseHeight(gridNode)) {
return null;
}
}
if (true == gridNode.hasAttribute("Width")) {
if (!retWidget.parseWidth(gridNode)) {
return null;
}
}
if (false == isFlipPanelGrid) {
strRow = gridNode.getAttribute("row");
strColumn = gridNode.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 column defined");
return null;
}
}
try {
retWidget.setRow(Integer.parseInt(strRow));
retWidget.setColumn(Integer.parseInt(strColumn));
retWidget.setRowSpan(Integer.parseInt(rowSpan));
retWidget.setColumnSpan(Integer.parseInt(colSpan));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid " + WhatIsIt + " definition in Configuration file. " + ex.toString());
return null;
}
AliasMgr.getAliasMgr().UpdateCurrentColumn(Integer.parseInt(strColumn));
AliasMgr.getAliasMgr().UpdateCurrentRow(Integer.parseInt(strRow));
AliasMgr.getAliasMgr().PushAliasList(true);
if (true == gridNode.hasAttribute("File")) {
String strFileName = gridNode.getAttribute("File");
StartReadingExternalFile(gridNode);
AliasMgr.getAliasMgr().PushAliasList(true);
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(gridNode, new String[] { "row", "column", "rowSpan", "colSpan", "columnSpan", "hgap", "vgap", "Align", "File", "Height", "Width" });
if (false == AliasMgr.ReadAliasFromExternalFile(strFileName)) {
AliasMgr.getAliasMgr().PopAliasList();
return null;
}
FrameworkNode GridNode = WidgetBuilder.OpenDefinitionFile(gridNode.getAttribute("File"), "Grid");
if (null == GridNode) {
LOGGER.severe("Invalid file: " + strFileName + " no <Grid> found.");
return null;
}
// read grid from external file
retWidget = ReadGridInfo(GridNode, retWidget, strFileName);
if (null == retWidget) {
return null;
}
if (// could also be tasks defined in external file
!ConfigurationReader.ReadTasksFromExternalFile(strFileName)) {
return null;
}
AliasMgr.getAliasMgr().PopAliasList();
DoneReadingExternalFile();
}
/*
else
{ // if not an external declaration, check for known options
Utility.ValidateAttributes(new String[]
{
"row", "column", "rowSpan", "colSpan", "columnspan", "hgap", "vgap", "Align", "File", "Height", "Width", "Macro"
}, gridNode);
}
*/
if (gridNode.hasAttribute("Macro")) {
if (gridNode.hasAttribute("File")) {
LOGGER.severe("Grid cannot have both file and Macro.");
return null;
}
String strMacro = gridNode.getAttribute("Macro");
FrameworkNode nodeMacro = GridMacroMgr.getGridMacroMgr().getGridMacro(strMacro);
if (null == nodeMacro) {
LOGGER.severe("Grid Macro specified [" + strMacro + "] does not defined.");
return null;
}
// need to get alias from the grid macro is in
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(gridNode, new String[] { "rowSpan", "colSpan", "columnSpan", "hgap", "vgap", "Align", "Height", "Width" });
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(nodeMacro, new String[] { "rowSpan", "colSpan", "columnSpan", "hgap", "vgap", "Align", "Height", "Width" });
retWidget = ReadGridInfo(nodeMacro, retWidget, null);
if (null == retWidget) {
return null;
}
}
// 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(gridNode, retWidget, "");
AliasMgr.getAliasMgr().PopAliasList();
return retWidget;
}
use of kutch.biff.marvin.utility.FrameworkNode 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;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class QuickViewLCDWidgetBuilder method Build.
public static QuickViewLCDWidget Build(FrameworkNode masterNode, String widgetDefFilename) {
QuickViewLCDWidget _widget = new QuickViewLCDWidget();
for (FrameworkNode node : masterNode.getChildNodes()) {
if (BaseWidget.HandleCommonDefinitionFileConfig(_widget, node)) {
} else if (node.getNodeName().equalsIgnoreCase("#comment")) {
} else if (node.getNodeName().equalsIgnoreCase("RowWidth")) {
String str = node.getTextContent();
try {
_widget.setRowWidth(Integer.parseInt(str));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid <RowWidth> in QuickViewWidget Widget Definition File : " + str);
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("EvenBackgroundStyle")) {
_widget.setEvenBackgroundStyle(node.getTextContent());
} else if (node.getNodeName().equalsIgnoreCase("EvenStyle")) {
String ID = "";
if (node.hasAttribute("ID")) {
ID = node.getAttribute("ID");
}
_widget.setEvenStyle(ID, node.getTextContent());
} else if (node.getNodeName().equalsIgnoreCase("OddBackgroundStyle")) {
_widget.setOddBackgroundStyle(node.getTextContent());
} else if (node.getNodeName().equalsIgnoreCase("OddStyle")) {
String ID = "";
if (node.hasAttribute("ID")) {
ID = node.getAttribute("ID");
}
_widget.setOddStyle(ID, node.getTextContent());
} else if (node.getNodeName().equalsIgnoreCase("Order")) {
String strVal = node.getTextContent();
if (strVal.equalsIgnoreCase(QuickViewWidget.SortMode.Ascending.toString())) {
_widget.setSortMode(QuickViewLCDWidget.SortMode.Ascending);
} else if (strVal.equalsIgnoreCase(QuickViewLCDWidget.SortMode.Descending.toString())) {
_widget.setSortMode(QuickViewLCDWidget.SortMode.Descending);
} else if (strVal.equalsIgnoreCase(QuickViewWidget.SortMode.None.toString())) {
_widget.setSortMode(QuickViewLCDWidget.SortMode.None);
} else {
LOGGER.severe("Invalid <Order> Tag in QuickViewLCDWidget Widget Definition File. " + strVal);
return null;
}
} else {
LOGGER.severe("Invalid QuickViewLCDWidget Widget Definition File. Unknown Tag: " + node.getNodeName());
return null;
}
}
return _widget;
}
Aggregations