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());
}
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();
}
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();
}
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;
});
}
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);
}
Aggregations