edu.rice.cs.drjava.model
Class DummyOpenDefDoc

java.lang.Object
  extended by edu.rice.cs.drjava.model.DummyOpenDefDoc
All Implemented Interfaces:
DJDocument, Finalizable<DefinitionsDocument>, OpenDefinitionsDocument, INavigatorItem, AbstractDocumentInterface, SwingDocumentInterface, Comparable<OpenDefinitionsDocument>, Document, StyledDocument

public class DummyOpenDefDoc
extends Object
implements OpenDefinitionsDocument


Field Summary
protected  SwingDocument _defDoc
           
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
DummyOpenDefDoc()
           
 
Method Summary
 int _getIndentOfCurrStmt(int pos)
          Returns the indent level of the start of the statement that the cursor is on.
 int _getIndentOfCurrStmt(int pos, char[] delims)
          Returns the indent level of the start of the statement that the cursor is on.
 int _getIndentOfCurrStmt(int pos, char[] delims, char[] whitespace)
          Returns the indent level of the start of the statement that the cursor is on.
 int _getLineEndPos(int pos)
          Returns the absolute position of the end of the current line.
 int _getLineFirstCharPos(int pos)
          Returns the absolute position of the first non-whitespace character on the current line.
 int _getLineStartPos(int pos)
          Returns the absolute position of the beginning of the current line.
 int _getOffset(int lineNum)
           
 void addBrowserRegion(BrowserDocumentRegion r)
          Adds region r to the browserRegions collection for this
 void addDocumentListener(DocumentListener listener)
           
 void addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)
           
 Style addStyle(String nm, Style parent)
           
 void addUndoableEditListener(UndoableEditListener listener)
           
 void append(String str)
           
 void append(String str, AttributeSet set)
          Appends given string with specified attributes to end of this document.
 void append(String str, Style style)
           
 int balanceBackward()
          Finds the match for the closing brace immediately to the left, assuming there is such a brace.
 int balanceForward()
          Finds the match for the open brace immediately to the right, assuming there is such a brace.
 boolean canAbandonFile()
          Returns whether the GlobalModel can abandon this document, asking listeners if isModifiedSinceSave() is true.
 boolean checkIfClassFileInSync()
          Checks if the document is modified.
 void cleanUpPrintJob()
           
 void clear()
          Clears the entire text of the document.
 void clearBrowserRegions()
          Remove the browser regions for this document from the browser history manager.
 void close()
          Should be called when closing an ODD to let the ODD clean up after itself.
 int commentLines(int selStart, int selEnd)
          The following methods are forwarding methods required by the rest of the program in order for the OpenDefinitionsDocument to handle DefinitionsDocuments
 int compareTo(OpenDefinitionsDocument d)
           
 Position createPosition(int offs)
          Creates a "sticky" position within a document
 Position createUnwrappedPosition(int offs)
          Creates a WrappedPosition in the document.
 void documentModified()
          Called when this document is modified so it can notify the cache.
 void documentReset()
          Called when this document is reset so it can notify the cache.
 void documentSaved()
          Called when this document is saved so it can notify the cache.
 boolean fileExists()
          Returns true if the file exists on disk, or if the user has located it on disk.
 int findCharOnLine(int pos, char findChar)
          Determines if the given character exists on the line where the given cursor position is.
 int findNextEnclosingBrace(int pos, char opening, char closing)
          Searching forwards, finds the position of the enclosing brace.
 int findPrevDelimiter(int pos, char[] delims)
          Searching backwards, finds the position of the first character that is one of the given delimiters.
 int findPrevDelimiter(int pos, char[] delims, boolean skipParenPhrases)
          Searching backwards, finds the position of the first character that is one of the given delimiters.
 int findPrevEnclosingBrace(int pos, char opening, char closing)
          Searching backwards, finds the position of the enclosing brace.
 void generateJavadoc(FileSaveSelector saver)
          Generates Javadoc for this document, saving the output to a temporary directory.
 Color getBackground(AttributeSet attr)
           
 RegionManager<MovingDocumentRegion> getBookmarkManager()
           
 RegionManager<Breakpoint> getBreakpointManager()
           
 File getCachedClassFile()
           
 String getCanonicalPath()
          Returns canonical path for well-formed file, "(Untitled)" if no file exists, and absolute path if ill-formed.
 Element getCharacterElement(int pos)
           
 boolean getClassFileInSync()
           
 String getCompletePath()
          Returns canonical path (as defined above) followed by " *" if modified.
 int getCurrentCol()
           
 int getCurrentLine()
           
 int getCurrentLocation()
          Gets the current location of the cursor the document.
 Element getDefaultRootElement()
           
 DefinitionsDocument getDocument()
          Gets the associated DefinitionsDocument which may force materializing it.
 DocumentListener[] getDocumentListeners()
           
 String getEnclosingClassName(int pos, boolean qual)
          Searching backwards finds the name of the enclosing named class or interface.
 Position getEndPosition()
           
 File getFile()
          Returns the file for this document.
 String getFileName()
          Returns the name of this file, or "(Untitled)" if no file.
 List<FinalizationListener<DefinitionsDocument>> getFinalizationListeners()
           
 int getFirstNonWSCharPos(int pos)
          Finds the position of the first non-whitespace character after pos.
 int getFirstNonWSCharPos(int pos, boolean acceptComments)
          Similar to the single-argument version, but allows including comments.
 int getFirstNonWSCharPos(int pos, char[] whitespace, boolean acceptComments)
          Finds the position of the first non-whitespace character after pos.
 String getFirstTopLevelClassName()
          Returns the name of the top level class, if any.
 Font getFont(AttributeSet attr)
           
 Color getForeground(AttributeSet attr)
           
 ArrayList<HighlightStatus> getHighlightStatus(int start, int end)
          Returns highlight status info for text between start and end, coalescing adjoining blocks with the same status.
 INavigatorItem getIDoc()
           
 int getIndent()
          Gets the indent level.
 int getInitialHorizontalScroll()
           
 int getInitialSelectionEnd()
           
 int getInitialSelectionStart()
           
 int getInitialVerticalScroll()
           
 int getIntelligentBeginLinePos(int currPos)
          Returns the "intelligent" beginning of line.
 int getLength()
           
 String getLexiName()
           
 int getLineOfOffset(int offset)
          Translates an offset into the components text to a line number.
 Style getLogicalStyle(int p)
           
 String getName()
          Returns a "simple" name representing this INavigatorItem.
 int getNumberOfLines()
           
 int getOffsetOfLine(int line)
          Translates a line number into an offset.
 String getPackageName()
           
 String getPackageNameFromDocument()
           
 Pageable getPageable()
           
 Element getParagraphElement(int pos)
           
 File getParentDirectory()
          Returns the parent directory of this file, null if it has none.
 Object getProperty(Object key)
           
 String getQualifiedClassName()
           
 String getQualifiedClassName(int pos)
           
 File getRawFile()
          Returns the file for this document; does not check whether the file exists.
 ReducedModelControl getReduced()
           
 Element[] getRootElements()
           
 File getSourceRoot()
          Finds the root directory of the source files.
 Position getStartPosition()
           
 ReducedModelState getStateAtCurrent()
           
 Style getStyle(String nm)
           
 String getText()
          Gets the entire text of the document.
 String getText(int offset, int length)
           
 void getText(int offset, int length, Segment txt)
           
 long getTimestamp()
          Returns the date that this document was last modified.
 UndoableEditListener[] getUndoableEditListeners()
           
 CompoundUndoManager getUndoManager()
          Decorator pattern for the definitions document
 int gotoLine(int line)
          Moves the definitions document to the given line, and returns the resulting character position.
 void indentLines(int selStart, int selEnd)
          Default indentation - uses OTHER flag and no progress indicator.
 void indentLines(int selStart, int selEnd, Indenter.IndentReason reason, ProgressMonitor pm)
          Parameterized indentation for special-case handling.
 boolean inNewProjectPath(File f)
          Determines if this document in the file system tree below the specified root.
 boolean inProject()
           
 boolean inProjectPath()
          Determines if this document in the file system tree below the active project root.
 void insertString(int offset, String str, AttributeSet set)
          Inserts a string of text into the document.
 boolean isAuxiliaryFile()
           
 boolean isEmpty()
          Determines if the document is empty.
 boolean isModifiedSinceSave()
          Determines if this definitions document has changed since the last save.
 boolean isReady()
          Returns whether this document is resident in memory.
 boolean isShadowed(int pos)
          Determines if pos in document is inside a comment or a string.
 boolean isSourceFile()
           
 boolean isUntitled()
          Returns whether this document is currently untitled (indicating whether it has a file yet or not).
 boolean modifiedOnDisk()
          Determines if this definitions document has changed since the last save.
 void move(int dist)
          Moves the current location the specified number of chars (positive is right; negative is left).
 void preparePrintJob()
           
 void print()
           
 void putProperty(Object key, Object value)
           
 boolean quitFile()
          Saves file at user's discretion before quitting.
 void remove(int offs, int len)
          Removes a block of text from the specified location.
 void removeBrowserRegion(BrowserDocumentRegion r)
          Removes region r from the browserRegions collection
 void removeDocumentListener(DocumentListener listener)
           
 void removeFromDebugger()
          Called when this document is being closed, removing related state from the debug manager.
 void removeStyle(String nm)
           
 void removeUndoableEditListener(UndoableEditListener listener)
           
 void render(Runnable r)
           
 void resetModification()
          Resets the document to be unmodified.
 void resetUndoManager()
           
 void revertFile()
          Revert the document to the version saved on disk.
 boolean revertIfModifiedOnDisk()
          Asks the GlobalModel if it can revert current definitions to version on disk.
 void runMain()
          Runs the main method in this document in the interactions pane.
 boolean saveFile(FileSaveSelector com)
          Saves the document with a FileWriter.
 boolean saveFileAs(FileSaveSelector com)
          Saves the document with a FileWriter.
 void setCachedClassFile(File f)
           
 void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)
           
 void setClassFileInSync(boolean val)
           
 void setCurrentLocation(int location)
          Change the current location of the document
 void setFile(File file)
          Sets this document's file
 void setIndent(int indent)
          Sets the indent to a particular number of spaces.
 void setLogicalStyle(int pos, Style s)
           
 void setPackage(String s)
          Sets the cached package name returned by getPackageName();
 void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
           
 void startCompile()
          Starts compiling the source.
 void startJUnit()
          Starts testing the source using JUnit.
 int uncommentLines(int selStart, int selEnd)
           
 boolean undoManagerCanRedo()
           
 boolean undoManagerCanUndo()
           
 void updateModifiedSinceSave()
          Sets the document as modified.
 boolean verifyExists()
          If the file exists, returns true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_defDoc

