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

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

 class AbstractGlobalModel.ConcreteOpenDefDoc
extends Object
implements OpenDefinitionsDocument

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. Note that this class has a natural ordering that determines a coarser equivalence relation than equals.


Field Summary
private  DrJavaBook _book
           
protected  Set<BrowserDocumentRegion> _browserRegions
          This document's browser regions.
private  DCacheAdapter _cacheAdapter
           
protected  int _caretPosition
           
private  File _classFile
          The cached class file for the document
private  boolean _classFileInSync
          Specifies if classFile is in sync with current state of the document
private  File _file
           
private  String _image
          Cached String image of document as last read from or written to disk; initially null
private  int _initHScroll
           
private  int _initSelEnd
           
private  int _initSelStart
           
private  int _initVScroll
           
protected  String _lexiName
          The fully qualified name of the class with '.' converted to ' ' so that alphabetic ordering works properly.
protected  String _packageName
          The package name embedded in the document the last time is was loaded, reconstructed, or saved.
private  File _parentDir
          The folder containing this document
private  long _timestamp
           
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
(package private) AbstractGlobalModel.ConcreteOpenDefDoc(File f)
          Standard constructor for a document read from a file.
private AbstractGlobalModel.ConcreteOpenDefDoc(File f, File dir, long stamp)
           
(package private) AbstractGlobalModel.ConcreteOpenDefDoc(NullFile f)
           
 
Method Summary
 int _getIndentOfCurrStmt(int pos)
          Assumes read lock is already held.
 int _getIndentOfCurrStmt(int pos, char[] delims)
          Assumes read lock is already held.
 int _getIndentOfCurrStmt(int pos, char[] delims, char[] whitespace)
          Assumes read lock is already held.
 int _getLineEndPos(int pos)
          Gets end of line containing pos (line includes closing '\n').
 int _getLineFirstCharPos(int pos)
          Assumes read lock is already held.
 int _getLineStartPos(int pos)
          Gets start of line containing pos.
 int _getOffset(int lineNum)
          Gets offset of beginning of given 1-based line.
