edu.rice.cs.drjava.model
Class DefaultGlobalModel.ConcreteOpenDefDoc

java.lang.Object
  extended by edu.rice.cs.drjava.model.AbstractGlobalModel.ConcreteOpenDefDoc
      extended by edu.rice.cs.drjava.model.DefaultGlobalModel.ConcreteOpenDefDoc
All Implemented Interfaces:
DJDocument, Finalizable<DefinitionsDocument>, OpenDefinitionsDocument, INavigatorItem, AbstractDocumentInterface, SwingDocumentInterface, java.lang.Comparable<OpenDefinitionsDocument>, javax.swing.text.Document, javax.swing.text.StyledDocument
Enclosing class:
DefaultGlobalModel

 class DefaultGlobalModel.ConcreteOpenDefDoc
extends AbstractGlobalModel.ConcreteOpenDefDoc

Inner class to handle operations on each of the open DefinitionsDocuments by the GlobalModel.

This was at one time called the DefinitionsDocumentHandler but was renamed (2004-Jun-8) to be more descriptive/intuitive.


Field Summary
private  InteractionsListener _runMain
           
 
Fields inherited from class edu.rice.cs.drjava.model.AbstractGlobalModel.ConcreteOpenDefDoc
_browserRegions, _caretPosition, _lexiName, _packageName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
DefaultGlobalModel.ConcreteOpenDefDoc(java.io.File f)
          Standard constructor for a document read from a file.
DefaultGlobalModel.ConcreteOpenDefDoc(NullFile f)
           
 
Method Summary
protected  void _runInInteractions(java.lang.String command, java.lang.String qualifiedClassName)
          Runs the main method in this document in the interactions pane after resetting interactions with the source root for this document as the working directory.
 void generateJavadoc(FileSaveSelector saver)
          Generates Javadoc for this document, saving the output to a temporary directory.
 void removeFromDebugger()
          Called to indicate the document is being closed, so to remove all related state from the debug manager.
 void runApplet(java.lang.String qualifiedClassName)
          Runs this document as applet in the interactions pane after resetting interactions with the source root for this document as the working directory.
 void runMain(java.lang.String qualifiedClassName)
          Runs the main method in this document in the interactions pane after resetting interactions with the source root for this document as the working directory.
 void runSmart(java.lang.String qualifiedClassName)
          Runs this document, and tries to be smart about it.
 void startCompile()
          Starting compiling this document.
 void startJUnit()
          Runs JUnit on the current document.
 
