Example usage for javafx.scene.control TreeItem getValue

List of usage examples for javafx.scene.control TreeItem getValue

Introduction

In this page you can find the example usage for javafx.scene.control TreeItem getValue.

Prototype

public final T getValue() 

Source Link

Document

Returns the application-specific data represented by this TreeItem.

Usage

From source file:sonicScream.utilities.ScriptParser.java

private static StringBuilder recursiveBuildScript(StringBuilder scriptString, TreeItem<String> node,
        int level) {
    String tabs = "";
    for (int i = 1; i < level; i++) {
        tabs += "\t";
    }// w ww. j  ava2 s  .  co m

    if (node.getParent() != null) {
        scriptString.append(tabs + node.getValue() + "\n");
    }
    /* 
     * TODO: Figure out a way to track brace placement without just checking to see if a node has children. Maybe 
     * a custom node object that tracks whether a node is followed by braces?
     */
    if (!node.isLeaf()) {
        scriptString.append(tabs + "{\n");
        level++;
        for (int i = 0; i < node.getChildren().size(); i++) {
            scriptString = recursiveBuildScript(scriptString, node.getChildren().get(i), level);
        }
        level--;
        scriptString.append(tabs + "}\n");
    }
    return scriptString;
}

From source file:ubicrypt.ui.ctrl.HomeController.java

private static void removeItem(final TreeItem<ITreeItem> item) {
    final TreeItem<ITreeItem> parent = item.getParent();
    parent.getChildren().remove(item);//from   w w w .j a  v  a  2 s .c  o  m
    if (parent.getChildren().isEmpty() && !(parent.getValue() instanceof RootFilesItem)) {
        removeItem(parent);
    }
}

From source file:sonicScream.utilities.ScriptParser.java

public static boolean areScriptTreesEqual(TreeItem<String> lhs, TreeItem<String> rhs) {
    if (lhs.getChildren().size() != rhs.getChildren().size() || lhs.isLeaf() != rhs.isLeaf()) {
        return false;
    }//from  ww  w  .ja  v a  2s. co m

    boolean areEqual = true;

    if (!lhs.isLeaf()) {
        for (int i = 0; i < lhs.getChildren().size() - 1; i++) {
            areScriptTreesEqual(lhs.getChildren().get(i), rhs.getChildren().get(i));
        }
    }

    return lhs.getValue().equals(rhs.getValue());
}

From source file:acmi.l2.clientmod.xdat.Controller.java

private static boolean checkTreeNode(TreeItem<Object> treeItem, String nameFilter) {
    if (checkName(Objects.toString(treeItem.getValue()), nameFilter))
        return true;

    for (TreeItem<Object> childItem : treeItem.getChildren())
        if (checkTreeNode(childItem, nameFilter))
            return true;

    return false;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);//from  w  w  w.jav  a2 s .c om
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<String>(rootNode);
    treeView.setShowRoot(true);
    treeView.setEditable(true);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);/*from w  w  w .  j  ava2  s . c om*/
    System.out.println(rootNode.isExpanded());
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<String>(rootNode);
    treeView.setShowRoot(true);
    treeView.setEditable(true);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);//from  w  w w .  j  av a2s .  c  om
    System.out.println(rootNode.isLeaf());
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<String>(rootNode);
    treeView.setShowRoot(true);
    treeView.setEditable(true);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);/*from ww w .j a  va 2s .c om*/
    rootNode.setValue("new value");
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<String>(rootNode);
    treeView.setShowRoot(true);
    treeView.setEditable(true);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);//from   ww  w  . j  a  v a 2 s .c  om
    System.out.println(rootNode.toString());
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<String>(rootNode);
    treeView.setShowRoot(true);
    treeView.setEditable(true);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);/*from  w  ww.j a  va 2s .  c  o  m*/
    rootNode.setGraphic(rootIcon);
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<String>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<String>(rootNode);
    treeView.setShowRoot(true);
    treeView.setEditable(true);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}