edu.rice.cs.drjava.model
Class AbstractGlobalModel

java.lang.Object
  extended by edu.rice.cs.drjava.model.AbstractGlobalModel
All Implemented Interfaces:
OptionConstants, GlobalModel, ILoadDocuments, SingleDisplayModel, DocumentIterator
Direct Known Subclasses:
DefaultGlobalModel

public class AbstractGlobalModel
extends Object
implements SingleDisplayModel, OptionConstants, DocumentIterator

In simple terms, a DefaultGlobalModel without an interpreter, compiler, junit testing, debugger or javadoc. Hence, it only has only document handling functionality

Version:
$Id: AbstractGlobalModel.java 5553 2012-05-01 17:28:45Z rcartwright $

Nested Class Summary
(package private)  class AbstractGlobalModel.ConcreteOpenDefDoc
          A wrapper around a DefinitionsDocument or potential DefinitionsDocument (if it has been kicked out of the cache) The GlobalModel interacts with DefinitionsDocuments through this wrapper.
This call was formerly called the DefinitionsDocumentHandler but was renamed (2004-Jun-8) to be more descriptive/intuitive.
(package private)  class AbstractGlobalModel.FlatFileGroupingState
           
(package private)  class AbstractGlobalModel.ProjectFileGroupingState
           
private static class AbstractGlobalModel.TrivialFSS
           
 
Nested classes/interfaces inherited from interface edu.rice.cs.drjava.config.OptionConstants
OptionConstants.AccessLevelChoices, OptionConstants.COMPILER_PREFERENCE_CONTROL, OptionConstants.ConcJUnitCheckChoices, OptionConstants.DefaultFont, OptionConstants.DeleteLLClassFileChoices, OptionConstants.DynamicJavaAccessControlChoices, OptionConstants.FileExtRegistrationChoices, OptionConstants.HeapSizeChoices, OptionConstants.LookAndFeels, OptionConstants.PlasticThemes, OptionConstants.to, OptionConstants.VersionNotificationChoices
 
Field Summary
private  File _activeDirectory
          A pointer to the active directory, which is not necessarily the parent of the active document The user may click on a folder component in the navigation pane and that will set this field without setting the active document.
private  OpenDefinitionsDocument _activeDocument
          The active document pointer, which will never be null once the constructor is done.
protected  ConcreteRegionManager<MovingDocumentRegion> _bookmarkManager
          Manager for bookmark regions.
protected  ConcreteRegionManager<Breakpoint> _breakpointManager
          Manager for breakpoint regions.
protected  BrowserHistoryManager _browserHistoryManager
          Manager for browser history regions.
protected  DocumentCache _cache
          A document cache that manages how many unmodified documents are open at once.
protected  ConsoleDocument _consoleDoc
          The document used to display System.out and System.err, and to read from System.in.
protected  InteractionsDJDocument _consoleDocAdapter
          The document adapter used in the console document.
protected  IDocumentNavigator<OpenDefinitionsDocument> _documentNavigator
          The abstract container which contains views of open documents and allows user to navigate document focus among this collection of open documents
private  AbstractMap<File,OpenDefinitionsDocument> _documentsRepos
          Collection for storing all OpenDefinitionsDocuments.
protected  DefinitionsEditorKit _editorKit
          Factory for new definitions documents and views.
protected  LinkedList<RegionManager<MovingDocumentRegion>> _findResultsManagers
          Managers for find result regions.
static Log _log
           
 GlobalEventNotifier _notifier
          Keeps track of all listeners to the model, and has the ability to notify them of some event.
protected  PageFormat _pageFormat
          A PageFormat object for printing to paper.
protected  FileGroupingState _state
          Specifies the state of the navigator pane.
(package private) static String CLASSPATH_OUT_OF_SYNC_MSG
           
private  boolean classPathChanged
          A state varible indicating whether the class path has changed.
(package private) static String DOCUMENT_OUT_OF_SYNC_MSG
           
protected static HashMap<OptionParser<?>,OptionListener<? extends Object>> LISTENERS_TO_REMOVE
           
 OptionListener<? extends Object> STORED_PREFERENCES_LISTENER
           
 
Fields inherited from interface edu.rice.cs.drjava.config.OptionConstants
accessLevelChoices, ADVANCED_LEVEL, ALLOW_PRIVATE_ACCESS, ALWAYS_COMPILE_BEFORE_JAVADOC, ALWAYS_COMPILE_BEFORE_JUNIT, ALWAYS_SAVE_BEFORE_COMPILE, ALWAYS_SAVE_BEFORE_DEBUG, ALWAYS_SAVE_BEFORE_JAVADOC, ALWAYS_SAVE_BEFORE_RUN, apiJavadocChoices, apiJavadocDeprecated, apiJavadocVersionChoices, apiJavadocVersionDeprecated, AUTO_CLOSE_COMMENTS, AUTO_STEP_RATE, BACKUP_FILES, BOOKMARK_COLOR, BROWSER_FILE, BROWSER_HISTORY_MAX_SIZE, BROWSER_STRING, CLIPBOARD_HISTORY_SIZE, COMPILER_ERROR_COLOR, CONCJUNIT_CHECKS_ENABLED, concJUnitCheckChoices, CUSTOM_DRJAVA_JAR_VERSION_SUFFIX, DEBUG_AUTO_IMPORT, DEBUG_BREAKPOINT_COLOR, DEBUG_BREAKPOINT_DISABLED_COLOR, DEBUG_EXPRESSIONS_AND_METHODS_IN_WATCHES, DEBUG_MESSAGE_COLOR, DEBUG_PANEL_HEIGHT, DEBUG_SOURCEPATH, DEBUG_STEP_DRJAVA, DEBUG_STEP_EXCLUDE, DEBUG_STEP_INTERPRETER, DEBUG_STEP_JAVA, DEBUG_THREAD_COLOR, DEFAULT_COMPILER_PREFERENCE, DEFINITIONS_BACKGROUND_COLOR, DEFINITIONS_COMMENT_COLOR, DEFINITIONS_DOUBLE_QUOTED_COLOR, DEFINITIONS_KEYWORD_COLOR, DEFINITIONS_LINE_NUMBER_BACKGROUND_COLOR, DEFINITIONS_LINE_NUMBER_COLOR, DEFINITIONS_MATCH_COLOR, DEFINITIONS_NORMAL_COLOR, DEFINITIONS_NUMBER_COLOR, DEFINITIONS_SINGLE_QUOTED_COLOR, DEFINITIONS_TYPE_COLOR, DELETE_LL_CLASS_FILES, DELETE_LL_CLASS_FILES_CHOICES, 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, DISPLAY_ALL_COMPILER_VERSIONS, DISPLAY_RIGHT_MARGIN, DJ_FILE_EXTENSION, DOC_LIST_WIDTH, DRJAVA_ERRORS_BUTTON_COLOR, DRJAVA_SURVEY_DAYS, DRJAVA_USE_FORCE_QUIT, DYNAMICJAVA_ACCESS_CONTROL, DYNAMICJAVA_ACCESS_CONTROL_CHOICES, DYNAMICJAVA_REQUIRE_SEMICOLON, DYNAMICJAVA_REQUIRE_VARIABLE_TYPE, ELEMENTARY_LEVEL, 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, FILE_EXT_REGISTRATION, FILE_EXT_REGISTRATION_CHOICES, FIND_ALL_DOCUMENTS, FIND_MATCH_CASE, FIND_NO_COMMENTS_STRINGS, FIND_NO_TEST_CASES, FIND_ONLY_SELECTION, 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, FIXED_INTERACTIONS_DIRECTORY, FOLLOW_FILE_DELAY, FOLLOW_FILE_LINES, FONT_DOCLIST, FONT_LINE_NUMBERS, FONT_MAIN, FONT_TOOLBAR, FORCE_TEST_SUFFIX, FULL_JAVA, FUNCTIONAL_JAVA_LEVEL, heapSizeChoices, HISTORY_MAX_SIZE, INDENT_LEVEL, INTERACTIONS_AUTO_IMPORT_CLASSES, INTERACTIONS_ERROR_COLOR, INTERACTIONS_EXIT_PROMPT, INTERACTIONS_RESET_PROMPT, INTERMEDIATE_LEVEL, JAVA_FILE_EXTENSION, 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_1_7_LINK, JAVADOC_1_7_TEXT, JAVADOC_ACCESS_LEVEL, JAVADOC_ADDITIONAL_LINKS, 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, JUNIT_LINK, JUNIT_LOCATION, JUNIT_LOCATION_ENABLED, KEY_ABOUT, KEY_AUTO_REFRESH_PROJECT, KEY_BACKWARD, KEY_BACKWARD_SELECT, KEY_BEGIN_DOCUMENT, KEY_BEGIN_DOCUMENT_SELECT, KEY_BEGIN_LINE, KEY_BEGIN_LINE_SELECT, KEY_BOOKMARKS_PANEL, KEY_BOOKMARKS_TOGGLE, KEY_BROWSE_BACK, KEY_BROWSE_FORWARD, KEY_CHECK_NEW_VERSION, KEY_CLEAN_PROJECT, KEY_CLEAR_CONSOLE, KEY_CLEAR_HISTORY, KEY_CLEAR_LINE, KEY_CLOSE_ALL_FILES, KEY_CLOSE_FILE, KEY_CLOSE_PROJECT, KEY_CLOSE_SYSTEM_IN, KEY_CLOSING_BRACE, KEY_COMMENT_LINES, KEY_COMPILE, KEY_COMPILE_ALL, KEY_COMPILE_PROJECT, KEY_COMPLETE_FILE, KEY_COPY, KEY_CUT, KEY_CUT_LINE, KEY_DEBUG_AUTOMATIC_TRACE, 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_DOWN_SELECT, KEY_DRJAVA_ERRORS, KEY_DRJAVA_SURVEY, KEY_END_DOCUMENT, KEY_END_DOCUMENT_SELECT, KEY_END_LINE, KEY_END_LINE_SELECT, KEY_EXEC_PROCESS, KEY_EXECUTE_HISTORY, KEY_EXPORT_OLD, KEY_FIND_NEXT, KEY_FIND_PREV, KEY_FIND_REPLACE, KEY_FOLLOW_FILE, KEY_FOR_UNIT_TESTS_ONLY, KEY_FORCE_QUIT, KEY_FORWARD, KEY_FORWARD_SELECT, KEY_GENERATE_CUSTOM_DRJAVA, KEY_GOTO_FILE, KEY_GOTO_FILE_UNDER_CURSOR, KEY_GOTO_LINE, KEY_HELP, KEY_JAR_PROJECT, KEY_JAVADOC_ALL, KEY_JAVADOC_CURRENT, KEY_JUNIT_PROJECT, KEY_LIFT_CURRENT_INTERACTION, KEY_LOAD_HISTORY_SCRIPT, KEY_NEW_CLASS_FILE, KEY_NEW_DRJAVA_INSTANCE, KEY_NEW_FILE, KEY_NEW_PROJECT, KEY_NEW_TEST, KEY_NEXT_DOCUMENT, KEY_NEXT_PANE, KEY_NEXT_WORD, KEY_NEXT_WORD_SELECT, 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_PREVIOUS_WORD_SELECT, KEY_PRINT, KEY_PRINT_CONSOLE, KEY_PRINT_INTERACTIONS, KEY_PRINT_PREVIEW, KEY_PROJECT_PROPERTIES, KEY_QUICKSTART, KEY_QUIT, KEY_REDO, KEY_RENAME_FILE, KEY_RESET_INTERACTIONS, KEY_REVERT_FILE, KEY_RUN, KEY_RUN_APPLET, KEY_RUN_PROJECT, KEY_SAVE_ALL_FILES, KEY_SAVE_AS_PROJECT, KEY_SAVE_CONSOLE_COPY, KEY_SAVE_FILE, KEY_SAVE_FILE_AS, KEY_SAVE_FILE_COPY, KEY_SAVE_HISTORY, KEY_SAVE_INTERACTIONS_COPY, KEY_SAVE_PROJECT, KEY_SELECT_ALL, KEY_SHIFT_DELETE_NEXT, KEY_SHIFT_DELETE_PREVIOUS, KEY_TABBED_NEXT_REGION, KEY_TABBED_PREV_REGION, KEY_TEST, KEY_TEST_ALL, KEY_UNCOMMENT_LINES, KEY_UNDO, KEY_UP, KEY_UP_SELECT, KEY_VIEW_INTERACTIONS_CLASSPATH, LANGUAGE_LEVEL, LANGUAGE_LEVEL_EXTENSIONS, LAST_DIRECTORY, LAST_DRJAVA_SURVEY, LAST_DRJAVA_SURVEY_RESULT, LAST_INTERACTIONS_DIRECTORY, LAST_NEW_VERSION_NOTIFICATION, LIGHTWEIGHT_PARSING_ENABLED, LINEENUM_ENABLED, linkChoices, linkDeprecated, linkVersionChoices, linkVersionDeprecated, LOOK_AND_FEEL, MASK, MASTER_JVM_ARGS, MASTER_JVM_XMX, NEW_VERSION_ALLOWED, NEW_VERSION_NOTIFICATION, NEW_VERSION_NOTIFICATION_CHOICES, NEW_VERSION_NOTIFICATION_DAYS, OLD_DJ0_FILE_EXTENSION, OLD_DJ1_FILE_EXTENSION, OLD_DJ2_FILE_EXTENSION, OLD_PROJECT_FILE_EXTENSION, OPEN_FOLDER_RECURSIVE, PLASTIC_THEMES, PROJECT_FILE_EXTENSION, PROJECT_FILE_EXTENSION2, PROMPT_BEFORE_CLEAN, PROMPT_RENAME_LL_FILES, QUIT_PROMPT, RECENT_FILES, RECENT_FILES_MAX_SIZE, RECENT_PROJECTS, REMOTE_CONTROL_ENABLED, REMOTE_CONTROL_PORT, RESET_CLEAR_CONSOLE, RIGHT_MARGIN_COLOR, RIGHT_MARGIN_COLUMNS, RT_CONCJUNIT_LOCATION, 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, SMART_RUN_FOR_APPLETS_AND_PROGRAMS, STICKY_INTERACTIONS_DIRECTORY, SYSTEM_ERR_COLOR, SYSTEM_IN_COLOR, SYSTEM_OUT_COLOR, TABS_HEIGHT, TEXT_ANTIALIAS, TEXT_FILE_EXTENSION, TOOLBAR_ENABLED, TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, WARN_BREAKPOINT_OUT_OF_SYNC, WARN_CHANGE_DCP, WARN_CHANGE_INTERACTIONS, WARN_CHANGE_LAF, WARN_CHANGE_MISC, WARN_CHANGE_THEME, WARN_DEBUG_MODIFIED_FILE, WARN_IF_COMPIZ, WARN_PATH_CONTAINS_POUND, WINDOW_HEIGHT, WINDOW_STATE, WINDOW_STORE_POSITION, WINDOW_WIDTH, WINDOW_X, WINDOW_Y
 