protected SwingDocument _defDoc
Constructor Detail

DummyOpenDefDoc

public DummyOpenDefDoc()
Method Detail

compareTo

public int compareTo(OpenDefinitionsDocument d)
Specified by:
compareTo in interface Comparable<OpenDefinitionsDocument>

modifiedOnDisk

public boolean modifiedOnDisk()
Description copied from interface: OpenDefinitionsDocument
Determines if this definitions document has changed since the last save.

Specified by:
modifiedOnDisk in interface OpenDefinitionsDocument
Returns:
true if the document has been modified

addBrowserRegion

public void addBrowserRegion(BrowserDocumentRegion r)
Description copied from interface: OpenDefinitionsDocument
Adds region r to the browserRegions collection for this

Specified by:
addBrowserRegion in interface OpenDefinitionsDocument

removeBrowserRegion

public void removeBrowserRegion(BrowserDocumentRegion r)
Description copied from interface: OpenDefinitionsDocument
Removes region r from the browserRegions collection

Specified by:
removeBrowserRegion in interface OpenDefinitionsDocument

saveFile

public boolean saveFile(FileSaveSelector com)
                 throws IOException
Description copied from interface: OpenDefinitionsDocument
Saves the document with a FileWriter. If the file name is already set, the method will use that name instead of whatever selector is passed in.

