Example usage for javafx.scene.control SelectionModel select

List of usage examples for javafx.scene.control SelectionModel select

Introduction

In this page you can find the example usage for javafx.scene.control SelectionModel select.

Prototype

public abstract void select(T obj);

Source Link

Document

This method will attempt to select the index that contains the given object.

Usage

From source file:net.sourceforge.pmd.util.fxdesigner.SourceEditorController.java

public void focusNodeInTreeView(Node node) {
    SelectionModel<TreeItem<Node>> selectionModel = astTreeView.getSelectionModel();

    // node is different from the old one
    if (selectedTreeItem == null && node != null
            || selectedTreeItem != null && !Objects.equals(node, selectedTreeItem.getValue())) {
        ASTTreeItem found = ((ASTTreeItem) astTreeView.getRoot()).findItem(node);
        if (found != null) {
            selectionModel.select(found);
        }//from ww  w  .j av a2s . co m
        selectedTreeItem = found;

        astTreeView.getFocusModel().focus(selectionModel.getSelectedIndex());
        if (!treeViewWrapper.isIndexVisible(selectionModel.getSelectedIndex())) {
            astTreeView.scrollTo(selectionModel.getSelectedIndex());
        }
    }
}