edu.rice.cs.drjava.model.repl
Class History
java.lang.Object
edu.rice.cs.drjava.model.repl.History
- All Implemented Interfaces:
- OptionConstants, Serializable
public class History
- extends Object
- implements OptionConstants, Serializable
History class that records what has been typed in the interactions pane. This class is not thread safe;
it is only accessed from InteractionsDocument which takes responsibility for synchronization.
- Version:
- $Id: History.java 4620 2008-07-29 19:37:11Z rcartwright $
- See Also:
- Serialized Form
Fields inherited from interface edu.rice.cs.drjava.config.OptionConstants |
accessLevelChoices, ALLOW_PRIVATE_ACCESS, ALWAYS_COMPILE_BEFORE_JUNIT, ALWAYS_SAVE_BEFORE_COMPILE, ALWAYS_SAVE_BEFORE_DEBUG, ALWAYS_SAVE_BEFORE_JAVADOC, ALWAYS_SAVE_BEFORE_RUN, apiJavadocChoices, apiJavadocVersionChoices, AUTO_CLOSE_COMMENTS, BACKUP_FILES, BOOKMARK_COLOR, BROWSER_FILE, BROWSER_HISTORY_MAX_SIZE, BROWSER_STRING, choices, CLIPBOARD_HISTORY_SIZE, COMPILER_ERROR_COLOR, DEBUG_BREAKPOINT_COLOR, DEBUG_BREAKPOINT_DISABLED_COLOR, DEBUG_MESSAGE_COLOR, DEBUG_PANEL_HEIGHT, DEBUG_SOURCEPATH, DEBUG_STEP_DRJAVA, DEBUG_STEP_EXCLUDE, DEBUG_STEP_INTERPRETER, DEBUG_STEP_JAVA, DEBUG_THREAD_COLOR, DEFINITIONS_BACKGROUND_COLOR, DEFINITIONS_COMMENT_COLOR, DEFINITIONS_DOUBLE_QUOTED_COLOR, DEFINITIONS_KEYWORD_COLOR, DEFINITIONS_MATCH_COLOR, DEFINITIONS_NORMAL_COLOR, DEFINITIONS_NUMBER_COLOR, DEFINITIONS_SINGLE_QUOTED_COLOR, DEFINITIONS_TYPE_COLOR, DETACH_DEBUGGER, DETACH_TABBEDPANES, DIALOG_AUTOIMPORT_ENABLED, DIALOG_AUTOIMPORT_STATE, DIALOG_AUTOIMPORT_STORE_POSITION, DIALOG_CLIPBOARD_HISTORY_STATE, DIALOG_CLIPBOARD_HISTORY_STORE_POSITION, DIALOG_COMPLETE_JAVAAPI, DIALOG_COMPLETE_SCAN_CLASS_FILES, DIALOG_COMPLETE_WORD_STATE, DIALOG_COMPLETE_WORD_STORE_POSITION, DIALOG_DEBUGFRAME_STATE, DIALOG_DEBUGFRAME_STORE_POSITION, DIALOG_DRJAVA_ERROR_POPUP_ENABLED, DIALOG_DRJAVA_SURVEY_ENABLED, DIALOG_EDITEXTERNALPROCESS_STATE, DIALOG_EDITEXTERNALPROCESS_STORE_POSITION, DIALOG_EXTERNALPROCESS_STATE, DIALOG_EXTERNALPROCESS_STORE_POSITION, DIALOG_GOTOFILE_FULLY_QUALIFIED, DIALOG_GOTOFILE_STATE, DIALOG_GOTOFILE_STORE_POSITION, DIALOG_JAROPTIONS_STATE, DIALOG_JAROPTIONS_STORE_POSITION, DIALOG_LIGHTWEIGHT_PARSING_DELAY, DIALOG_OPENJAVADOC_STATE, DIALOG_OPENJAVADOC_STORE_POSITION, DIALOG_TABBEDPANES_STATE, DIALOG_TABBEDPANES_STORE_POSITION, DOC_LIST_WIDTH, DRJAVA_ERRORS_BUTTON_COLOR, DRJAVA_SURVEY_DAYS, DRJAVA_USE_FORCE_QUIT, EXTERNAL_SAVED_CMDLINES, EXTERNAL_SAVED_COUNT, EXTERNAL_SAVED_ENCLOSING_DJAPP_FILES, EXTERNAL_SAVED_NAMES, EXTERNAL_SAVED_PREFIX, EXTERNAL_SAVED_WORKDIRS, EXTPROCESS_FILE_EXTENSION, EXTPROCESS_FILE_NAME_INSIDE_JAR, EXTRA_CLASSPATH, EXTRA_COMPILERS, FIND_ALL_DOCUMENTS, FIND_MATCH_CASE, FIND_NO_COMMENTS_STRINGS, FIND_NO_TEST_CASES, FIND_REPLACE_FOCUS_IN_DEFPANE, FIND_RESULTS_COLOR1, FIND_RESULTS_COLOR2, FIND_RESULTS_COLOR3, FIND_RESULTS_COLOR4, FIND_RESULTS_COLOR5, FIND_RESULTS_COLOR6, FIND_RESULTS_COLOR7, FIND_RESULTS_COLOR8, FIND_RESULTS_COLORS, FIND_SEARCH_BACKWARDS, FIND_WHOLE_WORD, FOLLOW_FILE_DELAY, FOLLOW_FILE_LINES, FONT_DOCLIST, FONT_LINE_NUMBERS, FONT_MAIN, FONT_TOOLBAR, FORCE_TEST_SUFFIX, heapSizeChoices, HISTORY_MAX_SIZE, INDENT_LEVEL, INTERACTIONS_ERROR_COLOR, INTERACTIONS_EXIT_PROMPT, INTERACTIONS_RESET_PROMPT, JAVAC_LOCATION, JAVADOC_1_3_LINK, JAVADOC_1_3_TEXT, JAVADOC_1_4_LINK, JAVADOC_1_4_TEXT, JAVADOC_1_5_LINK, JAVADOC_1_5_TEXT, JAVADOC_1_6_LINK, JAVADOC_1_6_TEXT, JAVADOC_ACCESS_LEVEL, JAVADOC_API_REF_VERSION, JAVADOC_AUTO_TEXT, JAVADOC_CUSTOM_PARAMS, JAVADOC_DESTINATION, JAVADOC_FROM_ROOTS, JAVADOC_LINK_VERSION, JAVADOC_NONE_TEXT, JAVADOC_PROMPT_FOR_DESTINATION, KEY_ABOUT, KEY_BACKWARD, KEY_BEGIN_DOCUMENT, KEY_BEGIN_LINE, KEY_BOOKMARKS_PANEL, KEY_BOOKMARKS_TOGGLE, KEY_BROWSE_BACK, KEY_BROWSE_FORWARD, KEY_CHECK_NEW_VERSION, KEY_CLEAR_CONSOLE, KEY_CLEAR_HISTORY, KEY_CLEAR_LINE, KEY_CLOSE_ALL_FILES, KEY_CLOSE_FILE, KEY_CLOSE_PROJECT, KEY_CLOSING_BRACE, KEY_COMMENT_LINES, KEY_COMPILE, KEY_COMPILE_ALL, KEY_COMPLETE_FILE, KEY_COPY, KEY_CUT, KEY_CUT_LINE, KEY_DEBUG_BREAKPOINT_PANEL, KEY_DEBUG_BREAKPOINT_TOGGLE, KEY_DEBUG_CLEAR_ALL_BREAKPOINTS, KEY_DEBUG_MODE_TOGGLE, KEY_DEBUG_RESUME, KEY_DEBUG_STEP_INTO, KEY_DEBUG_STEP_OUT, KEY_DEBUG_STEP_OVER, KEY_DELETE_NEXT, KEY_DELETE_PREVIOUS, KEY_DETACH_DEBUGGER, KEY_DETACH_TABBEDPANES, KEY_DOWN, KEY_DRJAVA_ERRORS, KEY_DRJAVA_SURVEY, KEY_END_DOCUMENT, KEY_END_LINE, KEY_EXEC_PROCESS, KEY_EXECUTE_HISTORY, KEY_EXPORT_OLD, KEY_FIND_NEXT, KEY_FIND_PREV, KEY_FIND_REPLACE, KEY_FOLLOW_FILE, KEY_FORCE_QUIT, KEY_FORWARD, KEY_GOTO_FILE, KEY_GOTO_FILE_UNDER_CURSOR, KEY_GOTO_LINE, KEY_HELP, KEY_JAVADOC_ALL, KEY_JAVADOC_CURRENT, KEY_LIFT_CURRENT_INTERACTION, KEY_LOAD_HISTORY_SCRIPT, KEY_NEW_FILE, KEY_NEW_TEST, KEY_NEXT_DOCUMENT, KEY_NEXT_PANE, KEY_NEXT_WORD, KEY_OPEN_FILE, KEY_OPEN_FOLDER, KEY_OPEN_JAVADOC, KEY_OPEN_JAVADOC_UNDER_CURSOR, KEY_OPEN_PROJECT, KEY_OPENING_BRACE, KEY_PAGE_DOWN, KEY_PAGE_SETUP, KEY_PAGE_UP, KEY_PASTE, KEY_PASTE_FROM_HISTORY, KEY_PREFERENCES, KEY_PREVIOUS_DOCUMENT, KEY_PREVIOUS_PANE, KEY_PREVIOUS_WORD, KEY_PRINT, KEY_PRINT_CONSOLE, KEY_PRINT_INTERACTIONS, KEY_PRINT_PREVIEW, KEY_QUICKSTART, KEY_QUIT, KEY_REDO, KEY_RENAME_FILE, KEY_RESET_INTERACTIONS, KEY_REVERT_FILE, KEY_RUN, KEY_RUN_MAIN, KEY_SAVE_ALL_FILES, KEY_SAVE_FILE, KEY_SAVE_FILE_AS, KEY_SAVE_HISTORY, KEY_SELECT_ALL, KEY_SHIFT_DELETE_NEXT, KEY_SHIFT_DELETE_PREVIOUS, KEY_TEST, KEY_TEST_ALL, KEY_UNCOMMENT_LINES, KEY_UNDO, KEY_UP, KEY_VIEW_INTERACTIONS_CLASSPATH, LANGUAGE_LEVEL, LAST_DIRECTORY, LAST_DRJAVA_SURVEY, LAST_DRJAVA_SURVEY_RESULT, LAST_INTERACTIONS_DIRECTORY, LAST_NEW_VERSION_NOTIFICATION, LIGHTWEIGHT_PARSING_ENABLED, LINEENUM_ENABLED, linkVersionChoices, LOOK_AND_FEEL, MASK, MASTER_JVM_ARGS, MASTER_JVM_XMX, NEW_VERSION_NOTIFICATION, NEW_VERSION_NOTIFICATION_CHOICES, NEW_VERSION_NOTIFICATION_DAYS, OLD_PROJECT_FILE_EXTENSION, OPEN_FOLDER_RECURSIVE, PLASTIC_THEMES, PROJECT_FILE_EXTENSION, PROMPT_BEFORE_CLEAN, QUIT_PROMPT, RECENT_FILES, RECENT_FILES_MAX_SIZE, RECENT_PROJECTS, REMOTE_CONTROL_ENABLED, REMOTE_CONTROL_PORT, RESET_CLEAR_CONSOLE, RUN_WITH_ASSERT, SHOW_CODE_PREVIEW_POPUPS, SHOW_DEBUG_CONSOLE, SHOW_DEPRECATION_WARNINGS, SHOW_FALLTHROUGH_WARNINGS, SHOW_FINALLY_WARNINGS, SHOW_PATH_WARNINGS, SHOW_SERIAL_WARNINGS, SHOW_SOURCE_WHEN_SWITCHING, SHOW_UNCHECKED_WARNINGS, SLAVE_JVM_ARGS, SLAVE_JVM_XMX, STICKY_INTERACTIONS_DIRECTORY, SYSTEM_ERR_COLOR, SYSTEM_IN_COLOR, SYSTEM_OUT_COLOR, TABS_HEIGHT, TEXT_ANTIALIAS, TOOLBAR_ENABLED, TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, WARN_BREAKPOINT_OUT_OF_SYNC, WARN_CHANGE_LAF, WARN_CHANGE_THEME, WARN_DEBUG_MODIFIED_FILE, WARN_PATH_CONTAINS_POUND, WINDOW_HEIGHT, WINDOW_STATE, WINDOW_STORE_POSITION, WINDOW_WIDTH, WINDOW_X, WINDOW_Y |
Constructor Summary |
History()
Constructor, so we can add a listener to the Config item being used. |
History(int maxSize)
Creates a new History with the given size. |
Method Summary |
void |
add(String item)
Adds an item to the history and moves the cursor to point to the place after it. |
void |
clear()
Clears the vector |
void |
forwardSearch(String currentInteraction)
Forward-searches the history for the next matching string. |
String |
getCurrent()
Returns item in history at current position; returns "" if no current item exists. |
String |
getHistoryAsString()
Returns the history as a string by concatenating the lines in _vector with EOL as separator. |
String |
getHistoryAsStringWithSemicolons()
Returns the history as a string by concatenating each string in the vector separated by the delimiting
character. |
OptionListener<Integer> |
getHistoryOptionListener()
|
boolean |
hasNext()
Returns whether moveNext() would succeed right now. |
boolean |
hasPrevious()
Returns whether movePrevious() would succeed right now. |
String |
lastEntry()
Returns the last entry from the history. |
void |
moveEnd()
Move the cursor to just past the end. |
void |
moveNext(String entry)
Moves cursor forward 1, or throws exception if there is none. |
void |
movePrevious(String entry)
Moves cursor back 1, or throws exception if there is none. |
String |
removeLast()
Returns the last element and removes it, or returns null if the history is empty. |
void |
reverseSearch(String currentInteraction)
Reverse-searches the history for the previous matching string. |
void |
setEditedEntry(String entry)
Sets the edited entry to the given value. |
void |
setMaxSize(int newSize)
Changes the maximum number of interactions remembered by this History. |
int |
size()
Returns the number of items in this History. |
void |
writeToFile(FileSaveSelector selector)
Writes this (unedited) History to the file selected in the FileSaveSelector. |
static void |
writeToFile(FileSaveSelector selector,
String editedVersion)
Writes this History to the file selected in the FileSaveSelector. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INTERACTION_SEPARATOR
public static final String INTERACTION_SEPARATOR
- See Also:
- Constant Field Values
HISTORY_FORMAT_VERSION_2
public static final String HISTORY_FORMAT_VERSION_2
- Version flag at the beginning of saved history file format
If this is not present in a saved history, it is assumed to be the original format.
historyOptionListener
public final OptionListener<Integer> historyOptionListener
- The OptionListener for HISTORY_MAX_SIZE
History
public History()
- Constructor, so we can add a listener to the Config item being used.
History
public History(int maxSize)
- Creates a new History with the given size. An option listener is not added for the config framework.
- Parameters:
maxSize
- Number of lines to remember in the history.
getHistoryOptionListener
public OptionListener<Integer> getHistoryOptionListener()
setEditedEntry
public void setEditedEntry(String entry)
- Sets the edited entry to the given value.
- Parameters:
entry
- the string to set
add
public void add(String item)
- Adds an item to the history and moves the cursor to point to the place after it.
Note: Items are not inserted if they are empty. (This is in accordance with
bug #522123, but in divergence from feature #522213 which originally excluded
sequential duplicate entries from ever being stored.)
Thus, to access the newly inserted item, you must movePrevious first.
removeLast
public String removeLast()
- Returns the last element and removes it, or returns null if the history is empty.
- Returns:
- last element before it was removed, or null if history is empty
moveEnd
public void moveEnd()
- Move the cursor to just past the end. Thus, to access the last element, you must movePrevious.
movePrevious
public void movePrevious(String entry)
- Moves cursor back 1, or throws exception if there is none.
- Parameters:
entry
- the current entry (perhaps edited from what is in history)
lastEntry
public String lastEntry()
- Returns the last entry from the history. Throw array indexing exception if no such entry.
moveNext
public void moveNext(String entry)
- Moves cursor forward 1, or throws exception if there is none.
- Parameters:
entry
- the current entry (perhaps edited from what is in history)
hasNext
public boolean hasNext()
- Returns whether moveNext() would succeed right now.
hasPrevious
public boolean hasPrevious()
- Returns whether movePrevious() would succeed right now.
getCurrent
public String getCurrent()
- Returns item in history at current position; returns "" if no current item exists.
size
public int size()
- Returns the number of items in this History.
clear
public void clear()
- Clears the vector
getHistoryAsStringWithSemicolons
public String getHistoryAsStringWithSemicolons()
- Returns the history as a string by concatenating each string in the vector separated by the delimiting
character. A semicolon is added to the end of every statement that didn't already end with one.
getHistoryAsString
public String getHistoryAsString()
- Returns the history as a string by concatenating the lines in _vector with EOL as separator.
writeToFile
public void writeToFile(FileSaveSelector selector)
throws IOException
- Writes this (unedited) History to the file selected in the FileSaveSelector.
- Parameters:
selector
- File to save to
- Throws:
IOException
writeToFile
public static void writeToFile(FileSaveSelector selector,
String editedVersion)
throws IOException
- Writes this History to the file selected in the FileSaveSelector. The saved file will still include
any tags or extensions needed to recognize it as a saved interactions file.
- Parameters:
selector
- File to save toeditedVersion
- The edited version of the text to be saved (which already uses proper EOL string)
- Throws:
IOException
setMaxSize
public void setMaxSize(int newSize)
- Changes the maximum number of interactions remembered by this History.
- Parameters:
newSize
- New number of interactions to remember.
reverseSearch
public void reverseSearch(String currentInteraction)
- Reverse-searches the history for the previous matching string.
- Parameters:
currentInteraction
- the current interaction
forwardSearch
public void forwardSearch(String currentInteraction)
- Forward-searches the history for the next matching string.
- Parameters:
currentInteraction
- the current interaction