Specified by:
saveFile in interface OpenDefinitionsDocument
Parameters:
com - a selector that picks the file name
Returns:
true if the file was saved, false if the operation was canceled
Throws:
IOException

canAbandonFile

public boolean canAbandonFile()
Description copied from interface: OpenDefinitionsDocument
Returns whether the GlobalModel can abandon this document, asking listeners if isModifiedSinceSave() is true.

Specified by:
canAbandonFile in interface OpenDefinitionsDocument
Returns:
true if this document can be abandoned

quitFile

public boolean quitFile()
Description copied from interface: OpenDefinitionsDocument
Saves file at user's discretion before quitting.

Specified by:
quitFile in interface OpenDefinitionsDocument
Returns:
true if quitting should continue, false if the user cancelled

setCurrentLocation

public void setCurrentLocation(int location)
Description copied from interface: DJDocument
Change the current location of the document

Specified by:
setCurrentLocation in interface DJDocument
Parameters:
location - the new absolute location

getDocument

public DefinitionsDocument getDocument()
Description copied from interface: OpenDefinitionsDocument
Gets the associated DefinitionsDocument which may force materializing it.

Specified by:
getDocument in interface OpenDefinitionsDocument

isModifiedSinceSave

public boolean isModifiedSinceSave()
Description copied from interface: OpenDefinitionsDocument
Determines if this definitions document has changed since the last save.

Specified by:
isModifiedSinceSave in interface OpenDefinitionsDocument
Returns:
true if the document has been modified

balanceForward

public int balanceForward()
Description copied from interface: DJDocument
Finds the match for the open brace immediately to the right, assuming there is such a brace.

Specified by:
balanceForward in interface DJDocument
Returns:
the relative distance forwards to the offset after the matching brace.

balanceBackward

public int balanceBackward()
Description copied from interface: DJDocument
Finds the match for the closing brace immediately to the left, assuming there is such a brace.

Specified by:
balanceBackward in interface DJDocument
Returns:
the relative distance backwards to the offset before the matching brace.

getFile

public File getFile()
             throws FileMovedException
Description copied from interface: OpenDefinitionsDocument
Returns the file for this document.

Specified by:
getFile in interface OpenDefinitionsDocument
Returns:
the file for this document
Throws:
FileMovedException - if the document's file no longer exists

getRawFile

public File getRawFile()
Description copied from interface: OpenDefinitionsDocument
Returns the file for this document; does not check whether the file exists.

Specified by:
getRawFile in interface OpenDefinitionsDocument

getParentDirectory

public File getParentDirectory()
Description copied from interface: OpenDefinitionsDocument
Returns the parent directory of this file, null if it has none.

Specified by:
getParentDirectory in interface OpenDefinitionsDocument

fileExists

public boolean fileExists()
Description copied from interface: OpenDefinitionsDocument
Returns true if the file exists on disk, or if the user has located it on disk. Returns false if the file has been moved or deleted

Specified by:
fileExists in interface OpenDefinitionsDocument
Specified by:
fileExists in interface INavigatorItem

verifyExists

public boolean verifyExists()
Description copied from interface: OpenDefinitionsDocument
If the file exists, returns true. If it does not exist, prompts the user to look it up. If the user chooses a file, returns true, false otherwise.

Specified by:
verifyExists in interface OpenDefinitionsDocument

cleanUpPrintJob

public void cleanUpPrintJob()
Specified by:
cleanUpPrintJob in interface OpenDefinitionsDocument

getFirstTopLevelClassName

public String getFirstTopLevelClassName()
                                 throws ClassNameNotFoundException
Description copied from interface: OpenDefinitionsDocument
Returns the name of the top level class, if any.

Specified by:
getFirstTopLevelClassName in interface OpenDefinitionsDocument
Throws:
ClassNameNotFoundException - if no top level class name found.

startCompile

public void startCompile()
                  throws IOException
Description copied from interface: OpenDefinitionsDocument
Starts compiling the source. Demands that the definitions be saved before proceeding with the compile. Fires the appropriate events as the compiliation proceeds and finishes. Only executes in the event thread.

Specified by:
startCompile in interface OpenDefinitionsDocument
Throws:
IOException - if a file with errors cannot be opened

runMain

public void runMain()
             throws IOException
Description copied from interface: OpenDefinitionsDocument
Runs the main method in this document in the interactions pane. Demands that the definitions be saved and compiled before proceeding. Fires an event to signal when execution is about to begin.

Specified by:
runMain in interface OpenDefinitionsDocument
Throws:
IOException - propagated from GlobalModel.compileAll()

revertIfModifiedOnDisk

public boolean revertIfModifiedOnDisk()
                               throws IOException
Description copied from interface: OpenDefinitionsDocument
Asks the GlobalModel if it can revert current definitions to version on disk. If ok, it reverts the file to the version on disk.

Specified by:
revertIfModifiedOnDisk in interface OpenDefinitionsDocument
Returns:
true if the document has been reverted
Throws:
IOException

getPageable

public Pageable getPageable()
                     throws IllegalStateException
Specified by:
getPageable in interface OpenDefinitionsDocument
Throws:
IllegalStateException

gotoLine

public int gotoLine(int line)
Description copied from interface: OpenDefinitionsDocument
Moves the definitions document to the given line, and returns the resulting character position.

Specified by:
gotoLine in interface OpenDefinitionsDocument
Parameters:
line - Destination line number. If line exceeds the number of lines in the document, it is interpreted as the last line.
Returns:
Index into document of where it moved

print

public void print()
           throws PrinterException,
                  BadLocationException,
                  FileMovedException
Specified by:
print in interface OpenDefinitionsDocument
Throws:
PrinterException
BadLocationException
FileMovedException