Constructor Summary
AbstractGlobalModel()
          Constructs a new GlobalModel.
 
Method Summary
private  void _completeOpenFile(OpenDefinitionsDocument d)
           
protected  AbstractGlobalModel.ConcreteOpenDefDoc _createOpenDefinitionsDocument(File f)
          Creates a ConcreteOpenDefDoc for an existing file f.
protected  AbstractGlobalModel.ConcreteOpenDefDoc _createOpenDefinitionsDocument(NullFile f)
          Creates a ConcreteOpenDefDoc for a NullFile object f (corresponding to a new empty document)
protected  void _docAppend(ConsoleDocument doc, String s, String style)
          Appends a string to the given document using a particular attribute set.
private  void _ensureNotActive(List<OpenDefinitionsDocument> docs)
          Makes sure that none of the documents in the list are active.
private  void _ensureNotEmpty()
          Creates a new document if there are currently no documents open.
protected  OpenDefinitionsDocument _getOpenDocument(File file)
          Returns the OpenDefinitionsDocument corresponding to the given File, or null if that file is not open.
private  File _getSourceFileFromPath(String fileName, File path)
          Gets the file named filename from the given path, if it exists.
private  boolean _hasOneEmptyDocument()
          Returns whether there is currently only one open document which is untitled and unchanged.
private  void _init()
           