private  File _locateClassFile()
          Returns the class file for this source document by searching the source roots of open documents, the system classpath, and the "extra.classpath ".
 void addBrowserRegion(BrowserDocumentRegion r)
          Adds region r to the browserRegions collection for this
 void addDocumentListener(DocumentListener listener)
          Implementation of the javax.swing.text.Document interface.
 void addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)
          This method is put here because the ODD is the only way to get to the defdoc.
 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()
          Forwarding method to find the match for the open brace immediately to the right, assuming there is such a brace.
 boolean canAbandonFile()
          Asks the listeners if the GlobalModel can abandon the current document.
 boolean checkIfClassFileInSync()
          Determines if document has a class file consistent with its current state.
 void cleanUpPrintJob()
          Clears the pageable object used to hold the print job.
 void clear()
          Clears the entire text of the document.
 void clearBrowserRegions()
          Clear the browser history regions for this document.
 void close()
          Degenerate version of close; does not remove breakpoints in this document
 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 o)
          Orders ODDs by their lexical names.
 boolean containsClassOrInterfaceOrEnum()
          Returns true if one of the words 'class', 'interface' or 'enum' is found in non-comment text.
 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.
 int findCharOnLine(int pos, char findChar)
          Assumes read lock is already held.
 int findNextEnclosingBrace(int pos, char opening, char closing)
          Finds the next brace of specified form enclosing pos.
 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)
          Finds the previous brace of specified form enclosing pos.
 void generateJavadoc(FileSaveSelector saver)
          throws UnsupportedOperationException
 Color getBackground(AttributeSet attr)
           
 RegionManager<MovingDocumentRegion> getBookmarkManager()
           
 RegionManager<Breakpoint> getBreakpointManager()
           
 File getCachedClassFile()
           
 String getCanonicalPath()
          Returns the canonical path for this document, "(Untitled)" if unsaved), "" if the file path is ill-formed.
 int getCaretPosition()
           
 Element getCharacterElement(int pos)
           
 boolean getClassFileInSync()
           
 String getCompletePath()
          Returns the canonical path augmented by " *" if the document has been modified.
 int getCurrentCol()
           
 int getCurrentLine()
           
 int getCurrentLocation()
          Get the location of the cursor in the definitions according to the definitions document.
 Element getDefaultRootElement()
           
 DefinitionsDocument getDocument()
          Gets the definitions document being handled.
 DocumentListener[] getDocumentListeners()
           
 String getEnclosingClassName(int pos, boolean fullyQualified)
          Searching backwards finds the name of the enclosing named class or interface.
 Position getEndPosition()
           
 File getFile()
          Returns the file for this document, null if the document is untitled.
 String getFileName()
          Returns the name of this file, or "(Untitled)" if no file.
 List<FinalizationListener<DefinitionsDocument>> getFinalizationListeners()
           
 int getFirstNonWSCharPos(int pos)
          Only runs in the event thread.
 int getFirstNonWSCharPos(int pos, boolean acceptComments)
          Only runs in the event thread.
 int getFirstNonWSCharPos(int pos, char[] whitespace, boolean acceptComments)
          Assumes read lock is already held.
 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.
 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()
          Getter for lexicographic name; used to sort documents into segemented lexicographic ordder
 int getLineOfOffset(int offset)
          Translates an offset into the components text to a line 0-based number.
 Style getLogicalStyle(int p)
           
 String getMainClassName()
          Returns the name of the main (public) class, if any.
 String getName()
          Returns the name of the file for this document with an appended asterisk (if modified) or spaces
 int getNumberOfLines()
           
 int getOffsetOfLine(int line)
          Translates a 0-based line number into an offset.
 String getPackageName()
           
 String getPackageNameFromDocument()
           
 Pageable getPageable()
          Returns the Pageable object for printing.
 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 field for this document; does not check whether the file is NullFile or file exists.
 ReducedModelControl getReduced()
           
 Element[] getRootElements()
           
 File getSourceRoot()
          Finds the root directory for the source file for this document; null if document is Untitled.
 Position getStartPosition()
          The following two methods are in javax.swing.Document.
 ReducedModelState getStateAtCurrent()
           
 Style getStyle(String nm)
           
 String getText()
          Gets the text of this.
 String getText(int offset, int length)
          Gets the specified substring of this.
 void getText(int offset, int length, Segment txt)
           
 long getTimestamp()
          Returns the timestamp.
 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 projRoot)
          An open file is in the new project if the source root is the same as the new project root.
 boolean inProject()
          A file is in the project if it is explicitly listed as part of the project.
 boolean inProjectPath()
          A file is in the project if the source root is the same as the project root.
 void insertString(int offset, String str, AttributeSet a)
          Inserts a string of text into the document.
 boolean isAuxiliaryFile()
           
 boolean isEmpty()
          Determines if the document is empty.
 boolean isModifiedSinceSave()
          Determines if the document has been modified since the last save.
 boolean isReady()
          Returns true if 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 isUntitledAndEmpty()
           
protected  DDReconstructor makeReconstructor()
          Makes a default DDReconstructor that will make the corresponding DefinitionsDocument.
 boolean modifiedOnDisk()
          Determines if the file for this document has been modified since it was loaded.
 void move(int dist)
          Moves the current location the specified number of chars (positive is right; negative is left).
 void preparePrintJob()
          This method tells the document to prepare all the DrJavaBook and PagePrinter objects.
 void print()
          Prints the given document by bringing up a "Print" window.
 void putProperty(Object key, Object value)
           
 boolean quitFile()
          Fires the quit(File) event if isModifiedSinceSave() is true.
 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()
          throws UnsupportedOperationException
 void removeStyle(String nm)
           
 void removeUndoableEditListener(UndoableEditListener listener)
           
 void render(Runnable r)
           
 void resetModification()
          Whenever this document has been saved, this method should be called to update its "isModified" information.
 void resetUndoManager()
           
 void revertFile()
          Reverts current ODD to file content on disk.
 boolean revertIfModifiedOnDisk()
          Determines if the definitions document has been changed by an outside agent.
 void runApplet(String className)
          throws UnsupportedOperationException
 void runMain(String className)
          throws UnsupportedOperationException
 void runSmart(String className)
          throws UnsupportedOperationException
 boolean saveFile(FileSaveSelector com)
          Saves the document with a FileWriter.
 boolean saveFileAs(FileSaveSelector com)
          Saves the document with a FileWriter.
 void setCachedClassFile(File classFile)
           
 void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)
           
 void setClassFileInSync(boolean inSync)
           
 void setCurrentLocation(int location)
          Forwarding method to sync the definitions with whatever view component is representing them.
 void setFile(File file)
          Sets the file for this openDefinitionsDocument.
 void setIndent(int indent)
          Sets the indent to a particular number of spaces.