removeFromDebugger

public void removeFromDebugger()
Description copied from interface: OpenDefinitionsDocument
Called when this document is being closed, removing related state from the debug manager.

Specified by:
removeFromDebugger in interface OpenDefinitionsDocument

getBreakpointManager

public RegionManager<Breakpoint> getBreakpointManager()
Specified by:
getBreakpointManager in interface OpenDefinitionsDocument
Returns:
the breakpoint region manager.

getBookmarkManager

public RegionManager<MovingDocumentRegion> getBookmarkManager()
Specified by:
getBookmarkManager in interface OpenDefinitionsDocument
Returns:
the bookmark region manager.

clearBrowserRegions

public void clearBrowserRegions()
Description copied from interface: OpenDefinitionsDocument
Remove the browser regions for this document from the browser history manager.

Specified by:
clearBrowserRegions in interface OpenDefinitionsDocument

isReady

public boolean isReady()
Description copied from interface: OpenDefinitionsDocument
Returns whether this document is resident in memory.

Specified by:
isReady in interface OpenDefinitionsDocument

isUntitled

public boolean isUntitled()
Description copied from interface: OpenDefinitionsDocument
Returns whether this document is currently untitled (indicating whether it has a file yet or not).

Specified by:
isUntitled in interface OpenDefinitionsDocument
Specified by:
isUntitled in interface INavigatorItem
Returns:
true if the document is untitled and has no file

isSourceFile

public boolean isSourceFile()
Specified by:
isSourceFile in interface OpenDefinitionsDocument
Returns:
true if the document's filename ends with the extension ".java", ".dj0", "dj1", or "dj2".

isEmpty

public boolean isEmpty()
Description copied from interface: OpenDefinitionsDocument
Determines if the document is empty.

Specified by:
isEmpty in interface OpenDefinitionsDocument

getSourceRoot

public File getSourceRoot()
                   throws InvalidPackageException
Description copied from interface: OpenDefinitionsDocument
Finds the root directory of the source files.

Specified by:
getSourceRoot in interface OpenDefinitionsDocument
Returns:
The root directory of the source files, based on the package statement.
Throws:
InvalidPackageException - If the package statement is invalid, or if it does not match up with the location of the source file.

getFileName

public String getFileName()
Description copied from interface: OpenDefinitionsDocument
Returns the name of this file, or "(Untitled)" if no file.

Specified by:
getFileName in interface OpenDefinitionsDocument

getCanonicalPath

public String getCanonicalPath()
Description copied from interface: OpenDefinitionsDocument
Returns canonical path for well-formed file, "(Untitled)" if no file exists, and absolute path if ill-formed.

Specified by:
getCanonicalPath in interface OpenDefinitionsDocument

getCompletePath

public String getCompletePath()
Description copied from interface: OpenDefinitionsDocument
Returns canonical path (as defined above) followed by " *" if modified.

Specified by:
getCompletePath in interface OpenDefinitionsDocument

getName

public String getName()
Description copied from interface: INavigatorItem
Returns a "simple" name representing this INavigatorItem. Strings returned by this method may or may not be unique with respect to other INavigatorItems within or without a given IDocumentNavigator.

Specified by:
getName in interface INavigatorItem
Returns:
the simple name for this document.

startJUnit

public void startJUnit()
                throws ClassNotFoundException,
                       IOException
Description copied from interface: OpenDefinitionsDocument
Starts testing the source using JUnit. Demands that the definitions be saved and compiled before proceeding with testing. Fires the appropriate events as the testing proceeds and finishes. TODO: this method is redundant and should be deprecated

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

generateJavadoc

public void generateJavadoc(FileSaveSelector saver)
                     throws IOException
Description copied from interface: OpenDefinitionsDocument
Generates Javadoc for this document, saving the output to a temporary directory. The location is provided to the javadocEnded event on the given listener.

Specified by:
generateJavadoc in interface OpenDefinitionsDocument
Parameters:
saver - FileSaveSelector for saving the file if it needs to be saved
Throws:
IOException

getPackageName

public String getPackageName()
Specified by:
getPackageName in interface OpenDefinitionsDocument
Returns:
the name of the package at the time of the most recent save or load operation.

setPackage

public void setPackage(String s)
Description copied from interface: OpenDefinitionsDocument
Sets the cached package name returned by getPackageName();

Specified by:
setPackage in interface OpenDefinitionsDocument

getPackageNameFromDocument

public String getPackageNameFromDocument()
Specified by:
getPackageNameFromDocument in interface OpenDefinitionsDocument
Returns:
the name of the package currently embedded in document. Forwards to wrapped DefinitionsDocument.

getEnclosingClassName

public String getEnclosingClassName(int pos,
                                    boolean qual)
                             throws BadLocationException,
                                    ClassNameNotFoundException
Description copied from interface: OpenDefinitionsDocument
Searching backwards finds the name of the enclosing named class or interface. NB: ignores comments. WARNING: In long source files and when contained in anonymous inner classes, this function might take a LONG time.

Specified by:
getEnclosingClassName in interface OpenDefinitionsDocument
Parameters:
pos - Position to start from
qual - true to find the fully qualified class name
Returns:
name of the enclosing named class or interface
Throws:
BadLocationException
ClassNameNotFoundException

saveFileAs

public boolean saveFileAs(FileSaveSelector com)
                   throws IOException
Description copied from interface: OpenDefinitionsDocument
Saves the document with a FileWriter. The FileSaveSelector will either provide a file name or prompt the user for one. It is up to the caller to decide what needs to be done to choose a file to save to. Once the file has been saved succssfully, this method fires fileSave(File). If the save fails for any reason, the event is not fired.

Specified by:
saveFileAs in interface OpenDefinitionsDocument
Parameters:
com - a selector that picks the file name.
Returns:
true if the file was saved, false if the operation was canceled
Throws:
IOException

preparePrintJob