private  void _loadProject(ProjectFileIR ir)
          Loads the specified project into the document navigator and opens all of the files (if not already open).
 ProjectProfile _makeProjectProfile(File file, HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
          Writes the project profile augmented by usage info to specified file.
 OpenDefinitionsDocument _openFile(File file)
          Creates a document from a file.
private  OpenDefinitionsDocument[] _openFiles(File[] files)
          Opens all the files in the list, and notifies about the last file opened.
private  OpenDefinitionsDocument _rawOpenFile(File file)
          Creates an OpenDefinitionsDocument for a file.
private  void _registerOptionListeners()
          Registers OptionListeners.
private  void _setActiveDoc(INavigatorItem idoc)
           
 void _toggleBookmark(int pos1, int pos2)
          Raw version of toggleBookmark.
 void aboutToSaveFromSaveAll(OpenDefinitionsDocument doc)
          If the document is untitled, brings it to the top so that the user will know which is being saved.
 void addAuxiliaryFile(OpenDefinitionsDocument doc)
          Adds a document to the list of auxiliary files within _state.
protected  void addDocToClassPath(OpenDefinitionsDocument doc)
          Add a document to the classpath for the slave JVM.
protected  void addDocToNavigator(OpenDefinitionsDocument doc)
          Creates an iNavigatorItem for a document, and adds it to the navigator.
 void addListener(GlobalModelListener listener)
          Add a listener to this global model.
protected  void addNewListeners(Map<OptionParser<?>,String> newValues)
           
 void addToBrowserHistory()
          Add the current location to the browser history.
 void addToBrowserHistory(boolean before)
          Add the current location to the browser history.
 void autoRefreshProject()
          Perform an auto-refresh of the project, adding new source files to the project.
 void cleanBuildDirectory()
          Cleans the build directory.
 void clearHistory()
          throws UnsupportedOperationException
 boolean closeAllFiles()
          Attempts to close all open documents.
 boolean closeAllFilesOnQuit()
          Closes all open documents.
 boolean closeFile(OpenDefinitionsDocument doc)
          Closes an open definitions document, prompting to save if the document has been changed.
protected  boolean closeFileHelper(OpenDefinitionsDocument doc)
          Helper for closeFile.
 boolean closeFiles(List<OpenDefinitionsDocument> docs)
          This function closes a group of files assuming that the files are contiguous in the enumeration provided by the document navigator.
 boolean closeFileWithoutPrompt(OpenDefinitionsDocument doc)
          Closes an open definitions document, without prompting to save if the document has been changed.
 void closeProject(boolean suppressReset)
          Performs any needed operations on the model after project files have been closed.
 void configNewProject()
          Configures a new project (created by createNewProject) and writes it to disk; only runs in event thread.
 RegionManager<MovingDocumentRegion> createFindResultsManager()
           
 void createNewProject(File projFile)
          Creates a new FileGroupingState for specificed project file and default values for other properties.
 void dispose()
          Prepares this model to be thrown away.
 void disposeExternalResources()
          Disposes of external resources.
 void ensureJVMStarterFinished()
          Ensures that the _jvmStarter thread has executed.
 void exportOldProject(File file, HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
          Writes the project profile in the old project format.
 File findFileInPaths(String fileName, Iterable<File> paths)
          Searches for a file with the given name on the provided paths.
 String fixPathForNavigator(String path)
          Formats a string pathname for use in the document navigator.
 void forceQuit()
          Halts the program immediately.
 OpenDefinitionsDocument getActiveDocument()
          Returns the currently active document.
 boolean getAutoRefreshStatus()
          Gets autorfresh status of the project
 String getAuxiliaryBinTitle()
          Gives the title of the aux files bin for the navigator.
 List<OpenDefinitionsDocument> getAuxiliaryDocuments()
          Returns the OpenDefinitionsDocuments that are identified as auxiliary project source files.
 RegionManager<MovingDocumentRegion> getBookmarkManager()
           
 RegionManager<Breakpoint> getBreakpointManager()
           
 BrowserHistoryManager getBrowserHistoryManager()
           
 File getBuildDirectory()
           
 List<File> getClassFiles()
           
 Iterable<File> getClassPath()
          throws an UnsupportedOperationException
 CompilerModel getCompilerModel()
          Gets the CompilerModel, which provides all methods relating to compilers.
 ConsoleDocument getConsoleDocument()
          Gets the console document.
 File getCreateJarFile()
          Return the create jar file for the project.
 int getCreateJarFlags()
          Return the create jar flags for the project.
 String getCustomManifest()
           
 Debugger getDebugger()
          throws UnsupportedOperationException
 int getDebugPort()
          throws UnsupportedOperationException
 Container getDocCollectionWidget()
           
 DocumentCache getDocumentCache()
          This method is for use only by test cases.
 int getDocumentCount()
          Returns the document count
 OpenDefinitionsDocument getDocumentForFile(File file)
          Gets the document for the specified file; may involve opening the file.
 DocumentIterator getDocumentIterator()
          Gets a DocumentIterator to allow navigating through open Swing Documents.
 IDocumentNavigator<OpenDefinitionsDocument> getDocumentNavigator()
          Gets the DocumentNavigator, which controls the document view.
 DefinitionsEditorKit getEditorKit()
          Fetches the EditorKit implementation for use in the definitions pane.
 File[] getExclFiles()
          Return an array of the files excluded from the current project
 String getExternalBinTitle()
          Gives the title of the external files bin for the navigator
 Iterable<AbsRelFile> getExtraClassPath()
          Returns a project's extra classpaths; empty for FlatFileGroupingState
 File[] getFilesInFolder(File dir, boolean rec, String ext)
           
 List<RegionManager<MovingDocumentRegion>> getFindResultsManagers()
           
 String getHistoryAsString()
          Throws UnsupportedOperationException
 String getHistoryAsStringWithSemicolons()
          Returns the entire history as a String with semicolons as needed.
 Iterable<File> getInteractionsClassPath()
          throws new UnsupportedOperationException
 InteractionsDocument getInteractionsDocument()
          throws UnsupportedOperationException
 DefaultInteractionsModel getInteractionsModel()
          throws UnsupportedOperationException
 JavadocModel getJavadocModel()
          throws UnsupportedOperationException
 JUnitModel getJUnitModel()
          throws UnsupportedOperationException
 List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments()
          Returns a new collection of all language level documents currently open for editing.
 String getMainClass()
          Return the main file for the project If not in project mode, returns null.
 File getMainClassContainingFile()
          Return the File that contains the Main-Class.
 File getMasterWorkingDirectory()
           
 File[] getNewFilesInProject()
          gets files in the project source directory that are not accounted for in the project file.
private  OpenDefinitionsDocument getNextDocHelper(OpenDefinitionsDocument nextdoc, Component frame)
          Checks that the document exists, and if it doesn't, asks if the user wants to continue.
 OpenDefinitionsDocument getNextDocument(OpenDefinitionsDocument d)
          Returns the ODD preceding the given document in the document list.
 OpenDefinitionsDocument getNextDocument(OpenDefinitionsDocument d, Component frame)
          Returns the ODD preceding the given document in the document list.
 List<OpenDefinitionsDocument> getNonProjectDocuments()
          Returns the OpenDefinitionsDocuments that are NOT identified as project source files.
 GlobalEventNotifier getNotifier()
          Notifier list for the global model.
 int getNumCompilerErrors()
          throws UnsupportedOperationException
 OpenDefinitionsDocument getODDForDocument(AbstractDocumentInterface doc)
          Returns the OpenDefinitionsDocument corresponding to the INavigatorItem/DefinitionsDocument passed in.
 String getOpenAllFilesInFolderExtension()
           
 List<OpenDefinitionsDocument> getOpenDefinitionsDocuments()
          Returns a new collection of all documents currently open for editing.
 List<OpenDefinitionsDocument> getOutOfSyncDocuments()
           
 List<OpenDefinitionsDocument> getOutOfSyncDocuments(List<OpenDefinitionsDocument> lod)
           
protected static String getPackageName(String classname)
          Helper method used in subsequent anonymous inner class
 PageFormat getPageFormat()
           
 Map<OptionParser<?>,String> getPreferencesStoredInProject()
           
private  OpenDefinitionsDocument getPrevDocHelper(OpenDefinitionsDocument prevdoc)
           
 OpenDefinitionsDocument getPrevDocument(OpenDefinitionsDocument d)
          Returns the ODD preceding the given document in the document list.
 List<OpenDefinitionsDocument> getProjectDocuments()
          Returns the OpenDefinitionsDocuments that are identified as project source files.
 File getProjectFile()
           
 File[] getProjectFiles()
           
 File getProjectRoot()
           
 List<OpenDefinitionsDocument> getSortedOpenDefinitionsDocuments()
           
 String getSourceBinTitle()
          Gives the title of the source bin for the navigator.
 File getSourceFile(String fileName)
          Searches for a file with the given name on the current source roots and the augmented classpath.
 Iterable<File> getSourceRootSet()
          Gets an array of all sourceRoots for the open definitions documents, without duplicates.
 InteractionsDJDocument getSwingConsoleDocument()
          TODO: remove this swing dependency.
 InteractionsDJDocument getSwingInteractionsDocument()
          throws UnsupportedOperationException
 File getWorkingDirectory()
           
 boolean hasModifiedDocuments()
          Checks if any open definitions documents have been modified since last being saved.
 boolean hasModifiedDocuments(List<OpenDefinitionsDocument> lod)
          Checks if any given documents have been modified since last being saved.
 boolean hasOutOfSyncDocuments()
           
 boolean hasOutOfSyncDocuments(List<OpenDefinitionsDocument> lod)
           
 boolean hasUntitledDocuments()
          Checks if any open definitions documents are untitled.
 boolean inProject(File f)
          Returns true the given file is in the current project file.
 boolean inProjectPath(OpenDefinitionsDocument doc)
          A file is in the project if the source root is the same as the project root.
 void installActiveDocument()
          Invokes the activeDocumentChanged method in the global listener on the argument _activeDocument.
 void interpretCurrentInteraction()
          throw new UnsupportedOperationException
 boolean isAlreadyOpen(File file)
          Iterates over OpenDefinitionsDocuments, looking for this file.
 boolean isClassPathChanged()
           
 boolean isProjectActive()
           
 boolean isProjectChanged()
          Returns true if the project state has been changed
static boolean isUntitled(File f)
           
 void loadHistory(FileOpenSelector selector)
          throws UnsupportedOperationException
 InteractionsScriptModel loadHistoryAsScript(FileOpenSelector selector)
          throws UnsupportedOperationException
protected  FileGroupingState makeFlatFileGroupingState()
           
protected  FileGroupingState makeProjectFileGroupingState(File pr, String main, File bd, File wd, File project, File[] srcFiles, File[] auxFiles, File[] excludedFiles, Iterable<AbsRelFile> cp, File cjf, int cjflags, boolean refresh, String manifest, Map<OptionParser<?>,String> storedPreferences)
           
 OpenDefinitionsDocument newFile()
          Creates a new document, adds it to the list of open documents, and sets it to be active.
 OpenDefinitionsDocument newFile(File parentDir)
          Creates a new open definitions document and adds it to the list.
 OpenDefinitionsDocument newFile(File parentDir, String text)
          Creates a new open definitions document and adds it to the list.
 OpenDefinitionsDocument newFile(String text)
          Creates a new document, adds it to the list of open documents, and sets it to be active.
 OpenDefinitionsDocument newTestCase(String name, boolean makeSetUp, boolean makeTearDown)
          Creates a new junit test case.
 OpenDefinitionsDocument openFile(FileOpenSelector com)
          Open a file and add it to the pool of definitions documents.
protected  OpenDefinitionsDocument openFileHelper(FileOpenSelector com)
           
 OpenDefinitionsDocument[] openFiles(FileOpenSelector com)
          Open multiple files and add them to the pool of definitions documents.
protected  OpenDefinitionsDocument[] openFilesHelper(FileOpenSelector com)
           
 void openFolder(File dir, boolean rec, String ext)
          Opens all files in the specified folder dir and places them in the appropriate places in the document navigator.
 void openNewFilesInProject()
          Searches the source folder (recursively) for new files and opens them.
 void openProject(File projectFile)
          Parses the given project file and loads it into the document navigator and resets interactions pane.
protected static
<T> T
pop(ArrayList<T> stack)
          This pop method enables an ArrayList to serve as stack.
 void printDebugMessage(String s)
          throws UnsupportedOperationException
 void quit()
          Exits the program.
private  void quit(boolean force)
          Exits the program.
 void refreshActiveDocument()
          Makes the active document (in this model) the selection in the documentNavigator and invokes the activedocumentRefreshed method in the global listener on this document.
 void reloadProject(File file, HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
          Reloads a project without writing to disk.
 void removeAuxiliaryFile(OpenDefinitionsDocument doc)
          Removes a document from the list of auxiliary files within _state.
 void removeFindResultsManager(RegionManager<MovingDocumentRegion> rm)
          Remove a manager from the model.
 void removeListener(GlobalModelListener listener)
          Remove a listener from this global model.
protected  void removePreviousListeners()
           
 void resetConsole()
          Resets the console.
 void resetInteractions(File wd)
          A degenerate operation since this has no slave JVM and no interactions model.
 void resetInteractions(File wd, boolean forceReset)
          A degenerate operation since this has no slave JVM and no interactions model.
 void saveAllFiles(FileSaveSelector com)
          Saves all open files, prompting for names if necessary.
protected  void saveAllFilesHelper(FileSaveSelector com)
          Called by saveAllFiles in DefaultGlobalModel
 void saveConsoleCopy(ConsoleDocument doc, FileSaveSelector selector)
          throws UnsupportedOperationException
 void saveHistory(FileSaveSelector selector)
          throws UnsupportedOperationException
 void saveHistory(FileSaveSelector selector, String editedVersion)
          throws UnsupportedOperationException
 void saveProject(File file, HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
          Writes the project profile augmented by usage info to specified file.
 void setActiveDocument(OpenDefinitionsDocument doc)
          Sets the currently active document by updating the selection model.
 void setActiveFirstDocument()
          Selects the first document as the active document.
 void setActiveNextDocument()
          Sets the active document to be the next one in the collection.
 void setActivePreviousDocument()
          Sets the active document to be the previous one in the collection.
 void setAutoRefreshStatus(boolean status)
          Sets autofresh status of the project
 void setBuildDirectory(File f)
          Sets the class with the project's main method.
 void setClassPathChanged(boolean changed)
          Updates the classpath state.
 void setCreateJarFile(File f)
          Sets the create jar file of the project.
 void setCreateJarFlags(int f)
          Sets the create jar flags of the project.
 void setCustomManifest(String manifest)
           
(package private)  void setDefinitionsIndent(int indent)
          Set the indent tab size for all definitions documents.
 void setDocumentNavigator(IDocumentNavigator<OpenDefinitionsDocument> newnav)
           
 void setExcludedFiles(File[] fs)
          Sets the array of files excluded from the current project
 void setExtraClassPath(Iterable<AbsRelFile> cp)
          Sets the set of classpath entries to use as the projects set of classpath entries.
 void setFileGroupingState(FileGroupingState state)
           
 void setMainClass(String f)
          Sets the class with the project's main method.
 void setNumCompilerErrors(int num)
          throws UnsupportedOperationException
 void setPageFormat(PageFormat format)
           
 void setPreferencesStoredInProject(Map<OptionParser<?>,String> sp)
          Set the preferences stored in the project.
 void setProjectChanged(boolean changed)
          Notifies the project state that the project has been changed.
 void setProjectFile(File f)
          Sets project file to specifed value; used in "Save Project As ..." command in MainFrame.
 void setProjectRoot(File f)
          Sets the class with the project's main method.
 void setWorkingDirectory(File f)
          Sets the working directory for the project; ignored in flat file model.
private  void shutdown(boolean force)
           
 void systemErrPrint(String s)
          Prints System.err to the DrJava console.
 void systemInEcho(String s)
          Prints to the DrJava console as an echo of System.in.
 void systemOutPrint(String s)
          Prints System.out to the DrJava console.
 void toggleBookmark(int pos1, int pos2)
          Toogle the specified bookmark in the active document.
 void updateSyntaxHighlighting()
          Update the syntax highlighting for all open documents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

public static final Log _log

_cache

protected final DocumentCache _cache
A document cache that manages how many unmodified documents are open at once.


DOCUMENT_OUT_OF_SYNC_MSG

static final String DOCUMENT_OUT_OF_SYNC_MSG
See Also:
Constant Field Values

CLASSPATH_OUT_OF_SYNC_MSG

static final String CLASSPATH_OUT_OF_SYNC_MSG
See Also:
Constant Field Values

_notifier

public final GlobalEventNotifier _notifier
Keeps track of all listeners to the model, and has the ability to notify them of some event. Originally used a Command Pattern style, but this has been replaced by having EventNotifier directly implement all listener interfaces it supports. Set in constructor so that subclasses can install their own notifier with additional methods.


_editorKit

protected final DefinitionsEditorKit _editorKit
Factory for new definitions documents and views.


_documentsRepos

private final AbstractMap<File,OpenDefinitionsDocument> _documentsRepos
Collection for storing all OpenDefinitionsDocuments.


_consoleDoc

protected final ConsoleDocument _consoleDoc
The document used to display System.out and System.err, and to read from System.in.


_consoleDocAdapter

protected final InteractionsDJDocument _consoleDocAdapter
The document adapter used in the console document.


_pageFormat

protected volatile PageFormat _pageFormat
A PageFormat object for printing to paper.


_activeDocument

private volatile OpenDefinitionsDocument _activeDocument
The active document pointer, which will never be null once the constructor is done. Maintained by the _gainVisitor with a navigation listener.


_activeDirectory

private volatile File _activeDirectory
A pointer to the active directory, which is not necessarily the parent of the active document The user may click on a folder component in the navigation pane and that will set this field without setting the active document. It is used by the newFile method to place new files into the active directory.


classPathChanged

private volatile boolean classPathChanged
A state varible indicating whether the class path has changed. Reset to false by resetInteractions.


_documentNavigator

protected volatile IDocumentNavigator<OpenDefinitionsDocument> _documentNavigator
The abstract container which contains views of open documents and allows user to navigate document focus among this collection of open documents


_breakpointManager

protected final ConcreteRegionManager<Breakpoint> _breakpointManager
Manager for breakpoint regions.


_bookmarkManager

protected final ConcreteRegionManager<MovingDocumentRegion> _bookmarkManager
Manager for bookmark regions.


_findResultsManagers

protected final LinkedList<RegionManager<MovingDocumentRegion>> _findResultsManagers
Managers for find result regions.


_browserHistoryManager

protected final BrowserHistoryManager _browserHistoryManager
Manager for browser history regions.


_state

protected volatile FileGroupingState _state
Specifies the state of the navigator pane. The global model delegates the compileAll command to the _state. FileGroupingState synchronization is handled by the compilerModel (??).


LISTENERS_TO_REMOVE

protected static final HashMap<OptionParser<?>,OptionListener<? extends Object>> LISTENERS_TO_REMOVE

STORED_PREFERENCES_LISTENER

public final OptionListener<? extends Object> STORED_PREFERENCES_LISTENER
Constructor Detail

AbstractGlobalModel

public AbstractGlobalModel()
Constructs a new GlobalModel.

Method Detail

getNotifier

public GlobalEventNotifier getNotifier()
Notifier list for the global model.

Specified by:
getNotifier in interface GlobalModel

getBreakpointManager

public RegionManager<Breakpoint> getBreakpointManager()
Specified by:
getBreakpointManager in interface GlobalModel
Returns:
manager for breakpoint regions.

getBookmarkManager

public RegionManager<MovingDocumentRegion> getBookmarkManager()
Specified by:
getBookmarkManager in interface GlobalModel
Returns:
manager for bookmark regions.

getFindResultsManagers

public List<RegionManager<MovingDocumentRegion>> getFindResultsManagers()
Returns:
new copy of list of find results managers for find result regions.

createFindResultsManager

public RegionManager<MovingDocumentRegion> createFindResultsManager()
Specified by:
createFindResultsManager in interface GlobalModel
Returns:
new manager for find result regions.

removeFindResultsManager

public void removeFindResultsManager(RegionManager<MovingDocumentRegion> rm)
Remove a manager from the model.

Specified by:
removeFindResultsManager in interface GlobalModel

getBrowserHistoryManager

public BrowserHistoryManager getBrowserHistoryManager()
Specified by:
getBrowserHistoryManager in interface GlobalModel
Returns:
manager for browser history regions.

_init

private void _init()

setFileGroupingState

public void setFileGroupingState(FileGroupingState state)
Parameters:
state - the new file grouping state.

addAuxiliaryFile

public void addAuxiliaryFile(OpenDefinitionsDocument doc)
Adds a document to the list of auxiliary files within _state. The LinkedList class is not thread safe, so the add operation is synchronized.

Specified by:
addAuxiliaryFile in interface GlobalModel

removeAuxiliaryFile

public void removeAuxiliaryFile(OpenDefinitionsDocument doc)
Removes a document from the list of auxiliary files within _state. The LinkedList class is not thread safe, so operations on _auxiliaryFiles are synchronized.

Specified by:
removeAuxiliaryFile in interface GlobalModel

makeProjectFileGroupingState

protected FileGroupingState makeProjectFileGroupingState(File pr,
                                                         String main,
                                                         File bd,
                                                         File wd,
                                                         File project,
                                                         File[] srcFiles,
                                                         File[] auxFiles,
                                                         File[] excludedFiles,
                                                         Iterable<AbsRelFile> cp,
                                                         File cjf,
                                                         int cjflags,
                                                         boolean refresh,
                                                         String manifest,
                                                         Map<OptionParser<?>,String> storedPreferences)

isClassPathChanged

public boolean isClassPathChanged()
Returns:
true if the class path state has been changed.

setClassPathChanged

public void setClassPathChanged(boolean changed)
Updates the classpath state.


setProjectChanged

public void setProjectChanged(boolean changed)
Notifies the project state that the project has been changed.

Specified by:
setProjectChanged in interface GlobalModel

isProjectChanged

public boolean isProjectChanged()
Description copied from interface: GlobalModel
Returns true if the project state has been changed

Specified by:
isProjectChanged in interface GlobalModel
Returns:
true if the project state has been changed.

isProjectActive

public boolean isProjectActive()
Specified by:
isProjectActive in interface GlobalModel
Returns:
true if the model has a project open, false otherwise.

getProjectFile

public File getProjectFile()
Specified by:
getProjectFile in interface GlobalModel
Returns:
the file that points to the current project file. Null if not currently in project view

getProjectFiles

public File[] getProjectFiles()
Specified by:
getProjectFiles in interface GlobalModel
Returns:
all files currently saved as source files in the project file. If _state not in project mode, returns null

inProject

public boolean inProject(File f)
Description copied from interface: GlobalModel
Returns true the given file is in the current project file.

Specified by:
inProject in interface GlobalModel
Returns:
true the given file is in the current project file.

inProjectPath

public boolean inProjectPath(OpenDefinitionsDocument doc)
A file is in the project if the source root is the same as the project root. this means that project files must be saved at the source root. (we query the model through the model's state)

Specified by:
inProjectPath in interface GlobalModel

setMainClass

public void setMainClass(String f)
Sets the class with the project's main method.

Specified by:
setMainClass in interface GlobalModel

getMainClass

public String getMainClass()
Description copied from interface: GlobalModel
Return the main file for the project If not in project mode, returns null.

Specified by:
getMainClass in interface GlobalModel
Returns:
the class with the project's main method.

getMainClassContainingFile

public File getMainClassContainingFile()
Description copied from interface: GlobalModel
Return the File that contains the Main-Class.

Specified by:
getMainClassContainingFile in interface GlobalModel
Returns:
the file containing the project's main class.

setCreateJarFile

public void setCreateJarFile(File f)
Sets the create jar file of the project.

Specified by:
setCreateJarFile in interface GlobalModel

getCreateJarFile

public File getCreateJarFile()
Return the create jar file for the project. If not in project mode, returns null.

Specified by:
getCreateJarFile in interface GlobalModel

setCreateJarFlags

public void setCreateJarFlags(int f)
Sets the create jar flags of the project.

Specified by:
setCreateJarFlags in interface GlobalModel

getCreateJarFlags

public int getCreateJarFlags()
Return the create jar flags for the project. If not in project mode, returns 0.

Specified by:
getCreateJarFlags in interface GlobalModel

getProjectRoot

public File getProjectRoot()
Specified by:
getProjectRoot in interface GlobalModel
Returns:
the root of the project sourc tree (assuming one exists).

setProjectRoot

public void setProjectRoot(File f)
Sets the class with the project's main method. Degenerate version overridden in DefaultGlobalModel.

Specified by:
setProjectRoot in interface GlobalModel

setProjectFile

public void setProjectFile(File f)
Sets project file to specifed value; used in "Save Project As ..." command in MainFrame.

Specified by:
setProjectFile in interface GlobalModel

getBuildDirectory

public File getBuildDirectory()
Specified by:
getBuildDirectory in interface GlobalModel
Returns:
the build directory for the project (assuming one exists).

getPreferencesStoredInProject

public Map<OptionParser<?>,String> getPreferencesStoredInProject()
Specified by:
getPreferencesStoredInProject in interface GlobalModel
Returns:
the stored preferences.

setPreferencesStoredInProject

public void setPreferencesStoredInProject(Map<OptionParser<?>,String> sp)
Description copied from interface: GlobalModel
Set the preferences stored in the project.

Specified by:
setPreferencesStoredInProject in interface GlobalModel

setBuildDirectory

public void setBuildDirectory(File f)
Sets the class with the project's main method. Degenerate version overridden in DefaultGlobalModel.

Specified by:
setBuildDirectory in interface GlobalModel

getAutoRefreshStatus

public boolean getAutoRefreshStatus()
Gets autorfresh status of the project

Specified by:
getAutoRefreshStatus in interface GlobalModel

setAutoRefreshStatus

public void setAutoRefreshStatus(boolean status)
Sets autofresh status of the project

Specified by:
setAutoRefreshStatus in interface GlobalModel

getMasterWorkingDirectory

public File getMasterWorkingDirectory()
Specified by:
getMasterWorkingDirectory in interface GlobalModel
Returns:
the working directory for the Master JVM (editor and GUI).

getWorkingDirectory

public File getWorkingDirectory()
Specified by:
getWorkingDirectory in interface GlobalModel
Returns:
the working directory for the Slave (Interactions) JVM

setWorkingDirectory

public void setWorkingDirectory(File f)
Sets the working directory for the project; ignored in flat file model.

Specified by:
setWorkingDirectory in interface GlobalModel

cleanBuildDirectory

public void cleanBuildDirectory()
Description copied from interface: GlobalModel
Cleans the build directory.

Specified by:
cleanBuildDirectory in interface GlobalModel

getClassFiles

public List<File> getClassFiles()
Specified by:
getClassFiles in interface GlobalModel
Returns:
a list of class files.

getPackageName

protected static String getPackageName(String classname)
Helper method used in subsequent anonymous inner class


removePreviousListeners

protected void removePreviousListeners()

addNewListeners

protected void addNewListeners(Map<OptionParser<?>,String> newValues)

makeFlatFileGroupingState

protected FileGroupingState makeFlatFileGroupingState()

getSourceBinTitle

public String getSourceBinTitle()
Gives the title of the source bin for the navigator.

Specified by:
getSourceBinTitle in interface GlobalModel
Returns:
The text used for the source bin in the tree navigator

getExternalBinTitle

public String getExternalBinTitle()
Gives the title of the external files bin for the navigator

Specified by:
getExternalBinTitle in interface GlobalModel
Returns:
The text used for the external files bin in the tree navigator.

getAuxiliaryBinTitle

public String getAuxiliaryBinTitle()
Gives the title of the aux files bin for the navigator.

Specified by:
getAuxiliaryBinTitle in interface GlobalModel
Returns:
The text used for the aux files bin in the tree navigator.

addListener

public void addListener(GlobalModelListener listener)
Add a listener to this global model.

Specified by:
addListener in interface GlobalModel
Parameters:
listener - a listener that reacts on events generated by the GlobalModel.

removeListener

public void removeListener(GlobalModelListener listener)
Remove a listener from this global model.

Specified by:
removeListener in interface GlobalModel
Parameters:
listener - a listener that reacts on events generated by the GlobalModel This method is synchronized using the readers/writers event protocol incorporated in EventNotifier.

getEditorKit

public DefinitionsEditorKit getEditorKit()
Description copied from interface: GlobalModel
Fetches the EditorKit implementation for use in the definitions pane.

Specified by:
getEditorKit in interface GlobalModel

getInteractionsModel

public DefaultInteractionsModel getInteractionsModel()
throws UnsupportedOperationException

Specified by:
getInteractionsModel in interface GlobalModel

getSwingInteractionsDocument

public InteractionsDJDocument getSwingInteractionsDocument()
throws UnsupportedOperationException

Specified by:
getSwingInteractionsDocument in interface GlobalModel
Returns:
InteractionsDJDocument in use by the InteractionsDocument.

getInteractionsDocument

public InteractionsDocument getInteractionsDocument()
throws UnsupportedOperationException

Specified by:
getInteractionsDocument in interface GlobalModel

getConsoleDocument

public ConsoleDocument getConsoleDocument()
Description copied from interface: GlobalModel
Gets the console document.

Specified by:
getConsoleDocument in interface GlobalModel

getSwingConsoleDocument

public InteractionsDJDocument getSwingConsoleDocument()
Description copied from interface: GlobalModel
TODO: remove this swing dependency.

Specified by:
getSwingConsoleDocument in interface GlobalModel
Returns:
InteractionsDJDocument in use by the ConsoleDocument.

getPageFormat

public PageFormat getPageFormat()
Specified by:
getPageFormat in interface GlobalModel

setPageFormat

public void setPageFormat(PageFormat format)
Specified by:
setPageFormat in interface GlobalModel

getCompilerModel

public CompilerModel getCompilerModel()
Description copied from interface: GlobalModel
Gets the CompilerModel, which provides all methods relating to compilers.

Specified by:
getCompilerModel in interface GlobalModel

getNumCompilerErrors

public int getNumCompilerErrors()
throws UnsupportedOperationException

Specified by:
getNumCompilerErrors in interface GlobalModel

setNumCompilerErrors

public void setNumCompilerErrors(int num)
throws UnsupportedOperationException

Specified by:
setNumCompilerErrors in interface GlobalModel

getJUnitModel

public JUnitModel getJUnitModel()
throws UnsupportedOperationException

Specified by:
getJUnitModel in interface GlobalModel

getJavadocModel

public JavadocModel getJavadocModel()
throws UnsupportedOperationException

Specified by:
getJavadocModel in interface GlobalModel

getDocumentNavigator

public IDocumentNavigator<OpenDefinitionsDocument> getDocumentNavigator()
Description copied from interface: GlobalModel
Gets the DocumentNavigator, which controls the document view.

Specified by:
getDocumentNavigator in interface GlobalModel

setDocumentNavigator

public void setDocumentNavigator(IDocumentNavigator<OpenDefinitionsDocument> newnav)
Specified by:
setDocumentNavigator in interface GlobalModel

toggleBookmark

public void toggleBookmark(int pos1,
                           int pos2)
Toogle the specified bookmark in the active document.

Parameters:
pos1 - first selection position
pos2 - second selection position

_toggleBookmark

public void _toggleBookmark(int pos1,
                            int pos2)
Raw version of toggleBookmark. ASSUMES that read lock is already held

Parameters:
pos1 - first selection position
pos2 - second selection position

newFile

public OpenDefinitionsDocument newFile(File parentDir)
Creates a new open definitions document and adds it to the list. Public for testing purposes. Only runs in the event thread.

Parameters:
parentDir - directory in which the document should be located
Returns:
The new open document

newFile

public OpenDefinitionsDocument newFile(File parentDir,
                                       String text)
Creates a new open definitions document and adds it to the list. Public for testing purposes. Only runs in the event thread.

Parameters:
parentDir - directory in which the document should be located
text - text for the new document
Returns:
The new open document

newFile

public OpenDefinitionsDocument newFile(String text)
Creates a new document, adds it to the list of open documents, and sets it to be active.

Specified by:
newFile in interface GlobalModel
Parameters:
text - for the new document
Returns:
The new open document

newFile

public OpenDefinitionsDocument newFile()
Creates a new document, adds it to the list of open documents, and sets it to be active.

Specified by:
newFile in interface GlobalModel
Returns:
The new open document

newTestCase

public OpenDefinitionsDocument newTestCase(String name,
                                           boolean makeSetUp,
                                           boolean makeTearDown)
Creates a new junit test case.

Specified by:
newTestCase in interface GlobalModel
Parameters:
name - the name of the new test case
makeSetUp - true iff an empty setUp() method should be included
makeTearDown - true iff an empty tearDown() method should be included
Returns:
the new open test case

getDocumentCache

public DocumentCache getDocumentCache()
This method is for use only by test cases.


openFile

public OpenDefinitionsDocument openFile(FileOpenSelector com)
                                 throws IOException,
                                        OperationCanceledException,
                                        AlreadyOpenException
Open a file and add it to the pool of definitions documents. The provided file selector chooses a file, and on a successful open, the fileOpened() event is fired. This method also checks if there was previously a single unchanged, untitled document open, and if so, closes it after a successful opening.

Specified by:
openFile in interface ILoadDocuments
Parameters:
com - a command pattern command that selects what file to open
Returns:
The open document, or null if unsuccessful
Throws:
IOException
OperationCanceledException - if the open was canceled
AlreadyOpenException - if the file is already open

openFileHelper

protected OpenDefinitionsDocument openFileHelper(FileOpenSelector com)
                                          throws IOException,
                                                 OperationCanceledException,
                                                 AlreadyOpenException
Throws:
IOException
OperationCanceledException
AlreadyOpenException

openFiles

public OpenDefinitionsDocument[] openFiles(FileOpenSelector com)
                                    throws IOException,
                                           OperationCanceledException,
                                           AlreadyOpenException
Open multiple files and add them to the pool of definitions documents. The provided file selector chooses a collection of files, and on successfully opening each file, the fileOpened() event is fired. This method also checks if there was previously a single unchanged, untitled document open, and if so, closes it after a successful opening.

Specified by:
openFiles in interface ILoadDocuments
Parameters:
com - a command pattern command that selects what file to open
Returns:
The open document, or null if unsuccessful
Throws:
IOException
OperationCanceledException - if the open was canceled
AlreadyOpenException - if the file is already open

openFilesHelper

protected OpenDefinitionsDocument[] openFilesHelper(FileOpenSelector com)
                                             throws IOException,
                                                    OperationCanceledException,
                                                    AlreadyOpenException
Throws:
IOException
OperationCanceledException
AlreadyOpenException

_openFiles

private OpenDefinitionsDocument[] _openFiles(File[] files)
                                      throws IOException,
                                             OperationCanceledException,
                                             AlreadyOpenException
Opens all the files in the list, and notifies about the last file opened.

Throws:
IOException
OperationCanceledException
AlreadyOpenException

openFolder

public void openFolder(File dir,
                       boolean rec,
                       String ext)
                throws IOException,
                       OperationCanceledException,
                       AlreadyOpenException
Opens all files in the specified folder dir and places them in the appropriate places in the document navigator. If "open folders recursively" is checked, this operation opens all files in the subtree rooted at dir.

Specified by:
openFolder in interface GlobalModel
Throws:
IOException
OperationCanceledException
AlreadyOpenException

getOpenAllFilesInFolderExtension

public String getOpenAllFilesInFolderExtension()
Returns:
the file extension for the "Open Folder..." command for the currently selected compiler.

getFilesInFolder

public File[] getFilesInFolder(File dir,
                               boolean rec,
                               String ext)
                        throws IOException,
                               OperationCanceledException,
                               AlreadyOpenException
Throws:
IOException
OperationCanceledException
AlreadyOpenException

getNewFilesInProject

public File[] getNewFilesInProject()
gets files in the project source directory that are not accounted for in the project file.

Returns:
null if not in project mode

openNewFilesInProject

public void openNewFilesInProject()
Searches the source folder (recursively) for new files and opens them.


saveAllFiles

public void saveAllFiles(FileSaveSelector com)
                  throws IOException
Saves all open files, prompting for names if necessary. When prompting (i.e., untitled document), set that document as active.

Specified by:
saveAllFiles in interface GlobalModel
Parameters:
com - a FileSaveSelector
Throws:
IOException

saveAllFilesHelper

protected void saveAllFilesHelper(FileSaveSelector com)
                           throws IOException
Called by saveAllFiles in DefaultGlobalModel

Throws:
IOException

createNewProject

public void createNewProject(File projFile)
Creates a new FileGroupingState for specificed project file and default values for other properties.

Specified by:
createNewProject in interface GlobalModel
Parameters:
projFile - the new project file (which does not yet exist in the file system)

configNewProject

public void configNewProject()
                      throws IOException
Configures a new project (created by createNewProject) and writes it to disk; only runs in event thread.

Specified by:
configNewProject in interface GlobalModel
Throws:
IOException

_makeProjectProfile

public ProjectProfile _makeProjectProfile(File file,
                                          HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
                                   throws IOException
Writes the project profile augmented by usage info to specified file. Assumes DrJava is in project mode.

Parameters:
file - where to save the project
info -
Throws:
IOException

saveProject

public void saveProject(File file,
                        HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
                 throws IOException
Writes the project profile augmented by usage info to specified file. Assumes DrJava is in project mode.

Specified by:
saveProject in interface GlobalModel
Parameters:
file - where to save the project
info - Extra view-related information that should be included in the project file
Throws:
IOException

exportOldProject

public void exportOldProject(File file,
                             HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
                      throws IOException
Writes the project profile in the old project format. Assumes DrJava is in project mode.

Parameters:
file - where to save the project
Throws:
IOException

reloadProject

public void reloadProject(File file,
                          HashMap<OpenDefinitionsDocument,DocumentInfoGetter> info)
                   throws IOException
Description copied from interface: GlobalModel
Reloads a project without writing to disk.

Specified by:
reloadProject in interface GlobalModel
Parameters:
file - project file; does not actually get touched
Throws:
IOException

openProject

public void openProject(File projectFile)
                 throws IOException,
                        MalformedProjectFileException
Parses the given project file and loads it into the document navigator and resets interactions pane. Assumes preceding project, if any, has already been closed.

Specified by:
openProject in interface GlobalModel
Parameters:
projectFile - The project file to parse
Throws:
IOException
MalformedProjectFileException

_loadProject

private void _loadProject(ProjectFileIR ir)
                   throws IOException
Loads the specified project into the document navigator and opens all of the files (if not already open). Assumes that any prior project has been closed. Only runs in event thread.

Parameters:
ir - The project file to load
Throws:
IOException

autoRefreshProject

public void autoRefreshProject()
Perform an auto-refresh of the project, adding new source files to the project.


closeProject

public void closeProject(boolean suppressReset)
Performs any needed operations on the model after project files have been closed. This method is not responsible for closing any files; both the files in the project and the project file have already been closed (by MainFrame._closeProject()). Resets interations unless suppressReset is true.

Specified by:
closeProject in interface GlobalModel

aboutToSaveFromSaveAll

public void aboutToSaveFromSaveAll(OpenDefinitionsDocument doc)
If the document is untitled, brings it to the top so that the user will know which is being saved.


closeFile

public boolean closeFile(OpenDefinitionsDocument doc)
Closes an open definitions document, prompting to save if the document has been changed. Returns whether the file was successfully closed. Also ensures the invariant that there is always at least one open document holds by creating a new file if necessary.

Specified by:
closeFile in interface GlobalModel
Returns:
true if the document was closed

closeAllFiles

public boolean closeAllFiles()
Attempts to close all open documents. Also ensures the invariant that there is always at least one open document holds by creating a new file if necessary. Resets interactions iff operation succeeds.

Specified by:
closeAllFiles in interface GlobalModel
Returns:
true if all documents were closed

closeFiles

public boolean closeFiles(List<OpenDefinitionsDocument> docs)
This function closes a group of files assuming that the files are contiguous in the enumeration provided by the document navigator. This assumption is used in selecting which remaining document (if any) to activate.

The corner cases in which the file that is being closed had been externally deleted have been addressed in a few places, namely DefaultGlobalModel.canAbandonFile() and MainFrame.ModelListener.canAbandonFile(). If the DefinitionsDocument for the OpenDefinitionsDocument being closed is not in the cache (see model.cache.DocumentCache) then it is closed without prompting the user to save it. If it is in the cache, then we can successfully notify the user that the file is selected for closing and ask whether to saveAs, close, or cancel.

Specified by:
closeFiles in interface GlobalModel
Specified by:
closeFiles in interface SingleDisplayModel
Parameters:
docs - the list od OpenDefinitionsDocuments to close
Returns:
whether all files were closed

closeFileHelper

protected boolean closeFileHelper(OpenDefinitionsDocument doc)
Helper for closeFile. This method was the closeFile(...) method before projects were added to DrJava.


closeFileWithoutPrompt

public boolean closeFileWithoutPrompt(OpenDefinitionsDocument doc)
Closes an open definitions document, without prompting to save if the document has been changed. Returns whether the file was successfully closed. NOTE: This method should not be called unless it can be absolutely known that the document being closed is not the active document. The closeFile() method in SingleDisplayModel ensures that a new active document is set, but closeFileWithoutPrompt does not.

Specified by:
closeFileWithoutPrompt in interface GlobalModel
Returns:
true if the document was closed.

closeAllFilesOnQuit

public boolean closeAllFilesOnQuit()
Closes all open documents. This operation can be cancelled by the user since it checks if all files can be abandoned BEFORE it actually modifies the project state.

Specified by:
closeAllFilesOnQuit in interface SingleDisplayModel
Returns:
false if the user cancelled

quit

public void quit()
Exits the program. Only quits if all documents are successfully closed.

Specified by:
quit in interface GlobalModel

forceQuit

public void forceQuit()
Halts the program immediately.

Specified by:
forceQuit in interface GlobalModel

quit

private void quit(boolean force)
Exits the program. If force is true, quits regardless of whether all documents are successfully closed.


shutdown

private void shutdown(boolean force)

dispose

public void dispose()
Prepares this model to be thrown away. Never called outside of tests. This version ignores the slave JVM.

Specified by:
dispose in interface SingleDisplayModel

disposeExternalResources

public void disposeExternalResources()
Disposes of external resources. This is a no op in AbstractGlobalModel.

Specified by:
disposeExternalResources in interface SingleDisplayModel

getDocumentForFile

public OpenDefinitionsDocument getDocumentForFile(File file)
                                           throws IOException
Gets the document for the specified file; may involve opening the file.

Specified by:
getDocumentForFile in interface GlobalModel
Parameters:
file - File contained by the document to be returned
Returns:
OpenDefinitionsDocument containing file
Throws:
IOException

isAlreadyOpen

public boolean isAlreadyOpen(File file)
Iterates over OpenDefinitionsDocuments, looking for this file. TODO: This is not very efficient!


getODDForDocument

public OpenDefinitionsDocument getODDForDocument(AbstractDocumentInterface doc)
Returns the OpenDefinitionsDocument corresponding to the INavigatorItem/DefinitionsDocument passed in.

Specified by:
getODDForDocument in interface GlobalModel
Parameters:
doc - the searched for Document
Returns:
its corresponding OpenDefinitionsDocument

getDocumentIterator

public DocumentIterator getDocumentIterator()
Gets a DocumentIterator to allow navigating through open Swing Documents.

Specified by:
getDocumentIterator in interface GlobalModel

getNextDocument

public OpenDefinitionsDocument getNextDocument(OpenDefinitionsDocument d)
Returns the ODD preceding the given document in the document list. NOTE: the returned document may be null if the document wasn't found and the user did not want to continue.

Specified by:
getNextDocument in interface DocumentIterator
Parameters:
d - the current Document
Returns:
the next Document (or null if not found and user did not want to continue)

getNextDocument

public OpenDefinitionsDocument getNextDocument(OpenDefinitionsDocument d,
                                               Component frame)
Returns the ODD preceding the given document in the document list. NOTE: the returned document may be null if the document wasn't found and the user did not want to continue.

Specified by:
getNextDocument in interface DocumentIterator
Parameters:
d - the current Document
frame - the frame that should serve as parent for a potential dialog window
Returns:
the next Document (or null if not found and user did not want to continue)

getNextDocHelper

private OpenDefinitionsDocument getNextDocHelper(OpenDefinitionsDocument nextdoc,
                                                 Component frame)
Checks that the document exists, and if it doesn't, asks if the user wants to continue. NOTE: the returned document may be null if the document wasn't found and the user did not want to continue.

Parameters:
d - the next Document
frame - the frame that should serve as parent for a potential dialog window
Returns:
the next Document (or null if not found and user did not want to continue)

getPrevDocument

public OpenDefinitionsDocument getPrevDocument(OpenDefinitionsDocument d)
Returns the ODD preceding the given document in the document list.

Specified by:
getPrevDocument in interface DocumentIterator
Parameters:
d - the current Document
Returns:
the previous Document

getPrevDocHelper

private OpenDefinitionsDocument getPrevDocHelper(OpenDefinitionsDocument prevdoc)

getDocumentCount

public int getDocumentCount()
Description copied from interface: GlobalModel
Returns the document count

Specified by:
getDocumentCount in interface GlobalModel
Specified by:
getDocumentCount in interface DocumentIterator
Returns:
the size of the collection of OpenDefinitionsDocuments

getOpenDefinitionsDocuments

public List<OpenDefinitionsDocument> getOpenDefinitionsDocuments()
Returns a new collection of all documents currently open for editing. This is equivalent to the results of getDocumentForFile for the set of all files for which isAlreadyOpen returns true.

Specified by:
getOpenDefinitionsDocuments in interface GlobalModel
Returns:
a random-access List of the open definitions documents..

getLLOpenDefinitionsDocuments

public List<OpenDefinitionsDocument> getLLOpenDefinitionsDocuments()
Returns a new collection of all language level documents currently open for editing.

Specified by:
getLLOpenDefinitionsDocuments in interface GlobalModel
Returns:
a random-access List of the open definitions documents..

getSortedOpenDefinitionsDocuments

public List<OpenDefinitionsDocument> getSortedOpenDefinitionsDocuments()

hasOutOfSyncDocuments

public boolean hasOutOfSyncDocuments()
Specified by:
hasOutOfSyncDocuments in interface GlobalModel
Returns:
true if all open documents are in sync with their primary class files.

hasOutOfSyncDocuments

public boolean hasOutOfSyncDocuments(List<OpenDefinitionsDocument> lod)
Specified by:
hasOutOfSyncDocuments in interface GlobalModel
Returns:
true iff no document in given list is out of sync with its primary class file.

getOutOfSyncDocuments

public List<OpenDefinitionsDocument> getOutOfSyncDocuments()
Specified by:
getOutOfSyncDocuments in interface GlobalModel
Returns:
true if all open documents are in sync with their primary class files.

getOutOfSyncDocuments

public List<OpenDefinitionsDocument> getOutOfSyncDocuments(List<OpenDefinitionsDocument> lod)
Specified by:
getOutOfSyncDocuments in interface GlobalModel
Returns:
list of open documents in given list that are out of sync with their primary class files.

setDefinitionsIndent

void setDefinitionsIndent(int indent)
Set the indent tab size for all definitions documents.

Parameters:
indent - the number of spaces to make per level of indent

resetInteractions

public void resetInteractions(File wd)
A degenerate operation since this has no slave JVM and no interactions model.

Specified by:
resetInteractions in interface GlobalModel

resetInteractions

public void resetInteractions(File wd,
                              boolean forceReset)
A degenerate operation since this has no slave JVM and no interactions model.

Specified by:
resetInteractions in interface GlobalModel

resetConsole

public void resetConsole()
Resets the console. Fires consoleReset() event.

Specified by:
resetConsole in interface GlobalModel

interpretCurrentInteraction

public void interpretCurrentInteraction()
throw new UnsupportedOperationException

Specified by:
interpretCurrentInteraction in interface GlobalModel

loadHistory

public void loadHistory(FileOpenSelector selector)
                 throws IOException
throws UnsupportedOperationException

Specified by:
loadHistory in interface GlobalModel
Throws:
IOException

loadHistoryAsScript

public InteractionsScriptModel loadHistoryAsScript(FileOpenSelector selector)
                                            throws IOException,
                                                   OperationCanceledException
throws UnsupportedOperationException

Specified by:
loadHistoryAsScript in interface GlobalModel
Throws:
IOException
OperationCanceledException

clearHistory

public void clearHistory()
throws UnsupportedOperationException

Specified by:
clearHistory in interface GlobalModel

saveConsoleCopy

public void saveConsoleCopy(ConsoleDocument doc,
                            FileSaveSelector selector)
                     throws IOException
throws UnsupportedOperationException

Specified by:
saveConsoleCopy in interface GlobalModel
Throws:
IOException

saveHistory

public void saveHistory(FileSaveSelector selector)
                 throws IOException
throws UnsupportedOperationException

Specified by:
saveHistory in interface GlobalModel
Parameters:
selector - File to save to
Throws:
IOException

saveHistory

public void saveHistory(FileSaveSelector selector,
                        String editedVersion)
                 throws IOException
throws UnsupportedOperationException

Specified by:
saveHistory in interface GlobalModel
Parameters:
selector - File to save to
editedVersion - Edited verison of the history which will be saved to file instead of the lines saved in the history. The saved file will still include any tags needed to recognize it as a saved interactions file.
Throws:
IOException

getHistoryAsStringWithSemicolons

public String getHistoryAsStringWithSemicolons()
Returns the entire history as a String with semicolons as needed.

Specified by:
getHistoryAsStringWithSemicolons in interface GlobalModel

getHistoryAsString

public String getHistoryAsString()
Throws UnsupportedOperationException

Specified by:
getHistoryAsString in interface GlobalModel

_registerOptionListeners

private void _registerOptionListeners()
Registers OptionListeners. Factored out code from the two constructor.


_docAppend

protected void _docAppend(ConsoleDocument doc,
                          String s,
                          String style)
Appends a string to the given document using a particular attribute set. Also waits for a small amount of time (InteractionsModel.WRITE_DELAY) to prevent any one writer from flooding the model with print calls to the point that the user interface could become unresponsive. Only runs in event thread.

Parameters:
doc - Document to append to
s - String to append to the end of the document
style - the style to print with

systemOutPrint

public void systemOutPrint(String s)
Prints System.out to the DrJava console. This method can safely be run outside the event thread.

Specified by:
systemOutPrint in interface GlobalModel

systemErrPrint

public void systemErrPrint(String s)
Prints System.err to the DrJava console. This method can safely be run outside the event thread.

Specified by:
systemErrPrint in interface GlobalModel

systemInEcho

public void systemInEcho(String s)
Prints to the DrJava console as an echo of System.in. This method can safely be run outside the event thread.

Specified by:
systemInEcho in interface GlobalModel

printDebugMessage

public void printDebugMessage(String s)
throws UnsupportedOperationException

Specified by:
printDebugMessage in interface GlobalModel

getInteractionsClassPath

public Iterable<File> getInteractionsClassPath()
throws new UnsupportedOperationException

Specified by:
getInteractionsClassPath in interface GlobalModel

getExtraClassPath

public Iterable<AbsRelFile> getExtraClassPath()
Returns a project's extra classpaths; empty for FlatFileGroupingState

Specified by:
getExtraClassPath in interface GlobalModel
Returns:
The classpath entries loaded along with the project

setExtraClassPath

public void setExtraClassPath(Iterable<AbsRelFile> cp)
Sets the set of classpath entries to use as the projects set of classpath entries. This is normally used by the project preferences..

Specified by:
setExtraClassPath in interface GlobalModel

getExclFiles

public File[] getExclFiles()
Return an array of the files excluded from the current project

Specified by:
getExclFiles in interface SingleDisplayModel

setExcludedFiles

public void setExcludedFiles(File[] fs)
Sets the array of files excluded from the current project

Specified by:
setExcludedFiles in interface SingleDisplayModel

getSourceRootSet

public Iterable<File> getSourceRootSet()
Gets an array of all sourceRoots for the open definitions documents, without duplicates.

Specified by:
getSourceRootSet in interface GlobalModel

getDebugger

public Debugger getDebugger()
throws UnsupportedOperationException

Specified by:
getDebugger in interface GlobalModel

getDebugPort

public int getDebugPort()
                 throws IOException
throws UnsupportedOperationException

Specified by:
getDebugPort in interface GlobalModel
Throws:
IOException - if unable to get a valid port number.

hasModifiedDocuments

public boolean hasModifiedDocuments()
Checks if any open definitions documents have been modified since last being saved.

Specified by:
hasModifiedDocuments in interface GlobalModel
Returns:
whether any documents have been modified

hasModifiedDocuments

public boolean hasModifiedDocuments(List<OpenDefinitionsDocument> lod)
Checks if any given documents have been modified since last being saved.

Specified by:
hasModifiedDocuments in interface GlobalModel
Returns:
whether any documents have been modified

hasUntitledDocuments

public boolean hasUntitledDocuments()
Checks if any open definitions documents are untitled.

Specified by:
hasUntitledDocuments in interface GlobalModel
Returns:
whether any documents are untitled

getSourceFile

public File getSourceFile(String fileName)
Searches for a file with the given name on the current source roots and the augmented classpath.

Specified by:
getSourceFile in interface GlobalModel
Parameters:
fileName - name of the source file to look for
Returns:
the file corresponding to the given name, or null if it cannot be found

findFileInPaths

public File findFileInPaths(String fileName,
                            Iterable<File> paths)
Searches for a file with the given name on the provided paths. Returns NULL_FILE if the file is not found.

Specified by:
findFileInPaths in interface GlobalModel
Parameters:
fileName - Name of the source file to look for
paths - An array of directories to search
Returns:
the file if it is found, or null otherwise

_getSourceFileFromPath

private File _getSourceFileFromPath(String fileName,
                                    File path)
Gets the file named filename from the given path, if it exists. Returns NULL_FILE if it's not there.

Parameters:
fileName - the file to look for
path - the path to look for it in
Returns:
the file if it exists

addToBrowserHistory

public void addToBrowserHistory()
Add the current location to the browser history. Only runs in event thread. Assumes that doc is not null.

Specified by:
addToBrowserHistory in interface GlobalModel

addToBrowserHistory

public void addToBrowserHistory(boolean before)
Add the current location to the browser history. Only runs in event thread. Assumes that doc is not null.

Parameters:
before - true if the location should be inserted before the current region

getClassPath

public Iterable<File> getClassPath()
throws an UnsupportedOperationException

Specified by:
getClassPath in interface GlobalModel

isUntitled

public static boolean isUntitled(File f)

updateSyntaxHighlighting

public void updateSyntaxHighlighting()
Update the syntax highlighting for all open documents.


_createOpenDefinitionsDocument

protected AbstractGlobalModel.ConcreteOpenDefDoc _createOpenDefinitionsDocument(NullFile f)
Creates a ConcreteOpenDefDoc for a NullFile object f (corresponding to a new empty document)

Returns:
OpenDefinitionsDocument object for a new document

_createOpenDefinitionsDocument

protected AbstractGlobalModel.ConcreteOpenDefDoc _createOpenDefinitionsDocument(File f)
                                                                         throws IOException
Creates a ConcreteOpenDefDoc for an existing file f.

Returns:
OpenDefinitionsDocument object for f
Throws:
FileNotFoundException - if file f does not exist
IOException

_getOpenDocument

protected OpenDefinitionsDocument _getOpenDocument(File file)
Returns the OpenDefinitionsDocument corresponding to the given File, or null if that file is not open.

Parameters:
file - File object to search for
Returns:
Corresponding OpenDefinitionsDocument, or null

getNonProjectDocuments

public List<OpenDefinitionsDocument> getNonProjectDocuments()
Returns the OpenDefinitionsDocuments that are NOT identified as project source files.

Specified by:
getNonProjectDocuments in interface GlobalModel

getAuxiliaryDocuments

public List<OpenDefinitionsDocument> getAuxiliaryDocuments()
Returns the OpenDefinitionsDocuments that are identified as auxiliary project source files.

Specified by:
getAuxiliaryDocuments in interface GlobalModel

getProjectDocuments

public List<OpenDefinitionsDocument> getProjectDocuments()
Returns the OpenDefinitionsDocuments that are identified as project source files.

Specified by:
getProjectDocuments in interface GlobalModel

fixPathForNavigator

public String fixPathForNavigator(String path)
                           throws IOException
Description copied from interface: GlobalModel
Formats a string pathname for use in the document navigator.

Specified by:
fixPathForNavigator in interface GlobalModel
Throws:
IOException

_rawOpenFile

private OpenDefinitionsDocument _rawOpenFile(File file)
                                      throws IOException,
                                             AlreadyOpenException
Creates an OpenDefinitionsDocument for a file. Does not add to the navigator or notify that the file's open. This method should be called only from within another open method that will do all of this clean up.

Parameters:
file - the file to open
Throws:
IOException
AlreadyOpenException

pop

protected static <T> T pop(ArrayList<T> stack)
This pop method enables an ArrayList to serve as stack.


addDocToNavigator

protected void addDocToNavigator(OpenDefinitionsDocument doc)
Creates an iNavigatorItem for a document, and adds it to the navigator. A helper for opening a file or creating a new file.

Parameters:
doc - the document to add to the navigator

addDocToClassPath

protected void addDocToClassPath(OpenDefinitionsDocument doc)
Add a document to the classpath for the slave JVM. Does nothing here because there is no slave JVM. Overridden in DefaultGlobalModel.


_openFile

public OpenDefinitionsDocument _openFile(File file)
                                  throws IOException,
                                         AlreadyOpenException
Creates a document from a file.

Parameters:
file - File to read document from
Returns:
openened document
Throws:
IOException
AlreadyOpenException

_completeOpenFile

private void _completeOpenFile(OpenDefinitionsDocument d)

getActiveDocument

public OpenDefinitionsDocument getActiveDocument()
Returns the currently active document.

Specified by:
getActiveDocument in interface SingleDisplayModel
Returns:
the currently active document.

setActiveDocument

public void setActiveDocument(OpenDefinitionsDocument doc)
Sets the currently active document by updating the selection model.

Specified by:
setActiveDocument in interface SingleDisplayModel
Parameters:
doc - Document to set as active

getDocCollectionWidget

public Container getDocCollectionWidget()
Specified by:
getDocCollectionWidget in interface SingleDisplayModel
Returns:
the IDocumentNavigator container expressed as an AWT component.

setActiveNextDocument

public void setActiveNextDocument()
Sets the active document to be the next one in the collection.

Specified by:
setActiveNextDocument in interface SingleDisplayModel

setActivePreviousDocument

public void setActivePreviousDocument()
Sets the active document to be the previous one in the collection.

Specified by:
setActivePreviousDocument in interface SingleDisplayModel

_hasOneEmptyDocument

private boolean _hasOneEmptyDocument()
Returns whether there is currently only one open document which is untitled and unchanged.


_ensureNotEmpty

private void _ensureNotEmpty()
Creates a new document if there are currently no documents open.


_ensureNotActive

private void _ensureNotActive(List<OpenDefinitionsDocument> docs)
Makes sure that none of the documents in the list are active. Should only be executed in event thread.


setActiveFirstDocument

public void setActiveFirstDocument()
Selects the first document as the active document.

Specified by:
setActiveFirstDocument in interface SingleDisplayModel

_setActiveDoc

private void _setActiveDoc(INavigatorItem idoc)

installActiveDocument

public void installActiveDocument()
Invokes the activeDocumentChanged method in the global listener on the argument _activeDocument. This process sets up _activeDocument as the document in the definitions pane.


refreshActiveDocument

public void refreshActiveDocument()
Makes the active document (in this model) the selection in the documentNavigator and invokes the activedocumentRefreshed method in the global listener on this document. The latter process refreshes the state of the _activeDocument as the document in the definitions pane.

Specified by:
refreshActiveDocument in interface GlobalModel
Specified by:
refreshActiveDocument in interface SingleDisplayModel

ensureJVMStarterFinished

public void ensureJVMStarterFinished()
Ensures that the _jvmStarter thread has executed. Never called in practice outside of GlobalModelTestCase.setUp().

Specified by:
ensureJVMStarterFinished in interface SingleDisplayModel

setCustomManifest

public void setCustomManifest(String manifest)
Specified by:
setCustomManifest in interface GlobalModel

getCustomManifest

public String getCustomManifest()
Specified by:
getCustomManifest in interface GlobalModel