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

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

public abstract class RMIInteractionsModel
extends InteractionsModel

A Swing specific InteractionsModel which can serve as the glue between a local InteractionsDocument and a remote JavaInterpreter in another JVM.

Version:
$Id: RMIInteractionsModel.java 4694 2008-12-08 20:47:26Z dlsmith $

Field Summary
protected  MainJVM _jvm
          RMI interface to the remote Java 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
RMIInteractionsModel(MainJVM jvm, ConsoleDocumentInterface cDoc, File wd, int historySize, int writeDelay)
          Constructs an InteractionsModel which can communicate with another JVM.
 
Method Summary
protected  void _interpret(String toEval)
          Interprets the given command.
protected abstract  void _notifyInterpreterChanged(boolean inProgress)
          Notifies listeners that the interpreter has changed.
protected  void _resetInterpreter(File wd)
          Resets the Java interpreter.
 void addBuildDirectoryClassPath(File f)
          These add the given path to the build directory classpaths used in the interpreter.
 void addExternalFilesClassPath(File f)
          These add the given path to the external files classpaths used in the interpreter.
 void addExtraClassPath(File f)
          These add the given path to the extra classpaths used in the interpreter.
 void addInterpreter(String name)
          Adds a named interpreter to the list.
 void addProjectClassPath(File f)
          Adds the given path to the interpreter's classpath.
 void addProjectFilesClassPath(File f)
          These add the given path to the project files classpaths used in the interpreter.
 void enableRestart()
          Enables restarting of slave JVM.
 Iterable<File> getClassPath()
          Gets the interpreter classpath from the interpreter jvm.
 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 removeInterpreter(String name)
          Removes the interpreter with the given name, if it exists.
 void setActiveInterpreter(String name, String prompt)
          Sets the active interpreter.
 void setPrivateAccessible(boolean allow)
          Sets whether or not the interpreter should allow access to private members.
 void setToDefaultInterpreter()
          Sets the default interpreter to be the current one.
 
Methods inherited from class edu.rice.cs.drjava.model.repl.InteractionsModel
_addNewline, _createNewDebugPort, _deleteSemiColon, _getHistoryText, _interactionIsOver, _interpreterResetFailed, _notifyInteractionEnded, _notifyInteractionIncomplete, _notifyInteractionStarted, _notifyInterpreterExited, _notifyInterpreterReady, _notifyInterpreterResetFailed, _notifyInterpreterResetting, _notifySlaveJVMUsed, _notifySyntaxErrorOccurred, _removeSeparators, _testClassCall, _writerDelay, addListener, append, changeInputListener, getBanner, getBanner, getConsoleDocument, 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

_jvm

protected final MainJVM _jvm
RMI interface to the remote Java interpreter.

Constructor Detail

RMIInteractionsModel

public RMIInteractionsModel(MainJVM jvm,
                            ConsoleDocumentInterface cDoc,
                            File wd,
                            int historySize,
                            int writeDelay)
Constructs an InteractionsModel which can communicate with another JVM.

Parameters:
jvm - RMI interface to the slave JVM
cDoc - document to use in the InteractionsDocument
historySize - Number of lines to store in the history
writeDelay - Number of milliseconds to wait after each println
Method Detail

_interpret

protected void _interpret(String toEval)
Interprets the given command.

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 f)
Adds the given path to the interpreter's classpath.

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

addBuildDirectoryClassPath

public void addBuildDirectoryClassPath(File f)
These add the given path to the build directory classpaths used in the interpreter.

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

addProjectFilesClassPath

public void addProjectFilesClassPath(File f)
These add the given path to the project files classpaths used in the interpreter.

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

addExternalFilesClassPath

public void addExternalFilesClassPath(File f)
These add the given path to the external files classpaths used in the interpreter.

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

addExtraClassPath

public void addExtraClassPath(File f)
These add the given path to the extra classpaths used in the interpreter.

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

_resetInterpreter

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

Specified by:
_resetInterpreter in class InteractionsModel

addInterpreter

public void addInterpreter(String name)
Adds a named interpreter to the list.

Parameters:
name - the unique name for the interpreter
Throws:
IllegalArgumentException - if the name is not unique

removeInterpreter

public void removeInterpreter(String name)
Removes the interpreter with the given name, if it exists.

Parameters:
name - Name of the interpreter to remove

setActiveInterpreter

public void setActiveInterpreter(String name,
                                 String prompt)
Sets the active interpreter.

Parameters:
name - the (unique) name of the interpreter.
prompt - the prompt the interpreter should have.

setToDefaultInterpreter

public void setToDefaultInterpreter()
Sets the default interpreter to be the current one.


_notifyInterpreterChanged

protected abstract void _notifyInterpreterChanged(boolean inProgress)
Notifies listeners that the interpreter has changed. (Subclasses must maintain listeners.)

Parameters:
inProgress - Whether the new interpreter is currently in progress with an interaction, i.e., whether an interactionEnded event will be fired)

setPrivateAccessible

public void setPrivateAccessible(boolean allow)
Sets whether or not the interpreter should allow access to private members.


getClassPath

public Iterable<File> getClassPath()
Gets the interpreter classpath from the interpreter jvm.

Returns:
a vector of classpath elements

enableRestart

public void enableRestart()
Enables restarting of slave JVM.