javafx.scene.control.TreeView Java Examples

The following examples show how to use javafx.scene.control.TreeView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TreeViewSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(
            new TreeItem<String>("Child Node 1"),
            new TreeItem<String>("Child Node 2"),
            new TreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(
            new TreeItem<String>("Child Node 4"),
            new TreeItem<String>("Child Node 5"),
            new TreeItem<String>("Child Node 6"),
            new TreeItem<String>("Child Node 7"),
            new TreeItem<String>("Child Node 8"),
            new TreeItem<String>("Child Node 9"),
            new TreeItem<String>("Child Node 10"),
            new TreeItem<String>("Child Node 11"),
            new TreeItem<String>("Child Node 12")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);

    getChildren().add(treeView);
}
 
Example #2
Source File: DataSourceTreeViewInit.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
/**
 * 刷新数据源下的 table
 * <p>
 * 对table
 */
private void refreshDataSource(TreeView<DataItem> treeViewDataSource) {
    TreeItem<DataItem> dataSourceTreeItem = treeViewDataSource.getSelectionModel().getSelectedItem();
    DataSource dataSource = (DataSource) dataSourceTreeItem.getValue();
    List<Table> tables = tableService.refreshTables(dataSource);
    if (!tables.isEmpty()) {
        ObservableList<TreeItem<DataItem>> children = dataSourceTreeItem.getChildren();
        children.remove(0, children.size());
        tables.forEach(table -> {
            TreeItem<DataItem> tableTreeItem = TreeUtils.add2Tree(table, dataSourceTreeItem);
            tableTreeItem.setGraphic(new ImageView("/image/table.png"));
        });
    }

    // 关闭右边的 Border 展示
    this.rightBorderShowClose(dataSource);
}
 
Example #3
Source File: TreeViewFactory.java    From ariADDna with Apache License 2.0 6 votes vote down vote up
/**
 * Customizing treeView
 *
 * @param tree treeView
 */
private void setTreeCellFactory(TreeView<SimpleTreeElement> tree) {
    tree.setCellFactory(param -> new TreeCell<SimpleTreeElement>() {
        @Override
        public void updateItem(SimpleTreeElement item, boolean empty) {
            super.updateItem(item, empty);
            //setDisclosureNode(null);

            if (empty) {
                setText("");
                setGraphic(null);
            } else {
                setText(item.getName());
            }
        }

    });

    tree.getSelectionModel().selectedItemProperty()
            .addListener((observable, oldValue, newValue) -> {
                if (newValue != null) {
                    System.out.println(newValue.getValue());
                }
            });
}
 
Example #4
Source File: FunctionStage.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private Node createTree() {
    VBox treeContentBox = new VBox();
    tree.setRoot(functionInfo.getRoot(true));
    tree.setShowRoot(false);
    tree.getSelectionModel().selectedItemProperty().addListener(new TreeViewSelectionChangeListener());
    tree.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
        @Override
        public TreeCell<Object> call(TreeView<Object> param) {
            return new FunctionTreeCell();
        }
    });
    filterByName.setOnAction((e) -> {
        tree.setRoot(functionInfo.refreshNode(filterByName.isSelected()));
        expandAll();
    });
    filterByName.setSelected(true);
    expandAll();
    treeContentBox.getChildren().addAll(topButtonBar, tree, filterByName);
    VBox.setVgrow(tree, Priority.ALWAYS);
    return treeContentBox;
}
 
Example #5
Source File: DockFX.java    From DockFX with GNU Lesser General Public License v3.0 6 votes vote down vote up
private TreeView<String> generateRandomTree() {
  // create a demonstration tree view to use as the contents for a dock node
  TreeItem<String> root = new TreeItem<String>("Root");
  TreeView<String> treeView = new TreeView<String>(root);
  treeView.setShowRoot(false);

  // populate the prototype tree with some random nodes
  Random rand = new Random();
  for (int i = 4 + rand.nextInt(8); i > 0; i--) {
    TreeItem<String> treeItem = new TreeItem<String>("Item " + i);
    root.getChildren().add(treeItem);
    for (int j = 2 + rand.nextInt(4); j > 0; j--) {
      TreeItem<String> childItem = new TreeItem<String>("Child " + j);
      treeItem.getChildren().add(childItem);
    }
  }

  return treeView;
}
 
