Search in sources :

Example 6 with TreeView

use of javafx.scene.control.TreeView in project OwlPlug by DropSnorz.

the class PluginsController method initialize.

/**
 * FXML initialize method.
 */
@FXML
public void initialize() {
    newLinkButton.setOnAction(e -> {
        newLinkController.show();
    });
    treePluginNode = new FilterableTreeItem<>("(all)");
    treeFileRootNode = new FilterableTreeItem<>("(all)");
    treeView.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {

        @Override
        public TreeCell<Object> call(TreeView<Object> p) {
            return new PluginTreeCell(getApplicationDefaults(), pluginService);
        }
    });
    treeView.setRoot(treePluginNode);
    clearAndFillPluginTree();
    // Dispatches treeView selection event to the nodeInfoController
    treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            TreeItem<Object> selectedItem = newValue;
            nodeInfoController.setNode(selectedItem.getValue());
        }
    });
    // Handles tabPane selection event and toggles displayed treeView
    treeViewTabPane.getSelectionModel().selectedItemProperty().addListener((observable, oldTab, newTab) -> {
        if (newTab.getId().equals("treeTabAll")) {
            treeView.setRoot(treePluginNode);
        } else {
            treeView.setRoot(treeFileRootNode);
        }
    });
    // Binds search property to plugin tree filter
    treePluginNode.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        if (searchTextField.getText() == null || searchTextField.getText().isEmpty()) {
            return null;
        }
        return item -> item.toString().toLowerCase().contains(searchTextField.getText().toLowerCase());
    }, searchTextField.textProperty()));
    // Binds search property to plugin tree filter
    treeFileRootNode.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        if (searchTextField.getText() == null || searchTextField.getText().isEmpty()) {
            return null;
        }
        return item -> item.toString().toLowerCase().contains(searchTextField.getText().toLowerCase());
    }, searchTextField.textProperty()));
    syncButton.setOnAction(e -> {
        this.getAnalyticsService().pageView("/app/core/action/syncPlugins");
        pluginService.syncPlugins();
    });
    taskFactory.addSyncPluginsListener(() -> clearAndFillPluginTree());
}
Also used : PluginTreeCell(com.owlplug.core.ui.PluginTreeCell) PluginTreeCell(com.owlplug.core.ui.PluginTreeCell) TreeCell(javafx.scene.control.TreeCell) TreeView(javafx.scene.control.TreeView) JFXTreeView(com.jfoenix.controls.JFXTreeView) FXML(javafx.fxml.FXML)

Example 7 with TreeView

use of javafx.scene.control.TreeView in project selenium_java by sergueik.

the class TreeViewSample method start.

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<>(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<String> depNode = new TreeItem<>(employee.getDepartment(), new ImageView(depIcon));
            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<>(rootNode);
    treeView.setEditable(true);
    treeView.setCellFactory(e -> new TextFieldTreeCellImpl());
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}
Also used : TreeItem(javafx.scene.control.TreeItem) TreeView(javafx.scene.control.TreeView) ImageView(javafx.scene.image.ImageView) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 8 with TreeView

use of javafx.scene.control.TreeView in project MiscellaneousStudy by mikoto2000.

the class TreeViewSample method start.

@Override
public void start(Stage stage) {
    // ルート要素である TreeItem を作成
    TreeItem<String> root = new TreeItem<String>("Root Node");
    // ルートの子要素を作成
    TreeItem<String> item1 = new TreeItem<String>("Item 1");
    TreeItem<String> item2 = new TreeItem<String>("Item 2");
    TreeItem<String> item3 = new TreeItem<String>("Item 3");
    TreeItem<String> item4 = new TreeItem<String>("Item 4");
    // item4 の子要素
    TreeItem<String> item41 = new TreeItem<String>("Item 4-1");
    TreeItem<String> item42 = new TreeItem<String>("Item 4-2");
    TreeItem<String> item43 = new TreeItem<String>("Item 4-3");
    // item4 に子要素を追加する
    ObservableList<TreeItem<String>> image4tChildren = item4.getChildren();
    image4tChildren.add(item41);
    image4tChildren.add(item42);
    image4tChildren.add(item43);
    // ルート要素に子要素を追加する
    ObservableList<TreeItem<String>> rootChildren = root.getChildren();
    rootChildren.add(item1);
    rootChildren.add(item2);
    rootChildren.add(item3);
    rootChildren.add(item4);
    // 子を持つノードを開く
    root.setExpanded(true);
    item4.setExpanded(true);
    // TreeView にルート要素を指定しながらインスタンス化
    TreeView<String> treeView = new TreeView<String>(root);
    // シーン作成
    Scene scene = new Scene(treeView);
    stage.setScene(scene);
    stage.setTitle("Tree View Sample");
    stage.show();
}
Also used : TreeItem(javafx.scene.control.TreeItem) TreeView(javafx.scene.control.TreeView) Scene(javafx.scene.Scene)

