DefaultSourceDocument Class
- public abstract class DefaultSourceDocument
extends DefaultDocument
implements ISourceDocument
A default implementation of ISourceDocument
. This makes the
assumptions that any ISourceElement parse tree is made up of element types
deriving from DefaultSourceElement.
-
Hierarchy
-
Object
DefaultElement
DefaultDocument
DefaultSourceDocument
-
All Implemented Interfaces
-
ICookieSupport
, IDocument
, IDriverSupport
, IElement
, IPropertySupport
, ISourceDocument
-
Direct Known Subclasses
-
TextDocument
public static final String |
-
PROP_ColumnNumber
- A property identifier used to keep track of the caret column number in the last used source view for this document.
|
public static final String |
-
PROP_LineNumber
- A property identifier used to keep track of the caret line number in the last used source view for this document.
|
-
DefaultSourceDocument(
Class handler, URI fileURI)
- Creates a new document using the appropriate handler, initializing the document with data found at the specified
URI.
|
protected void |
-
createDrivers ()
- Creates the drivers for this file.
|
protected UndoableEditListener |
-
createUndoableEditListener ()
- Creates the UndoableEditListener for this document.
|
protected UndoManager |
-
createUndoManager ()
- Creates an undo manager for this document.
|
public void |
-
fireElementChildAdded (IElement el, IElement elAdded)
- Fire an element modified event.
|
public void |
-
fireElementChildRemoved (IElement el, IElement elRemoved)
- Fire an element modified event.
|
public void |
-
fireElementModified (IElement el, String sProperty, Object oldValue, Object newValue)
- Fire an element modified event.
|
public IElement |
-
getElementFromOffset (int offset)
- Returns the smallest elemnt that encloses the specified offset.
|
public String |
-
getHandlerId ()
- Returns the String representing the document handler for this document.
|
public Reader |
-
getReader ()
- Returns a Reader for the contents of this document.
|
public ISourceModel |
-
getSourceModel ()
- Returns the source model associated with this source document.
|
public IToken |
-
getTokenFromOffset (int offset)
- Returns the token found at the specified offset.
|
public IDocumentViewInfo [] |
-
getViewInfo ()
- Returns an array of the
IDocumentViewInfo objects that are valid for this document.
|
public boolean |
-
isMerging ()
- Lets external users check to see if the document's parse tree is currently
being merged.
|
public boolean |
-
mergeMetadata (ISourceElement sourceRootElement)
mergeMetaData is called by the IDE to indicate that a new parse tree is available due to a
recompile.
|
public boolean |
-
onOpen ()
- Method called by the document service when this document is initially opened.
|
public void |
-
onRemove ()
- Method called by the document service when this document is removed from the document cache.
|
public boolean |
-
onSave ()
- DefaultSourceDocument's onSave method takes care of certain save-time operations, such as trimming of trailing
whitespace from lines if enabled, and then calls to
DefaultDocument.onSave()
|
public boolean |
-
reload ()
- Discard any in memory changes to this document and reload it's contents from the
persistent store.
|
public synchronized void |
-
requestTwoWayEdit (TwoWayEdit edit)
- Initiates a two-way edit from a
TwoWayEdit object.
|
protected void |
-
setRootElement (IElement root)
- Sets the root element for this document, firing appropriate element change events.
|
protected void |
-
uriChanged (URI uriOld, URI uriNew)
- When a document's URI changes, the compiler is notified of the change and a recompilation is initiated.
|
public boolean |
-
waitForPendingCompilations ()
- This method will block the calling thread until all pending compilations of this document are complete.
|
public IDocumentElement |
-
waitForRootElement ()
- Blocks the calling thread until a root element is available for this document.
|
Methods from com.bea.ide.document.DefaultDocument |
addCookie , addDriver , addElementChangeListener , addPropertyChangeListener , addPropertyChangeListener , computeEditable , createReadOnlyListener , fileSystemChanged , finalize , fireElementModified , fireElementModified , getCookie , getDriver , getIFile , getInputStream , getProperty , getRootElement , getRootElement , getURI , isBinary , isEditable , isModified , isReadOnly , makeEditable , removeCookie , removeElementChangeListener , removePropertyChangeListener , removePropertyChangeListener , setProperty ,
|
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods from interface com.bea.ide.document.IDocument |
addElementChangeListener , getHandlerId , getIFile , getInputStream , getReader , getRootElement , getRootElement , getURI , getViewInfo , isBinary , isEditable , isModified , isReadOnly , makeEditable , onOpen , onRemove , onSave , reload , removeElementChangeListener , waitForRootElement
|
PROP_ColumnNumber
public static final String
PROP_ColumnNumber
- A property identifier used to keep track of the caret column number in the last used source view for this document.
PROP_LineNumber
public static final String
PROP_LineNumber
- A property identifier used to keep track of the caret line number in the last used source view for this document.
DefaultSourceDocument
public DefaultSourceDocument(Class
handler,
URI
fileURI)
- Creates a new document using the appropriate handler, initializing the document with data found at the specified
URI.
createDrivers() Method
protected void createDrivers()
Creates the drivers for this file. By default, a document has just a default compiler driver and a default
source view driver. These will allow for a source view containing syntax coloring and error reporting if
the language extension is recognized by the compiler.
createUndoableEditListener() Method
protected UndoableEditListener
createUndoableEditListener()
Creates the UndoableEditListener for this document. This listener is responsible for passing all appropriate
edits to this document's UndoManager.
Returns
- A new UndoableEditListener
createUndoManager() Method
protected UndoManager
createUndoManager()
Creates an undo manager for this document.
Returns
- A new undo manager
fireElementChildAdded(IElement, IElement) Method
public void fireElementChildAdded(IElement
el,
IElement
elAdded)
Fire an element modified event. This method fires an event indicating that a child was added to an element
-
Overrides
-
DefaultDocument.fireElementChildAdded(IElement, IElement)
Parameters
-
el
- Element that was changed
-
elAdded
- Element added as a child to the changed element
fireElementChildRemoved(IElement, IElement) Method
public void fireElementChildRemoved(IElement
el,
IElement
elRemoved)
Fire an element modified event. This method fires an event indicating that a child was removed from an element
-
Overrides
-
DefaultDocument.fireElementChildRemoved(IElement, IElement)
Parameters
-
el
- Element that was changed
-
elRemoved
- Element removed as a child to the changed element
fireElementModified(IElement, String, Object, Object) Method
public void fireElementModified(IElement
el,
String
sProperty,
Object
oldValue,
Object
newValue)
Fire an element modified event. This method fires an event indiciting that a property on the element was
modified.
-
Overrides
-
DefaultDocument.fireElementModified(IElement, String, Object, Object)
Parameters
-
el
- Element that was changed
-
sProperty
- String name of the property that was modified
-
oldValue
- The old value of the specified property
-
newValue
- The new value of the specified property
getElementFromOffset(int) Method
public IElement
getElementFromOffset(int offset)
Description copied from ISourceDocument.getElementFromOffset(int)
Returns the smallest elemnt that encloses the specified offset. This method is expensive, and should be called
as sparingly as possible.
Parameters
-
offset
- a zero-based character index within the document.
Returns
- the parse tree element found at the specified offset. May return null if the document is not parsed
at the time that the method is called.
Related Topics
ISourceDocument.getElementFromOffset(int)
getHandlerId() Method
public String
getHandlerId()
Description copied from IDocument.getHandlerId()
Returns the String representing the document handler for this document. The
getDocInfo
method of the DocumentSvc
may be used in order to obtain the IDocumentInfo
interface using this String.
Returns
- String representing the document handler for this document.
Related Topics
IDocument.getHandlerId()
getReader() Method
public Reader
getReader()
Description copied from IDocument.getReader()
Returns a Reader for the contents of this document. IDocument implementers should implement
this method and allow the FileSvc to write the doc's content to disk rather than writing the
file directly. This will allow the FileSvc to properly coordinate change events and alert the
user to file save issues, like file locked and other IO errors. Binary documents should return null.
Returns
- A Reader object for the contents of the document or null if this is a binary document.
Related Topics
IDocument.getReader()
getSourceModel() Method
public ISourceModel
getSourceModel()
Description copied from ISourceDocument.getSourceModel()
Returns the source model associated with this source document. Once the file is initially loaded, this method
should never return null.
Related Topics
ISourceDocument.getSourceModel()
getTokenFromOffset(int) Method
public IToken
getTokenFromOffset(int offset)
Returns the token found at the specified offset.
Parameters
-
offset
- a valid offset within the document
Returns
- the compiler IToken object found at that offset
getViewInfo() Method
public IDocumentViewInfo
[] getViewInfo()
Description copied from IDocument.getViewInfo()
Returns an array of the IDocumentViewInfo
objects that are valid for this document.
These will be used by the DocumentSvc to display the document panel for this document.
Returns
- Array of
IDocumentViewInfo
objects for this document.
Related Topics
IDocument.getViewInfo()
isMerging() Method
public boolean isMerging()
Lets external users check to see if the document's parse tree is currently
being merged. Tree merging always takes place on the AWT thread, and always
blocks that thread from start until completion, so
this method is only interesting when called from another thread.
mergeMetadata(ISourceElement) Method
public boolean mergeMetadata(ISourceElement
sourceRootElement)
mergeMetaData
is called by the IDE to indicate that a new parse tree is available due to a
recompile. Implementors guarantee that after the merge all elements with unchanged properties remain unchanged,
with the exception of range and compiler cookie information, and that appropriate change events are generated
for all elements that are not equivalent.
For a complete description of the merge algorithm, see DefaultSourceDocument.mergeElements
.
Parameters
-
sourceRootElement
- the root of the new parse tree for this document
Returns
- boolean indicating whether the merge succeeded.
onOpen() Method
public boolean onOpen()
Description copied from IDocument.onOpen()
Method called by the document service when this document is initially opened. This is
called automatically by the document service. It may return false to indicate that this
document should not be opened.
-
Overrides
-
DefaultDocument.onOpen()
Returns
- boolean indicating whether the document should be opened
Related Topics
IDocument.onOpen()
onRemove() Method
public void onRemove()
Description copied from IDocument.onRemove()
Method called by the document service when this document is removed from the document cache.
After this, another document may be created to handle this URI. Any services that this document
has registered itself with as a handler for a particular URI should be notified that it is no
longer the document for its URI.
-
Overrides
-
DefaultDocument.onRemove()
Related Topics
IDocument.onRemove()
onSave() Method
public boolean onSave()
DefaultSourceDocument's onSave method takes care of certain save-time operations, such as trimming of trailing
whitespace from lines if enabled, and then calls to DefaultDocument.onSave()
-
Overrides
-
DefaultDocument.onSave()
Returns
- boolean indicating whether the document should be saved
reload() Method
public boolean reload()
Description copied from IDocument.reload()
Discard any in memory changes to this document and reload it's contents from the
persistent store. This operation may return false indicating that the attempt to
read the data from the persistent store failed. In this case, the in-memory contents of the
document should be the same as before the call to reload
Returns
true
if the reload succeeded; false
if the attempt to reload from the store failed.
Related Topics
IDocument.reload()
requestTwoWayEdit(TwoWayEdit) Method
public synchronized void requestTwoWayEdit(TwoWayEdit
edit)
throws InvalidElementException
Initiates a two-way edit from a TwoWayEdit
object. While this method may be called directly, this is almost never
done; generally, all requests for two-way edits should go through an
ISourceElement
implementation.
When called, this method will block the AWT thread until the requested edit
completes.
Parameters
-
edit
- The object defining this edit.
Exceptions
-
InvalidElementException
setRootElement(IElement) Method
protected void setRootElement(IElement
root)
Sets the root element for this document, firing appropriate element change events.
-
Overrides
-
DefaultDocument.setRootElement(IElement)
Parameters
-
root
- The new root element. Null is a valid value, used to indicate that a parse
tree is no longer available for this document.
uriChanged(URI, URI) Method
protected void uriChanged(URI
uriOld,
URI
uriNew)
When a document's URI changes, the compiler is notified of the change and a recompilation is initiated.
Document types which override this method must call uriChanged in their super class.
-
Overrides
-
DefaultDocument.uriChanged(URI, URI)
Related Topics
DefaultDocument.uriChanged(URI, URI)
waitForPendingCompilations() Method
public boolean waitForPendingCompilations()
This method will block the calling thread until all pending compilations of this document are complete. Note
that compilation can be a lengthy process, so it is not advisable to call this method on the AWT thread.
This method should never be called from within a compilation read or write lock, as that could
prevent the compiler from completing compilation, causing a deadlock.
Returns
- boolean indicating whether the call succeeded
waitForRootElement() Method
public IDocumentElement
waitForRootElement()
Blocks the calling thread until a root element is available for this document. Note
that compilation can be a lengthy process, so it is not advisable to call this method on the AWT thread.
This method should never be called from within a compilation read or write lock, as that could
prevent the compiler from completing compilation, causing a deadlock.
-
Overrides
-
DefaultDocument.waitForRootElement()
Returns
- the root element of this document. If this document cannot be compiled, null may be returned.