Search in sources :

Example 1 with JFXTreeViewPath

use of com.jfoenix.controls.JFXTreeViewPath in project S4T1TM2 by CSUS-CSC-131-Spring2018.

the class YaamDemo method constructPathbar.

private void constructPathbar() {
    StackPane pathBarContainer = new StackPane();
    content.getChildren().addAll(pathBarContainer);
    pathBarContainer.setId("pathBar");
    pathBarContainer.setAlignment(Pos.CENTER);
    pathBarContainer.layoutXProperty().bind(brandName.widthProperty());
    pathBarContainer.layoutYProperty().bind(brandName.heightProperty().divide(2));
    pathBarContainer.prefWidthProperty().bind(content.widthProperty().subtract(brandName.widthProperty()));
    pathBarContainer.prefHeightProperty().bind(brandName.heightProperty().divide(2));
    pathTree = new TreeView<>();
    pathBar = new JFXTreeViewPath(pathTree);
    pathTree.setRoot(new TreeItem<>("Home"));
    pathTree.getSelectionModel().select(pathTree.getRoot());
    pathBarContainer.getChildren().add(pathBar);
}
Also used : JFXTreeViewPath(com.jfoenix.controls.JFXTreeViewPath) StackPane(javafx.scene.layout.StackPane)

Example 2 with JFXTreeViewPath

use of com.jfoenix.controls.JFXTreeViewPath in project S4T1TM2 by CSUS-CSC-131-Spring2018.

the class TreeViewDemo method start.

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);
    final JFXTreeView<String> treeView = new JFXTreeView<>(rootNode);
    treeView.setEditable(true);
    // creating node and adding to department
    for (Employee employee : employees) {
        FilterableTreeItem<String> empLeaf = new FilterableTreeItem<>(employee.getName());
        FilterableTreeItem<String> test = new FilterableTreeItem<>("Test");
        empLeaf.getInternalChildren().add(test);
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                ((FilterableTreeItem) depNode).getInternalChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            FilterableTreeItem<String> depNode = new FilterableTreeItem<>(employee.getDepartment());
            rootNode.getInternalChildren().add(depNode);
            depNode.getInternalChildren().add(empLeaf);
        }
    }
    // initialize stage
    stage.setTitle("Tree View Sample");
    stage.setTitle("Agile Manager");
    stage.setWidth(800);
    stage.setHeight(600);
    treeView.setPrefHeight(600);
    treeView.setPrefWidth(200);
    // creating pane
    VBox box = new VBox();
    box.setPrefWidth(200);
    box.setPrefHeight(600);
    final Scene scene = new Scene(box);
    scene.setFill(Color.LIGHTGRAY);
    // treeView.setShowRoot(false);
    // create search functionality
    TextField filterField = new JFXTextField();
    filterField.setPromptText("Search...");
    // define search predicate
    rootNode.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        // predicate is reevaluated when filterfield is modified
        if (filterField.getText() == null || filterField.getText().isEmpty())
            return null;
        return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText()));
    }, filterField.textProperty()));
    // add to pane
    box.getChildren().addAll(new JFXTreeViewPath(treeView), treeView, filterField);
    VBox.setVgrow(treeView, Priority.ALWAYS);
    // stage shit
    stage.setScene(scene);
    stage.show();
}
Also used : Scene(javafx.scene.Scene) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) Predicate(java.util.function.Predicate) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TreeItem(javafx.scene.control.TreeItem) FilteredList(javafx.collections.transformation.FilteredList) FXCollections(javafx.collections.FXCollections) Field(java.lang.reflect.Field) VBox(javafx.scene.layout.VBox) Bindings(javafx.beans.binding.Bindings) Application(javafx.application.Application) JFXTreeViewPath(com.jfoenix.controls.JFXTreeViewPath) Priority(javafx.scene.layout.Priority) List(java.util.List) ListChangeListener(javafx.collections.ListChangeListener) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Arrays.asList(java.util.Arrays.asList) ObservableList(javafx.collections.ObservableList) JFXTreeView(com.jfoenix.controls.JFXTreeView) JFXTextField(com.jfoenix.controls.JFXTextField) JFXTextField(com.jfoenix.controls.JFXTextField) Scene(javafx.scene.Scene) JFXTreeView(com.jfoenix.controls.JFXTreeView) JFXTreeViewPath(com.jfoenix.controls.JFXTreeViewPath) TextField(javafx.scene.control.TextField) JFXTextField(com.jfoenix.controls.JFXTextField) VBox(javafx.scene.layout.VBox)

Example 3 with JFXTreeViewPath

use of com.jfoenix.controls.JFXTreeViewPath in project JFoenix by jfoenixadmin.

the class TreeViewDemo method start.

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);
    final JFXTreeView<String> treeView = new JFXTreeView<>(rootNode);
    for (Employee employee : employees) {
        FilterableTreeItem<String> empLeaf = new FilterableTreeItem<>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                ((FilterableTreeItem) depNode).getInternalChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            FilterableTreeItem<String> depNode = new FilterableTreeItem<>(employee.getDepartment());
            rootNode.getInternalChildren().add(depNode);
            depNode.getInternalChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);
    treeView.setShowRoot(false);
    TextField filterField = new JFXTextField();
    rootNode.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        if (filterField.getText() == null || filterField.getText().isEmpty())
            return null;
        return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText()));
    }, filterField.textProperty()));
    box.getChildren().addAll(new JFXTreeViewPath(treeView), treeView, filterField);
    VBox.setVgrow(treeView, Priority.ALWAYS);
    stage.setScene(scene);
    stage.show();
}
Also used : Scene(javafx.scene.Scene) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TreeItem(javafx.scene.control.TreeItem) Predicate(java.util.function.Predicate) FilteredList(javafx.collections.transformation.FilteredList) FXCollections(javafx.collections.FXCollections) VBox(javafx.scene.layout.VBox) Field(java.lang.reflect.Field) Bindings(javafx.beans.binding.Bindings) Application(javafx.application.Application) JFXTreeViewPath(com.jfoenix.controls.JFXTreeViewPath) Priority(javafx.scene.layout.Priority) List(java.util.List) ListChangeListener(javafx.collections.ListChangeListener) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Arrays.asList(java.util.Arrays.asList) ObservableList(javafx.collections.ObservableList) JFXTreeView(com.jfoenix.controls.JFXTreeView) JFXTextField(com.jfoenix.controls.JFXTextField) JFXTextField(com.jfoenix.controls.JFXTextField) Scene(javafx.scene.Scene) JFXTreeView(com.jfoenix.controls.JFXTreeView) JFXTreeViewPath(com.jfoenix.controls.JFXTreeViewPath) TextField(javafx.scene.control.TextField) JFXTextField(com.jfoenix.controls.JFXTextField) VBox(javafx.scene.layout.VBox)

Aggregations

JFXTreeViewPath (com.jfoenix.controls.JFXTreeViewPath)3 JFXTextField (com.jfoenix.controls.JFXTextField)2 JFXTreeView (com.jfoenix.controls.JFXTreeView)2 Field (java.lang.reflect.Field)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Predicate (java.util.function.Predicate)2 Application (javafx.application.Application)2 Bindings (javafx.beans.binding.Bindings)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)2 FXCollections (javafx.collections.FXCollections)2 ListChangeListener (javafx.collections.ListChangeListener)2 ObservableList (javafx.collections.ObservableList)2 FilteredList (javafx.collections.transformation.FilteredList)2 Scene (javafx.scene.Scene)2 TextField (javafx.scene.control.TextField)2 TreeItem (javafx.scene.control.TreeItem)2 Priority (javafx.scene.layout.Priority)2