use of kutch.biff.marvin.widget.TabWidget in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadTabs.
private List<TabWidget> ReadTabs(Document doc, List<String> TabID_List) {
FrameworkNode appNode = new FrameworkNode(doc.getChildNodes().item(0));
ArrayList<TabWidget> TabList = new ArrayList<>();
for (FrameworkNode node : appNode.getChildNodes(true)) {
if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("DemoFramework")) {
LOGGER.warning("DemoFramework XML tag is deprecated. Use 'Marvin'");
continue;
}
if (node.getNodeName().equalsIgnoreCase("Marvin")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("Application")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("Tab")) {
TabWidget tab = null;
if (node.hasAttributes()) {
if (node.hasAttribute("ID")) {
boolean found = false;
String id = node.getAttribute("ID");
if (TabAlreadyLoaded(TabList, id)) {
LOGGER.severe("<Tab ID=" + id + "> defined twice in <Tabs>.");
return null;
}
for (String string : TabID_List) {
if (0 == string.compareToIgnoreCase(id)) {
found = true;
tab = new TabWidget(id);
FrameworkNode tabNode = null;
AliasMgr.getAliasMgr().PushAliasList(true);
// Make TabID an alias = to the ID :-)
AliasMgr.getAliasMgr().AddAlias("TabID", id);
if (// can externally define widgets within
node.hasAttribute("File")) {
WidgetBuilder.StartReadingExternalFile(node);
tabNode = OpenTabDefinitionFile(node.getAttribute("File"));
if (null == tabNode) {
LOGGER.severe("Invalid tab definition file: " + node.getAttribute("File"));
return null;
}
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(node, new String[] { "ID", "File", "Align", "hgap", "vgap" });
if (false == AliasMgr.getAliasMgr().ReadAliasFromExternalFile(node.getAttribute("File"))) {
return null;
}
if (!ConfigurationReader.ReadTasksFromExternalFile(node.getAttribute("File"))) {
return null;
}
} else {
Utility.ValidateAttributes(new String[] { "ID", "File", "Align", "hgap", "vgap" }, node);
tabNode = node;
}
if (null == tabNode) {
return null;
}
if (false == tab.LoadConfiguration(tabNode)) {
return null;
}
if (node.hasAttribute("File")) {
WidgetBuilder.DoneReadingExternalFile();
}
break;
}
}
if (true == found) {
AliasMgr.getAliasMgr().PopAliasList();
} else {
LOGGER.warning("<Tab ID=" + id + "> found, but not used in <Tabs>.");
continue;
}
} else {
LOGGER.warning("<Tab> with no ID found.");
return null;
}
if (true == node.hasAttribute("Align")) {
String str = node.getAttribute("Align");
tab.setAlignment(str);
}
if (node.hasAttribute("hgap")) {
try {
if (!tab.parsehGapValue(node)) {
LOGGER.config("Setting hGap for Tab ID=" + tab.getMinionID() + " to " + node.getAttribute("hgap"));
}
// tab.sethGap(Integer.parseInt(node.getAttribute("hgap")));
} catch (Exception ex) {
LOGGER.warning("Tab ID=" + tab.getMinionID() + " has invalid hgap. Ignoring");
}
}
if (node.hasAttribute("vgap")) {
try {
if (!tab.parsevGapValue(node)) {
LOGGER.config("Setting vGap for Tab ID=" + tab.getMinionID() + " to " + node.getAttribute("vgap"));
}
// tab.setvGap(Integer.parseInt(node.getAttribute("vgap")));
// LOGGER.config("Setting vGap for Tab ID=" + tab.getMinionID() + " to " + node.getAttribute("vgap"));
} catch (Exception ex) {
LOGGER.warning("Tab ID=" + tab.getMinionID() + " has invalid vgap. Ignoring");
}
}
}
if (null == tab) {
LOGGER.severe("Malformed <Tab> found in configuration file");
return null;
}
TabList.add(tab);
} else if (node.getNodeName().equalsIgnoreCase("TaskList")) {
ConfigurationReader.ReadTaskList(node);
} else if (node.getNodeName().equalsIgnoreCase("Prompt")) {
ConfigurationReader.ReadPrompt(node);
} else if (node.getNodeName().equalsIgnoreCase("AliasList")) {
} else {
LOGGER.warning("Unexpected Tag Type in configuration file: " + node.getNodeName());
}
}
if (false == VerifyDesiredTabsPresent(TabList, TabID_List)) {
return null;
}
return SortTabs(TabList, TabID_List);
}
use of kutch.biff.marvin.widget.TabWidget in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method VerifyDesiredTabsPresent.
private boolean VerifyDesiredTabsPresent(List<TabWidget> listTabs, List<String> TabID_List) {
boolean RetVal = true;
for (String id : TabID_List) {
boolean found = false;
for (TabWidget tab : listTabs) {
if (0 == id.compareToIgnoreCase(tab.getMinionID())) {
found = true;
break;
}
}
if (false == found) {
LOGGER.severe("Tab with ID=" + id + " defined in <Tabs>, however not in <Tab> definitions.");
RetVal = false;
}
}
return RetVal;
}
use of kutch.biff.marvin.widget.TabWidget in project Board-Instrumentation-Framework by intel.
the class MarvinAdminTask method SetVisible.
/**
* Make a tab visible or invisible
*/
private void SetVisible() {
LOGGER.info("Performing Set Visible Tab MarvinAdminTask, to Tab: " + _Data);
if (// could be Volume or JumpTo
_Data.contains(":")) {
String[] parts = _Data.split(":");
boolean fVisible;
if (parts.length > 1) {
String strTabID = parts[0];
String strVisibility = parts[1];
if (strVisibility.equalsIgnoreCase("true")) {
fVisible = true;
} else if (strVisibility.equalsIgnoreCase("false")) {
fVisible = false;
} else {
LOGGER.severe("MarvinAdminTask received invalid command --> " + _Data);
return;
}
List<TabWidget> tabs = GetConfigReader().getTabs();
int invisCount = 0;
for (int iLoop = 0; iLoop < tabs.size(); iLoop++) {
TabWidget tab = tabs.get(iLoop);
if (// Minion ID is the Tab ID
tab.getMinionID().equalsIgnoreCase(strTabID)) {
if (fVisible) {
if (tab.isVisible()) {
LOGGER.info("Asked to set tab ID " + strTabID + " visible, but it is already visible");
return;
}
getConfig().getPane().getTabs().add(tab.getTabIndex() - invisCount, tab.getTabControl());
tab.setVisible(fVisible);
return;
}
// else make invisible
if (!tab.isVisible()) {
LOGGER.info("Asked to set tab ID " + strTabID + " invisible, but it is already invisible");
return;
}
getConfig().getPane().getTabs().remove(iLoop - invisCount);
tab.setVisible(fVisible);
return;
} else {
if (!tab.isVisible()) {
// make sure and insert at right point, could be 'invisible' tabs ahead of us, so the index would be off.
invisCount++;
}
}
}
}
} else {
LOGGER.severe("Received invalid MarvinAdminTask : " + _Data);
return;
}
LOGGER.warning("Invalid Tab ID [" + _Data + "] specified for a SetActiveTab MarvinAdminTask");
}
Aggregations