edu.rice.cs.drjava.model.repl
Class InteractionsEventNotifier

java.lang.Object
  extended by edu.rice.cs.drjava.model.EventNotifier<InteractionsListener>
      extended by edu.rice.cs.drjava.model.repl.InteractionsEventNotifier
All Implemented Interfaces:
InteractionsListener

public class InteractionsEventNotifier
extends EventNotifier<InteractionsListener>
implements InteractionsListener

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

This class has a specific role of managing InteractionsListeners. Other classes with similar names use similar code to perform the same function for other interfaces, e.g. JavadocEventNotifier 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: InteractionsEventNotifier.java 4419 2008-03-27 06:58:07Z rcartwright $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.EventNotifier
_listeners, _lock
 
Constructor Summary
InteractionsEventNotifier()
           
 
Method Summary
 void interactionEnded()
          Called when an interaction has finished running.
 void interactionErrorOccurred(int offset, int length)
          Called when the interactions window generates a syntax error.
 void interactionIncomplete()
          Notifies the view that the current interaction is incomplete.
 void interactionStarted()
          Called after an interaction is started by the GlobalModel.
 void interpreterChanged(boolean inProgress)
          Called when the active interpreter is changed.
 void interpreterExited(int status)
          Called when the interactions JVM was closed by System.exit or by being aborted.
 void interpreterReady(File wd)
          Called when the interactions window is reset.
 void interpreterResetFailed(Throwable t)
          Called if the interpreter reset failed.
 void interpreterResetting()
          Called when the interactionsJVM has begun resetting.
 void slaveJVMUsed()
          Notifies listeners that the slaveJVM has been used.
 
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

InteractionsEventNotifier

public InteractionsEventNotifier()
Method Detail

interactionStarted

public void interactionStarted()
Called after an interaction is started by the GlobalModel.

Specified by:
interactionStarted in interface InteractionsListener

interactionEnded

public void interactionEnded()
Called when an interaction has finished running.

Specified by:
interactionEnded in interface InteractionsListener

interactionErrorOccurred

public void interactionErrorOccurred(int offset,
                                     int length)
Called when the interactions window generates a syntax error.

Specified by:
interactionErrorOccurred in interface InteractionsListener
Parameters:
offset - the error's offset into the InteractionsDocument
length - the length of the error

interpreterResetting

public void interpreterResetting()
Called when the interactionsJVM has begun resetting.

Specified by:
interpreterResetting in interface InteractionsListener

interpreterReady

public void interpreterReady(File wd)
Called when the interactions window is reset.

Specified by:
interpreterReady in interface InteractionsListener

interpreterResetFailed

public void interpreterResetFailed(Throwable t)
Called if the interpreter reset failed.

Specified by:
interpreterResetFailed in interface InteractionsListener
Parameters:
t - Throwable explaining why the reset failed. (Subclasses must maintain listeners.)

interpreterExited

public void interpreterExited(int status)
Called when the interactions JVM was closed by System.exit or by being aborted. Immediately after this the interactions will be reset.

Specified by:
interpreterExited in interface InteractionsListener
Parameters:
status - the exit code

interpreterChanged

public void interpreterChanged(boolean inProgress)
Called when the active interpreter is changed.

Specified by:
interpreterChanged in interface InteractionsListener
Parameters:
inProgress - Whether the new interpreter is currently in progress with an interaction (ie. whether an interactionEnded event will be fired)

interactionIncomplete

public void interactionIncomplete()
Notifies the view that the current interaction is incomplete.

Specified by:
interactionIncomplete in interface InteractionsListener

slaveJVMUsed

public void slaveJVMUsed()
Notifies listeners that the slaveJVM has been used.

Specified by:
slaveJVMUsed in interface InteractionsListener