Java Code Examples for javafx.scene.control.MultipleSelectionModel#getSelectedIndex()

The following examples show how to use javafx.scene.control.MultipleSelectionModel#getSelectedIndex() . 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: WidgetTree.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Called by selection handler when selected widgets have changed, or on new model
 *  @param widgets Widgets to select in tree
 */
public void setSelectedWidgets(final List<Widget> widgets)
{
    if (! active.compareAndSet(false, true))
        return;
    try
    {
        final MultipleSelectionModel<TreeItem<WidgetOrTab>> selection = tree_view.getSelectionModel();
        selection.clearSelection();
        for (Widget widget : widgets)
            selection.select(widget2tree.get(widget));

        // If something's selected, show it.
        // Otherwise leave tree at current position.
        final int index = selection.getSelectedIndex();
        if (index >= 0)
            tree_view.scrollTo(index);
    }
    finally
    {
        active.set(false);
    }
}
 
Example 2
Source File: UpDownHandler.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(ActionEvent event) {
    MultipleSelectionModel<ClassPathElement> selectionModel = classPathListView.getSelectionModel();
    ObservableList<ClassPathElement> items = classPathListView.getItems();
    int selectedIndex = selectionModel.getSelectedIndex();
    ClassPathElement selectedItem = selectionModel.getSelectedItem();
    items.remove(selectedItem);
    if (shouldMoveUp) {
        items.add(selectedIndex - 1, selectedItem);
    } else {
        items.add(selectedIndex + 1, selectedItem);
    }
    selectionModel.clearAndSelect(items.indexOf(selectedItem));
}
 
Example 3
Source File: HistoryUpDownHandler.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(ActionEvent event) {
    MultipleSelectionModel<JSONObject> selectionModel = historyView.getSelectionModel();
    ObservableList<JSONObject> items = historyView.getItems();
    int selectedIndex = selectionModel.getSelectedIndex();
    JSONObject selectedItem = selectionModel.getSelectedItem();
    items.remove(selectedItem);
    if (shouldMoveUp) {
        items.add(selectedIndex - 1, selectedItem);
    } else {
        items.add(selectedIndex + 1, selectedItem);
    }
    selectionModel.select(selectedItem);
    TestRunnerHistory.getInstance().rewrite("favourites", items);
}