Class ScriptRecorder


  • public class ScriptRecorder
    extends java.lang.Object
    A singleton class used to add lines to the script currently being recorded (if one is being recorded at all).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ImageVariableTable imageTable
      The table containing image-placeholder-to-image-name mappings for the script we are currently recording.
      protected static java.lang.String LINE_SEPARATOR
      The line separator to use for scripts.
      static int PAUSED
      Status indicating that the script recorder is currently paused.
      protected int recorderStatus
      The current status of the recorder, either PAUSED, RECORDING, or STOPPED.
      static int RECORDING
      Status indicating that the script recorder is currently recording.
      protected java.util.Vector recordingListeners
      A list of listeners who want to know about lines added to the script.
      protected java.lang.String script
      The contents of the current script being recorded.
      protected static ScriptRecorder singletonReference
      The reference to the only occurrance of this class.
      static java.lang.String[] statusStrings
      Strings describing the various recorder statuses.
      static int STOPPED
      Status indicating that the script recorder is currently stopped (either never started, or recording is over).
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ScriptRecorder()
      Creates a new ScriptRecorder object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCommentLine​(java.lang.String line)
      Appends a comment line to the current script (if one is being recorded).
      void addLine​(ScriptableActionInterface scriptAction)
      Add a line to the current script by requesting a script action to generate its script line.
      void addLine​(java.lang.String action, ParameterTable parameterList)
      Appends a line of text to the current script (if one is being recorded) using a script action and list of parameters.
      void addScriptRecordingListener​(ScriptRecordingListener listener)
      Adds a class to the recorder's list of listeners.
      ImageVariableTable getImageTable()
      Returns a reference to the image table being used to run the current script.
      int getRecorderStatus()
      Returns the current status of the script recorder.
      static ScriptRecorder getReference()
      Returns a reference to the script recorder.
      java.lang.String getScript()
      Returns the current script.
      protected void notifyListenersOfScriptChange()
      Notifies any ScriptRecorderListeners of the current script text, after it has changed in some manner.
      protected void notifyListenersOfScriptStatus()
      Notifies any ScriptRecorderListeners of the current recording status of the script recorder.
      void pauseRecording()
      Pauses the recording of the script we are currently recording.
      void removeScriptRecordingListener​(ScriptRecordingListener listener)
      Removes a listener from the recorder.
      void resetScript()
      Erases the current script.
      protected void setRecorderStatus​(int status)
      Changes the current status of the script recorder and notifies any recorder listeners of the change.
      void setScript​(java.lang.String newScript)
      Changes the script being recorded by this class.
      boolean startRecording()
      Starts the recording of a new script (if one isn't already being recorded).
      void stopRecording()
      Stops script recording.
      java.lang.String storeImage​(java.lang.String imageName)
      Convenience method used to store the name of an image in the image table being recorded/used in the current script.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LINE_SEPARATOR

        protected static final java.lang.String LINE_SEPARATOR
        The line separator to use for scripts.
        See Also:
        Constant Field Values
      • singletonReference

        protected static ScriptRecorder singletonReference
        The reference to the only occurrance of this class.
      • PAUSED

        public static final int PAUSED
        Status indicating that the script recorder is currently paused.
        See Also:
        Constant Field Values
      • RECORDING

        public static final int RECORDING
        Status indicating that the script recorder is currently recording.
        See Also:
        Constant Field Values
      • STOPPED

        public static final int STOPPED
        Status indicating that the script recorder is currently stopped (either never started, or recording is over).
        See Also:
        Constant Field Values
      • statusStrings

        public static final java.lang.String[] statusStrings
        Strings describing the various recorder statuses.
      • script

        protected java.lang.String script
        The contents of the current script being recorded.
      • recorderStatus

        protected int recorderStatus
        The current status of the recorder, either PAUSED, RECORDING, or STOPPED.
      • recordingListeners

        protected java.util.Vector recordingListeners
        A list of listeners who want to know about lines added to the script.
      • imageTable

        protected ImageVariableTable imageTable
        The table containing image-placeholder-to-image-name mappings for the script we are currently recording.
    • Constructor Detail

      • ScriptRecorder

        protected ScriptRecorder()
        Creates a new ScriptRecorder object. May only be called by getReference() since this is a singleton class.
    • Method Detail

      • getReference

        public static final ScriptRecorder getReference()
        Returns a reference to the script recorder.
        Returns:
        A reference to the script recorder.
      • addLine

        public void addLine​(ScriptableActionInterface scriptAction)
        Add a line to the current script by requesting a script action to generate its script line.
        Parameters:
        scriptAction - The script action to add to the current script we are recording.
      • addCommentLine

        public void addCommentLine​(java.lang.String line)
        Appends a comment line to the current script (if one is being recorded).
        Parameters:
        line - A comment to be added to the script (should not include an end-line character).
      • addLine

        public void addLine​(java.lang.String action,
                            ParameterTable parameterList)
        Appends a line of text to the current script (if one is being recorded) using a script action and list of parameters.
        Parameters:
        action - The action to put into the new script line.
        parameterList - The list of parameters to include in the new script line.
      • resetScript

        public void resetScript()
        Erases the current script.
      • getImageTable

        public ImageVariableTable getImageTable()
        Returns a reference to the image table being used to run the current script.
        Returns:
        The image table which should be used to run the current script, or null if no script is being run at the moment.
      • getScript

        public java.lang.String getScript()
        Returns the current script.
        Returns:
        The script being recorded.
      • getRecorderStatus

        public int getRecorderStatus()
        Returns the current status of the script recorder.
        Returns:
        Either PAUSED, RECORDING, or STOPPED.
      • setRecorderStatus

        protected void setRecorderStatus​(int status)
        Changes the current status of the script recorder and notifies any recorder listeners of the change.
        Parameters:
        status - The new status for the script recorder.
      • setScript

        public void setScript​(java.lang.String newScript)
        Changes the script being recorded by this class. Used by the script recorder dialog to read in a script from disk or allow the user to manually edit the script.
        Parameters:
        newScript - The new script text.
      • startRecording

        public boolean startRecording()
        Starts the recording of a new script (if one isn't already being recorded). Any script text which was previously recorded and stored in the recorder is erased (unless we are resuming from a recorder pause).
        Returns:
        True if recording was started successfully, false otherwise.
      • pauseRecording

        public void pauseRecording()
        Pauses the recording of the script we are currently recording.
      • stopRecording

        public void stopRecording()
        Stops script recording. Call getScript() to get the recorded script.
      • storeImage

        public java.lang.String storeImage​(java.lang.String imageName)
        Convenience method used to store the name of an image in the image table being recorded/used in the current script.
        Parameters:
        imageName - The name of the image to store.
        Returns:
        The image variable placeholder which has been assigned to the image name (may not be a new variable if the name is already in the table).
      • addScriptRecordingListener

        public void addScriptRecordingListener​(ScriptRecordingListener listener)
        Adds a class to the recorder's list of listeners.
        Parameters:
        listener - A class which wants to be notified about changes in the recorder's status and script text.
      • removeScriptRecordingListener

        public void removeScriptRecordingListener​(ScriptRecordingListener listener)
        Removes a listener from the recorder.
        Parameters:
        listener - A class which no longer wants to know about changes in the recorder's state.
      • notifyListenersOfScriptChange

        protected void notifyListenersOfScriptChange()
        Notifies any ScriptRecorderListeners of the current script text, after it has changed in some manner.
      • notifyListenersOfScriptStatus

        protected void notifyListenersOfScriptStatus()
        Notifies any ScriptRecorderListeners of the current recording status of the script recorder.