Example usage for javafx.scene.control SelectionModel getSelectedIndex

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

Introduction

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

Prototype

public final int getSelectedIndex() 

Source Link

Document

Returns the integer value indicating the currently selected index in this model.

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);
        }// w  w  w .j a  va  2s. c o  m
        selectedTreeItem = found;

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