public void preparePrintJob()
                     throws BadLocationException,
                            FileMovedException
Specified by:
preparePrintJob in interface OpenDefinitionsDocument
Throws:
BadLocationException
FileMovedException

revertFile

public void revertFile()
                throws IOException
Description copied from interface: OpenDefinitionsDocument
Revert the document to the version saved on disk.

Specified by:
revertFile in interface OpenDefinitionsDocument
Throws:
IOException

checkIfClassFileInSync

public boolean checkIfClassFileInSync()
Description copied from interface: OpenDefinitionsDocument
Checks if the document is modified. If not, searches for the class file corresponding to this document and compares the timestamps of the class file to that of the source file.

Specified by:
checkIfClassFileInSync in interface OpenDefinitionsDocument
Specified by:
checkIfClassFileInSync in interface INavigatorItem
Returns:
is the class file and this OpenDefinitionsDocument are in sync

documentSaved

public void documentSaved()
Description copied from interface: OpenDefinitionsDocument
Called when this document is saved so it can notify the cache.

Specified by:
documentSaved in interface OpenDefinitionsDocument

documentModified

public void documentModified()
Description copied from interface: OpenDefinitionsDocument
Called when this document is modified so it can notify the cache.

Specified by:
documentModified in interface OpenDefinitionsDocument

documentReset

public void documentReset()
Description copied from interface: OpenDefinitionsDocument
Called when this document is reset so it can notify the cache.

Specified by:
documentReset in interface OpenDefinitionsDocument

getCurrentLocation

public int getCurrentLocation()
Description copied from interface: DJDocument
Gets the current location of the cursor the document. Unlike the Swing document model, which is stateless, we must maintain a current location as part of the document because the implementation of the reduced model relies on this state information.

Specified by:
getCurrentLocation in interface DJDocument
Returns:
where the cursor is as the number of characters into the document

getIDoc

public INavigatorItem getIDoc()

resetModification

public void resetModification()
Description copied from interface: OpenDefinitionsDocument
Resets the document to be unmodified.

Specified by:
resetModification in interface OpenDefinitionsDocument

getTimestamp

public long getTimestamp()
Description copied from interface: OpenDefinitionsDocument
Returns the date that this document was last modified.

Specified by:
getTimestamp in interface OpenDefinitionsDocument

updateModifiedSinceSave

public void updateModifiedSinceSave()
Description copied from interface: OpenDefinitionsDocument
Sets the document as modified.

Specified by:
updateModifiedSinceSave in interface OpenDefinitionsDocument

setFile

public void setFile(File file)
Description copied from interface: OpenDefinitionsDocument
Sets this document's file

Specified by:
setFile in interface OpenDefinitionsDocument
Parameters:
file - the file that this OpenDefinitionsDocument is associated with

close

public void close()
Description copied from interface: OpenDefinitionsDocument
Should be called when closing an ODD to let the ODD clean up after itself.

Specified by:
close in interface OpenDefinitionsDocument

inProjectPath

public boolean inProjectPath()
Description copied from interface: OpenDefinitionsDocument
Determines if this document in the file system tree below the active project root.

Specified by:
inProjectPath in interface OpenDefinitionsDocument

inNewProjectPath

public boolean inNewProjectPath(File f)
Description copied from interface: OpenDefinitionsDocument
Determines if this document in the file system tree below the specified root.

Specified by:
inNewProjectPath in interface OpenDefinitionsDocument

inProject

public boolean inProject()
Specified by:
inProject in interface OpenDefinitionsDocument
Specified by:
inProject in interface INavigatorItem
Returns:
true if the documents file is saved in the current project file.

isAuxiliaryFile

public boolean isAuxiliaryFile()
Specified by:
isAuxiliaryFile in interface OpenDefinitionsDocument
Specified by:
isAuxiliaryFile in interface INavigatorItem
Returns:
true if the document's file is a project auxiliary file.

_getLineStartPos

public int _getLineStartPos(int pos)
Description copied from interface: DJDocument
Returns the absolute position of the beginning of the current line. (Just after most recent newline, or 0) Doesn't ignore comments.

Specified by:
_getLineStartPos in interface DJDocument
Parameters:
pos - Any position on the current line
Returns:
position of the beginning of this line

_getLineEndPos

public int _getLineEndPos(int pos)
Description copied from interface: DJDocument
Returns the absolute position of the end of the current line. (At the next newline, or the end of the document.)

Specified by:
_getLineEndPos in interface DJDocument
Parameters:
pos - Any position on the current line
Returns:
position of the end of this line

addDocumentListener

public void addDocumentListener(DocumentListener listener)
Specified by:
addDocumentListener in interface Document

addUndoableEditListener

public void addUndoableEditListener(UndoableEditListener listener)
Specified by:
addUndoableEditListener in interface Document

createPosition

public Position createPosition(int offs)
                        throws BadLocationException
Description copied from interface: AbstractDocumentInterface
Creates a "sticky" position within a document

Specified by:
createPosition in interface AbstractDocumentInterface
Specified by:
createPosition in interface Document
Throws:
BadLocationException

createUnwrappedPosition

public Position createUnwrappedPosition(int offs)
                                 throws BadLocationException
Description copied from interface: OpenDefinitionsDocument
Creates a WrappedPosition in the document.

Specified by:
createUnwrappedPosition in interface OpenDefinitionsDocument
Throws:
BadLocationException

getDefaultRootElement

public Element getDefaultRootElement()
Specified by:
getDefaultRootElement in interface Document

getStartPosition

public Position getStartPosition()
Specified by:
getStartPosition in interface Document

getEndPosition

public Position getEndPosition()
Specified by:
getEndPosition in interface Document

getLength

public int getLength()
Specified by:
getLength in interface AbstractDocumentInterface
Specified by:
getLength in interface Document

getProperty

public Object getProperty(Object key)
Specified by:
getProperty in interface Document

getRootElements

public Element[] getRootElements()
Specified by:
getRootElements in interface Document

getText

