Package ghidra.framework.plugintool.mgr

# Class EventManager

java.lang.Object
ghidra.framework.plugintool.mgr.EventManager

public class EventManager extends 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

  Modifier and Type
  Method
  Description
  `void`
  `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 produce
  `void`
  `addToolListener(ToolListener listener)`
  Add the given tool listener to be notified when tool events are generated
  `void`
  `clear()`
  Clear last plugin events fired, current event, listeners, etc.
  `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.
  `String[]`
  `getEventsConsumed()`
  Get the names of all events consumed by plugins in the tool.
  `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 class
  `void`
  `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

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### EventManager

    public EventManager(PluginTool tool)
    Construct a new EventManager.
    Parameters:
      `tool` - plugin tool associated with this EventManager

- ## Method Details

  - ### addEventListener

    public 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.
    Parameters:
      `eventClass` - class of the event of interest
      `listener` - listener to notify

  - ### addAllEventListener

    public void addAllEventListener(PluginEventListener listener)

  - ### removeAllEventListener

    public void removeAllEventListener(PluginEventListener listener)

  - ### 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 interest
      `listener` - listener to remove

  - ### addToolListener

    public void addToolListener(ToolListener listener)
    Add the given tool listener to be 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 class
    Returns:
      true if there are any listeners

  - ### addEventProducer

    public void addEventProducer(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(Class<? extends PluginEvent> eventClass)
    Remove the class of a PluginEvent that a plugin produces.
    Parameters:
      `eventClass` - class for the PluginEvent

  - ### getEventsProduced

    public String[] getEventsProduced()
    Get the names of all events produced by plugins in the tool.
    Returns:
      array of PluginEvent names

  - ### getEventsConsumed

    public 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; 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

    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(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)