Class SelectionEventManager
java.lang.Object
org.openstreetmap.josm.data.osm.event.SelectionEventManager
- All Implemented Interfaces:
DataSelectionListener,MainLayerManager.ActiveLayerChangeListener
public class SelectionEventManager
extends Object
implements DataSelectionListener, MainLayerManager.ActiveLayerChangeListener
Similar like
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)- Since:
- 2912
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static interfaceNested 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
FieldsModifier and TypeFieldDescriptionprivate final CopyOnWriteArrayList<SelectionEventManager.ListenerInfo>private final CopyOnWriteArrayList<SelectionEventManager.ListenerInfo>private static final SelectionEventManager -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a newSelectionEventManager. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled whenever the active or edit layer changed.voidaddSelectionListener(DataSelectionListener listener) Adds a selection listener that gets notified for selections immediately.voidAdds a selection listener that gets notified for selections later in the EDT thread.private static voidfireEvent(List<SelectionEventManager.ListenerInfo> listeners, DataSelectionListener.SelectionChangeEvent event) static SelectionEventManagerReturns the unique instance.private voidremove(SelectionEventManager.ListenerInfo searchListener) voidremoveSelectionListener(DataSelectionListener listener) Unregisters aDataSelectionListener.voidOnly to be used during unit tests, to reset the state.voidCalled whenever the selection is changed.
-
Field Details
-
INSTANCE
-
inEDTListeners
-
immediatelyListeners
-
-
Constructor Details
-
SelectionEventManager
protected SelectionEventManager()Constructs a newSelectionEventManager.
-
-
Method Details
-
getInstance
Returns the unique instance.- Returns:
- the unique instance
-
addSelectionListener
Adds a selection listener that gets notified for selections immediately.- Parameters:
listener- The listener to add.- Since:
- 12098
-
addSelectionListenerForEdt
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
Unregisters aDataSelectionListener.- Parameters:
listener- listener to remove- Since:
- 12098
-
remove
-
activeOrEditLayerChanged
Description copied from interface:MainLayerManager.ActiveLayerChangeListenerCalled 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:
activeOrEditLayerChangedin interfaceMainLayerManager.ActiveLayerChangeListener- Parameters:
e- The change event.
-
selectionChanged
Description copied from interface:DataSelectionListenerCalled 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:
selectionChangedin interfaceDataSelectionListener- Parameters:
event- The selection change event.- See Also:
-
fireEvent
private static void fireEvent(List<SelectionEventManager.ListenerInfo> listeners, DataSelectionListener.SelectionChangeEvent event) -
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.
-