Methods inherited from class edu.rice.cs.drjava.model.AbstractGlobalModel.ConcreteOpenDefDoc
_getIndentOfCurrStmt, _getIndentOfCurrStmt, _getIndentOfCurrStmt, _getLineEndPos, _getLineFirstCharPos, _getLineStartPos, _getOffset, addBrowserRegion, addDocumentListener, addFinalizationListener, addStyle, addUndoableEditListener, append, append, append, balanceBackward, balanceForward, canAbandonFile, checkIfClassFileInSync, cleanUpPrintJob, clear, clearBrowserRegions, close, commentLines, compareTo, containsClassOrInterfaceOrEnum, createPosition, createUnwrappedPosition, documentModified, documentReset, documentSaved, fileExists, findCharOnLine, findNextEnclosingBrace, findPrevDelimiter, findPrevDelimiter, findPrevEnclosingBrace, getBackground, getBookmarkManager, getBreakpointManager, getCachedClassFile, getCanonicalPath, getCaretPosition, getCharacterElement, getClassFileInSync, getCompletePath, getCurrentCol, getCurrentLine, getCurrentLocation, getDefaultRootElement, getDocument, getDocumentListeners, getEnclosingClassName, getEndPosition, getFile, getFileName, getFinalizationListeners, getFirstNonWSCharPos, getFirstNonWSCharPos, getFirstNonWSCharPos, getFirstTopLevelClassName, getFont, getForeground, getHighlightStatus, getIndent, getInitialHorizontalScroll, getInitialSelectionEnd, getInitialSelectionStart, getInitialVerticalScroll, getIntelligentBeginLinePos, getLength, getLexiName, getLineOfOffset, getLogicalStyle, getMainClassName, getName, getNumberOfLines, getOffsetOfLine, getPackageName, getPackageNameFromDocument, getPageable, getParagraphElement, getParentDirectory, getProperty, getQualifiedClassName, getQualifiedClassName, getRawFile, getReduced, getRootElements, getSourceRoot, getStartPosition, getStateAtCurrent, getStyle, getText, getText, getText, getTimestamp, getUndoableEditListeners, getUndoManager, gotoLine, indentLines, indentLines, inNewProjectPath, inProject, inProjectPath, insertString, isAuxiliaryFile, isEmpty, isModifiedSinceSave, isReady, isShadowed, isSourceFile, isUntitled, isUntitledAndEmpty, makeReconstructor, modifiedOnDisk, move, preparePrintJob, print, putProperty, quitFile, remove, removeBrowserRegion, removeDocumentListener, removeStyle, removeUndoableEditListener, render, resetModification, resetUndoManager, revertFile, revertIfModifiedOnDisk, saveFile, saveFileAs, setCachedClassFile, setCharacterAttributes, setClassFileInSync, setCurrentLocation, setFile, setIndent, setInitialHScroll, setInitialSelEnd, setInitialSelStart, setInitialVScroll, setLogicalStyle, setPackage, setParagraphAttributes, setParentDirectory, toString, uncommentLines, undoManagerCanRedo, undoManagerCanUndo, updateModifiedSinceSave, updateSyntaxHighlighting, verifyExists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_runMain

private volatile InteractionsListener _runMain
Constructor Detail

DefaultGlobalModel.ConcreteOpenDefDoc

DefaultGlobalModel.ConcreteOpenDefDoc(java.io.File f)
Standard constructor for a document read from a file. Initializes this ODD's DD.

Parameters:
f - file describing DefinitionsDocument to manage

DefaultGlobalModel.ConcreteOpenDefDoc

DefaultGlobalModel.ConcreteOpenDefDoc(NullFile f)
Method Detail

startCompile

public void startCompile()
                  throws java.io.IOException
Starting compiling this document. Used only for unit testing. Only rus in the event thread.

Specified by:
startCompile in interface OpenDefinitionsDocument
Overrides:
startCompile in class AbstractGlobalModel.ConcreteOpenDefDoc
Throws:
java.io.IOException - if a file with errors cannot be opened

_runInInteractions

protected void _runInInteractions(java.lang.String command,
                                  java.lang.String qualifiedClassName)
                           throws ClassNameNotFoundException,
                                  java.io.IOException
Runs the main method in this document in the interactions pane after resetting interactions with the source root for this document as the working directory. Warns the use if the class files for the doucment are not up to date. Fires an event to signal when execution is about to begin. NOTE: this code normally runs in the event thread; it cannot block waiting for an event that is triggered by event thread execution! NOTE: the command to run is constructed using MessageFormat. That means that certain characters, single quotes and curly braces, for example, are special. To write single quotes, you need to double them. To write curly braces, you need to enclose them in single quotes. Example: MessageFormat.format("Abc {0} ''foo'' '{'something'}'", "def") returns "Abc def 'foo' {something}".

Parameters:
command - the command to run, with {0} indicating the place where the class name will be written
qualifiedClassName - the qualified name of the class (in this document) to run. If NULL, it is the name of the top level class.
Throws:
ClassNameNotFoundException - propagated from getFirstTopLevelClass()
java.io.IOException - propagated from GlobalModel.compileAll()

runMain

public void runMain(java.lang.String qualifiedClassName)
             throws ClassNameNotFoundException,
                    java.io.IOException
