edu.rice.cs.drjava.model.debug
Class DebugEventNotifier

java.lang.Object
  extended by edu.rice.cs.drjava.model.EventNotifier<DebugListener>
      extended by edu.rice.cs.drjava.model.debug.DebugEventNotifier
All Implemented Interfaces:
DebugListener, RegionManagerListener<Breakpoint>

public class DebugEventNotifier
extends EventNotifier<DebugListener>
implements DebugListener

Keeps track of all listeners to a Debugger, and has the ability to notify them of some event.

This class has a specific role of managing DebugListeners. Other classes with similar names use similar code to perform the same function for other interfaces, e.g. InteractionsEventNotifier and GlobalEventNotifier. These classes implement the appropriate interface definition so that they can be used transparently as composite packaging for a particular listener interface.

Components which might otherwise manage their own list of listeners use EventNotifiers instead to simplify their internal implementation. Notifiers should therefore be considered a private implementation detail of the components, and should not be used directly outside of the "host" component.

All methods in this class must use the synchronization methods provided by ReaderWriterLock. This ensures that multiple notifications (reads) can occur simultaneously, but only one thread can be adding or removing listeners (writing) at a time, and no reads can occur during a write.

No methods on this class should be synchronized using traditional Java synchronization!

Version:
$Id: DebugEventNotifier.java 4443 2008-04-15 22:25:56Z mgricken $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.EventNotifier
_listeners, _lock
 
Constructor Summary
DebugEventNotifier()
           
 
Method Summary
 void breakpointReached(Breakpoint bp)
          Called when a breakpoint is reached during execution.
 void currThreadDied()
          Called when the current thread dies.
 void currThreadResumed()
          Called when the current thread is resumed.
 void currThreadSet(DebugThreadData thread)
          Called when the current (selected) thread is set in the debugger.
 void currThreadSuspended()
          Called when the current thread is suspended.
 void debuggerShutdown()
          Called when debugger mode has been disabled.
 void debuggerStarted()
          Called when debugger mode has been enabled.
 void nonCurrThreadDied()
          Called when any thread other than the current thread dies.
 void regionAdded(Breakpoint bp)
          Called when a breakpoint is set in a document.
 void regionChanged(Breakpoint bp)
          Called when a breakpoint is changed during execution.
 void regionRemoved(Breakpoint bp)
          Called when a breakpoint is removed from a document.
 void stepRequested()
          Called when a step is requested on the current thread.
 void threadLocationUpdated(OpenDefinitionsDocument doc, int lineNumber, boolean shouldHighlight)
          Called when the given line is reached by the current thread in the debugger, to request that the line be displayed.
 void threadStarted()
          Called when a thread starts.
 void watchRemoved(DebugWatchData w)
          Called when a watch is removed.
 void watchSet(DebugWatchData w)
          Called when a watch is set.
 
Methods inherited from class edu.rice.cs.drjava.model.EventNotifier
addListener, removeAllListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugEventNotifier

public DebugEventNotifier()
Method Detail

debuggerStarted

public void debuggerStarted()
Called when debugger mode has been enabled. Must be executed in event thread.

Specified by:
debuggerStarted in interface DebugListener

debuggerShutdown

public void debuggerShutdown()
Called when debugger mode has been disabled. Must be executed in event thread.

Specified by:
debuggerShutdown in interface DebugListener

threadLocationUpdated

public void threadLocationUpdated(OpenDefinitionsDocument doc,
                                  int lineNumber,
                                  boolean shouldHighlight)
Called when the given line is reached by the current thread in the debugger, to request that the line be displayed. Must be executed only in the event thread.

Specified by:
threadLocationUpdated in interface DebugListener
Parameters:
doc - Document to display
lineNumber - Line to display or highlight
shouldHighlight - true iff the line should be highlighted.

regionAdded

public void regionAdded(Breakpoint bp)
Called when a breakpoint is set in a document. Must be executed in event thread.

Specified by:
regionAdded in interface RegionManagerListener<Breakpoint>
Parameters:
bp - the breakpoint

breakpointReached

public void breakpointReached(Breakpoint bp)
Called when a breakpoint is reached during execution. Must be executed in event thread.

Specified by:
breakpointReached in interface DebugListener
Parameters:
bp - the breakpoint

regionChanged

public void regionChanged(Breakpoint bp)
Called when a breakpoint is changed during execution. Must be executed in event thread.

Specified by:
regionChanged in interface RegionManagerListener<Breakpoint>
Parameters:
bp - the breakpoint

watchSet

public void watchSet(DebugWatchData w)
Called when a watch is set. Must be executed in event thread.

Specified by:
watchSet in interface DebugListener
Parameters:
w - the watch

watchRemoved

public void watchRemoved(DebugWatchData w)
Called when a watch is removed. Must be executed in event thread.

Specified by:
watchRemoved in interface DebugListener
Parameters:
w - the watch

regionRemoved

public void regionRemoved(Breakpoint bp)
Called when a breakpoint is removed from a document. Must be executed in event thread.

Specified by:
regionRemoved in interface RegionManagerListener<Breakpoint>
Parameters:
bp - the breakpoint

stepRequested

public void stepRequested()
Called when a step is requested on the current thread. Must be executed in event thread.

Specified by:
stepRequested in interface DebugListener

currThreadSuspended

public void currThreadSuspended()
Called when the current thread is suspended.

Specified by:
currThreadSuspended in interface DebugListener

currThreadResumed

public void currThreadResumed()
Called when the current thread is resumed. Must be executed in event thread.

Specified by:
currThreadResumed in interface DebugListener

threadStarted

public void threadStarted()
Called when a thread starts. Must be executed in event thread.

Specified by:
threadStarted in interface DebugListener

currThreadDied

public void currThreadDied()
Called when the current thread dies. Must be executed in event thread.

Specified by:
currThreadDied in interface DebugListener

nonCurrThreadDied

public void nonCurrThreadDied()
Called when any thread other than the current thread dies. Must be executed in event thread.

Specified by:
nonCurrThreadDied in interface DebugListener

currThreadSet

public void currThreadSet(DebugThreadData thread)
Called when the current (selected) thread is set in the debugger.

Specified by:
currThreadSet in interface DebugListener
Parameters:
thread - the thread that was set as current