Package com.macrofocus.common.selection
Interface Selection<E>
- Type Parameters:
E
- the type of elements that can be selected
- All Superinterfaces:
Iterable<E>
- All Known Subinterfaces:
MutableSelection<E>
,MutableSingleSelection<E>
,SingleSelection<E>
- All Known Implementing Classes:
AbstractMutableSelection
,AbstractMutableSingleSelection
,AbstractSelection
,BeanSingleSelection
,NullSelection
,NullSingleSelection
,PropertySingleSelection
,SimpleSelection
,SimpleSingleSelection
This interface represents the current state of a selection. A selection is to be understood in the broad sense and
not only related to user interactions.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSelectionListener
(SelectionListener<E> listener) Add a listener to the list that's notified each time a change to the selection occurs.void
addWeakSelectionListener
(SelectionListener<E> listener) Add a listener to the list that's notified each time a change to the selection occurs.int
Returns the number of elements currently selected.Returns the selected elements as a Set.boolean
isActive()
Indicates whether at least one element is currently selected.boolean
boolean
isSelected
(E element) Indicates whether a given element is selected or not.void
removeSelectionListener
(SelectionListener<E> listener) Remove a listener to the list that's notified each time a change to the selection occurs.void
Remove all listeners to the list that's notified each time a change to the selection occurs.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
isActive
boolean isActive()Indicates whether at least one element is currently selected.- Returns:
- true if at least one element is selected, false otherwise.
-
isSelected
Indicates whether a given element is selected or not.- Parameters:
element
- the element to be tested- Returns:
- true if the element is selected, false otherwise
-
getSelectedSet
Returns the selected elements as a Set.- Returns:
- the Set of selected elements.
-
getSelectedCount
int getSelectedCount()Returns the number of elements currently selected.- Returns:
- the number of selected elements.
-
addSelectionListener
Add a listener to the list that's notified each time a change to the selection occurs.- Parameters:
listener
- the SelectionListener
-
addWeakSelectionListener
Add a listener to the list that's notified each time a change to the selection occurs. The listener will automatically be disposed of should no other object have a reference to it.- Parameters:
listener
- the SelectionListener
-
removeSelectionListener
Remove a listener to the list that's notified each time a change to the selection occurs.- Parameters:
listener
- the SelectionListener
-
removeSelectionListeners
void removeSelectionListeners()Remove all listeners to the list that's notified each time a change to the selection occurs. -
isEnabled
boolean isEnabled()
-