public String getText(int offset,
                      int length)
               throws BadLocationException
Specified by:
getText in interface AbstractDocumentInterface
Specified by:
getText in interface Document
Throws:
BadLocationException

getText

public void getText(int offset,
                    int length,
                    Segment txt)
             throws BadLocationException
Specified by:
getText in interface Document
Throws:
BadLocationException

insertString

public void insertString(int offset,
                         String str,
                         AttributeSet set)
                  throws BadLocationException
Description copied from interface: DJDocument
Inserts a string of text into the document. It turns out that this is not where we should do custom processing of the insert; that is done in AbstractDJDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet).

Specified by:
insertString in interface DJDocument
Specified by:
insertString in interface AbstractDocumentInterface
Specified by:
insertString in interface Document
Throws:
BadLocationException

append

public void append(String str,
                   AttributeSet set)
Description copied from interface: AbstractDocumentInterface
Appends given string with specified attributes to end of this document.

Specified by:
append in interface AbstractDocumentInterface

append

public void append(String str,
                   Style style)

append

public void append(String str)

putProperty

public void putProperty(Object key,
                        Object value)
Specified by:
putProperty in interface Document

remove

public void remove(int offs,
                   int len)
            throws BadLocationException
Description copied from interface: DJDocument
Removes a block of text from the specified location. We don't update the reduced model here; that happens in AbstractDJDocument.removeUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent).

Specified by:
remove in interface DJDocument
Specified by:
remove in interface AbstractDocumentInterface
Specified by:
remove in interface Document
Throws:
BadLocationException

removeDocumentListener

public void removeDocumentListener(DocumentListener listener)
Specified by:
removeDocumentListener in interface Document

removeUndoableEditListener

public void removeUndoableEditListener(UndoableEditListener listener)
Specified by:
removeUndoableEditListener in interface Document

render

public void render(Runnable r)
Specified by:
render in interface Document

getUndoManager

public CompoundUndoManager getUndoManager()
Decorator pattern for the definitions document

Specified by:
getUndoManager in interface OpenDefinitionsDocument

commentLines

public int commentLines(int selStart,
                        int selEnd)
Description copied from interface: OpenDefinitionsDocument
The following methods are forwarding methods required by the rest of the program in order for the OpenDefinitionsDocument to handle DefinitionsDocuments

Specified by:
commentLines in interface OpenDefinitionsDocument

uncommentLines

public int uncommentLines(int selStart,
                          int selEnd)
Specified by:
uncommentLines in interface OpenDefinitionsDocument

indentLines

public void indentLines(int selStart,
                        int selEnd)
Description copied from interface: DJDocument
Default indentation - uses OTHER flag and no progress indicator.

Specified by:
indentLines in interface DJDocument
Parameters:
selStart - the offset of the initial character of the region to indent
selEnd - the offset of the last character of the region to indent

getCurrentLine

public int getCurrentLine()
Specified by:
getCurrentLine in interface OpenDefinitionsDocument

getCurrentCol

public int getCurrentCol()
Specified by:
getCurrentCol in interface OpenDefinitionsDocument

getClassFileInSync

public boolean getClassFileInSync()
Specified by:
getClassFileInSync in interface OpenDefinitionsDocument

setClassFileInSync

public void setClassFileInSync(boolean val)
Specified by:
setClassFileInSync in interface OpenDefinitionsDocument

getIntelligentBeginLinePos

public int getIntelligentBeginLinePos(int currPos)
                               throws BadLocationException
Description copied from interface: DJDocument
Returns the "intelligent" beginning of line. If currPos is to the right of the first non-whitespace character, the position of the first non-whitespace character is returned. If currPos is at or to the left of the first non-whitespace character, the beginning of the line is returned.

Specified by:
getIntelligentBeginLinePos in interface DJDocument
Parameters:
currPos - A position on the current line
Throws:
BadLocationException

_getOffset

public int _getOffset(int lineNum)
Specified by:
_getOffset in interface OpenDefinitionsDocument

getQualifiedClassName

public String getQualifiedClassName()
                             throws ClassNameNotFoundException
Specified by:
getQualifiedClassName in interface OpenDefinitionsDocument
Throws:
ClassNameNotFoundException

getQualifiedClassName

public String getQualifiedClassName(int pos)
                             throws ClassNameNotFoundException
Specified by:
getQualifiedClassName in interface OpenDefinitionsDocument
Throws:
ClassNameNotFoundException

getLexiName

public String getLexiName()
Specified by:
getLexiName in interface OpenDefinitionsDocument

getStateAtCurrent

public ReducedModelState getStateAtCurrent()
Specified by:
getStateAtCurrent in interface DJDocument

resetUndoManager

public void resetUndoManager()
Specified by:
resetUndoManager in interface OpenDefinitionsDocument

getCachedClassFile

public File getCachedClassFile()
Specified by:
getCachedClassFile in interface OpenDefinitionsDocument

setCachedClassFile

public void setCachedClassFile(File f)
Specified by:
setCachedClassFile in interface OpenDefinitionsDocument

getDocumentListeners

public DocumentListener[] getDocumentListeners()
Specified by:
getDocumentListeners in interface OpenDefinitionsDocument

getUndoableEditListeners

public UndoableEditListener[] getUndoableEditListeners()
Specified by:
getUndoableEditListeners in interface OpenDefinitionsDocument

addFinalizationListener

public void addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)
Specified by:
addFinalizationListener in interface Finalizable<DefinitionsDocument>
Parameters:
fl - the finalization listener to be notified when this object is garbage collected

getFinalizationListeners

public List<FinalizationListener<DefinitionsDocument>> getFinalizationListeners()
Specified by:
getFinalizationListeners in interface Finalizable<DefinitionsDocument>
Returns:
the list of registered FinalizationListeners

undoManagerCanUndo

public boolean undoManagerCanUndo()
Specified by:
undoManagerCanUndo in interface OpenDefinitionsDocument
Returns:
whether the undo manager can perform any undos.

