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

java.lang.Object
  extended by edu.rice.cs.drjava.model.repl.InteractionsModel
      extended by edu.rice.cs.drjava.model.repl.RMIInteractionsModel
          extended by edu.rice.cs.drjava.model.repl.DefaultInteractionsModel
All Implemented Interfaces:
InteractionsModelCallback

public class DefaultInteractionsModel
extends RMIInteractionsModel

Interactions model which can notify GlobalModelListeners on events. TODO: remove invokeLater wrappers here and enforce the policy that all of the listener methods must use them

Version:
$Id: DefaultInteractionsModel.java 4691 2008-12-02 23:33:27Z dlsmith $

Field Summary
protected  DefaultGlobalModel _model
          Model that contains the interpreter to use.
 
Fields inherited from class edu.rice.cs.drjava.model.repl.RMIInteractionsModel
_jvm
 
Fields inherited from class edu.rice.cs.drjava.model.repl.InteractionsModel
_cDoc, _document, _inputListener, _lastError, _notifier, _pane, _secondToLastError, _waitingForFirstInterpreter, _workingDirectory, _writerLock, BANNER_PREFIX
 
Constructor Summary
DefaultInteractionsModel(DefaultGlobalModel model, MainJVM jvm, ConsoleDocumentInterface cDoc, File wd)
          Creates a new InteractionsModel.
 
Method Summary
protected  void _interpreterResetFailed(Throwable t)
          Any extra action to perform (beyond notifying listeners) when the interpreter fails to reset.
protected  void _notifyInteractionEnded()
          In the event thread, notifies listeners that an interaction has ended.
protected  void _notifyInteractionIncomplete()
          In the event thread, notifies the view that the current interaction is incomplete.
 void _notifyInteractionStarted()
          In the event thread, notifies listeners that an interaction has started.
protected  void _notifyInterpreterChanged(boolean inProgress)
          In the event thread, notifies listeners that the interpreter has changed.
protected  void _notifyInterpreterExited(int status)
          In the event thread, notifies listeners that the interpreter has exited unexpectedly.
 void _notifyInterpreterReady(File wd)
          In the event thread, notifies listeners that the interpreter is ready.
protected  void _notifyInterpreterResetFailed(Throwable t)
          In the event thread, notifies listeners that the interpreter reset failed.
protected  void _notifyInterpreterResetting()
          In the event thread, notifies listeners that the interpreter is resetting.
protected  void _notifySlaveJVMUsed()
          In the event thread, notifies listeners that the slave JVM has been used.
protected  void _notifySlaveJVMUsed(File wd)
          In the event thread, notifies listeners that slave JVM has been used.
protected  void _notifySyntaxErrorOccurred(int offset, int length)
          In the event thread, notifies listeners that an error was present in the interaction.
 ConsoleDocument getConsoleDocument()
          Gets the console tab document for this interactions model
 String getConsoleInput()
          Returns a line of text entered by the user at the equivalent of System.in.
 void interpreterReady(File wd)
          Called when the Java interpreter is ready to use.
 void replSystemErrPrint(String s)
          Called when the repl prints to System.err.
 void replSystemOutPrint(String s)
          Called when the repl prints to System.out.
 
Methods inherited from class edu.rice.cs.drjava.model.repl.RMIInteractionsModel
_interpret, _resetInterpreter, addBuildDirectoryClassPath, addExternalFilesClassPath, addExtraClassPath, addInterpreter, addProjectClassPath, addProjectFilesClassPath, enableRestart, getClassPath, getVariableToString, getVariableType, removeInterpreter, setActiveInterpreter, setPrivateAccessible, setToDefaultInterpreter
 
Methods inherited from class edu.rice.cs.drjava.model.repl.InteractionsModel
_addNewline, _createNewDebugPort, _deleteSemiColon, _getHistoryText, _interactionIsOver, _removeSeparators, _testClassCall, _writerDelay, addListener, append, changeInputListener, getBanner, getBanner, getDebugPort, getDocument, getLastError, getSecondToLastError, getStartUpBanner, getWorkingDirectory, interactionContinues, interpret, interpretCurrentInteraction, interpreterResetFailed, interpreterResetting, loadHistory, loadHistoryAsScript, removeAllInteractionListeners, removeLastFromHistory, removeListener, replCalledSystemExit, replReturnedResult, replReturnedSyntaxError, replReturnedVoid, replThrewException, resetInterpreter, resetLastErrors, scrollToCaret, setDebugPort, setInputListener, setUpPane, setWaitingForFirstInterpreter, slaveJVMUsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_model

protected final DefaultGlobalModel _model
Model that contains the interpreter to use.

Constructor Detail

DefaultInteractionsModel