(package private)  void setInitialHScroll(int i)
           
(package private)  void setInitialSelEnd(int i)
           
(package private)  void setInitialSelStart(int i)
           
(package private)  void setInitialVScroll(int i)
           
 void setLogicalStyle(int pos, Style s)
           
 void setPackage(String name)
          Sets the cached _packageName for the preceding method.
 void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
           
 void setParentDirectory(File pd)
          Sets the parent directory of the document only if it is "Untitled"
 void startCompile()
          throws UnsupportedOperationException
 void startJUnit()
          throws UnsupportedOperationException
 String toString()
           
 int uncommentLines(int selStart, int selEnd)
           
 boolean undoManagerCanRedo()
          If the undo manager is unavailable, no redos are available
 boolean undoManagerCanUndo()
          If the undo manager is unavailable, no undos are available
 void updateModifiedSinceSave()
          Originally designed to allow undoManager to set the current document to be modified whenever an undo or redo is performed.
 void updateSyntaxHighlighting()
          Update the syntax highlighting for the file type.
 boolean verifyExists()
          Returns true if the file exists on disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_image

private volatile String _image
Cached String image of document as last read from or written to disk; initially null


_file

private volatile File _file

_timestamp

private volatile long _timestamp

_parentDir

private volatile File _parentDir
The folder containing this document


_classFile

private volatile File _classFile
The cached class file for the document


_classFileInSync

private volatile boolean _classFileInSync
Specifies if classFile is in sync with current state of the document


_packageName

protected volatile String _packageName
The package name embedded in the document the last time is was loaded, reconstructed, or saved. When loading a project, this information is extracted from the project file eliminating the need to read every document file. For non-project files, it is extracted from the text of the file. If there is an error, it is left as "".


_lexiName

protected volatile String _lexiName
The fully qualified name of the class with '.' converted to ' ' so that alphabetic ordering works properly.


_cacheAdapter

private volatile DCacheAdapter _cacheAdapter

_browserRegions

protected final Set<BrowserDocumentRegion> _browserRegions
This document's browser regions.


_initVScroll

private volatile int _initVScroll

_initHScroll

private volatile int _initHScroll

_initSelStart

private volatile int _initSelStart

_initSelEnd

private volatile int _initSelEnd

_book

private volatile DrJavaBook _book

_caretPosition

protected int _caretPosition
Constructor Detail

AbstractGlobalModel.ConcreteOpenDefDoc

AbstractGlobalModel.ConcreteOpenDefDoc(File f)
Standard constructor for a document read from a file. Initializes this ODD's DD. Assumes that f exists.

Parameters:
f - file describing DefinitionsDocument to manage; should be in canonical form

AbstractGlobalModel.ConcreteOpenDefDoc

AbstractGlobalModel.ConcreteOpenDefDoc(NullFile f)

AbstractGlobalModel.ConcreteOpenDefDoc

private AbstractGlobalModel.ConcreteOpenDefDoc(File f,
                                               File dir,
                                               long stamp)
Method Detail

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

getRawFile

public File getRawFile()
Returns the file field for this document; does not check whether the file is NullFile or file exists.

Specified by:
getRawFile in interface OpenDefinitionsDocument

getFile

public File getFile()
             throws FileMovedException
Returns the file for this document, null if the document is untitled. If the document's file does not exist, this throws a FileMovedException. If a FileMovedException is thrown, you can retrieve the non-existence source file from the FileMovedException by using the getFile() method.

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

setFile

public void setFile(File file)
Sets the file for this openDefinitionsDocument. Synch ensures that _file and _timestamp are consistent.

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

updateSyntaxHighlighting

public void updateSyntaxHighlighting()
Update the syntax highlighting for the file type.

Specified by:
updateSyntaxHighlighting in interface OpenDefinitionsDocument

getTimestamp

public long getTimestamp()
Returns the timestamp.

Specified by:
getTimestamp in interface OpenDefinitionsDocument

setClassFileInSync

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

getClassFileInSync

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

setCachedClassFile

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

getCachedClassFile

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

resetModification

public void resetModification()
Whenever this document has been saved, this method should be called to update its "isModified" information.

Specified by:
resetModification 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
Returns:
The parent directory; should be in canonical form.

setParentDirectory

public void setParentDirectory(File pd)
Sets the parent directory of the document only if it is "Untitled"

