Search in sources :

Example 1 with TreeView

use of javafx.scene.control.TreeView in project Gargoyle by callakrsos.

the class FilteredTreeItemExam method start.

@Override
public void start(Stage primaryStage) throws Exception {
    FilterableTreeItem<String> filterableTreeItem = new FilterableTreeItem<>("");
    filterableTreeItem.setExpanded(true);
    TreeView<String> treeView = new TreeView<>(filterableTreeItem);
    treeView.setShowRoot(false);
    treeView.setRoot(filterableTreeItem);
    BorderPane borderPane = new BorderPane(treeView);
    TextField value = new TextField();
    value.textProperty().addListener((oba, oldval, newval) -> {
        Callable<TreeItemPredicate<String>> func = () -> {
            Predicate<String> predicate = str -> str.indexOf(newval) >= 0;
            return TreeItemPredicate.<String>create(predicate);
        };
        ObjectBinding<TreeItemPredicate<String>> createObjectBinding = Bindings.createObjectBinding(func, hide);
        filterableTreeItem.predicateProperty().bind(createObjectBinding);
    });
    borderPane.setTop(value);
    Scene scene = new Scene(borderPane);
    primaryStage.setScene(scene);
    primaryStage.show();
    FilterableTreeItem<String> e = new FilterableTreeItem<>("ABC");
    //		e.getChildren().add(new FilterableTreeItem<>("DEF"));
    //		e.getChildren().add(new FilterableTreeItem<>("김aa"));
    //		e.getChildren().add(new FilterableTreeItem<>("김bb"));
    //		e.getChildren().add(new FilterableTreeItem<>("김cc"));
    //		filterableTreeItem.getChildren().add(e);
    //		filterableTreeItem.getChildren().add(new FilterableTreeItem<>("DEF"));
    //		filterableTreeItem.getChildren().add(new FilterableTreeItem<>("김DD"));
    //
    e.getSourceChildren().add(new FilterableTreeItem<>("DEF"));
    e.getSourceChildren().add(new FilterableTreeItem<>("김aa"));
    e.getSourceChildren().add(new FilterableTreeItem<>("김bb"));
    e.getSourceChildren().add(new FilterableTreeItem<>("김cc"));
    filterableTreeItem.getSourceChildren().add(e);
    filterableTreeItem.getSourceChildren().add(new FilterableTreeItem<>("DEF"));
    filterableTreeItem.getSourceChildren().add(new FilterableTreeItem<>("김DD"));
// filterableTreeItem.predicateProperty()
// .bind(Bindings.createObjectBinding(() ->
// TreeItemPredicate<String>.create(str -> str.indexOf("김") >= 0),
// hide));
}
Also used : BorderPane(javafx.scene.layout.BorderPane) FilterableTreeItem(com.kyj.fx.voeditor.visual.component.tree.FilterableTreeItem) Scene(javafx.scene.Scene) Predicate(java.util.function.Predicate) TreeItemPredicate(com.kyj.fx.voeditor.visual.component.tree.TreeItemPredicate) TreeItemPredicate(com.kyj.fx.voeditor.visual.component.tree.TreeItemPredicate) TreeView(javafx.scene.control.TreeView) TextField(javafx.scene.control.TextField)

Example 2 with TreeView

use of javafx.scene.control.TreeView in project Challenger4SysAdmins by fvarrui.

the class TreeEditorController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    treeView.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {

        public TreeCell<Object> call(TreeView<Object> param) {
            return new CustomTreeCell();
        }
    });
    challenge.addListener((o, ov, nv) -> {
        if (nv != null)
            treeView.setRoot(new ChallengeTreeItem(nv));
        else
            treeView.setRoot(null);
    });
    selectedItem.addListener((o, ov, nv) -> {
        if (nv != null) {
            seleccionado.set(nv.getValue());
        } else {
            seleccionado.set(null);
        }
    });
    selectedItem.bind(treeView.getSelectionModel().selectedItemProperty());
    addButton.disableProperty().bind(seleccionado.isNull());
    deleteButton.disableProperty().bind(seleccionado.isNull());
}
Also used : CustomTreeCell(fvarrui.sysadmin.editor.components.tree.CustomTreeCell) TreeCell(javafx.scene.control.TreeCell) CustomTreeCell(fvarrui.sysadmin.editor.components.tree.CustomTreeCell) TreeView(javafx.scene.control.TreeView) ChallengeTreeItem(fvarrui.sysadmin.editor.components.tree.ChallengeTreeItem)

Example 3 with TreeView

use of javafx.scene.control.TreeView in project blue by kunstmusik.

the class BlueJFXControlsApplication method setTreeViewTest.

private void setTreeViewTest(TabPane root) {
    TreeView<String> tv = new TreeView<>();
    tv.setRoot(new TreeItem<>("TEST"));
    root.getTabs().add(new Tab("TreeView", tv));
}
Also used : Tab(javafx.scene.control.Tab) TreeView(javafx.scene.control.TreeView)

Example 4 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 5 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)

Aggregations

TreeView (javafx.scene.control.TreeView)9 TreeItem (javafx.scene.control.TreeItem)4 Scene (javafx.scene.Scene)3 TreeCell (javafx.scene.control.TreeCell)3 Image (javafx.scene.image.Image)3 BorderPane (javafx.scene.layout.BorderPane)3 Insets (javafx.geometry.Insets)2 TextFieldTreeCell (javafx.scene.control.cell.TextFieldTreeCell)2 MouseEvent (javafx.scene.input.MouseEvent)2 FilterableTreeItem (com.kyj.fx.voeditor.visual.component.tree.FilterableTreeItem)1 TreeItemPredicate (com.kyj.fx.voeditor.visual.component.tree.TreeItemPredicate)1 FilePathTreeItem (com.negativevr.media_library.storage.FilePathTreeItem)1 MomentAddTypeController (controller.controller.MomentAddTypeController)1 MomentRemoveTypeController (controller.controller.MomentRemoveTypeController)1 TypeController (controller.controller.TypeController)1 InterviewTreeView (controller.interviewTreeView.InterviewTreeView)1 TypeTreeView (controller.typeTreeView.TypeTreeView)1 Layer (fractal.Layer)1 Palette (fractal.Palette)1 RenderManager (fractal.RenderManager)1