public DefaultInteractionsModel(DefaultGlobalModel model,
                                MainJVM jvm,
                                ConsoleDocumentInterface cDoc,
                                File wd)
Creates a new InteractionsModel.

Parameters:
model - DefaultGlobalModel to do the interpretation
jvm - the RMI interface used by the Main JVM to access the Interpreter JVM
cDoc - document
wd - the working directory for interactions i/o
Method Detail

replSystemOutPrint

public void replSystemOutPrint(String s)
Called when the repl prints to System.out. This method can safely be called from outside the event thread.

Specified by:
replSystemOutPrint in interface InteractionsModelCallback
Overrides:
replSystemOutPrint in class InteractionsModel
Parameters:
s - String to print

replSystemErrPrint

public void replSystemErrPrint(String s)
Called when the repl prints to System.err. This method can safely be called from outside the event thread.

Specified by:
replSystemErrPrint in interface InteractionsModelCallback
Overrides:
replSystemErrPrint in class InteractionsModel
Parameters:
s - String to print

getConsoleInput

public String getConsoleInput()
Returns a line of text entered by the user at the equivalent of System.in. This method may be safely called from outside the event thread.

Specified by:
getConsoleInput in interface InteractionsModelCallback
Overrides:
getConsoleInput in class InteractionsModel
Returns:
the input given to System.in

_interpreterResetFailed

protected void _interpreterResetFailed(Throwable t)
Any extra action to perform (beyond notifying listeners) when the interpreter fails to reset.

Specified by:
_interpreterResetFailed in class InteractionsModel
Parameters:
t - The Throwable thrown by System.exit

interpreterReady

public void interpreterReady(File wd)
Called when the Java interpreter is ready to use. This method body adds actions that involve the global model. This method may run outside the event thread.

Specified by:
interpreterReady in interface InteractionsModelCallback
Overrides:
interpreterReady in class InteractionsModel

_notifyInteractionStarted

public void _notifyInteractionStarted()
In the event thread, notifies listeners that an interaction has started.

Specified by:
_notifyInteractionStarted in class InteractionsModel

_notifyInteractionEnded

protected void _notifyInteractionEnded()
In the event thread, notifies listeners that an interaction has ended.

Specified by:
_notifyInteractionEnded in class InteractionsModel

_notifySyntaxErrorOccurred

protected void _notifySyntaxErrorOccurred(int offset,
                                          int length)
In the event thread, notifies listeners that an error was present in the interaction.

Specified by:
_notifySyntaxErrorOccurred in class InteractionsModel
Parameters:
offset - the first character of the error in the InteractionsDocument
length - the length of the error.

_notifyInterpreterChanged

protected void _notifyInterpreterChanged(boolean inProgress)
In the event thread, notifies listeners that the interpreter has changed.

Specified by:
_notifyInterpreterChanged in class RMIInteractionsModel
Parameters:
inProgress - Whether the new interpreter is currently in progress.

_notifyInterpreterResetting

protected void _notifyInterpreterResetting()
In the event thread, notifies listeners that the interpreter is resetting.

Specified by:
_notifyInterpreterResetting in class InteractionsModel

_notifyInterpreterReady

public void _notifyInterpreterReady(File wd)
In the event thread, notifies listeners that the interpreter is ready. Sometimes called from outside the event thread.

Specified by:
_notifyInterpreterReady in class InteractionsModel

_notifySlaveJVMUsed

protected void _notifySlaveJVMUsed(File wd)
In the event thread, notifies listeners that slave JVM has been used.


_notifyInterpreterExited

protected void _notifyInterpreterExited(int status)
In the event thread, notifies listeners that the interpreter has exited unexpectedly.

Specified by:
_notifyInterpreterExited in class InteractionsModel
Parameters:
status - Status code of the dead process

_notifyInterpreterResetFailed

protected void _notifyInterpreterResetFailed(Throwable t)
In the event thread, notifies listeners that the interpreter reset failed.

Specified by:
_notifyInterpreterResetFailed in class InteractionsModel
Parameters:
t - Throwable causing the failure

_notifyInteractionIncomplete

protected void _notifyInteractionIncomplete()
In the event thread, notifies the view that the current interaction is incomplete.

Specified by:
_notifyInteractionIncomplete in class InteractionsModel

_notifySlaveJVMUsed

protected void _notifySlaveJVMUsed()
In the event thread, notifies listeners that the slave JVM has been used.

Specified by:
_notifySlaveJVMUsed in class InteractionsModel

getConsoleDocument

public ConsoleDocument getConsoleDocument()
Description copied from class: InteractionsModel
Gets the console tab document for this interactions model

Specified by:
getConsoleDocument in class InteractionsModel