Example #6
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public int getRowAt(TreeView<?> treeView, Point2D point) {
    if (point == null) {
        return treeView.getSelectionModel().getSelectedIndex();
    }
    point = treeView.localToScene(point);
    int itemCount = treeView.getExpandedItemCount();
    @SuppressWarnings("rawtypes")
    List<TreeCell> cells = new ArrayList<>();
    for (int i = 0; i < itemCount; i++) {
        cells.add(getCellAt(treeView, i));
    }
    TreeCell<?> selected = null;
    for (Node cellNode : cells) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (TreeCell<?>) cellNode;
            break;
        }
    }
    if (selected == null) {
        return -1;
    }
    return selected.getIndex();
}
 
Example #7
Source File: JavaFXTreeViewElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override
public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
    if (selector.equals("select-by-properties")) {
        return findNodeByProperties(new JSONObject((String) params[0]));
    } else if (selector.equals("root")) {
        return Arrays.asList(new JavaFXTreeViewNodeElement(this, 0));
    } else if (selector.equals("nth-node")) {
        return Arrays.asList(new JavaFXTreeViewNodeElement(this, ((Integer) params[0]).intValue() - 1));
    } else if (selector.equals("all-nodes")) {
        TreeView<?> treeView = (TreeView<?>) getComponent();
        ArrayList<IJavaFXElement> r = new ArrayList<>();
        int nrows = treeView.getExpandedItemCount();
        for (int i = 0; i < nrows; i++) {
            r.add(new JavaFXTreeViewNodeElement(this, i));
        }
        return r;
    }
    return super.getByPseudoElement(selector, params);
}
 
Example #8
Source File: FXTree.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
public FXTree()
{
    tree_view = new TreeView<>();
    tree_view.setCellFactory(cell -> new TreeModelItemCell());

    // Publish currently selected PV
    tree_view.getSelectionModel().selectedItemProperty().addListener((prop, old_item, selected) ->
    {
        ProcessVariable selection = null;
        if (selected != null)
        {
            final TreeModelItem item = selected.getValue();
            if (item.getSeverity() != null)
                selection = new ProcessVariable(item.getPVName());
        }
        SelectionService.getInstance().setSelection("PVTree", selection == null ? Collections.emptyList() : Arrays.asList(selection));
    });

    // Provide context menu
    createContextMenu();

    model.addListener(model_listener);
}
 
Example #9
Source File: JavaFXTreeViewElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private boolean setSelectionPath(String value) {
    TreeView<?> treeView = (TreeView<?>) getComponent();
    JSONArray pathElements = new JSONArray(value);
    List<TreeItem<?>> paths = new ArrayList<>();
    for (int i = 0; i < pathElements.length(); i++) {
        paths.add(getPath(treeView, pathElements.getString(i)));
    }
    treeView.getSelectionModel().clearSelection();
    for (@SuppressWarnings("rawtypes")
    TreeItem treeItem : paths) {
        if (getVisibleCellAt(treeView, treeItem) == null) {
            treeView.scrollTo(treeView.getRow(treeItem));
        }
        treeView.getSelectionModel().select(treeItem);
    }
    return true;
}
 
Example #10
Source File: JavaFXTreeViewNodeElement.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
    TreeView<?> treeView = (TreeView<?>) getComponent();
    @SuppressWarnings("rawtypes")
    TreeItem item = getPath(treeView, path);
    if (item == null)
        return Arrays.asList();
    if (getVisibleCellAt(treeView, item) == null) {
        EventQueueWait.exec(() -> treeView.scrollTo(treeView.getRow(item)));
        return Arrays.asList();
    }
    if (selector.equals("editor")) {
        return Arrays.asList(JavaFXElementFactory.createElement(getEditor(), driver, window));
    }
    return super.getByPseudoElement(selector, params);
}
 
Example #11
Source File: AnchorFX_settings.java    From AnchorFX with GNU Lesser General Public License v3.0 6 votes vote down vote up
private TreeView<String> generateRandomTree() {
    // create a demonstration tree view to use as the contents for a dock node
    TreeItem<String> root = new TreeItem<String>("Root");
    TreeView<String> treeView = new TreeView<String>(root);
    treeView.setShowRoot(false);

    // populate the prototype tree with some random nodes
    Random rand = new Random();
    for (int i = 4 + rand.nextInt(8); i > 0; i--) {
        TreeItem<String> treeItem = new TreeItem<String>("Item " + i);
        root.getChildren().add(treeItem);
        for (int j = 2 + rand.nextInt(4); j > 0; j--) {
            TreeItem<String> childItem = new TreeItem<String>("Child " + j);
            treeItem.getChildren().add(childItem);
        }
    }

    return treeView;
}
 
