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

java.lang.Object
  extended by edu.rice.cs.drjava.model.repl.InteractionsScriptModel

public class InteractionsScriptModel
extends Object

Manages the execution of a Interactions History as a script of individual commands. Useful for presentations.

Version:
$Id: InteractionsScriptModel.java 5175 2010-01-20 08:46:32Z mgricken $

Field Summary
private  int _currentInteraction
          The index into the list of the current interaction.
private  InteractionsDocument _doc
          The interactions document.
private  List<String> _interactions
          The interactions to perform.
private  InteractionsModel _model
          The interactions model associated with the script.
private  boolean _passedCurrent
          Indicates whether the iterator has "passed" the current interaction, which is the case after an execution.
 
Constructor Summary
InteractionsScriptModel(InteractionsModel model, List<String> interactions)
          Constructs a new interactions script using the given model and interactions.
 
Method Summary
private  void _showCurrentInteraction()
          Clears the current text at the prompt and shows the current interaction from the script.
 void executeInteraction()
          Executes the current interaction.
 boolean hasNextInteraction()
           
 boolean hasPrevInteraction()
           
 void nextInteraction()
          Enters the next interaction into the interactions pane.
 void prevInteraction()
          Enters the previous interaction into the interactions pane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_model

private volatile InteractionsModel _model
The interactions model associated with the script.


_doc

private volatile InteractionsDocument _doc
The interactions document.


_interactions

private volatile List<String> _interactions
The interactions to perform.


_currentInteraction

private volatile int _currentInteraction
The index into the list of the current interaction.


_passedCurrent

private volatile boolean _passedCurrent
Indicates whether the iterator has "passed" the current interaction, which is the case after an execution. In this state, "next" will show the interaction after our index, and "prev" will show the interaction at our index (which was mostrecently executed).

Constructor Detail

InteractionsScriptModel

public InteractionsScriptModel(InteractionsModel model,
                               List<String> interactions)
Constructs a new interactions script using the given model and interactions.

Parameters:
model - the interactions model
interactions - the interactions that make up the script.
Method Detail

nextInteraction

public void nextInteraction()
Enters the next interaction into the interactions pane. Should only run in the event thread.


prevInteraction

public void prevInteraction()
Enters the previous interaction into the interactions pane. Should only run in the event thread.


_showCurrentInteraction

private void _showCurrentInteraction()
Clears the current text at the prompt and shows the current interaction from the script. Should only run in the event thread. Assumes that write lock is already held.


executeInteraction

public void executeInteraction()
Executes the current interaction. Should only run in the event thread. After this call, we have passed the current interaction.


hasNextInteraction

public boolean hasNextInteraction()
Returns:
true iff this script has another interaction to perform.

hasPrevInteraction

public boolean hasPrevInteraction()
Returns:
true iff this script has a previous interaction to perform.