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

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

public class SimpleInteractionsModel
extends InteractionsModel

A simple implementation of InteractionsModel, which uses a DynamicJavaAdapter directly (in the same JVM) to interpret code. It can be used in a standalone interface, such as edu.rice.cs.drjava.ui.SimpleInteractionsWindow.

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

Field Summary
protected  ClassPathManager _classPathManager
           
protected  edu.rice.cs.dynamicjava.interpreter.Interpreter _interpreter
           
 
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
SimpleInteractionsModel()
          Creates a new InteractionsModel using a InteractionsDJDocument.
SimpleInteractionsModel(InteractionsDJDocument document)
          Creates a new InteractionsModel with the given document adapter.
 
Method Summary
protected  void _interpret(String toEval)
          Interprets the given command.
protected  void _interpreterResetFailed(Throwable t)
          Any extra action to perform (beyond notifying listeners) when the interpreter fails to reset.
protected  void _notifyInteractionEnded()
          Notifies listeners that an interaction has ended.
protected  void _notifyInteractionIncomplete()
          Notifies listeners that the interperaction was incomplete.
 void _notifyInteractionStarted()
          Notifies listeners that an interaction has started.
protected  void _notifyInterpreterExited(int status)
          Notifies listeners that the interpreter has exited unexpectedly.
 void _notifyInterpreterReady(File wd)
          Notifies listeners that the interpreter is ready.
protected  void _notifyInterpreterResetFailed(Throwable t)
          Notifies listeners that the interpreter reset failed.
protected  void _notifyInterpreterResetting()
          Notifies listeners that the interpreter is resetting.
protected  void _notifySlaveJVMUsed()
          Notifies listeners that the slave JVM has been used.
protected  void _notifySyntaxErrorOccurred(int offset, int length)
          Notifies listeners that an interaction contained a syntax error.
protected  void _resetInterpreter(File wd)
          Resets the Java interpreter.
 void addBuildDirectoryClassPath(File path)
          Adds the given path to the interpreter's classpath.
 void addExternalFilesClassPath(File path)
          Adds the given path to the interpreter's classpath.
 void addExtraClassPath(File path)
          Adds the given path to the interpreter's classpath.
 void addProjectClassPath(File path)
          Adds the given path to the interpreter's classpath.
 void addProjectFilesClassPath(File path)
          Adds the given path to the interpreter's classpath.
 ConsoleDocument getConsoleDocument()
          Returns null because console tab document is not supported in this model
 String getVariableToString(String var)
          Gets the string representation of the value of a variable in the current interpreter.
 String getVariableType(String var)
          Gets the class name of a variable in the current interpreter.
 void setInterpreterPrivateAccessible(boolean accessible)
          Sets whether protected and private variables and methods can be accessed from within the interpreter.
 
Methods inherited from class edu.rice.cs.drjava.model.repl.InteractionsModel
_addNewline, _createNewDebugPort, _deleteSemiColon, _getHistoryText, _interactionIsOver, _removeSeparators, _testClassCall, _writerDelay, addListener, append, changeInputListener, getBanner, getBanner, getConsoleInput, getDebugPort, getDocument, getLastError, getSecondToLastError, getStartUpBanner, getWorkingDirectory, interactionContinues, interpret, interpretCurrentInteraction, interpreterReady, interpreterResetFailed, interpreterResetting, loadHistory, loadHistoryAsScript, removeAllInteractionListeners, removeLastFromHistory, removeListener, replCalledSystemExit, replReturnedResult, replReturnedSyntaxError, replReturnedVoid, replSystemErrPrint, replSystemOutPrint, 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

_classPathManager

protected ClassPathManager _classPathManager

_interpreter

protected edu.rice.cs.dynamicjava.interpreter.Interpreter _interpreter
Constructor Detail

SimpleInteractionsModel

public SimpleInteractionsModel()
Creates a new InteractionsModel using a InteractionsDJDocument.


SimpleInteractionsModel