Example #12
Source File: TreeViewFactory.java    From ariADDna with Apache License 2.0 6 votes vote down vote up
/**
 * Generate treeView of file items
 * TODO: work with VUFS items
 *
 * @return tree view
 */
public TreeView<SimpleTreeElement> getSimple() {
    TreeView<SimpleTreeElement> tree = new TreeView<>();
    TreeItem<SimpleTreeElement> root = new TreeItem<>(new SimpleTreeElement("root", 0));
    TreeItem<SimpleTreeElement> outer1 =
            makeBranch(new SimpleTreeElement("Folder1", 1), root);
    TreeItem<SimpleTreeElement> outer2 =
            makeBranch(new SimpleTreeElement("Documents", 2), root);
    TreeItem<SimpleTreeElement> inner1;
    TreeItem<SimpleTreeElement> inner2;

    makeBranch(new SimpleTreeElement("MyFotos", 3), outer1);
    makeBranch(new SimpleTreeElement("OtherFiles", 4), outer1);
    makeBranch(new SimpleTreeElement("WorkFiles", 5), root);
    makeBranch(new SimpleTreeElement("Projects", 6), root);

    tree.setRoot(root);
    tree.setPrefWidth(200);

    setTreeCellFactory(tree);

    tree.setShowRoot(false);
    return tree;

}
 
Example #13
Source File: JavaFXTreeViewCheckBoxTreeCellElementTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectTreeItemCheckBoxSelectedNotSelected() {
    TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
    treeItem.setSelected(true);
    JSONObject o = new JSONObject();
    o.put("select", "/Root node/Child Node 2");
    IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
    IJavaFXElement cb = item.findElementByCssSelector(".::editor");
    cb.marathon_select("Child Node 2:unchecked");
    new Wait("Wait for tree item check box to be deselected") {
        @Override
        public boolean until() {
            String selected = cb.getAttribute("selected");
            return selected.equals("false");
        }
    };
}
 
Example #14
Source File: JavaFXTreeViewElementTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void marathon_select_none() throws Throwable {
    TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    Platform.runLater(() -> treeView.marathon_select("[\"/Root node/Child Node 2\"]"));
    new Wait("Waiting for the text item to be selected.") {
        @Override
        public boolean until() {
            return 2 == treeViewNode.getSelectionModel().getSelectedIndex();
        }
    };
    Platform.runLater(() -> treeView.marathon_select("[]"));
    new Wait("Waiting for no items selected.") {
        @Override
        public boolean until() {
            return 0 == treeViewNode.getSelectionModel().getSelectedIndices().size();
        }
    };
}
 
Example #15
Source File: PreferencesDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected JComponent getCenter()
{
	// Build the settings panel
	JPanel emptyPanel = new JPanel();
	emptyPanel.setPreferredSize(new Dimension(780, 420));

	settingsTree = new TreeView<>();
	settingsTree.setRoot(new TreeItem<>(null));

	// Build the split pane
	splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, GuiUtility.wrapParentAsJFXPanel(settingsTree),
			emptyPanel
	);
	splitPane.setOneTouchExpandable(true);
	splitPane.setDividerSize(10);

	return splitPane;
}
 
Example #16
Source File: FileBrowseService.java    From AsciidocFX with Apache License 2.0 6 votes vote down vote up
private void focusFoundItem(TreeItem<Item> searchFoundItem) {
    if (Objects.nonNull(searchFoundItem)) {

        TreeView<Item> fileSystemView = controller.getFileSystemView();
        threadService.runActionLater(() -> {

            fileSystemView.getSelectionModel().clearSelection();

            int selectedIndex = findIndex(searchFoundItem);

            fileSystemView.getSelectionModel().select(searchFoundItem);

            fileSystemView.scrollTo(selectedIndex);

            TreeItem<Item> parent = searchFoundItem.getParent();
            if (Objects.nonNull(parent)) {
                if (!parent.isExpanded()) {
                    parent.setExpanded(true);
                }
            }
        }, true);
    }
}
 
Example #17
Source File: TextFieldTreeViewSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TextFieldTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 1"), new TreeItem<String>("Child Node 2"),
            new TreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 4"),
            new TreeItem<String>("Child Node 5"), new TreeItem<String>("Child Node 6"), new TreeItem<String>("Child Node 7"),
            new TreeItem<String>("Child Node 8"), new TreeItem<String>("Child Node 9"), new TreeItem<String>("Child Node 10"),
            new TreeItem<String>("Child Node 11"), new TreeItem<String>("Child Node 12")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(TextFieldTreeCell.forTreeView());

    getChildren().add(treeView);
}
 
