use of kutch.biff.marvin.widget.GridWidget 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;
}
Aggregations