Package org.graffiti.event
Class ListenerManager
java.lang.Object
org.graffiti.event.ListenerManager
public class ListenerManager extends Object
Class that is responsible to keep track of all the Listeners that are
registered. It therefore provides methods to add and remove certain types of
Listeners. It also contains methods representing all available events. When
one of these methods is called, the
ListenerManager
delegates
the call to all Listeners registered in the appropriate listener set. When a
listener is registered as strict, it does not get any messages during the
time a transaction is active (i.e. between transactionStarted
and transactionFinished
). Non strict listeners receive events
independent of transactions. It is not possible to add a Listener both as
strict and non strict. At the end of a transaction, a set is passed within a
TransactionEvent
that contains all objects that (might) have
been changed. This set is passed to both, strict and non strict listeners.- Version:
- $Revision: 1.18 $
-
Constructor Summary
Constructors Constructor Description ListenerManager()
Default contructor. -
Method Summary
Modifier and Type Method Description void
addAllTimeAttributeListener(AttributeListener l)
Registers AttributeListener l by adding it to the list of nonstrict and strict transaction AttributeListeners.void
addAllTimeEdgeListener(EdgeListener l)
Registers EdgeListener l by adding it to the list of nonstrict transaction EdgeListeners.void
addAllTimeGraphListener(GraphListener l)
Registers GraphListener l by adding it to the list of GraphListeners.void
addAllTimeNodeListener(NodeListener l)
RegistersNodeListener
l by adding it to the list of nonstrict transaction NodeListeners.void
addDelayedAttributeListener(AttributeListener l)
Registers AttributeListener l by adding it to the list of strict transaction AttributeListeners.void
addDelayedEdgeListener(EdgeListener l)
Registers EdgeListener l by adding it to the list of strict transaction EdgeListeners.void
addDelayedGraphListener(GraphListener l)
Registers GraphListener l by adding it to the list of strict transaction GraphListeners.void
addDelayedNodeListener(NodeListener l)
RegistersNodeListener
l by adding it to the list of strict transaction NodeListeners.void
finishOpenTransactions()
int
getNumTransactionsActive()
void
postAttributeAdded(AttributeEvent event)
Called after an attribute has been added.void
postAttributeChanged(AttributeEvent event)
Called after an attribute has been changed.void
postAttributeRemoved(AttributeEvent event)
Called after an attribute has been removed.void
postDirectedChanged(EdgeEvent event)
Called after the edge was set directed or undirected.void
postEdgeAdded(GraphEvent event)
Called after an edge has been added to the graph.void
postEdgeRemoved(GraphEvent event)
Called after an edge has been removed from the graph.void
postEdgeReversed(EdgeEvent event)
Called after the edge has been reversed.void
postGraphCleared(GraphEvent event)
Called after methodclear()
has been called on a graph.void
postNodeAdded(GraphEvent event)
Called after an edge has been added to the graph.void
postNodeRemoved(GraphEvent event)
Called after a node has been removed from the graph.void
postSourceNodeChanged(EdgeEvent event)
Called after the source node of an edge has changed.void
postTargetNodeChanged(EdgeEvent event)
Called after the target node of an edge has changed.void
postUndirectedEdgeAdded(NodeEvent event)
Called after an (undirected) edge has been added to the node.void
postUndirectedEdgeRemoved(NodeEvent event)
Called after an (undirected) edge has been removed from the node.void
preAttributeAdded(AttributeEvent event)
Called just before an attribute is added.void
preAttributeChanged(AttributeEvent event)
Called before a change of an attribute takes place.void
preAttributeRemoved(AttributeEvent event)
Called just before an attribute is removed.void
preDirectedChanged(EdgeEvent event)
Called before the edge is set directed or undirected.void
preEdgeAdded(GraphEvent event)
Called just before an edge is added to the graph.void
preEdgeRemoved(GraphEvent event)
Called just before an edge is removed from the graph.void
preEdgeReversed(EdgeEvent event)
Called before the edge is going to be reversed.void
preGraphCleared(GraphEvent event)
Called before methodclear()
is called on a graph.void
preNodeAdded(GraphEvent event)
Called just before a node is added to the graph.void
preNodeRemoved(GraphEvent event)
Called just before a node is removed from the graph.void
preSourceNodeChanged(EdgeEvent event)
Called before a change of the source node of an edge takes place.void
preTargetNodeChanged(EdgeEvent event)
Called before a change of the target node of an edge takes place.void
preUndirectedEdgeAdded(NodeEvent event)
Called just before an (undirected) edge is added to the node.void
preUndirectedEdgeRemoved(NodeEvent event)
Called just before an (undirected) edge is removed from the node.void
removeAttributeListener(AttributeListener l)
Unregisters AttributeListener l by removing it from the list of AttributeListeners.void
removeEdgeListener(EdgeListener l)
Unregisters EdgeListener l by removing it from the list of EdgeListeners.void
removeGraphListener(GraphListener l)
Unregisters GraphListener l by removing it from the list of non-strict and strict transaction GraphListeners.void
removeNodeListener(NodeListener l)
UnregistersNodeListener
l by removing it from the list of NodeListenersvoid
transactionFinished(Object source)
Called when a transaction has finished.void
transactionFinished(Object source, boolean forgetChanges)
void
transactionFinished(Object source, boolean forgetChanges, BackgroundTaskStatusProviderSupportingExternalCall status)
void
transactionStarted(Object source)
Called when a transaction has started.
-
Constructor Details
-
ListenerManager
public ListenerManager()Default contructor. Initializes all listener sets as empty hash sets.
-
-
Method Details
-
addAllTimeAttributeListener
Registers AttributeListener l by adding it to the list of nonstrict and strict transaction AttributeListeners.- Parameters:
l
- the AttributeListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addAllTimeEdgeListener
Registers EdgeListener l by adding it to the list of nonstrict transaction EdgeListeners.- Parameters:
l
- the EdgeListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addAllTimeGraphListener
Registers GraphListener l by adding it to the list of GraphListeners.- Parameters:
l
- the GraphListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addAllTimeNodeListener
RegistersNodeListener
l by adding it to the list of nonstrict transaction NodeListeners.- Parameters:
l
- the NodeListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addDelayedAttributeListener
Registers AttributeListener l by adding it to the list of strict transaction AttributeListeners.- Parameters:
l
- the AttributeListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addDelayedEdgeListener
Registers EdgeListener l by adding it to the list of strict transaction EdgeListeners.- Parameters:
l
- the EdgeListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addDelayedGraphListener
Registers GraphListener l by adding it to the list of strict transaction GraphListeners.- Parameters:
l
- the GraphListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
addDelayedNodeListener
RegistersNodeListener
l by adding it to the list of strict transaction NodeListeners.- Parameters:
l
- the NodeListener that is registered.- Throws:
ListenerRegistrationException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!
-
postAttributeAdded
Called after an attribute has been added. Calls the same method in allAttributeListeners
in thestrictAttributeListenerList
- Parameters:
event
- the AttributeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postAttributeChanged
Called after an attribute has been changed. Calls the same method in allAttributeListeners
in thestrictAttributeListenerList
- Parameters:
event
- the AttributeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postAttributeRemoved
Called after an attribute has been removed. Calls the same method in allAttributeListeners
in thestrictAttributeListenerList
- Parameters:
event
- the AttributeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postDirectedChanged
Called after the edge was set directed or undirected. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postEdgeAdded
Called after an edge has been added to the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postEdgeRemoved
Called after an edge has been removed from the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postEdgeReversed
Called after the edge has been reversed. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postGraphCleared
Called after methodclear()
has been called on a graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postNodeAdded
Called after an edge has been added to the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postNodeRemoved
Called after a node has been removed from the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postSourceNodeChanged
Called after the source node of an edge has changed. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postTargetNodeChanged
Called after the target node of an edge has changed. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postUndirectedEdgeAdded
Called after an (undirected) edge has been added to the node. (For directed edges pre- In/Out- EdgeAdded is called.) Calls the same method in all NodeListeners in the strictNodeListenerList- Parameters:
event
- the NodeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
postUndirectedEdgeRemoved
Called after an (undirected) edge has been removed from the node. (For directed edges pre- In/Out- EdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList- Parameters:
event
- the NodeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preAttributeAdded
Called just before an attribute is added. Calls the same method in allAttributeListeners
in thestrictAttributeListenerList
- Parameters:
event
- the AttributeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preAttributeChanged
Called before a change of an attribute takes place. Calls the same method in allAttributeListeners
in thestrictAttributeListenerList
- Parameters:
event
- the AttributeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preAttributeRemoved
Called just before an attribute is removed. Calls the same method in allAttributeListeners
in thestrictAttributeListenerList
- Parameters:
event
- the AttributeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preDirectedChanged
Called before the edge is set directed or undirected. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preEdgeAdded
Called just before an edge is added to the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preEdgeRemoved
Called just before an edge is removed from the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preEdgeReversed
Called before the edge is going to be reversed. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preGraphCleared
Called before methodclear()
is called on a graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preNodeAdded
Called just before a node is added to the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preNodeRemoved
Called just before a node is removed from the graph. Calls the same method in allGraphListeners
in thestrictGraphListenerList
- Parameters:
event
- the GraphEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preSourceNodeChanged
Called before a change of the source node of an edge takes place. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preTargetNodeChanged
Called before a change of the target node of an edge takes place. Calls the same method in allEdgeListeners
in thestrictEdgeListenerList
- Parameters:
event
- the EdgeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preUndirectedEdgeAdded
Called just before an (undirected) edge is added to the node. (For directed edges pre- In/Out- EdgeAdded is called.) Calls the same method in all NodeListeners in the strictNodeListenerList- Parameters:
event
- the NodeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
preUndirectedEdgeRemoved
Called just before an (undirected) edge is removed from the node. (For directed edges pre- In/Out- EdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList- Parameters:
event
- the NodeEvent detailing the changes.- Throws:
IllegalArgumentException
- DOCUMENT ME!
-
removeAttributeListener
Unregisters AttributeListener l by removing it from the list of AttributeListeners.- Parameters:
l
- the AttributeListener that is unregistered.- Throws:
ListenerNotFoundException
- if the listener to delete cannot be found in the listener list.
-
removeEdgeListener
Unregisters EdgeListener l by removing it from the list of EdgeListeners.- Parameters:
l
- the EdgeListener that is unregistered.- Throws:
ListenerNotFoundException
- if the listener to delete cannot be found in the listener list.
-
removeGraphListener
Unregisters GraphListener l by removing it from the list of non-strict and strict transaction GraphListeners.- Parameters:
l
- the GraphListener that is unregistered.- Throws:
ListenerNotFoundException
- if the listener to delete cannot be found in the listener list.
-
removeNodeListener
UnregistersNodeListener
l by removing it from the list of NodeListeners- Parameters:
l
- the NodeListener that is unregistered.- Throws:
ListenerNotFoundException
- if the listener to delete cannot be found in the listener list.
-
finishOpenTransactions
public void finishOpenTransactions() -
transactionFinished
Called when a transaction has finished. Changes the event it gets by reusing thesource
but adding theSet
of (probably) changed objects.- Parameters:
source
- the object, which initiated the end of the transaction.
-
transactionFinished
-
transactionFinished
public void transactionFinished(Object source, boolean forgetChanges, BackgroundTaskStatusProviderSupportingExternalCall status) -
transactionStarted
Called when a transaction has started.- Parameters:
source
- the object, which initiated the transaction.
-
getNumTransactionsActive
public int getNumTransactionsActive()
-