Example #18
Source File: ChoiceBoxTreeViewSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ChoiceBoxTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 1"), new TreeItem<String>("Option 2"),
            new TreeItem<String>("Option 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 4"),
            new TreeItem<String>("Option 5"), new TreeItem<String>("Option 6")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(ChoiceBoxTreeCell.forTreeView(items));

    getChildren().add(treeView);
}
 
Example #19
Source File: ComboBoxTreeViewSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ComboBoxTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 1"), new TreeItem<String>("Option 2"),
            new TreeItem<String>("Option 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 4"),
            new TreeItem<String>("Option 5"), new TreeItem<String>("Option 6")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(ComboBoxTreeCell.forTreeView(items));

    getChildren().add(treeView);
}
 
Example #20
Source File: CheckBoxTreeViewSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public CheckBoxTreeViewSample() {
    final CheckBoxTreeItem<String> treeRoot = new CheckBoxTreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new CheckBoxTreeItem<String>("Child Node 1"),
            new CheckBoxTreeItem<String>("Child Node 2"), new CheckBoxTreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren()
            .addAll(Arrays.asList(new CheckBoxTreeItem<String>("Child Node 4"), new CheckBoxTreeItem<String>("Child Node 5"),
                    new CheckBoxTreeItem<String>("Child Node 6"), new CheckBoxTreeItem<String>("Child Node 7"),
                    new TreeItem<String>("Child Node 8"), new CheckBoxTreeItem<String>("Child Node 9"),
                    new CheckBoxTreeItem<String>("Child Node 10"), new CheckBoxTreeItem<String>("Child Node 11"),
                    new CheckBoxTreeItem<String>("Child Node 12")));

    final TreeView treeView = new TreeView();
    treeView.setCellFactory(CheckBoxTreeCell.forTreeView());
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);

    getChildren().add(treeView);
}
 
Example #21
Source File: TreeViewSample1.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TreeViewSample1() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 1"), new TreeItem<String>("Child Node 2"),
            new TreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 4"),
            new TreeItem<String>("Child Node 5"), new TreeItem<String>("Child Node 6"), new TreeItem<String>("Child Node 7"),
            new TreeItem<String>("Child Node 8"), new TreeItem<String>("Child Node 9"), new TreeItem<String>("Child Node 10"),
            new TreeItem<String>("Child Node 11"), new TreeItem<String>("Child Node 12"), new TreeItem<String>("Child Node 13"),
            new TreeItem<String>("Child Node 14"), new TreeItem<String>("Child Node 15"), new TreeItem<String>("Child Node 16"),
            new TreeItem<String>("Child Node 17"), new TreeItem<String>("Child Node 18"), new TreeItem<String>("Child Node 19"),
            new TreeItem<String>("Child Node 20"), new TreeItem<String>("Child Node 21"), new TreeItem<String>("Child Node 22"),
            new TreeItem<String>("Child Node 23"), new TreeItem<String>("Child Node 24")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);

    getChildren().add(treeView);
}
 
Example #22
Source File: RFXTreeViewTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void getText() {
    @SuppressWarnings("rawtypes")
    TreeView treeView = (TreeView) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXTreeView rTreeView = new RFXTreeView(treeView, null, null, lr);
            treeView.getSelectionModel().select(2);
            rTreeView.focusLost(new RFXTreeView(null, null, null, null));
            text.add(rTreeView.getAttribute("text"));
        }
    });
    new Wait("Waiting for tree text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"/Root node/Child Node 2\"]", text.get(0));
}
 
Example #23
Source File: RFXTreeViewTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void getTextForMultipleSelection() {
    @SuppressWarnings("rawtypes")
    TreeView treeView = (TreeView) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXTreeView rTreeView = new RFXTreeView(treeView, null, null, lr);
            @SuppressWarnings("rawtypes")
            MultipleSelectionModel selectionModel = treeView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 3);
            rTreeView.focusLost(new RFXTreeView(null, null, null, null));
            text.add(rTreeView.getAttribute("text"));
        }
    });
    new Wait("Waiting for tree text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"/Root node/Child Node 2\",\"/Root node/Child Node 3\"]", text.get(0));
}
 
