private void clearSelection(JFXListView<?> selectedList) { if (allowClear) { allowClear = false; if (this != selectedList) { this.getSelectionModel().clearSelection(); } for (int i = 0; i < sublistsProperty.get().size(); i++) { if (sublistsProperty.get().get(i) != selectedList) { sublistsProperty.get().get(i).getSelectionModel().clearSelection(); } } allowClear = true; } }
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (newValue != null) { TreeItem<DisplayWorkflowClassesModel> item = search(workflowView.getRoot(), newValue); if (item != null) { workflowView.getSelectionModel().select(item); } else { workflowView.getSelectionModel().clearSelection(); } } if (newValue == null) { workflowView.getSelectionModel().clearSelection(); } } });
/** * Deselect the old/previous selection * * @param container The list view in which the selection should be updated * @param oldSelection The old/previous selection */ private void updateOldSelection(ListView<CompactListElement<E>> container, ListWidgetSelection<E> oldSelection) { // deselect the old element Optional.ofNullable(oldSelection).map(ListWidgetSelection::getSelection).ifPresent(selection -> { final int oldValueIndex = getControl().getElements().indexOf(selection); // In some corner cases (category / filter changes, the current selection can disappear) if (mappedElements.size() > oldValueIndex && oldValueIndex != -1) { container.getSelectionModel().clearSelection(oldValueIndex); } }); }
/** * Deselect the old/previous selection * * @param container The list view in which the selection should be updated * @param oldSelection The old/previous selection */ private void updateOldSelection(ListView<DetailsListElement<E>> container, ListWidgetSelection<E> oldSelection) { // deselect the old element Optional.ofNullable(oldSelection).map(ListWidgetSelection::getSelection).ifPresent(selection -> { final int oldValueIndex = getControl().getElements().indexOf(selection); // In some corner cases (category / filter changes, the current selection can disappear) if (mappedElements.size() > oldValueIndex && oldValueIndex != -1) { container.getSelectionModel().clearSelection(oldValueIndex); } }); }
private void clearSelection(JFXListView<?> selectedList) { if (allowClear) { allowClear = false; if (this != selectedList) { this.getSelectionModel().clearSelection(); } for (int i = 0; i < sublistsProperty.get().size(); i++) { if (sublistsProperty.get().get(i) != selectedList) { sublistsProperty.get().get(i).getSelectionModel().clearSelection(); } } allowClear = true; } }
private void moveToTargetAll() { move(getSourceListView(), getTargetListView(), new ArrayList<>( getSourceListView().getItems())); getSourceListView().getSelectionModel().clearSelection(); }
private void moveToSourceAll() { move(getTargetListView(), getSourceListView(), new ArrayList<>( getTargetListView().getItems())); getTargetListView().getSelectionModel().clearSelection(); }
private void moveToTarget() { move(getSourceListView(), getTargetListView()); getSourceListView().getSelectionModel().clearSelection(); }
private void moveToSource() { move(getTargetListView(), getSourceListView()); getTargetListView().getSelectionModel().clearSelection(); }
/** * {@inheritDoc} */ @Override public void initializeParts() { super.initializeParts(); getStyleClass().add("simple-listview-control"); fieldLabel = new Label(field.labelProperty().getValue()); listView.setItems(field.getItems()); listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); for (int i = 0; i < field.getItems().size(); i++) { if (field.getSelection().contains(field.getItems().get(i))) { listView.getSelectionModel().select(i); } else { listView.getSelectionModel().clearSelection(i); } } }
/** * {@inheritDoc} */ @Override public void setupValueChangedListeners() { super.setupValueChangedListeners(); field.itemsProperty().addListener((observable, oldValue, newValue) -> listView.setItems(field.getItems())); field.selectionProperty().addListener((observable, oldValue, newValue) -> { if (preventUpdate) { return; } preventUpdate = true; for (int i = 0; i < field.getItems().size(); i++) { if (field.getSelection().contains(field.getItems().get(i))) { listView.getSelectionModel().select(i); } else { listView.getSelectionModel().clearSelection(i); } } preventUpdate = false; }); field.errorMessagesProperty().addListener((observable, oldValue, newValue) -> toggleTooltip(listView)); field.tooltipProperty().addListener((observable, oldValue, newValue) -> toggleTooltip(listView)); listView.focusedProperty().addListener((observable, oldValue, newValue) -> toggleTooltip(listView)); }
tree.getSelectionModel().clearSelection(); for (TreeItem<TreeData> item : treeViewTraverser.breadthFirst(tree.getRoot())) { programmaticallySelect=true;