public class SelectionModel extends IAdaptable.Bound.Impl<IViewer> implements IDisposable
SelectionModel
is used to store the current viewer's selection.
It represents the selection as an ordered list of IContentPart
s.
Thereby, it supports a multi-selection and allows to identify a primary
selection (the head element of the list) that may be treated specially.Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>> |
selectionUnmodifiable
Returns an unmodifiable read-only list property that represents the
current selection.
|
adaptable
IAdaptable.Bound.Impl<T extends IAdaptable>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SELECTION_PROPERTY
Name of the
selectionUnmodifiableProperty() . |
Constructor and Description |
---|
SelectionModel() |
Modifier and Type | Method and Description |
---|---|
void |
appendToSelection(IContentPart<? extends javafx.scene.Node> toBeAppended)
Updates the current selection by adding the given
IContentPart to
it, preserving already selected elements. |
void |
appendToSelection(java.util.List<? extends IContentPart<? extends javafx.scene.Node>> toBeAppended)
Updates the current selection by adding the given
IContentPart s
to it, preserving already selected elements. |
void |
clearSelection()
Clears the current selection.
|
void |
dispose() |
javafx.collections.ObservableList<IContentPart<? extends javafx.scene.Node>> |
getSelectionUnmodifiable()
Returns an unmodifiable observable list of the currently selected
IContentPart s. |
boolean |
isSelected(IContentPart<? extends javafx.scene.Node> contentPart)
Returns whether the given
IContentPart is part of the current
selection. |
void |
prependToSelection(IContentPart<? extends javafx.scene.Node> toBePrepended)
Updates the current selection by adding the given
IContentPart to
it, preserving already selected elements. |
void |
prependToSelection(java.util.List<? extends IContentPart<? extends javafx.scene.Node>> toBePrepended)
Updates the current selection by adding the given
IContentPart s
to it, preserving already selected elements. |
void |
removeFromSelection(java.util.Collection<? extends IContentPart<? extends javafx.scene.Node>> contentParts)
Removes the given
IContentPart s from the current selection if
they are contained. |
void |
removeFromSelection(IContentPart<? extends javafx.scene.Node> contentPart)
Removes the given
IContentPart from the current selection if it
is currently selected. |
javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>> |
selectionUnmodifiableProperty()
Returns an unmodifiable read-only list property that represents the
current selection.
|
void |
setAdaptable(IViewer adaptable) |
void |
setSelection(IContentPart<? extends javafx.scene.Node> newSelection)
Replaces the current selection with the given
IContentPart . |
void |
setSelection(java.util.List<? extends IContentPart<? extends javafx.scene.Node>> selection)
Replaces the current selection with the given list of
IContentPart s. |
adaptableProperty, getAdaptable
public javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>> selectionUnmodifiableProperty
getSelectionUnmodifiable()
public static final java.lang.String SELECTION_PROPERTY
selectionUnmodifiableProperty()
.public void appendToSelection(IContentPart<? extends javafx.scene.Node> toBeAppended)
IContentPart
to
it, preserving already selected elements.
If the given content part is not already selected, it will be added to the back of the given selection, otherwise it will be moved to the back. A member of the current selection that is not contained in the given list, will remain selected.
toBeAppended
- The IContentPart
to add to/move to the back of the
current selection.public void appendToSelection(java.util.List<? extends IContentPart<? extends javafx.scene.Node>> toBeAppended)
IContentPart
s
to it, preserving already selected elements.
A member of the given list that is not contained in the current selection, will be added to it. A member of the current selection that is not contained in the given list, will remain selected.
The selection order will be adjusted, so that the members of the given list are added at the back (in the order they are given), preceded by the already selected elements not contained in the given list (preserving their relative order).
toBeAppended
- The IContentPart
s to add to/move to the back of the
current selection.public void clearSelection()
public void dispose()
dispose
in interface IDisposable
public javafx.collections.ObservableList<IContentPart<? extends javafx.scene.Node>> getSelectionUnmodifiable()
IContentPart
s.IContentPart
s.public boolean isSelected(IContentPart<? extends javafx.scene.Node> contentPart)
IContentPart
is part of the current
selection.contentPart
- The IContentPart
which is checked for containment.true
if the IContentPart
is contained by the
current selection.public void prependToSelection(IContentPart<? extends javafx.scene.Node> toBePrepended)
IContentPart
to
it, preserving already selected elements.
If the given content part is not already selected, it will be added to the front of the given selection, otherwise it will be moved to the front. A member of the current selection that is not contained in the given list, will remain selected.
toBePrepended
- The IContentPart
to add to/move to the front of the
current selection.public void prependToSelection(java.util.List<? extends IContentPart<? extends javafx.scene.Node>> toBePrepended)
IContentPart
s
to it, preserving already selected elements.
A member of the given list that is not contained in the current selection, will be added to it. A member of the current selection that is not contained in the given list, will remain selected.
The selection order will be adjusted, so that the members of the given list are added in front (in the order they are given), followed by the already selected elements not contained in the given list (preserving their relative order).
toBePrepended
- The IContentPart
s to add to/move to the front of the
current selection.public void removeFromSelection(java.util.Collection<? extends IContentPart<? extends javafx.scene.Node>> contentParts)
IContentPart
s from the current selection if
they are contained. Ignores those that are not part of the current
selection.contentParts
- The IContentPart
s which are removed from the
selection.public void removeFromSelection(IContentPart<? extends javafx.scene.Node> contentPart)
IContentPart
from the current selection if it
is currently selected. Will not change the current selection otherwise.contentPart
- The IContentPart
that is to be removed from the
selection.public javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>> selectionUnmodifiableProperty()
getSelectionUnmodifiable()
public void setAdaptable(IViewer adaptable)
setAdaptable
in interface IAdaptable.Bound<IViewer>
setAdaptable
in class IAdaptable.Bound.Impl<IViewer>
public void setSelection(IContentPart<? extends javafx.scene.Node> newSelection)
IContentPart
.newSelection
- The IContentPart
constituting the new selection.public void setSelection(java.util.List<? extends IContentPart<? extends javafx.scene.Node>> selection)
IContentPart
s.selection
- The list of IContentPart
s constituting the new
selection.Copyright (c) 2014, 2016 itemis AG and others. All rights reserved.