Class SelectionEventManager
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.event.SelectionEventManager
-
- All Implemented Interfaces:
DataSelectionListener
,MainLayerManager.ActiveLayerChangeListener
public class SelectionEventManager extends java.lang.Object implements DataSelectionListener, MainLayerManager.ActiveLayerChangeListener
Similar likeDatasetEventManager
, 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 usingDataSet.addSelectionListener(DataSelectionListener)
- Since:
- 2912
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SelectionEventManager.DataListenerInfo
private static interface
SelectionEventManager.ListenerInfo
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.osm.DataSelectionListener
DataSelectionListener.AbstractSelectionEvent, DataSelectionListener.SelectionAddEvent, DataSelectionListener.SelectionChangeEvent, DataSelectionListener.SelectionRemoveEvent, DataSelectionListener.SelectionReplaceEvent, DataSelectionListener.SelectionToggleEvent
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo>
immediatelyListeners
private java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo>
inEDTListeners
private static SelectionEventManager
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description protected
SelectionEventManager()
Constructs a newSelectionEventManager
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 aDataSelectionListener
.void
resetState()
Only to be used during unit tests, to reset the state.void
selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Called whenever the selection is changed.
-
-
-
Field Detail
-
INSTANCE
private static final SelectionEventManager INSTANCE
-
inEDTListeners
private final java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo> inEDTListeners
-
immediatelyListeners
private final java.util.concurrent.CopyOnWriteArrayList<SelectionEventManager.ListenerInfo> immediatelyListeners
-
-
Constructor Detail
-
SelectionEventManager
protected SelectionEventManager()
Constructs a newSelectionEventManager
.
-
-
Method Detail
-
getInstance
public static SelectionEventManager getInstance()
Returns the unique instance.- Returns:
- the unique instance
-
addSelectionListener
public void addSelectionListener(DataSelectionListener listener)
Adds a selection listener that gets notified for selections immediately.- Parameters:
listener
- The listener to add.- Since:
- 12098
-
addSelectionListenerForEdt
public void addSelectionListenerForEdt(DataSelectionListener listener)
Adds a selection listener that gets notified for selections later in the EDT thread. Events are sent in the right order but may be delayed.- Parameters:
listener
- The listener to add.- Since:
- 12098
-
removeSelectionListener
public void removeSelectionListener(DataSelectionListener listener)
Unregisters aDataSelectionListener
.- Parameters:
listener
- listener to remove- Since:
- 12098
-
remove
private void remove(SelectionEventManager.ListenerInfo searchListener)
-
activeOrEditLayerChanged
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Description copied from interface:MainLayerManager.ActiveLayerChangeListener
Called whenever the active or edit layer changed.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.
- Specified by:
activeOrEditLayerChanged
in interfaceMainLayerManager.ActiveLayerChangeListener
- Parameters:
e
- The change event.
-
selectionChanged
public void selectionChanged(DataSelectionListener.SelectionChangeEvent event)
Description copied from interface:DataSelectionListener
Called whenever the selection is changed. You get notified about the new selection, the elements that were added and removed and the layer that triggered the event.- Specified by:
selectionChanged
in interfaceDataSelectionListener
- Parameters:
event
- The selection change event.- See Also:
DataSelectionListener.SelectionChangeEvent
-
fireEvent
private static void fireEvent(java.util.List<SelectionEventManager.ListenerInfo> listeners, DataSelectionListener.SelectionChangeEvent event)
-
resetState
public void resetState()
Only to be used during unit tests, to reset the state. Do not use it in plugins/other code. Called after the layer manager was reset by the test framework.
-
-