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