Parameters:
pd - The parent directory

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.

setInitialVScroll

void setInitialVScroll(int i)

setInitialHScroll

void setInitialHScroll(int i)

setInitialSelStart

void setInitialSelStart(int i)

setInitialSelEnd

void setInitialSelEnd(int i)

getDocument

public DefinitionsDocument getDocument()
Gets the definitions document being handled.

Specified by:
getDocument in interface OpenDefinitionsDocument
Returns:
document being handled

getFirstTopLevelClassName

public String getFirstTopLevelClassName()
                                 throws ClassNameNotFoundException
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.

getMainClassName

public String getMainClassName()
                        throws ClassNameNotFoundException
Returns the name of the main (public) class, if any.

Throws:
ClassNameNotFoundException - if no top level class name found.

getFileName

public String getFileName()
Returns the name of this file, or "(Untitled)" if no file.

Specified by:
getFileName in interface OpenDefinitionsDocument

getName

public String getName()
Returns the name of the file for this document with an appended asterisk (if modified) or spaces

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

getCanonicalPath

public String getCanonicalPath()
Returns the canonical path for this document, "(Untitled)" if unsaved), "" if the file path is ill-formed.

Specified by:
getCanonicalPath in interface OpenDefinitionsDocument

getCompletePath

public String getCompletePath()
Returns the canonical path augmented by " *" if the document has been modified.

Specified by:
getCompletePath in interface OpenDefinitionsDocument

getSourceRoot

public File getSourceRoot()
                   throws InvalidPackageException
Finds the root directory for the source file for this document; null if document is Untitled.

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.

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 name)
Sets the cached _packageName for the preceding method.

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.

updateModifiedSinceSave

public void updateModifiedSinceSave()
Originally designed to allow undoManager to set the current document to be modified whenever an undo or redo is performed. Now it actually does this.

Specified by:
updateModifiedSinceSave in interface OpenDefinitionsDocument

getLexiName

public String getLexiName()
Getter for lexicographic name; used to sort documents into segemented lexicographic ordder

Specified by:
getLexiName in interface OpenDefinitionsDocument

getPageable

public Pageable getPageable()
                     throws IllegalStateException
Returns the Pageable object for printing.

Specified by:
getPageable in interface OpenDefinitionsDocument
Returns:
A Pageable representing this document.
Throws:
IllegalStateException

cleanUpPrintJob

public void cleanUpPrintJob()
Clears the pageable object used to hold the print job.

Specified by:
cleanUpPrintJob in interface OpenDefinitionsDocument

inProjectPath

public boolean inProjectPath()
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 OpenDefinitionsDocument

inNewProjectPath

public boolean inNewProjectPath(File projRoot)
An open file is in the new project if the source root is the same as the new project root.

Specified by:
inNewProjectPath in interface OpenDefinitionsDocument

inProject

public boolean inProject()
A file is in the project if it is explicitly listed as part of the project.

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.

isEmpty

public boolean isEmpty()
Determines if the document is empty.

Specified by:
isEmpty in interface OpenDefinitionsDocument

isAuxiliaryFile

public boolean isAuxiliaryFile()
Specified by:
isAuxiliaryFile in interface OpenDefinitionsDocument
Specified by:
isAuxiliaryFile in interface INavigatorItem
Returns:
true if this is an auxiliary file.

isSourceFile

public boolean isSourceFile()
Specified by:
isSourceFile in interface OpenDefinitionsDocument
Returns:
true if this has a legal source file name for the currently active compiler

isUntitled

public boolean isUntitled()
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

isUntitledAndEmpty

public boolean isUntitledAndEmpty()

fileExists

public boolean fileExists()
Returns true if the file exists 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()
Returns true if the file exists on disk. Prompts the user otherwise

Specified by:
verifyExists in interface OpenDefinitionsDocument

makeReconstructor

protected DDReconstructor makeReconstructor()
Makes a default DDReconstructor that will make the corresponding DefinitionsDocument.


saveFile

public boolean saveFile(FileSaveSelector com)
                 throws IOException
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 if the doc is untitled
Returns:
true if the file was saved, false if the operation was canceled
Throws:
IOException

saveFileAs

public boolean saveFileAs(FileSaveSelector com)
                   throws IOException
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. This is synchronized against the compiler model to prevent saving and compiling at the same time- this used to freeze drjava.

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 - if the save fails due to an IO error

