public class SelectionEventManager extends java.lang.Object implements DataSelectionListener, MainLayerManager.ActiveLayerChangeListener
DatasetEventManager
, just for selection events.
It allows to register listeners to global selection events for the selection in the current edit layer.
If you want to listen to selections to a specific data layer,
you can register a listener to that layer by using DataSet.addSelectionListener(DataSelectionListener)
Modifier and Type | Class and Description |
---|---|
private static class |
SelectionEventManager.DataListenerInfo |
private static interface |
SelectionEventManager.ListenerInfo |
DataSelectionListener.AbstractSelectionEvent, DataSelectionListener.SelectionAddEvent, DataSelectionListener.SelectionChangeEvent, DataSelectionListener.SelectionRemoveEvent, DataSelectionListener.SelectionReplaceEvent, DataSelectionListener.SelectionToggleEvent
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo> |
immediatelyListeners |
private java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo> |
inEDTListeners |
private static SelectionEventManager |
INSTANCE |
Modifier | Constructor and Description |
---|---|
protected |
SelectionEventManager()
Constructs a new
SelectionEventManager . |
Modifier and Type | Method and Description |
---|---|
void |
activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Called whenever the active or edit layer changed.
|
void |
addSelectionListener(DataSelectionListener listener)
Adds a selection listener that gets notified for selections immediately.
|
void |
addSelectionListenerForEdt(DataSelectionListener listener)
Adds a selection listener that gets notified for selections later in the EDT thread.
|
private static void |
fireEvent(java.util.List<SelectionEventManager.ListenerInfo> listeners,
DataSelectionListener.SelectionChangeEvent event) |
static SelectionEventManager |
getInstance()
Returns the unique instance.
|
private void |
remove(SelectionEventManager.ListenerInfo searchListener) |
void |
removeSelectionListener(DataSelectionListener listener)
Unregisters a
DataSelectionListener . |
void |
resetState()
Only to be used during unit tests, to reset the state.
|
void |
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.
|
private static final SelectionEventManager INSTANCE
private final java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo> inEDTListeners
private final java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo> immediatelyListeners
protected SelectionEventManager()
SelectionEventManager
.public static SelectionEventManager getInstance()
public void addSelectionListener(DataSelectionListener listener)
listener
- The listener to add.public void addSelectionListenerForEdt(DataSelectionListener listener)
listener
- The listener to add.public void removeSelectionListener(DataSelectionListener listener)
DataSelectionListener
.listener
- listener to removeprivate void remove(SelectionEventManager.ListenerInfo searchListener)
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
MainLayerManager.ActiveLayerChangeListener
You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
activeOrEditLayerChanged
in interface MainLayerManager.ActiveLayerChangeListener
e
- The change event.public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
DataSelectionListener
selectionChanged
in interface DataSelectionListener
event
- The selection change event.DataSelectionListener.SelectionChangeEvent
private static void fireEvent(java.util.List<SelectionEventManager.ListenerInfo> listeners, DataSelectionListener.SelectionChangeEvent event)
public void resetState()