|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
edu.rice.cs.util.text.SwingDocument
edu.rice.cs.drjava.model.AbstractDJDocument
edu.rice.cs.drjava.model.definitions.DefinitionsDocument
public class DefinitionsDocument
The document model for the definitions pane; it contains a reduced model since it extends AbstractDJDocument.
AbstractDJDocument
,
Serialized FormNested Class Summary | |
---|---|
static class |
DefinitionsDocument.WrappedPosition
Wrapper for Position objects to allow relinking to a new Document. |
Nested classes/interfaces inherited from class edu.rice.cs.drjava.model.AbstractDJDocument |
---|
AbstractDJDocument.CharInsertCommand, AbstractDJDocument.InsertCommand, AbstractDJDocument.RemoveCommand, AbstractDJDocument.UninsertCommand, AbstractDJDocument.UnremoveCommand |
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument |
---|
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElement |
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
---|
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement |
Nested classes/interfaces inherited from interface edu.rice.cs.drjava.config.OptionConstants |
---|
OptionConstants.AccessLevelChoices, OptionConstants.DefaultFont, OptionConstants.HeapSizeChoices, OptionConstants.LookAndFeels, OptionConstants.PlasticThemes, OptionConstants.VersionNotificationChoices |
Field Summary | |
---|---|
static Log |
_log
|
Fields inherited from class edu.rice.cs.drjava.model.AbstractDJDocument |
---|
_currentLocation, _indent, _keywords, _normEndings, _primTypes, _reduced, CLOSING_BRACES, delimiters, newline, POS_THRESHOLD |
Fields inherited from class edu.rice.cs.util.text.SwingDocument |
---|
_condition, _styles, _wrappedPosListLock |
Fields inherited from class javax.swing.text.DefaultStyledDocument |
---|
buffer, BUFFER_SIZE_DEFAULT |
Fields inherited from class javax.swing.text.AbstractDocument |
---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
Fields inherited from interface javax.swing.text.Document |
---|
StreamDescriptionProperty, TitleProperty |
Constructor Summary | |
---|---|
DefinitionsDocument(GlobalEventNotifier notifier)
Main constructor. |
|
DefinitionsDocument(GlobalEventNotifier notifier,
CompoundUndoManager undoManager)
Main constructor. |
|
DefinitionsDocument(Indenter indenter,
GlobalEventNotifier notifier)
Convenience constructor for using a custom indenter. |
Method Summary | |
---|---|
int |
_findPrevKeyword(String text,
String kw,
int pos)
Assuming that text is a document prefix including offset pos, finds the index of the keyword kw searching back from pos. |
String |
_getEnclosingClassName(int pos,
boolean qual)
Searches backwards to find the name of the enclosing named class or interface. |
int |
_getOffset(int lineNum)
Returns the offset corresponding to the first character of the given line number, or -1 if the lineNum is not found. |
boolean |
_isAnonymousInnerClass(int pos,
int openCurlyPos)
Returns true if this position is the instantiation of an anonymous inner class. |
protected void |
_styleChanged()
Recolors the rest of the document based on the change that triggered this call. |
void |
addDocumentClosedListener(DocumentClosedListener l)
|
void |
addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)
Registers a finalization listener with the specific instance of the ddoc |
protected void |
addUndoRedo(AbstractDocument.DefaultDocumentEvent chng,
Runnable undoCommand,
Runnable doCommand)
|
void |
close()
Closes this DefinitionsDocument (but not the enclosing OpenDefinitionsDocument). |
int |
commentLines(int selStart,
int selEnd)
Comments out all lines between selStart and selEnd, inclusive. |
Position |
createPosition(int offset)
Factory method for created WrappedPositions. |
void |
documentSaved()
Informs this document's undo manager that the document has been saved. |
protected void |
endCompoundEdit(int key)
|
protected void |
endLastCompoundEdit()
|
protected void |
finalize()
This is called when this method is GC'd. |
int |
getCurrentCol()
Return the current column of the cursor position. |
int |
getCurrentLine()
Return the current line of the cursor position. |
String |
getEnclosingClassName(int pos,
boolean qual)
Searches backwards to find the name of the enclosing named class or interface. |
String |
getEnclosingTopLevelClassName(int pos)
Returns the name of the class or interface enclosing the caret position at the top level. |
List<FinalizationListener<DefinitionsDocument>> |
getFinalizationListeners()
|
String |
getFirstTopLevelClassName()
Gets the name of the top level class in this source file by finding the first declaration of a class or interface. |
int |
getLineOfOffset(int offset)
Return the line number corresponding to offset. |
String |
getMainClassName()
Gets the name of the document's main class: the document's only public class/interface or first top level class if document contains no public classes or interfaces. |
UndoableEdit |
getNextRedo()
Public accessor for the next undo action. |
String |
getNextTopLevelClassName(int startPos,
int endPos)
|
UndoableEdit |
getNextUndo()
Public accessor for the next undo action. |
OpenDefinitionsDocument |
getOpenDefDoc()
|
String |
getPackageName()
Gets the package name embedded in the text of this document by minimally parsing the document to find the package statement. |
String |
getQualifiedClassName()
Gets the package and main class/interface name of this OpenDefinitionsDocument |
String |
getQualifiedClassName(int pos)
Gets fully qualified class name of the top level class enclosing the given position. |
CompoundUndoManager |
getUndoManager()
Getter method for CompoundUndoManager |
WeakHashMap<DefinitionsDocument.WrappedPosition,Integer> |
getWrappedPositionOffsets()
Remove all positions that have been garbage-collected from the list of positions, then return a weakly-linked hashmap with positions and their current offsets. |
void |
gotoLine(int line)
Goes to a particular line in the document. |
void |
insertString(int offset,
String str,
AttributeSet a)
Inserts a string of text into the document. |
boolean |
isModifiedSinceSave()
Determines if the document has been modified since the last save. |
protected Indenter |
makeNewIndenter(int indentLevel)
Returns a new indenter. |
void |
remove(int offset,
int len)
Removes a block of text from the specified location. |
void |
removeDocumentClosedListener(DocumentClosedListener l)
|
void |
resetModification()
Resets the modification state of this document. |
void |
resetUndoManager()
Resets the undo manager. |
void |
setOpenDefDoc(OpenDefinitionsDocument odd)
Sets the OpenDefinitionsDocument that holds this DefinitionsDocument (the odd can only be set once). |
void |
setWrappedPositionOffsets(WeakHashMap<DefinitionsDocument.WrappedPosition,Integer> whm)
Re-create the wrapped positions in the hashmap, update the wrapped position, and add them to the list. |
protected int |
startCompoundEdit()
|
boolean |
tabsRemoved()
Returns true iff tabs are to removed on text insertion. |
String |
toString()
|
int |
uncommentLines(int selStart,
int selEnd)
Uncomments all lines between selStart and selEnd, inclusive. |
void |
updateModifiedSinceSave()
Resets the modification state of this document to be consistent with state of _undoManager. |
Methods inherited from class edu.rice.cs.util.text.SwingDocument |
---|
_getText, addColoring, append, append, append, createUnwrappedPosition, forceInsertText, forceRemoveText, getDefaultStyle, getDocStyle, getDocText, getEditCondition, getPageable, getText, insertText, print, removeText, setDocStyle, setEditCondition |
Methods inherited from class javax.swing.text.DefaultStyledDocument |
---|
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, removeDocumentListener, removeStyle, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.rice.cs.drjava.model.DJDocument |
---|
getText |
Methods inherited from interface edu.rice.cs.util.text.AbstractDocumentInterface |
---|
append, getLength, getText |
Methods inherited from interface javax.swing.text.StyledDocument |
---|
addStyle, getBackground, getCharacterElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, removeStyle, setCharacterAttributes, setLogicalStyle, setParagraphAttributes |
Methods inherited from interface javax.swing.text.Document |
---|
addDocumentListener, addUndoableEditListener, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeDocumentListener, removeUndoableEditListener, render |
Methods inherited from interface edu.rice.cs.util.text.EditDocumentInterface |
---|
getLength |
Field Detail |
---|
public static final Log _log
Constructor Detail |
---|
public DefinitionsDocument(Indenter indenter, GlobalEventNotifier notifier)
indenter
- custom indenter classnotifier
- used by CompoundUndoManager to announce undoable editspublic DefinitionsDocument(GlobalEventNotifier notifier)
notifier
- used by CompoundUndoManager to announce undoable editspublic DefinitionsDocument(GlobalEventNotifier notifier, CompoundUndoManager undoManager)
notifier
- used by CompoundUndoManager to announce undoable editsMethod Detail |
---|
public void addDocumentClosedListener(DocumentClosedListener l)
public void removeDocumentClosedListener(DocumentClosedListener l)
public void close()
protected Indenter makeNewIndenter(int indentLevel)
public void setOpenDefDoc(OpenDefinitionsDocument odd)
odd
- the OpenDefinitionsDocument to set as this DD's holderpublic OpenDefinitionsDocument getOpenDefDoc()
protected void _styleChanged()
_styleChanged
in class AbstractDJDocument
public String getQualifiedClassName() throws ClassNameNotFoundException
ClassNameNotFoundException
public String getQualifiedClassName(int pos) throws ClassNameNotFoundException
ClassNameNotFoundException
public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
AbstractDJDocument.insertUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AttributeSet)
. If _removeTabs is set to true, remove all tabs from str. It is a current invariant
of the tabification functionality that the document contains no tabs, but we want to allow the user to override
this functionality.
insertString
in interface DJDocument
insertString
in interface AbstractDocumentInterface
insertString
in interface Document
insertString
in class SwingDocument
BadLocationException
public void remove(int offset, int len) throws BadLocationException
AbstractDJDocument.removeUpdate(javax.swing.text.AbstractDocument.DefaultDocumentEvent)
.
remove
in interface DJDocument
remove
in interface AbstractDocumentInterface
remove
in interface Document
remove
in class SwingDocument
BadLocationException
public void updateModifiedSinceSave()
public void resetModification()
public boolean isModifiedSinceSave()
public int getCurrentCol()
public int getCurrentLine()
public int getLineOfOffset(int offset)
public int _getOffset(int lineNum)
lineNum
- the line number for which to calculate the offset.
public boolean tabsRemoved()
public int commentLines(int selStart, int selEnd)
selStart
- the document offset for the start of the selectionselEnd
- the document offset for the end of the selectionpublic int uncommentLines(int selStart, int selEnd)
selStart
- the document offset for the start of the selectionselEnd
- the document offset for the end of the selectionpublic void gotoLine(int line)
public int _findPrevKeyword(String text, String kw, int pos) throws BadLocationException
BadLocationException
public String getEnclosingClassName(int pos, boolean qual) throws BadLocationException, ClassNameNotFoundException
pos
- Position to start fromqual
- true to find the fully qualified class name
BadLocationException
ClassNameNotFoundException
public String _getEnclosingClassName(int pos, boolean qual) throws BadLocationException, ClassNameNotFoundException
pos
- Position to start fromqual
- true to find the fully qualified class name
BadLocationException
ClassNameNotFoundException
public boolean _isAnonymousInnerClass(int pos, int openCurlyPos) throws BadLocationException
pos
- position of "new"openCurlyPos
- position of the next '{'
BadLocationException
public String getPackageName()
public String getEnclosingTopLevelClassName(int pos) throws ClassNameNotFoundException
ClassNameNotFoundException
- if no enclosing class foundpublic String getMainClassName() throws ClassNameNotFoundException
ClassNameNotFoundException
public String getFirstTopLevelClassName() throws ClassNameNotFoundException
ClassNameNotFoundException
- if no top level class foundpublic String getNextTopLevelClassName(int startPos, int endPos) throws ClassNameNotFoundException
ClassNameNotFoundException
public Position createPosition(int offset) throws BadLocationException
createPosition
in interface AbstractDocumentInterface
createPosition
in interface Document
createPosition
in class AbstractDocument
BadLocationException
public WeakHashMap<DefinitionsDocument.WrappedPosition,Integer> getWrappedPositionOffsets()
public void setWrappedPositionOffsets(WeakHashMap<DefinitionsDocument.WrappedPosition,Integer> whm) throws BadLocationException
whm
- weakly-linked hashmap of wrapped positions and their offsets
BadLocationException
public CompoundUndoManager getUndoManager()
public void resetUndoManager()
public UndoableEdit getNextUndo()
public UndoableEdit getNextRedo()
public void documentSaved()
protected int startCompoundEdit()
startCompoundEdit
in class AbstractDJDocument
protected void endCompoundEdit(int key)
endCompoundEdit
in class AbstractDJDocument
protected void endLastCompoundEdit()
endLastCompoundEdit
in class AbstractDJDocument
protected void addUndoRedo(AbstractDocument.DefaultDocumentEvent chng, Runnable undoCommand, Runnable doCommand)
addUndoRedo
in class AbstractDJDocument
public void addFinalizationListener(FinalizationListener<DefinitionsDocument> fl)
NOTE:This should only be used by test cases. This is to ensure that we don't spring memory leaks by allowing our unit tests to keep track of whether objects are being finalized (garbage collected)
addFinalizationListener
in interface Finalizable<DefinitionsDocument>
fl
- the listener to registerpublic List<FinalizationListener<DefinitionsDocument>> getFinalizationListeners()
getFinalizationListeners
in interface Finalizable<DefinitionsDocument>
protected void finalize()
finalize
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |