Package ghidra.framework.plugintool.mgr
Class EventManager
java.lang.Object
ghidra.framework.plugintool.mgr.EventManager
Helper class to manage the events that plugins consume and produce. This class keeps track of the
last events that went out so that when a plugin is added, it receives those events.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllEventListener
(PluginEventListener listener) void
addEventListener
(Class<? extends PluginEvent> eventClass, PluginEventListener listener) Add a plugin event listener that will be notified when an event of the given event class is generated.void
addEventProducer
(Class<? extends PluginEvent> eventClass) Add the class for the PluginEvent that a plugin will producevoid
addToolListener
(ToolListener listener) Add the given tool listener to be notified notified when tool events are generatedvoid
clear()
Clear last plugin events fired, current event, listeners, etc.void
Clear the list of last plugin events firedvoid
fireEvent
(PluginEvent event) Notify all plugin listeners that are registered to consume the given event.String[]
Get the names of all events consumed by plugins in the tool.String[]
Get the names of all events produced by plugins in the tool.Return an array of the last plugin events fired.boolean
Return whether there are any registered tool listeners for the tool associated with classvoid
processToolEvent
(PluginEvent event) Convert the given tool event to a plugin event; notify the appropriate plugin listeners.void
removeAllEventListener
(PluginEventListener listener) void
removeEventListener
(Class<? extends PluginEvent> eventClass, PluginEventListener listener) Remove the plugin event listener from the list of listeners notified when an event of the given event class is generated.void
removeEventListener
(String className) Remove the event listener by className; the plugin registered for events, but the construction failed.void
removeEventProducer
(Class<? extends PluginEvent> eventClass) Remove the class of a PluginEvent that a plugin produces.void
removeToolListener
(ToolListener listener) Remove the given tool listener from the list of tool listeners
-
Constructor Details
-
EventManager
Construct a new EventManager.- Parameters:
tool
- plugin tool associated with this EventManager
-
-
Method Details
-
addEventListener
Add a plugin event listener that will be notified when an event of the given event class is generated.- Parameters:
eventClass
- class of the event of interestlistener
- listener to notify
-
addAllEventListener
-
removeAllEventListener
-
removeEventListener
public void removeEventListener(Class<? extends PluginEvent> eventClass, PluginEventListener listener) Remove the plugin event listener from the list of listeners notified when an event of the given event class is generated.- Parameters:
eventClass
- class of the event of interestlistener
- listener to remove
-
addToolListener
Add the given tool listener to be notified notified when tool events are generated- Parameters:
listener
- listener to add
-
removeToolListener
Remove the given tool listener from the list of tool listeners- Parameters:
listener
- listener to remove
-
hasToolListeners
public boolean hasToolListeners()Return whether there are any registered tool listeners for the tool associated with class- Returns:
- true if there are any listeners
-
addEventProducer
Add the class for the PluginEvent that a plugin will produce- Parameters:
eventClass
- class for the PluginEvent
-
removeEventProducer
Remove the class of a PluginEvent that a plugin produces.- Parameters:
eventClass
- class for the PluginEvent
-
getEventsProduced
Get the names of all events produced by plugins in the tool.- Returns:
- array of PluginEvent names
-
getEventsConsumed
Get the names of all events consumed by plugins in the tool.- Returns:
- array of PluginEvent names
-
fireEvent
Notify all plugin listeners that are registered to consume the given event. Events are fired in the SwingThread.- Parameters:
event
- event to fire
-
processToolEvent
Convert the given tool event to a plugin event; notify the appropriate plugin listeners. This method allows one tool's event manager to send events to another connected tool.- Parameters:
event
- tool event
-
clearLastEvents
public void clearLastEvents()Clear the list of last plugin events fired -
clear
public void clear()Clear last plugin events fired, current event, listeners, etc. -
getLastEvents
Return an array of the last plugin events fired. EventManager maps the event class to the last event fired.- Returns:
- array of plugin events
-
removeEventListener
Remove the event listener by className; the plugin registered for events, but the construction failed.- Parameters:
className
- class name of the plugin (event listener)
-