Search in sources :

Example 56 with TreeItem

use of javafx.scene.control.TreeItem in project certmgr by hdecarne.

the class UserCertStoreTreeTableViewHelper method updateHelper.

private void updateHelper(TreeItem<T> parent, Set<UserCertStoreEntry> entries) {
    ObservableList<TreeItem<T>> items = parent.getChildren();
    List<TreeItem<T>> itemsToRemove = new ArrayList<>(items.size());
    Map<UserCertStoreEntry, TreeItem<T>> itemsToUpdate = new HashMap<>(items.size());
    for (TreeItem<T> item : items) {
        if (entries.contains(item.getValue().getEntry())) {
            // entry does still exist -> remember for update
            itemsToUpdate.put(item.getValue().getEntry(), item);
        } else {
            // entry no longer in store -> remember for remove
            itemsToRemove.add(item);
        }
    }
    items.removeAll(itemsToRemove);
    for (UserCertStoreEntry entry : entries) {
        TreeItem<T> entryItem = itemsToUpdate.get(entry);
        if (entryItem == null) {
            entryItem = new TreeItem<>(this.modelFactory.apply(entry));
            entryItem.graphicProperty().bind(entryItem.getValue().graphicProperty());
            items.add(entryItem);
        } else {
            entryItem.getValue().updateGraphic();
        }
        updateHelper(entryItem, entry.issuedEntries());
    }
    items.sort(this.comparator);
}
Also used : TreeItem(javafx.scene.control.TreeItem) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry)

Example 57 with TreeItem

use of javafx.scene.control.TreeItem 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 58 with TreeItem

use of javafx.scene.control.TreeItem in project jphp by jphp-compiler.

the class UXTreeView method getExpandedItems.

@Getter
public Memory getExpandedItems(Environment env) {
    TreeItem root = getWrappedObject().getRoot();
    ArrayMemory result = new ArrayMemory();
    if (root != null) {
        _getExpandedItems(env, root, result);
    }
    return result;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) TreeItem(javafx.scene.control.TreeItem)

Example 59 with TreeItem

use of javafx.scene.control.TreeItem 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)

Example 60 with TreeItem

use of javafx.scene.control.TreeItem in project jgnash by ccavanaugh.

the class BudgetTableController method loadAccountTree.

private void loadAccountTree() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final TreeItem<Account> root = new TreeItem<>(engine.getRootAccount());
    root.setExpanded(true);
    accountTreeView.setRoot(root);
    loadChildren(root);
}
Also used : Account(jgnash.engine.Account) TreeItem(javafx.scene.control.TreeItem) Engine(jgnash.engine.Engine)

Aggregations

TreeItem (javafx.scene.control.TreeItem)76 File (java.io.File)15 TreeView (javafx.scene.control.TreeView)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 ObjectProperty (javafx.beans.property.ObjectProperty)9 MenuItem (javafx.scene.control.MenuItem)9 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 IOException (java.io.IOException)7 Optional (java.util.Optional)7 FXCollections (javafx.collections.FXCollections)7 ListChangeListener (javafx.collections.ListChangeListener)7 ObservableList (javafx.collections.ObservableList)7 ActionEvent (javafx.event.ActionEvent)7 ContextMenu (javafx.scene.control.ContextMenu)7 Stage (javafx.stage.Stage)7 FXML (javafx.fxml.FXML)6 Button (javafx.scene.control.Button)6