undoManagerCanRedo

public boolean undoManagerCanRedo()
Specified by:
undoManagerCanRedo in interface OpenDefinitionsDocument
Returns:
whether the undo manager can perform any redos.

getFont

public Font getFont(AttributeSet attr)
Specified by:
getFont in interface StyledDocument

getBackground

public Color getBackground(AttributeSet attr)
Specified by:
getBackground in interface StyledDocument

getForeground

public Color getForeground(AttributeSet attr)
Specified by:
getForeground in interface StyledDocument

getCharacterElement

public Element getCharacterElement(int pos)
Specified by:
getCharacterElement in interface StyledDocument

getParagraphElement

public Element getParagraphElement(int pos)
Specified by:
getParagraphElement in interface StyledDocument

getLogicalStyle

public Style getLogicalStyle(int p)
Specified by:
getLogicalStyle in interface StyledDocument

setLogicalStyle

public void setLogicalStyle(int pos,
                            Style s)
Specified by:
setLogicalStyle in interface StyledDocument

setCharacterAttributes

public void setCharacterAttributes(int offset,
                                   int length,
                                   AttributeSet s,
                                   boolean replace)
Specified by:
setCharacterAttributes in interface StyledDocument

setParagraphAttributes

public void setParagraphAttributes(int offset,
                                   int length,
                                   AttributeSet s,
                                   boolean replace)
Specified by:
setParagraphAttributes in interface StyledDocument

getStyle

public Style getStyle(String nm)
Specified by:
getStyle in interface StyledDocument

removeStyle

public void removeStyle(String nm)
Specified by:
removeStyle in interface StyledDocument

addStyle

public Style addStyle(String nm,
                      Style parent)
Specified by:
addStyle in interface StyledDocument

findPrevEnclosingBrace

public int findPrevEnclosingBrace(int pos,
                                  char opening,
                                  char closing)
                           throws BadLocationException
Description copied from interface: DJDocument
Searching backwards, finds the position of the enclosing brace. NB: ignores comments.

Specified by:
findPrevEnclosingBrace in interface DJDocument
Parameters:
pos - Position to start from
opening - opening brace character
closing - closing brace character
Returns:
position of enclosing curly brace, or ERROR_INDEX (-1) if beginning of document is reached.
Throws:
BadLocationException

findNextEnclosingBrace

public int findNextEnclosingBrace(int pos,
                                  char opening,
                                  char closing)
                           throws BadLocationException
Description copied from interface: DJDocument
Searching forwards, finds the position of the enclosing brace. NB: ignores comments.

Specified by:
findNextEnclosingBrace in interface DJDocument
Parameters:
pos - Position to start from
opening - opening brace character
closing - closing brace character
Returns:
position of enclosing curly brace, or ERROR_INDEX (-1) if beginning of document is reached.
Throws:
BadLocationException

getFirstNonWSCharPos

public int getFirstNonWSCharPos(int pos)
                         throws BadLocationException
Description copied from interface: DJDocument
Finds the position of the first non-whitespace character after pos. NB: Skips comments and all whitespace, including newlines

Specified by:
getFirstNonWSCharPos in interface DJDocument
Parameters:
pos - Position to start from
Returns:
position of first non-whitespace character after pos, or ERROR_INDEX (-1) if end of document is reached
Throws:
BadLocationException

getFirstNonWSCharPos

public int getFirstNonWSCharPos(int pos,
                                boolean acceptComments)
                         throws BadLocationException
Description copied from interface: DJDocument
Similar to the single-argument version, but allows including comments.

Specified by:
getFirstNonWSCharPos in interface DJDocument
Parameters:
pos - Position to start from
acceptComments - if true, find non-whitespace chars in comments
Returns:
position of first non-whitespace character after pos, or ERROR_INDEX (-1) if end of document is reached
Throws:
BadLocationException

getFirstNonWSCharPos

public int getFirstNonWSCharPos(int pos,
                                char[] whitespace,
                                boolean acceptComments)
                         throws BadLocationException
Description copied from interface: DJDocument
Finds the position of the first non-whitespace character after pos. NB: Skips comments and all whitespace, including newlines

Specified by:
getFirstNonWSCharPos in interface DJDocument
Parameters:
pos - Position to start from
whitespace - array of whitespace chars to ignore
acceptComments - if true, find non-whitespace chars in comments
Returns:
position of first non-whitespace character after pos, or ERROR_INDEX (-1) if end of document is reached
Throws:
BadLocationException

_getLineFirstCharPos

public int _getLineFirstCharPos(int pos)
                         throws BadLocationException
Description copied from interface: DJDocument
Returns the absolute position of the first non-whitespace character on the current line. NB: Doesn't ignore comments.

Specified by:
_getLineFirstCharPos in interface DJDocument
Parameters:
pos - position on the line
Returns:
position of first non-whitespace character on this line, or the end of the line if no non-whitespace character is found.
Throws:
BadLocationException

findCharOnLine

public int findCharOnLine(int pos,
                          char findChar)
Description copied from interface: DJDocument
Determines if the given character exists on the line where the given cursor position is. Does not search in quotes or comments.

Does not work if character being searched for is a '/' or a '*'

Specified by:
findCharOnLine in interface DJDocument
Parameters:
pos - Cursor position
findChar - Character to search for
Returns:
true if this node's rule holds.

_getIndentOfCurrStmt

public int _getIndentOfCurrStmt(int pos)
                         throws BadLocationException
