Package ghidra.framework.plugintool.mgr
Class EventManager
- java.lang.Object
-
- ghidra.framework.plugintool.mgr.EventManager
-
public class EventManager extends java.lang.Object
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
Constructors Constructor Description EventManager(PluginTool tool)
Construct a new EventManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAllEventListener(PluginEventListener listener)
void
addEventListener(java.lang.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(java.lang.Class<? extends PluginEvent> eventClass)
Add the class for the PluginEvent that a plugin will produce.void
addToolListener(ToolListener listener)
Add the given tool listener to a list of tool listeners notified when tool events are generated.void
clearLastEvents()
Clear the list of last plugin events fired.void
fireEvent(PluginEvent event)
Notify all plugin listeners that are registered to consume the given event.java.lang.String[]
getEventsConsumed()
Get the names of all events consumed by plugins in the tool.java.lang.String[]
getEventsProduced()
Get the names of all events produced by plugins in the tool.PluginEvent[]
getLastEvents()
Return an array of the last plugin events fired.boolean
hasToolListeners()
Return whether there are any registered tool listeners for the tool associated with this EventManager.void
processToolEvent(PluginEvent event)
Convert the given tool event to a plugin event, and notify the appropriate plugin event listeners.void
removeAllEventListener(PluginEventListener listener)
void
removeEventListener(java.lang.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(java.lang.String className)
Remove the event listener by className; the plugin registered for events, but the construction failed.void
removeEventProducer(java.lang.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 Detail
-
EventManager
public EventManager(PluginTool tool)
Construct a new EventManager.- Parameters:
tool
- plugin tool associated with this EventManager
-
-
Method Detail
-
addEventListener
public void addEventListener(java.lang.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.- Parameters:
eventClass
- class of the event of interestlistener
- listener to notify
-
addAllEventListener
public void addAllEventListener(PluginEventListener listener)
-
removeAllEventListener
public void removeAllEventListener(PluginEventListener listener)
-
removeEventListener
public void removeEventListener(java.lang.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
public void addToolListener(ToolListener listener)
Add the given tool listener to a list of tool listeners notified when tool events are generated.- Parameters:
listener
- listener to add
-
removeToolListener
public void removeToolListener(ToolListener listener)
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 this EventManager.
-
addEventProducer
public void addEventProducer(java.lang.Class<? extends PluginEvent> eventClass)
Add the class for the PluginEvent that a plugin will produce.- Parameters:
eventClass
- class for the PluginEvent
-
removeEventProducer
public void removeEventProducer(java.lang.Class<? extends PluginEvent> eventClass)
Remove the class of a PluginEvent that a plugin produces.- Parameters:
eventClass
- class for the PluginEvent
-
getEventsProduced
public java.lang.String[] getEventsProduced()
Get the names of all events produced by plugins in the tool.- Returns:
- array of PluginEvent names
-
getEventsConsumed
public java.lang.String[] getEventsConsumed()
Get the names of all events consumed by plugins in the tool.- Returns:
- array of PluginEvent names
-
fireEvent
public void fireEvent(PluginEvent event)
Notify all plugin listeners that are registered to consume the given event. Events are fired in the SwingThread.- Parameters:
event
- event to fire
-
processToolEvent
public void processToolEvent(PluginEvent event)
Convert the given tool event to a plugin event, and notify the appropriate plugin event listeners.- Parameters:
event
- tool event
-
clearLastEvents
public void clearLastEvents()
Clear the list of last plugin events fired.
-
getLastEvents
public PluginEvent[] 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
public void removeEventListener(java.lang.String className)
Remove the event listener by className; the plugin registered for events, but the construction failed.- Parameters:
className
- class name of the plugin (event listener)
-
-