use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class BarGaugeWidgetBuilder method Build.
public static BarGaugeWidget Build(FrameworkNode masterNode, String widgetDefFilename) {
BarGaugeWidget gauge = new BarGaugeWidget();
for (FrameworkNode node : masterNode.getChildNodes()) {
if (BaseWidget.HandleCommonDefinitionFileConfig(gauge, node)) {
continue;
} else if (node.getNodeName().equalsIgnoreCase("MinValue")) {
String str = node.getTextContent();
try {
gauge.setMinValue(Double.parseDouble(str));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid MinValue in BarGauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("MaxValue")) {
String str = node.getTextContent();
try {
gauge.setMaxValue(Double.parseDouble(str));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid MaxValue in BarGauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("Decimals")) {
String str = node.getTextContent();
try {
gauge.setDecimalPlaces(Integer.parseInt(str));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid Decimals in Bareauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("UnitText")) {
String str = node.getTextContent();
gauge.setUnitText(str);
} else {
LOGGER.severe("Invalid BarGauge Widget Definition File. Unknown Tag: " + node.getNodeName());
return null;
}
}
return gauge;
}
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 WidgetBuilder method ParseWidgetDefinitionFile.
/*
* private static int GetIntAttribute(FrameworkNode node, String Attribute,
* boolean fRequired) { if (node.hasAttribute(Attribute)) { try { return
* Integer.parseInt(node.getAttribute(Attribute)); } catch (Exception ex) {
* LOGGER.severe("Invalid attribute for Widget in Application.xml: " +
* node.getNodeName()); return -1; } } if (true == fRequired) {
* LOGGER.severe("Missing attribute [" + Attribute +
* "] Widget in Application.xml: " + node.getNodeName()); return -1; } return
* -2; }
*/
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
!AliasMgr.ReadAliasFromRootDocument(docWidget)) // file!
{
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("MenuButton")) {
retWidget = ButtonWidgetBuilder.BuildMenuButton(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("ToggleButton")) {
retWidget = ButtonWidgetBuilder.BuildToggleButton(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("FileWriter")) {
retWidget = FileWriterWidgetBuilder.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 if (strWidget.equalsIgnoreCase("ListBoxText")) {
retWidget = TextBuilder.ListBoxText_Build(baseNode, Filename);
} else if (strWidget.equalsIgnoreCase("TableChart")) {
retWidget = TableChartBuilder.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";
boolean isOnDemand = false;
DynamicItemInfoContainer info = null;
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 (gridNode.hasChild("OnDemand")) {
FrameworkNode demandNode = gridNode.getChild("OnDemand");
info = ConfigurationReader.ReadOnDemandInfo(demandNode);
OnDemandGridWidget objWidget = new OnDemandGridWidget(info);
if (demandNode.hasChild("Growth")) {
objWidget.ReadGrowthInfo(demandNode.getChild("Growth"));
}
// get hgap and all those good things
ReadGridAttributes(objWidget, gridNode, false);
retWidget = objWidget;
WhatIsIt = "OnDemand Grid";
isOnDemand = true;
// delete the ondemand section, not needed anymore
gridNode.DeleteChildNodes("OnDemand");
// int row = gridNode.getIntegerAttribute("row", 0);
// int col = gridNode.getIntegerAttribute("column", 0);
// gridNode.AddAttibute("GRID_COLUMN_ODD", col % 2 == 0 ? "FALSE" : "TRUE");
// gridNode.AddAttibute("GRID_ROW_ODD", row % 2 == 0 ? "FALSE" : "TRUE");
info.setNode(gridNode);
}
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));
if (isOnDemand) {
// need to nuke these, otherwise the on-demand grid will suck them up, and that
// will be a problem.
gridNode.DeleteAttribute("rowspan");
gridNode.DeleteAttribute("colspan");
gridNode.DeleteAttribute("columnpan");
gridNode.DeleteAttribute("hgap");
gridNode.DeleteAttribute("vgap");
gridNode.DeleteAttribute("align");
gridNode.DeleteAttribute("height");
gridNode.DeleteAttribute("width");
AliasMgr.getAliasMgr().PushAliasList(false);
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(gridNode, new String[] { "row", "column", "rowSpan", "colSpan", "columnSpan", "hgap", "vgap", "Align", "File", "Height", "Width" });
// have to do this way down here, after the other stuff
info.TakeAliasSnapshot();
AliasMgr.getAliasMgr().PopAliasList();
return retWidget;
}
AliasMgr.getAliasMgr().AddUpdateAlias("GRID_ROW_ODD", AliasMgr.getAliasMgr().GetAlias("CurrentRowIsOddAlias"));
AliasMgr.getAliasMgr().AddUpdateAlias("GRID_COLUMN_ODD", AliasMgr.getAliasMgr().GetAlias("CurrentColumnIsOddAlias"));
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
!ConfigurationReader.ReadTasksFromExternalFile(strFileName)) // file
{
return null;
}
AliasMgr.getAliasMgr().PopAliasList();
DoneReadingExternalFile();
}
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 SteelLCDWidgetBuilder method Build.
public static SteelLCDWidget Build(FrameworkNode masterNode, String widgetDefFilename) {
SteelLCDWidget lcd = new SteelLCDWidget();
for (FrameworkNode node : masterNode.getChildNodes()) {
if (BaseWidget.HandleCommonDefinitionFileConfig(lcd, node)) {
continue;
} else if (node.getNodeName().equalsIgnoreCase("MinValue")) {
String str = node.getTextContent();
try {
lcd.setMinValue(Double.parseDouble(str));
} catch (Exception ex) {
LOGGER.severe("Invalid MinValue in Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("MaxValue")) {
String str = node.getTextContent();
try {
lcd.setMaxValue(Double.parseDouble(str));
} catch (Exception ex) {
LOGGER.severe("Invalid MaxValue in SteelSimpleGauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("Decimals")) {
String str = node.getTextContent();
try {
lcd.setDecimalPlaces(Integer.parseInt(str));
} catch (Exception ex) {
LOGGER.severe("Invalid Decimals in SteelSimpleGauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("UnitText")) {
String str = node.getTextContent();
lcd.setUnitText(str);
} else if (node.getNodeName().equalsIgnoreCase("UnitText")) {
String str = node.getTextContent();
lcd.setUnitText(str);
} else if (node.getNodeName().equalsIgnoreCase("KeepAspectRatio")) {
String str = node.getTextContent();
if (0 == str.compareToIgnoreCase("False")) {
lcd.setKeepAspectRatio(false);
} else if (0 == str.compareToIgnoreCase("True")) {
lcd.setKeepAspectRatio(true);
} else {
LOGGER.severe("Invalid LCD Widget Definition File. KeepAspectRation should be True or False, not:" + str);
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("ShowMaxMeasuredValue")) {
String str = node.getTextContent();
if (0 == str.compareToIgnoreCase("True")) {
lcd.setShowMeasuredMax(true);
} else if (0 == str.compareToIgnoreCase("False")) {
lcd.setShowMeasuredMax(false);
} else {
LOGGER.severe("Invalid LCD Widget Definition File. ShowMaxMeasuredValue should be True or False, not:" + str);
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("ShowMinMeasuredValue")) {
String str = node.getTextContent();
if (0 == str.compareToIgnoreCase("True")) {
lcd.setShowMeasuredMin(true);
} else if (0 == str.compareToIgnoreCase("False")) {
lcd.setShowMeasuredMin(false);
} else {
LOGGER.severe("Invalid LCD Widget Definition File. ShowMaxMeasuredValue should be True or False, not:" + str);
return null;
}
} else {
LOGGER.severe("Invalid LCD Widget Definition File. Unknown Tag: " + node.getNodeName());
return null;
}
}
return lcd;
}
Aggregations