|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.editor.BasicDocument
A BasicDocument
is an implementation of the
Document
interface, similar to "PlainDocument" without
the extra overhead of the Element structures for maintaining line
number information, and with a different text buffer
implementation. This document does not maintain any attribute
information currently.
Each BasicDocument
instance has an associated
LanguageSupport
that adds extra document support
specific to a given document language, such as Java or HTML. The
LanguageSupport
for a document is set up using the
provided filename through suffix mapping, or by explicitly
setting the LanguageSupport
by calling
setLanguageSupport()
with a LanguageSupport
instance.
Like the Swing text document implementations, this document
implementation provides support for UndoableEdit's. The document
relies on the underlying TextBuffer
for generating
the UndoableEdit's. Note that UndoableEdit's are fired by this
document only for edits initiated through this document. Edits
performed on the TextBuffer directly apart from this document
will not result in an UndoableEdit through this document.
Note that the compound edit support here in BasicDocument
has been deprecated. Clients should use the edit support in
BasicEditorPane
instead, which also includes support
for specifying an edit name (for display) and for saving caret
position information with the UndoableEdit
. Please
refer for information regarding undo support.
Lastly, please note that this document implementation currently does not support composed or bidi text input due to the model changes to optimize memory use and performance. This is an open issue that will be addressed soon.
LanguageSupport
Field Summary | |
static java.lang.String |
eolTypePropertyName
public constant for the eol type property name. |
static java.lang.String |
readOnlyPropertyName
Public constant for the read only property name. |
Fields inherited from interface javax.swing.text.Document |
StreamDescriptionProperty, TitleProperty |
Fields inherited from interface oracle.javatools.buffer.TextBufferListener |
EOL_TYPE_ATTRIBUTE, MODIFIED_ATTRIBUTE, READ_ONLY_ATTRIBUTE, RELOAD_END_ATTRIBUTE, RELOAD_START_ATTRIBUTE |
Constructor Summary | |
BasicDocument()
Create a new default BasicDocument . |
|
BasicDocument(java.lang.String fileName)
Creates a plain text document - this uses the the default TextBuffer implementation as the underlying data model. |
|
BasicDocument(java.lang.String fileName,
TextBuffer buffer)
Creates a plain text document using the buffer provider specified. |
|
BasicDocument(TextBuffer buffer)
Create a new BasicDocument using the provided buffer. |
Method Summary | |
void |
addDocumentListener(javax.swing.event.DocumentListener listener)
Registers the given observer to begin receiving notifications when changes are made to the document. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Registers the given observer to begin receiving notifications when undoable edits are made to the document. |
void |
attributeUpdate(int attribute)
Provides notification regarding a change to one of the buffer attributes. |
void |
beginEdit()
Deprecated. all edits (compound or otherwise) made to the document related to an editor pane should be initiated through BasicEditorPane.beginEdit() |
javax.swing.text.Position |
createPosition(int offset)
This method allows an application to mark a place in a sequence of character content. |
void |
endEdit()
Deprecated. all edits (compound or otherwise) made to the document related to an editor pane should be ended through BasicEditorPane.endEdit() |
void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Report a bound property update to any registered listeners. |
protected void |
fireUndoableEditEvent(javax.swing.undo.UndoableEdit edit)
An internal utility routine to fire UndoableEdit events that are generated by this document to the undoable edit listeners. |
protected NumberRange |
getComposedTextRange()
Fetch the current range of composed text input - this is generally uncommitted text. |
javax.swing.text.Element |
getDefaultRootElement()
Fetches the default root element for this document. |
DocumentRenderer |
getDocumentRenderer()
Fetches the document renderer from the language support for this document. |
javax.swing.text.Position |
getEndPosition()
Returns a position that represents the end of the document. |
LanguageSupport |
getLanguageSupport()
Fetches the LanguageSupport associated with this document. |
int |
getLength()
Returns number of characters of data currently in the document. |
LineMap |
getLineMap()
Fetches a line map for this document for calculating line positions. |
javax.swing.text.Element |
getParagraphElement(int pos)
Get the paragraph element containing the given position. |
java.lang.Object |
getProperty(java.lang.Object key)
Gets properties associated with the document. |
javax.swing.text.Element[] |
getRootElements()
Returns all of the root elements that are defined. |
javax.swing.text.Position |
getStartPosition()
Returns a position that represents the start of the document. |
java.lang.String |
getText(int offset,
int length)
Fetches the text contained within the given portion of the document. |
void |
getText(int offset,
int length,
javax.swing.text.Segment txt)
Fetches the text contained within the given portion of the document. |
TextBuffer |
getTextBuffer()
Fetches the underlying Content of this document. |
void |
insertString(int offset,
java.lang.String str,
javax.swing.text.AttributeSet set)
Inserts a string into the document. |
void |
insertUpdate(int offset,
int count,
char[] insertedData)
Provides notification about an insertion into the text buffer. |
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed. |
void |
putProperty(java.lang.Object key,
java.lang.Object value)
Puts a new property on the list. |
void |
readLock()
Attempts to acquire a read lock on this document and the underlying text buffer - this is a blocking call. |
void |
readUnlock()
Releases a held read lock on this Document. |
void |
remove(int offset,
int length)
Removes a portion of the content of the document. |
void |
removeDocumentListener(javax.swing.event.DocumentListener listener)
Unregisters the given observer from the notification list so it will no longer receive change updates. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Unregisters the given observer from the notification list so it will no longer receive updates. |
void |
removeUpdate(int offset,
int count,
char[] removedData)
Provides notification about a removal from the text buffer. |
void |
render(java.lang.Runnable r)
This allows the model to be safely rendered in the presence of currency, if the model supports being updated asynchronously. |
void |
setLanguageSupport(LanguageSupport support)
Set the LanguageSupport used by this document to the specified one. |
void |
setLanguageSupport(java.lang.String fileName)
Sets the LanguageSupport for editing the type of content indicated by the specified filename. |
void |
writeLock()
Attempts to acquire a write lock on this document and the underlying text buffer - this is a blocking call. |
void |
writeUnlock()
Releases a held write lock on this Document. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String readOnlyPropertyName
public static final java.lang.String eolTypePropertyName
Constructor Detail |
public BasicDocument()
BasicDocument
.
public BasicDocument(java.lang.String fileName)
fileName
- the file name to use when creating a language supportpublic BasicDocument(java.lang.String fileName, TextBuffer buffer)
fileName
- the file name to use when creating a language supportbuffer
- the text bufer to use as the document modelpublic BasicDocument(TextBuffer buffer)
BasicDocument
using the provided buffer.
buffer
- the text buffer to use as the document modelMethod Detail |
protected NumberRange getComposedTextRange()
public TextBuffer getTextBuffer()
public void setLanguageSupport(java.lang.String fileName)
fileName
- the name of the filepublic void setLanguageSupport(LanguageSupport support)
support
- the LanguageSupport to usepublic LanguageSupport getLanguageSupport()
public DocumentRenderer getDocumentRenderer()
public void beginEdit()
BasicEditorPane.beginEdit()
BasicEditorPane
instance, use
BasicEditorPane.beginEdit()
instead so that caret
information can also be preserved.
TextBuffer.beginEdit()
,
TextBuffer.endEdit()
public void endEdit()
BasicEditorPane.endEdit()
TextBuffer.beginEdit()
,
TextBuffer.endEdit()
public void readLock()
ReadTextBuffer.readLock()
,
TextBuffer.writeLock()
public void readUnlock()
public void writeLock()
ReadTextBuffer.readLock()
,
TextBuffer.writeLock()
public void writeUnlock()
public javax.swing.text.Element getParagraphElement(int pos)
public javax.swing.text.Element getDefaultRootElement()
getDefaultRootElement
in interface javax.swing.text.Document
public LineMap getLineMap()
public int getLength()
getLength
in interface javax.swing.text.Document
public void remove(int offset, int length) throws javax.swing.text.BadLocationException
remove
in interface javax.swing.text.Document
offset
- the offset from the begining >= 0length
- the number of characters to remove >= 0
javax.swing.text.BadLocationException
- some portion of the removal range
was not a valid part of the document. The location in the exception
is the first bad position encountered.public void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet set) throws javax.swing.text.BadLocationException
insertString
in interface javax.swing.text.Document
offset
- the offset into the document to insert the content >= 0.
All positions that track change at or after the given location
will move.str
- the string to insertset
- the attributes to associate with the inserted
content. This may be null if there are no attributes.
javax.swing.text.BadLocationException
- the given insert position is not a valid
position within the documentpublic java.lang.String getText(int offset, int length) throws javax.swing.text.BadLocationException
getText
in interface javax.swing.text.Document
offset
- the offset into the document representing the desired
start of the text >= 0length
- the length of the desired string >= 0
javax.swing.text.BadLocationException
- some portion of the given range
was not a valid part of the document. The location in the exception
is the first bad position encountered.public void getText(int offset, int length, javax.swing.text.Segment txt) throws javax.swing.text.BadLocationException
getText
in interface javax.swing.text.Document
offset
- the offset into the document representing the desired
start of the text >= 0length
- the length of the desired string >= 0txt
- the Segment object to return the text in
javax.swing.text.BadLocationException
- Some portion of the given range
was not a valid part of the document. The location in the exception
is the first bad position encountered.public javax.swing.text.Position getStartPosition()
getStartPosition
in interface javax.swing.text.Document
public javax.swing.text.Position getEndPosition()
getEndPosition
in interface javax.swing.text.Document
public javax.swing.text.Position createPosition(int offset) throws javax.swing.text.BadLocationException
createPosition
in interface javax.swing.text.Document
offset
- the offset from the start of the document >= 0
javax.swing.text.BadLocationException
- if the given position does not
represent a valid location in the associated documentpublic javax.swing.text.Element[] getRootElements()
getRootElements
in interface javax.swing.text.Document
public void render(java.lang.Runnable r)
render
in interface javax.swing.text.Document
r
- a Runnable used to render the modelpublic void addDocumentListener(javax.swing.event.DocumentListener listener)
addDocumentListener
in interface javax.swing.text.Document
listener
- the observer to registerDocument.removeDocumentListener(javax.swing.event.DocumentListener)
public void removeDocumentListener(javax.swing.event.DocumentListener listener)
removeDocumentListener
in interface javax.swing.text.Document
listener
- the observer to registerDocument.addDocumentListener(javax.swing.event.DocumentListener)
public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
addUndoableEditListener
in interface javax.swing.text.Document
listener
- the observer to registerUndoableEditEvent
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
removeUndoableEditListener
in interface javax.swing.text.Document
listener
- the observer to registerUndoableEditEvent
public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedpublic void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
propertyName
- The programmatic name of the property
that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.public java.lang.Object getProperty(java.lang.Object key)
getProperty
in interface javax.swing.text.Document
key
- a non-null property
public void putProperty(java.lang.Object key, java.lang.Object value)
putProperty
in interface javax.swing.text.Document
key
- the non-null property keyvalue
- the property publicprotected void fireUndoableEditEvent(javax.swing.undo.UndoableEdit edit)
edit
- the UndoableEdit generatedpublic void insertUpdate(int offset, int count, char[] insertedData)
insertUpdate
in interface TextBufferListener
offset
- the offset where the insert took placecount
- the number of characters inserted (insertedData.length)insertedData
- the contents of the insertionpublic void removeUpdate(int offset, int count, char[] removedData)
removeUpdate
in interface TextBufferListener
offset
- the offset where the removal took placecount
- the number of characters removed (removedData.length)removedData
- the contents of the removalpublic void attributeUpdate(int attribute)
attributeUpdate
in interface TextBufferListener
attribute
- the attribute that changed
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.