public SimpleInteractionsModel(InteractionsDJDocument document)
Creates a new InteractionsModel with the given document adapter.

Parameters:
document - Toolkit-independent document adapter
Method Detail

_interpret

protected void _interpret(String toEval)
Interprets the given command. Must run in event thread to properly sequence updating the interactions pane.

Specified by:
_interpret in class InteractionsModel
Parameters:
toEval - command to be evaluated

getVariableToString

public String getVariableToString(String var)
Gets the string representation of the value of a variable in the current interpreter.

Specified by:
getVariableToString in class InteractionsModel
Parameters:
var - the name of the variable
Returns:
A string representation of the value, or null if the variable is not defined.

getVariableType

public String getVariableType(String var)
Gets the class name of a variable in the current interpreter.

Specified by:
getVariableType in class InteractionsModel
Parameters:
var - the name of the variable

addProjectClassPath

public void addProjectClassPath(File path)
Adds the given path to the interpreter's classpath.

Specified by:
addProjectClassPath in class InteractionsModel
Parameters:
path - Path to add

addBuildDirectoryClassPath

public void addBuildDirectoryClassPath(File path)
Adds the given path to the interpreter's classpath.

Specified by:
addBuildDirectoryClassPath in class InteractionsModel
Parameters:
path - Path to add

addProjectFilesClassPath

public void addProjectFilesClassPath(File path)
Adds the given path to the interpreter's classpath.

Specified by:
addProjectFilesClassPath in class InteractionsModel
Parameters:
path - Path to add

addExternalFilesClassPath

public void addExternalFilesClassPath(File path)
Adds the given path to the interpreter's classpath.

Specified by:
addExternalFilesClassPath in class InteractionsModel
Parameters:
path - Path to add

addExtraClassPath

public void addExtraClassPath(File path)
Adds the given path to the interpreter's classpath.

Specified by:
addExtraClassPath in class InteractionsModel
Parameters:
path - Path to add

setInterpreterPrivateAccessible

public void setInterpreterPrivateAccessible(boolean accessible)
Sets whether protected and private variables and methods can be accessed from within the interpreter.


_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

_resetInterpreter

protected void _resetInterpreter(File wd)
Resets the Java interpreter.

Specified by:
_resetInterpreter in class InteractionsModel

_notifyInteractionStarted

public void _notifyInteractionStarted()
Notifies listeners that an interaction has started.

Specified by:
_notifyInteractionStarted in class InteractionsModel

_notifyInteractionEnded

protected void _notifyInteractionEnded()
Notifies listeners that an interaction has ended.

Specified by:
_notifyInteractionEnded in class InteractionsModel

_notifySyntaxErrorOccurred

protected void _notifySyntaxErrorOccurred(int offset,
                                          int length)
Notifies listeners that an interaction contained a syntax error.

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

_notifyInterpreterResetting

protected void _notifyInterpreterResetting()
Notifies listeners that the interpreter is resetting.

Specified by:
_notifyInterpreterResetting in class InteractionsModel

_notifyInterpreterReady

public void _notifyInterpreterReady(File wd)
Notifies listeners that the interpreter is ready.

Specified by:
_notifyInterpreterReady in class InteractionsModel

_notifyInterpreterExited

protected void _notifyInterpreterExited(int status)
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)
Notifies listeners that the interpreter reset failed.

Specified by:
_notifyInterpreterResetFailed in class InteractionsModel
Parameters:
t - Throwable explaining why the reset failed.

_notifyInteractionIncomplete

protected void _notifyInteractionIncomplete()
Notifies listeners that the interperaction was incomplete.

Specified by:
_notifyInteractionIncomplete in class InteractionsModel

_notifySlaveJVMUsed

protected void _notifySlaveJVMUsed()
Notifies listeners that the slave JVM has been used.

Specified by:
_notifySlaveJVMUsed in class InteractionsModel

getConsoleDocument

public ConsoleDocument getConsoleDocument()
Returns null because console tab document is not supported in this model

Specified by:
getConsoleDocument in class InteractionsModel