Example 9 with TreeView

use of javafx.scene.control.TreeView in project MiscellaneousStudy by mikoto2000.

the class EditableTreeViewController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    // ルートの子要素を作成
    TreeItem<String> item1 = new TreeItem<String>("Item 1");
    TreeItem<String> item2 = new TreeItem<String>("Item 2");
    TreeItem<String> item3 = new TreeItem<String>("Item 3");
    TreeItem<String> item4 = new TreeItem<String>("Item 4");
    // item4 の子要素
    TreeItem<String> item41 = new TreeItem<String>("Item 4-1");
    TreeItem<String> item42 = new TreeItem<String>("Item 4-2");
    TreeItem<String> item43 = new TreeItem<String>("Item 4-3");
    // item4 に子要素を追加する
    ObservableList<TreeItem<String>> image4tChildren = item4.getChildren();
    image4tChildren.add(item41);
    image4tChildren.add(item42);
    image4tChildren.add(item43);
    TreeItem<String> root = new TreeItem<String>("root");
    treeView.setRoot(root);
    // ルート要素に子要素を追加する
    ObservableList<TreeItem<String>> rootChildren = root.getChildren();
    rootChildren.add(item1);
    rootChildren.add(item2);
    rootChildren.add(item3);
    rootChildren.add(item4);
    // 子を持つノードを開く
    root.setExpanded(true);
    item4.setExpanded(true);
    // 編集可能にする
    treeView.setEditable(true);
    treeView.setCellFactory((TreeView<String> p) -> {
        TextFieldTreeCell<String> cell = new TextFieldTreeCell<String>();
        // 編集した文字列を、
        // セルが持つデータに反映させるロジックを指定。
        // 今回はテキストフィールドに入力した文字列を
        // そのままセルが持つデータとして使うので、
        // DefaultStringConverter を使用。
        cell.setConverter(new DefaultStringConverter());
        return cell;
    });
}
Also used : DefaultStringConverter(javafx.util.converter.DefaultStringConverter) TreeItem(javafx.scene.control.TreeItem) TreeView(javafx.scene.control.TreeView) TextFieldTreeCell(javafx.scene.control.cell.TextFieldTreeCell)

Example 10 with TreeView

use of javafx.scene.control.TreeView in project PathWeaver by wpilibsuite.

the class MainController method setupTreeView.

private void setupTreeView(TreeView<String> treeView, TreeItem<String> treeRoot, MenuItem newItem) {
    treeView.setRoot(treeRoot);
    treeView.setContextMenu(new ContextMenu());
    treeView.getContextMenu().getItems().addAll(newItem, FxUtils.menuItem("Delete", event -> delete()));
    treeRoot.setExpanded(true);
    // Don't show the roots "Paths" and "Autons" - cleaner appearance
    treeView.setShowRoot(false);
}
Also used : Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) Path(edu.wpi.first.pathweaver.path.Path) TreeItem(javafx.scene.control.TreeItem) WpilibPath(edu.wpi.first.pathweaver.path.wpilib.WpilibPath) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ContextMenu(javafx.scene.control.ContextMenu) FXMLLoader(javafx.fxml.FXMLLoader) GridPane(javafx.scene.layout.GridPane) Pane(javafx.scene.layout.Pane) Alert(javafx.scene.control.Alert) KeyCode(javafx.scene.input.KeyCode) MenuItem(javafx.scene.control.MenuItem) Files(java.nio.file.Files) CurrentSelections(edu.wpi.first.pathweaver.global.CurrentSelections) IOException(java.io.IOException) KeyEvent(javafx.scene.input.KeyEvent) Logger(java.util.logging.Logger) TreeView(javafx.scene.control.TreeView) FXML(javafx.fxml.FXML) List(java.util.List) Stage(javafx.stage.Stage) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) ContextMenu(javafx.scene.control.ContextMenu)

Aggregations

TreeView (javafx.scene.control.TreeView)15 TreeItem (javafx.scene.control.TreeItem)7 Scene (javafx.scene.Scene)5 TreeCell (javafx.scene.control.TreeCell)5 ArrayList (java.util.ArrayList)4 BorderPane (javafx.scene.layout.BorderPane)4 VBox (javafx.scene.layout.VBox)4 List (java.util.List)3 Button (javafx.scene.control.Button)3 Image (javafx.scene.image.Image)3 ImageView (javafx.scene.image.ImageView)3 IOException (java.io.IOException)2 FXML (javafx.fxml.FXML)2 Alert (javafx.scene.control.Alert)2 MenuItem (javafx.scene.control.MenuItem)2 Tab (javafx.scene.control.Tab)2 TextFieldTreeCell (javafx.scene.control.cell.TextFieldTreeCell)2 KeyCode (javafx.scene.input.KeyCode)2 KeyEvent (javafx.scene.input.KeyEvent)2 MouseEvent (javafx.scene.input.MouseEvent)2