preparePrintJob

public void preparePrintJob()
                     throws BadLocationException,
                            FileMovedException
This method tells the document to prepare all the DrJavaBook and PagePrinter objects.

Specified by:
preparePrintJob in interface OpenDefinitionsDocument
Throws:
BadLocationException
FileMovedException

print

public void print()
           throws PrinterException,
                  BadLocationException,
                  FileMovedException
Prints the given document by bringing up a "Print" window.

Specified by:
print in interface OpenDefinitionsDocument
Throws:
PrinterException
BadLocationException
FileMovedException

startCompile

public void startCompile()
                  throws IOException
throws UnsupportedOperationException

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

runMain

public void runMain(String className)
             throws IOException,
                    ClassNameNotFoundException
throws UnsupportedOperationException

Specified by:
runMain in interface OpenDefinitionsDocument
Parameters:
className - - the fully qualified name of the class contained in this document to run the main(String[]) method of
Throws:
IOException - propagated from GlobalModel.compileAll()
ClassNameNotFoundException - propagated from getFirstTopLevelClass()

runApplet

public void runApplet(String className)
               throws IOException,
                      ClassNameNotFoundException
throws UnsupportedOperationException

Specified by:
runApplet in interface OpenDefinitionsDocument
Parameters:
className - - the fully qualified name of the class contained in this document that will be run as applet
Throws:
IOException - propagated from GlobalModel.compileAll()
ClassNameNotFoundException - propagated from getFirstTopLevelClass()

runSmart

public void runSmart(String className)
              throws IOException,
                     ClassNameNotFoundException
throws UnsupportedOperationException

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

startJUnit

public void startJUnit()
                throws IOException,
                       ClassNotFoundException
throws UnsupportedOperationException

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

generateJavadoc

public void generateJavadoc(FileSaveSelector saver)
                     throws IOException
throws UnsupportedOperationException

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

isReady

public boolean isReady()
Returns true if this document is resident in memory. _cacheAdapter should be non-null.

Specified by:
isReady in interface OpenDefinitionsDocument

isModifiedSinceSave

public boolean isModifiedSinceSave()
Determines if the document has been modified since the last save.

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

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

modifiedOnDisk

public boolean modifiedOnDisk()
Determines if the file for this document has been modified since it was loaded.

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

checkIfClassFileInSync

public boolean checkIfClassFileInSync()
Determines if document has a class file consistent with its current state. If this document is unmodified, this method examines the primary class file corresponding to this document and compares the timestamps of the class file to that of the source file. An empty untitled document is consider to be "in sync".

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

_locateClassFile

private File _locateClassFile()
Returns the class file for this source document by searching the source roots of open documents, the system classpath, and the "extra.classpath ". Returns NULL_FILE if the class file could not be found.


revertIfModifiedOnDisk

public boolean revertIfModifiedOnDisk()
                               throws IOException
Determines if the definitions document has been changed by an outside agent. If the document has changed, asks the listeners if the GlobalModel should revert the document to the most recent version saved.

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

close

public void close()
Degenerate version of close; does not remove breakpoints in this document

Specified by:
close in interface OpenDefinitionsDocument

revertFile

public void revertFile()
                throws IOException
Reverts current ODD to file content on disk.

Specified by:
revertFile in interface OpenDefinitionsDocument
Throws:
IOException

canAbandonFile

public boolean canAbandonFile()
Asks the listeners if the GlobalModel can abandon the current document. Fires the canAbandonFile(File) event if isModifiedSinceSave() is true. Only executes in event thread except for tests.

Specified by:
canAbandonFile in interface OpenDefinitionsDocument
Returns:
true if the current document can be abandoned, false if the current action should be halted in its tracks (e.g., file open when the document has been modified since the last save).

quitFile

public boolean quitFile()
Fires the quit(File) event if isModifiedSinceSave() is true. The quitFile() event asks the user if the the file should be saved before quitting. Only executes in event thread.

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

gotoLine

public int gotoLine(int line)
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 it exceeds the number of lines in the document, it is interpreted as the last line.
Returns:
Index into document of where it moved

setCurrentLocation

public void setCurrentLocation(int location)
Forwarding method to sync the definitions with whatever view component is representing them.

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

getCurrentLocation

public int getCurrentLocation()
Get the location of the cursor in the definitions according to the definitions document.

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

getCaretPosition

