Search in sources :

Example 1 with DataPointGenerator

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;
}
Also used : DataPointGenerator(kutch.biff.marvin.utility.DataPointGenerator) ActionEvent(javafx.event.ActionEvent) ArrayList(java.util.ArrayList) MenuItem(javafx.scene.control.MenuItem) ImageView(javafx.scene.image.ImageView)

Example 2 with DataPointGenerator

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;
}
Also used : DataPointGenerator(kutch.biff.marvin.utility.DataPointGenerator) ArrayList(java.util.ArrayList)

Example 3 with DataPointGenerator

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;
}
Also used : DataPointGenerator(kutch.biff.marvin.utility.DataPointGenerator) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text) ListView(javafx.scene.control.ListView) Button(javafx.scene.control.Button)

Example 4 with DataPointGenerator

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;
}
Also used : DataPointGenerator(kutch.biff.marvin.utility.DataPointGenerator) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Aggregations

DataPointGenerator (kutch.biff.marvin.utility.DataPointGenerator)4 ArrayList (java.util.ArrayList)2 ActionEvent (javafx.event.ActionEvent)2 Insets (javafx.geometry.Insets)1 Button (javafx.scene.control.Button)1 Label (javafx.scene.control.Label)1 ListView (javafx.scene.control.ListView)1 MenuItem (javafx.scene.control.MenuItem)1 ImageView (javafx.scene.image.ImageView)1 GridPane (javafx.scene.layout.GridPane)1 Text (javafx.scene.text.Text)1 FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)1