use of kutch.biff.marvin.utility.DataPointGenerator in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadMenuItem.
public MenuItem ReadMenuItem(FrameworkNode menuNode, int itemIndex) {
if (menuNode.getNodeName().equalsIgnoreCase("MenuItem")) {
Utility.ValidateAttributes(new String[] { "Text", "Task", "CreateDataPoint" }, menuNode);
if (menuNode.hasAttribute("Text") && menuNode.hasAttribute("Task")) {
MenuItem objItem = new MenuItem(menuNode.getAttribute("Text"));
HandleMenuStyleOverride(objItem, menuNode);
if (menuNode.hasChild("Image")) {
ImageView iv = ConfigurationReader.GetImage(menuNode.getChild("Image"));
if (null != iv) {
objItem.setGraphic(iv);
}
}
if (true == Configuration.getConfig().getAllowTasks()) {
List<DataPointGenerator> dataPoints = new ArrayList<>();
String strTask = menuNode.getAttribute("Task");
if (menuNode.hasAttribute("CreateDataPoint")) {
dataPoints.addAll(ReadDataPointsForTask(itemIndex, menuNode.getAttribute("CreateDataPoint"), menuNode.getAttribute("Text"), menuNode.getAttribute("Task")));
if (dataPoints.size() == 0) {
return null;
}
}
objItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
for (DataPointGenerator dpGen : dataPoints) {
dpGen.generate();
}
TASKMAN.PerformTask(strTask);
}
});
}
return objItem;
}
}
return null;
}
use of kutch.biff.marvin.utility.DataPointGenerator in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadDataPointsForTask.
public static List<DataPointGenerator> ReadDataPointsForTask(int itemIndex, String strInput, String strTaskText, String strTask) {
List<DataPointGenerator> retList = new ArrayList<>();
if (// might be replacement of ^Text or ^Task
strInput.contains("^")) {
if (strInput.contains("^Text")) {
strInput = strInput.replace("^Text", strTaskText);
}
if (strInput.contains("^Task")) {
strInput = strInput.replace("^Task", strTask);
}
if (strInput.contains("^Index")) {
String strIndex = Integer.toString(itemIndex);
strInput = strInput.replace("^Index", strIndex);
}
}
String[] points = strInput.split("\\]");
for (String point : points) {
if (point.length() == 0) {
continue;
}
if (point.charAt(0) == ',' && point.charAt(1) == '[') {
point = point.substring(1);
}
if (point.charAt(0) == '[') {
point = point.substring(1);
String[] parts = point.split(",", 3);
if (parts.length != 3) {
retList.clear();
return retList;
}
String Namespace = parts[0];
String ID = parts[1];
String val = parts[2];
retList.add(new DataPointGenerator(Namespace, ID, val));
} else {
retList.clear();
return retList;
}
}
return retList;
}
use of kutch.biff.marvin.utility.DataPointGenerator in project Board-Instrumentation-Framework by intel.
the class Prompt_ListBox method SetupDialog.
@Override
protected Pane SetupDialog(Stage dialog) {
if (_ParamList.isEmpty()) {
LOGGER.severe("Listbox Prompt [" + toString() + "] had no <List> items.");
// return null;
}
GridPane root = new GridPane();
root.setHgap(5.0);
root.setVgap(5.0);
root.setPadding(new Insets(5, 5, 5, 5));
Button btn = new Button();
btn.setText("OK");
Label lblMessage = new Label(getMessage());
lblMessage.setWrapText(true);
ListView<String> listBox = new ListView<>();
ObservableList<String> items = FXCollections.observableArrayList(_DisplayTextList);
listBox.setItems(items);
listBox.getSelectionModel().select(_PrevSelection);
Text t = new Text(getMessage());
Double MaxWidth = t.getLayoutBounds().getWidth();
for (String strCheck : items) {
t = new Text(strCheck);
if (t.getLayoutBounds().getWidth() > MaxWidth) {
MaxWidth = t.getLayoutBounds().getWidth();
}
}
GridPane.setColumnSpan(lblMessage, 2);
root.add(lblMessage, 0, 0);
int len = items.size();
if (// only do max of 8 items in height
len > 8) {
len = 8;
}
// len++;
// hack! (but recommended from javafx community
double Height = 24 * len;
if (getWidth() > 0) {
MaxWidth = getWidth();
}
if (getHeight() > 0) {
Height = getHeight();
}
// +10 pushes box down enough to not hae scroll
listBox.setPrefHeight(Height + 10);
// add some padding at end
listBox.setPrefWidth(MaxWidth + 30);
root.add(listBox, 0, 2);
GridPane.setHalignment(btn, HPos.CENTER);
root.add(btn, 0, 3);
// place on correct screen and center
int xPos = (int) (Configuration.getConfig().getPrimaryScreen().getVisualBounds().getMinX());
int yPos = (int) (Configuration.getConfig().getPrimaryScreen().getVisualBounds().getMinY());
dialog.setX(xPos);
dialog.setY(yPos);
dialog.centerOnScreen();
btn.setOnAction((ActionEvent event) -> {
int Selection = listBox.getSelectionModel().getSelectedIndex();
List<DataPointGenerator> dataPoints = _DataPoints.get(Selection);
if (null != dataPoints) {
for (DataPointGenerator dp : dataPoints) {
dp.generate();
}
}
SetPromptedValue(_ParamList.get(Selection));
_PrevSelection = Selection;
dialog.close();
});
return root;
}
use of kutch.biff.marvin.utility.DataPointGenerator in project Board-Instrumentation-Framework by intel.
the class Prompt_ListBox method HandlePromptSpecificConfig.
/**
* @param baseNode
* @return
*/
@Override
public boolean HandlePromptSpecificConfig(FrameworkNode baseNode) {
if (baseNode.getNodeName().equalsIgnoreCase("List")) {
int itemIndex = 0;
for (FrameworkNode node : baseNode.getChildNodes(true)) {
if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#Comment")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("Item")) {
@SuppressWarnings("unused") String strDisplayText;
if (node.hasAttribute("Text")) {
strDisplayText = node.getAttribute("Text");
} else {
strDisplayText = node.getTextContent();
}
/*
* Beginning of work, but not yet done
*/
List<DataPointGenerator> dataPoints = null;
if (node.hasAttribute("CreateDataPoint")) {
dataPoints = ConfigurationReader.ReadDataPointsForTask(itemIndex++, node.getAttribute("CreateDataPoint"), node.getAttribute("Text"), node.getAttribute("Task"));
}
AddListItem(strDisplayText, node.getTextContent(), dataPoints);
} else {
LOGGER.severe("Invalid list item in prompt ID: " + this.toString() + " [" + node.getNodeName() + "]");
return false;
}
}
return true;
}
return false;
}
Aggregations