Runs the main method in this document in the interactions pane after resetting interactions with the source root for this document as the working directory. Warns the use if the class files for the doucment are not up to date. Fires an event to signal when execution is about to begin. NOTE: this code normally runs in the event thread; it cannot block waiting for an event that is triggered by event thread execution!

Specified by:
runMain in interface OpenDefinitionsDocument
Overrides:
runMain in class AbstractGlobalModel.ConcreteOpenDefDoc
Parameters:
qualifiedClassName - the qualified name of the class (in this document) to run. If NULL, it is the name of the top level class.
Throws:
ClassNameNotFoundException - propagated from getFirstTopLevelClass()
java.io.IOException - propagated from GlobalModel.compileAll()

runApplet

public void runApplet(java.lang.String qualifiedClassName)
               throws ClassNameNotFoundException,
                      java.io.IOException
Runs this document as applet in the interactions pane after resetting interactions with the source root for this document as the working directory. Warns the use if the class files for the doucment are not up to date. Fires an event to signal when execution is about to begin. NOTE: this code normally runs in the event thread; it cannot block waiting for an event that is triggered by event thread execution!

Specified by:
runApplet in interface OpenDefinitionsDocument
Overrides:
runApplet in class AbstractGlobalModel.ConcreteOpenDefDoc
Parameters:
qualifiedClassName - the qualified name of the class (in this document) to run. If NULL, it is the name of the top level class.
Throws:
ClassNameNotFoundException - propagated from getFirstTopLevelClass()
java.io.IOException - propagated from GlobalModel.compileAll()

runSmart

public void runSmart(java.lang.String qualifiedClassName)
              throws ClassNameNotFoundException,
                     java.io.IOException
Runs this document, and tries to be smart about it. It detects if the class is a regular Java class with a main method, if it is an applet, or if it is an ACM Java Task Force program. It runs the program appropriately in the interactions pane after resetting interactions with the source root for this document as the working directory. Warns the use if the class files for the doucment are not up to date. Fires an event to signal when execution is about to begin. NOTE: this code normally runs in the event thread; it cannot block waiting for an event that is triggered by event thread execution!

Specified by:
runSmart in interface OpenDefinitionsDocument
Overrides:
runSmart in class AbstractGlobalModel.ConcreteOpenDefDoc
Parameters:
qualifiedClassName - the qualified name of the class (in this document) to run. If NULL, it is the name of the top level class.
Throws:
ClassNameNotFoundException - propagated from getFirstTopLevelClass()
java.io.IOException - propagated from GlobalModel.compileAll()

startJUnit

public void startJUnit()
                throws java.lang.ClassNotFoundException,
                       java.io.IOException
Runs JUnit on the current document. Requires that all source documents are compiled before proceeding.

Specified by:
startJUnit in interface OpenDefinitionsDocument
Overrides:
startJUnit in class AbstractGlobalModel.ConcreteOpenDefDoc
Throws:
java.lang.ClassNotFoundException - when the class is compiled to a location not on the classpath.
java.io.IOException - if a file with errors cannot be opened

generateJavadoc

public void generateJavadoc(FileSaveSelector saver)
                     throws java.io.IOException
Generates Javadoc for this document, saving the output to a temporary directory. The location is provided to the javadocEnded event on the given listener. java@param saver FileSaveSelector for saving the file if it needs to be saved

Specified by:
generateJavadoc in interface OpenDefinitionsDocument
Overrides:
generateJavadoc in class AbstractGlobalModel.ConcreteOpenDefDoc
Parameters:
saver - FileSaveSelector for saving the file if it needs to be saved
Throws:
java.io.IOException

removeFromDebugger

public void removeFromDebugger()
Called to indicate the document is being closed, so to remove all related state from the debug manager.

Specified by:
removeFromDebugger in interface OpenDefinitionsDocument
Overrides:
removeFromDebugger in class AbstractGlobalModel.ConcreteOpenDefDoc