Class SelectionModel
- All Implemented Interfaces:
IAdaptable.Bound<IViewer>
,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.-
Property Summary
TypePropertyDescriptionjavafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>>
Returns an unmodifiable read-only list property that represents the current selection.Properties inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl
adaptable
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound
IAdaptable.Bound.Impl<T extends IAdaptable>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of theselectionUnmodifiableProperty()
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
appendToSelection
(List<? extends IContentPart<? extends javafx.scene.Node>> toBeAppended) Updates the current selection by adding the givenIContentPart
s to it, preserving already selected elements.void
appendToSelection
(IContentPart<? extends javafx.scene.Node> toBeAppended) Updates the current selection by adding the givenIContentPart
to it, preserving already selected elements.void
Clears the current selection.void
dispose()
javafx.collections.ObservableList<IContentPart<? extends javafx.scene.Node>>
Returns an unmodifiable observable list of the currently selectedIContentPart
s.boolean
isSelected
(IContentPart<? extends javafx.scene.Node> contentPart) Returns whether the givenIContentPart
is part of the current selection.void
prependToSelection
(List<? extends IContentPart<? extends javafx.scene.Node>> toBePrepended) Updates the current selection by adding the givenIContentPart
s to it, preserving already selected elements.void
prependToSelection
(IContentPart<? extends javafx.scene.Node> toBePrepended) Updates the current selection by adding the givenIContentPart
to it, preserving already selected elements.void
removeFromSelection
(Collection<? extends IContentPart<? extends javafx.scene.Node>> contentParts) Removes the givenIContentPart
s from the current selection if they are contained.void
removeFromSelection
(IContentPart<? extends javafx.scene.Node> contentPart) Removes the givenIContentPart
from the current selection if it is currently selected.javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>>
Returns an unmodifiable read-only list property that represents the current selection.void
setAdaptable
(IViewer adaptable) void
setSelection
(List<? extends IContentPart<? extends javafx.scene.Node>> selection) Replaces the current selection with the given list ofIContentPart
s.void
setSelection
(IContentPart<? extends javafx.scene.Node> newSelection) Replaces the current selection with the givenIContentPart
.Methods inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl
adaptableProperty, getAdaptable
-
Property Details
-
selectionUnmodifiable
public javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>> selectionUnmodifiablePropertyReturns an unmodifiable read-only list property that represents the current selection.- See Also:
-
-
Field Details
-
SELECTION_PROPERTY
Name of theselectionUnmodifiableProperty()
.- See Also:
-
-
Constructor Details
-
SelectionModel
public SelectionModel()
-
-
Method Details
-
appendToSelection
Updates the current selection by adding the givenIContentPart
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.
- Parameters:
toBeAppended
- TheIContentPart
to add to/move to the back of the current selection.
-
appendToSelection
public void appendToSelection(List<? extends IContentPart<? extends javafx.scene.Node>> toBeAppended) Updates the current selection by adding the givenIContentPart
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).
- Parameters:
toBeAppended
- TheIContentPart
s to add to/move to the back of the current selection.
-
clearSelection
public void clearSelection()Clears the current selection. -
dispose
public void dispose()- Specified by:
dispose
in interfaceIDisposable
- Since:
- 1.1
-
getSelectionUnmodifiable
public javafx.collections.ObservableList<IContentPart<? extends javafx.scene.Node>> getSelectionUnmodifiable()Returns an unmodifiable observable list of the currently selectedIContentPart
s.- Returns:
- An unmodifiable observable list of the currently selected
IContentPart
s.
-
isSelected
Returns whether the givenIContentPart
is part of the current selection.- Parameters:
contentPart
- TheIContentPart
which is checked for containment.- Returns:
true
if theIContentPart
is contained by the current selection.
-
prependToSelection
Updates the current selection by adding the givenIContentPart
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.
- Parameters:
toBePrepended
- TheIContentPart
to add to/move to the front of the current selection.
-
prependToSelection
public void prependToSelection(List<? extends IContentPart<? extends javafx.scene.Node>> toBePrepended) Updates the current selection by adding the givenIContentPart
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).
- Parameters:
toBePrepended
- TheIContentPart
s to add to/move to the front of the current selection.
-
removeFromSelection
public void removeFromSelection(Collection<? extends IContentPart<? extends javafx.scene.Node>> contentParts) Removes the givenIContentPart
s from the current selection if they are contained. Ignores those that are not part of the current selection.- Parameters:
contentParts
- TheIContentPart
s which are removed from the selection.
-
removeFromSelection
Removes the givenIContentPart
from the current selection if it is currently selected. Will not change the current selection otherwise.- Parameters:
contentPart
- TheIContentPart
that is to be removed from the selection.
-
selectionUnmodifiableProperty
public javafx.beans.property.ReadOnlyListProperty<IContentPart<? extends javafx.scene.Node>> selectionUnmodifiableProperty()Returns an unmodifiable read-only list property that represents the current selection.- See Also:
-
setAdaptable
- Specified by:
setAdaptable
in interfaceIAdaptable.Bound<IViewer>
- Overrides:
setAdaptable
in classIAdaptable.Bound.Impl<IViewer>
-
setSelection
Replaces the current selection with the givenIContentPart
.- Parameters:
newSelection
- TheIContentPart
constituting the new selection.
-
setSelection
Replaces the current selection with the given list ofIContentPart
s.- Parameters:
selection
- The list ofIContentPart
s constituting the new selection.
-