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 |
private static class |
SelectionEventManager.OldListenerInfo |
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> |
immedatelyListeners |
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 |
addSelectionListener(SelectionChangedListener listener,
DatasetEventManager.FireMode fireMode)
Registers a new
SelectionChangedListener . |
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 |
removeSelectionListener(SelectionChangedListener listener)
Unregisters a
SelectionChangedListener . |
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> immedatelyListeners
protected SelectionEventManager()
SelectionEventManager
.public static SelectionEventManager getInstance()
public void addSelectionListener(SelectionChangedListener listener, DatasetEventManager.FireMode fireMode)
SelectionChangedListener
.
It is preferred to add a DataSelectionListener - that listener will receive more information about the event.listener
- listener to addfireMode
- Set this to IN_EDT_CONSOLIDATED if you want the event to be fired in the EDT thread.
Set it to IMMEDIATELY if you want the event to fire in the thread that caused the selection update.public void addSelectionListener(DataSelectionListener listener)
listener
- The listener to add.public void addSelectionListenerForEdt(DataSelectionListener listener)
listener
- The listener to add.public void removeSelectionListener(SelectionChangedListener listener)
SelectionChangedListener
.listener
- listener to removepublic 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()