Example #24
Source File: RFXTreeViewCheckBoxTreeCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            Point2D point = getPoint(treeView, 1);
            RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
            rfxListView.focusGained(rfxListView);
            CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
            treeItem.setSelected(true);
            rfxListView.focusLost(rfxListView);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Child Node 1:checked", recording.getParameters()[0]);
}
 
Example #25
Source File: RFXTreeViewCheckBoxTreeCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectSelectedTreeItemCheckBox() {
    TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            Point2D point = getPoint(treeView, 1);
            RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
            CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
            treeItem.setSelected(true);
            rfxListView.focusGained(rfxListView);
            treeItem.setSelected(false);
            rfxListView.focusLost(rfxListView);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Child Node 1:unchecked", recording.getParameters()[0]);
}
 
Example #26
Source File: RFXTreeViewTextFieldTreeCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    @SuppressWarnings("unchecked")
    TreeView<String> treeView = (TreeView<String>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        TextFieldTreeCell<String> cell = (TextFieldTreeCell<String>) getCellAt(treeView, 2);
        Point2D point = getPoint(treeView, 2);
        RFXTreeView rfxTreeView = new RFXTreeView(treeView, null, point, lr);
        rfxTreeView.focusGained(rfxTreeView);
        cell.startEdit();
        cell.updateItem("Child node 4 Modified", false);
        cell.commitEdit("Child node 4 Modified");
        rfxTreeView.focusLost(rfxTreeView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Child node 4 Modified", recording.getParameters()[0]);
}
 
Example #27
Source File: RFXTreeViewChoiceBoxTreeCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    @SuppressWarnings("unchecked")
    TreeView<String> treeView = (TreeView<String>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        ChoiceBoxTreeCell<String> cell = (ChoiceBoxTreeCell<String>) getCellAt(treeView, 1);
        Point2D point = getPoint(treeView, 1);
        RFXTreeView rfxTreeView = new RFXTreeView(treeView, null, point, lr);
        rfxTreeView.focusGained(rfxTreeView);
        cell.startEdit();
        cell.updateItem("Option 5", false);
        cell.commitEdit("Option 5");
        rfxTreeView.focusLost(rfxTreeView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Option 5", recording.getParameters()[0]);
}
 
Example #28
Source File: RFXTreeViewComboBoxListCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void select() {
    @SuppressWarnings("unchecked")
    TreeView<String> treeView = (TreeView<String>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        ComboBoxTreeCell<String> cell = (ComboBoxTreeCell<String>) getCellAt(treeView, 1);
        Point2D point = getPoint(treeView, 1);
        RFXTreeView rfxTreeView = new RFXTreeView(treeView, null, point, lr);
        rfxTreeView.focusGained(rfxTreeView);
        cell.startEdit();
        cell.updateItem("Option 3", false);
        cell.commitEdit("Option 3");
        rfxTreeView.focusLost(rfxTreeView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Option 3", recording.getParameters()[0]);
}
 
Example #29
Source File: RFXTreeViewComboBoxListCellTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectEditable() {
    @SuppressWarnings("unchecked")
    TreeView<String> treeView = (TreeView<String>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        ComboBoxTreeCell<String> cell = (ComboBoxTreeCell<String>) getCellAt(treeView, 1);
        cell.setComboBoxEditable(true);
        Point2D point = getPoint(treeView, 1);
        RFXTreeView rfxtreeView = new RFXTreeView(treeView, null, point, lr);
        rfxtreeView.focusGained(rfxtreeView);
        cell.startEdit();
        cell.updateItem("Option 5", false);
        cell.commitEdit("Option 5");
        rfxtreeView.focusLost(rfxtreeView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Option 5", recording.getParameters()[0]);
}
 
Example #30
Source File: Properties.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
public Properties(final ScanEditor editor, final TreeView<ScanCommand> scan_tree, final UndoableActionManager undo)
{
    this.editor = editor;
    this.scan_tree = scan_tree;
    this.undo = undo;
    scroll.setFitToWidth(true);
    scroll.setMinHeight(0);

    setText("Command Detail");
    setContent(scroll);
    setCollapsible(false);
    setMaxHeight(Double.MAX_VALUE);

    // Scan tree allows selecting multiple items,
    // so could listen to getSelectedItems(),
    // but that one does not update when a new item it added
    // and the ScanCommandTree programmatically selects the new item.
    // The property view handles a single item only, anyway,
    // and selectedItemProperty() calls listener even when set
    // programmatically, i.e. for newly added command
    scan_tree.getSelectionModel().selectedItemProperty().addListener((p, old, item) -> setCommand(item));
}