public int getCaretPosition()
Specified by:
getCaretPosition in interface OpenDefinitionsDocument
Returns:
the caret position as set by the view.

balanceBackward

public int balanceBackward()
Finds the match for the closing brace immediately to the left, assuming there is such a brace. Only runs in the event thread.

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

balanceForward

public int balanceForward()
Forwarding method to find the match for the open brace immediately to the right, assuming there is such a brace. Only runs in the event thread.

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

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()
Clear the browser history regions for this document.

Specified by:
clearBrowserRegions in interface OpenDefinitionsDocument

removeFromDebugger

public void removeFromDebugger()
throws UnsupportedOperationException

Specified by:
removeFromDebugger in interface OpenDefinitionsDocument

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(OpenDefinitionsDocument o)
Orders ODDs by their lexical names. Note that equals defines a finer equivalence relation than compareTo.

Specified by:
compareTo in interface Comparable<OpenDefinitionsDocument>

addDocumentListener

public void addDocumentListener(DocumentListener listener)
Implementation of the javax.swing.text.Document interface.

Specified by:
addDocumentListener in interface Document

addUndoableEditListener

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

removeUndoableEditListener

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

getUndoableEditListeners

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

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

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

getDefaultRootElement

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

getStartPosition

public Position getStartPosition()
The following two methods are in javax.swing.Document.

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()
Gets the text of this. Avoids reloading the document if it is kicked out of the cache.

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

getText

public String getText(int offset,
                      int length)
               throws BadLocationException
Gets the specified substring of this. Avoids reloading the document if it is kicked out of the cache.

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 a)
                  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

render

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

undoManagerCanUndo

public boolean undoManagerCanUndo()
If the undo manager is unavailable, no undos are available

Specified by:
undoManagerCanUndo in interface OpenDefinitionsDocument
Returns:
whether the undo manager can perform any undo's

undoManagerCanRedo

public boolean undoManagerCanRedo()
If the undo manager is unavailable, no redos are available

Specified by:
undoManagerCanRedo in interface OpenDefinitionsDocument
Returns:
whether the undo manager can perform any redo's

getUndoManager

public CompoundUndoManager getUndoManager()
Decorator pattern for the definitions document.

Specified by:
getUndoManager in interface OpenDefinitionsDocument

_getLineStartPos

public int _getLineStartPos(int pos)
Gets start of line containing pos.

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)
Gets end of line containing pos (line includes closing '\n').

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

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

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

getCurrentLine

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

getCurrentCol

public int getCurrentCol()
Specified by:
getCurrentCol 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)
Gets offset of beginning of given 1-based line.

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

getStateAtCurrent

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

resetUndoManager

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

getDocumentListeners

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

getEnclosingClassName

public String getEnclosingClassName(int pos,
                                    boolean fullyQualified)
                             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
fullyQualified - true to find the fully qualified class name
Returns:
name of the enclosing named class or interface
Throws:
BadLocationException
ClassNameNotFoundException

findPrevEnclosingBrace

public int findPrevEnclosingBrace(int pos,
                                  char opening,
                                  char closing)
                           throws BadLocationException
Finds the previous brace of specified form enclosing pos.

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
Finds the next brace of specified form enclosing pos.

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
Only runs in the event thread.

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
Only runs in the event thread.

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
Assumes read lock is already held.

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
Assumes read lock is already held.

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)
Assumes read lock is already held.

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
Assumes read lock is already held.

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

_getIndentOfCurrStmt

public int _getIndentOfCurrStmt(int pos,
                                char[] delims)
                         throws BadLocationException
Assumes read lock is already held.

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

_getIndentOfCurrStmt

public int _getIndentOfCurrStmt(int pos,
                                char[] delims,
                                char[] whitespace)
                         throws BadLocationException
Assumes read lock is already held.

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

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

addFinalizationListener

public void addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)
This method is put here because the ODD is the only way to get to the defdoc.

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

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

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)
Translates an offset into the components text to a line 0-based number.

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

getOffsetOfLine

public int getOffsetOfLine(int line)
Translates a 0-based line number into an offset.

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

containsClassOrInterfaceOrEnum

public boolean containsClassOrInterfaceOrEnum()
                                       throws BadLocationException
Returns true if one of the words 'class', 'interface' or 'enum' is found in non-comment text.

Specified by:
containsClassOrInterfaceOrEnum in interface OpenDefinitionsDocument
Throws:
BadLocationException