Description copied from interface: DJDocument
Returns the indent level of the start of the statement that the cursor is on. Uses a default set of delimiters. (';', '{', '}') and a default set of whitespace characters (' ', '\t', n', ',').

Specified by:
_getIndentOfCurrStmt in interface DJDocument
Parameters:
pos - Cursor position
Throws:
BadLocationException

_getIndentOfCurrStmt

public int _getIndentOfCurrStmt(int pos,
                                char[] delims)
                         throws BadLocationException
Description copied from interface: DJDocument
Returns the indent level of the start of the statement that the cursor is on. Uses a default set of whitespace characters (' ', '\t', '\n', ',').

Specified by:
_getIndentOfCurrStmt in interface DJDocument
Parameters:
pos - Cursor position
Throws:
BadLocationException

_getIndentOfCurrStmt

public int _getIndentOfCurrStmt(int pos,
                                char[] delims,
                                char[] whitespace)
                         throws BadLocationException
Description copied from interface: DJDocument
Returns the indent level of the start of the statement that the cursor is on.

Specified by:
_getIndentOfCurrStmt in interface DJDocument
Parameters:
pos - Cursor position
delims - Delimiter characters denoting end of statement
whitespace - characters to skip when looking for beginning of next statement
Throws:
BadLocationException

indentLines

public void indentLines(int selStart,
                        int selEnd,
                        Indenter.IndentReason reason,
                        ProgressMonitor pm)
                 throws OperationCanceledException
Description copied from interface: DJDocument
Parameterized indentation for special-case handling.

Specified by:
indentLines in interface DJDocument
Parameters:
selStart - the offset of the initial character of the region to indent
selEnd - the offset of the last character of the region to indent
reason - a flag from Indenter to indicate the reason for the indent (indent logic may vary slightly based on the trigger action)
pm - used to display progress, null if no reporting is desired
Throws:
OperationCanceledException

findPrevDelimiter

public int findPrevDelimiter(int pos,
                             char[] delims)
                      throws BadLocationException
Description copied from interface: DJDocument
Searching backwards, finds the position of the first character that is one of the given delimiters. Does not look for delimiters inside paren phrases. (eg. skips semicolons used inside for statements.) NB: ignores comments.

Specified by:
findPrevDelimiter in interface DJDocument
Parameters:
pos - Position to start from
delims - array of characters to search for
Returns:
position of first matching delimiter, or ERROR_INDEX (-1) if beginning of document is reached.
Throws:
BadLocationException

findPrevDelimiter

public int findPrevDelimiter(int pos,
                             char[] delims,
                             boolean skipParenPhrases)
                      throws BadLocationException
Description copied from interface: DJDocument
Searching backwards, finds the position of the first character that is one of the given delimiters. Will not look for delimiters inside a paren phrase if skipParenPhrases is true. NB: ignores comments.

Specified by:
findPrevDelimiter in interface DJDocument
Parameters:
pos - Position to start from
delims - array of characters to search for
skipParenPhrases - whether to look for delimiters inside paren phrases (eg. semicolons in a for statement)
Returns:
position of first matching delimiter, or ERROR_INDEX (-1) if beginning of document is reached.
Throws:
BadLocationException

move

public void move(int dist)
Description copied from interface: DJDocument
Moves the current location the specified number of chars (positive is right; negative is left). It is used as a helper for setCurrentLocation(int).

Specified by:
move in interface DJDocument
Parameters:
dist - the distance from the current location to the new location.

getHighlightStatus

public ArrayList<HighlightStatus> getHighlightStatus(int start,
                                                     int end)
Description copied from interface: DJDocument
Returns highlight status info for text between start and end, coalescing adjoining blocks with the same status.

Specified by:
getHighlightStatus in interface DJDocument

setIndent

public void setIndent(int indent)
Description copied from interface: DJDocument
Sets the indent to a particular number of spaces.

Specified by:
setIndent in interface DJDocument
Parameters:
indent - the size of indent that you want for the document

getIndent

public int getIndent()
Description copied from interface: DJDocument
Gets the indent level.

Specified by:
getIndent in interface DJDocument
Returns:
the indent level

getInitialVerticalScroll

public int getInitialVerticalScroll()
Specified by:
getInitialVerticalScroll in interface OpenDefinitionsDocument
Returns:
the initial vertical scroll the pane should use when initialized.

getInitialHorizontalScroll

public int getInitialHorizontalScroll()
Specified by:
getInitialHorizontalScroll in interface OpenDefinitionsDocument
Returns:
the initial vertical scroll the pane should use when initialized.

getInitialSelectionStart

public int getInitialSelectionStart()
Specified by:
getInitialSelectionStart in interface OpenDefinitionsDocument
Returns:
the starting location of the cursor selection that should be set in the pane when initialized.

getInitialSelectionEnd

public int getInitialSelectionEnd()
Specified by:
getInitialSelectionEnd in interface OpenDefinitionsDocument
Returns:
the final location of the cursor selection that should be set in the pane when it is initialized.

getText

public String getText()
Description copied from interface: DJDocument
Gets the entire text of the document. Without this operation, a client must use locking to perform this task safely.

Specified by:
getText in interface DJDocument
Specified by:
getText in interface AbstractDocumentInterface

clear

public void clear()
Description copied from interface: DJDocument
Clears the entire text of the document. Without this operation, a client must use locking to perform this task safely.

Specified by:
clear in interface DJDocument

getReduced

public ReducedModelControl getReduced()
Specified by:
getReduced in interface DJDocument

getNumberOfLines

public int getNumberOfLines()
Specified by:
getNumberOfLines in interface OpenDefinitionsDocument
Returns:
the number of lines in this document.

isShadowed

public boolean isShadowed(int pos)
Determines if pos in document is inside a comment or a string.

Specified by:
isShadowed in interface OpenDefinitionsDocument

getLineOfOffset

public int getLineOfOffset(int offset)
Description copied from interface: OpenDefinitionsDocument
Translates an offset into the components text to a line number.

Specified by:
getLineOfOffset in interface OpenDefinitionsDocument
Parameters:
offset - the offset >= 0
Returns:
the line number >= 0

getOffsetOfLine

public int getOffsetOfLine(int line)
Description copied from interface: OpenDefinitionsDocument
Translates a line number into an offset.

Specified by:
getOffsetOfLine in interface OpenDefinitionsDocument
Parameters:
line - number >= 0
Returns:
offset >= 0