javafx.scene.control.SelectionModel Java Examples

The following examples show how to use javafx.scene.control.SelectionModel. 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: AstTreeView.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Focus the given node, handling scrolling if needed.
 */
@Override
public void setFocusNode(final Node node, DataHolder options) {
    SelectionModel<TreeItem<Node>> selectionModel = getSelectionModel();

    if (getRoot() == null || getRoot().getValue() == null) {
        return;
    }

    mapToMyTree(getRoot().getValue(), node, options.getData(CARET_POSITION))
        .map(((ASTTreeItem) getRoot())::findItem)
        .ifPresent(found -> {
            // don't fire any selection event while itself setting the selected item
            suppressibleSelectionEvents.suspendWhile(() -> selectionModel.select(found));

        });

    getFocusModel().focus(selectionModel.getSelectedIndex());
    if (!isIndexVisible(selectionModel.getSelectedIndex())) {
        scrollTo(selectionModel.getSelectedIndex());
    }
}
 
Example #2
Source File: AppUtils.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public static void disableIfNotSelected(SelectionModel selectionModel, Node... nodes) {
	BooleanBinding selected = selectionModel.selectedItemProperty().isNull();
	for (Node node : nodes) {
		node.disableProperty().bind(selected);
	}
}
 
Example #3
Source File: AppUtils.java    From java-ml-projects with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
public static void disableIfNotSelected(SelectionModel selectionModel, Node... nodes) {
	BooleanBinding selected = selectionModel.selectedItemProperty().isNull();
	for (Node node : nodes) {
		node.disableProperty().bind(selected);
	}
}