VR - The visual root node of the UI toolkit used, e.g.
javafx.scene.Node in case of JavaFX.public class SelectionModel<VR> extends java.lang.Object implements IPropertyChangeNotifier
SelectionModel is used to store the current viewer's selection.
It represents the selection as an ordered list of IContentParts.
Thereby, it supports a multi-selection and allows to identify a primary
selection (the head element of the list) that may be treated specially.
The SelectionModel is an IPropertyChangeNotifier and will
notify about changes to the selection, using the SELECTION_PROPERTY
property name.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
SELECTION_PROPERTY
"selection"
The property name which is used for
PropertyChangeEvents. |
| Constructor and Description |
|---|
SelectionModel() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
appendToSelection(IContentPart<VR,? extends VR> toBeAppended)
Updates the current selection by adding the given
IContentPart to
it, preserving already selected elements. |
void |
appendToSelection(java.util.List<? extends IContentPart<VR,? extends VR>> toBeAppended)
Updates the current selection by adding the given
IContentParts
to it, preserving already selected elements. |
void |
clearSelection()
Clears the current selection.
|
java.util.List<IContentPart<VR,? extends VR>> |
getSelection()
Returns an unmodifiable list of the currently selected
IContentParts. |
boolean |
isSelected(IContentPart<VR,? extends VR> contentPart)
Returns whether the given
IContentPart is part of the current
selection. |
void |
prependToSelection(IContentPart<VR,? extends VR> toBePrepended)
Updates the current selection by adding the given
IContentPart to
it, preserving already selected elements. |
void |
prependToSelection(java.util.List<? extends IContentPart<VR,? extends VR>> toBePrepended)
Updates the current selection by adding the given
IContentParts
to it, preserving already selected elements. |
void |
removeFromSelection(java.util.Collection<? extends IContentPart<VR,? extends VR>> contentParts)
Removes the given
IContentParts from the current selection if
they are contained. |
void |
removeFromSelection(IContentPart<VR,? extends VR> contentPart)
Removes the given
IContentPart from the current selection if it
is currently selected. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
setSelection(IContentPart<VR,? extends VR> newSelection)
Replaces the current selection with the given
IContentPart. |
void |
setSelection(java.util.List<? extends IContentPart<VR,? extends VR>> newSelection)
Replaces the current selection with the given list of
IContentPart s. |
public static final java.lang.String SELECTION_PROPERTY
"selection"The property name which is used for
PropertyChangeEvents.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface IPropertyChangeNotifierpublic void appendToSelection(IContentPart<VR,? extends VR> 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<VR,? extends VR>> toBeAppended)
IContentParts
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 IContentParts to add to/move to the back of the
current selection.public void clearSelection()
public java.util.List<IContentPart<VR,? extends VR>> getSelection()
IContentParts.IContentParts.public boolean isSelected(IContentPart<VR,? extends VR> 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<VR,? extends VR> 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<VR,? extends VR>> toBePrepended)
IContentParts
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 IContentParts to add to/move to the front of the
current selection.public void removeFromSelection(java.util.Collection<? extends IContentPart<VR,? extends VR>> contentParts)
IContentParts from the current selection if
they are contained. Ignores those that are not part of the current
selection.contentParts - The IContentParts which are removed from the
selection.public void removeFromSelection(IContentPart<VR,? extends VR> 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 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface IPropertyChangeNotifierpublic void setSelection(IContentPart<VR,? extends VR> newSelection)
IContentPart.newSelection - The IContentPart constituting the new selection.public void setSelection(java.util.List<? extends IContentPart<VR,? extends VR>> newSelection)
IContentPart s.newSelection - The list of IContentParts constituting the new
selection.Copyright (c) 2014 itemis AG and others. All rights reserved.