|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1) E13403-03 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.model.NodeListener oracle.ide.model.TextBufferTracker
public class TextBufferTracker
A tracker of changes to the TextBuffer
of a TextNode
. A
client which needs to track regions in a text buffer across edits can get
a tracker for the text node, store the tracker version along with the
offsets and lengths of the regions, and then at any time use the tracker
to adjust offsets and lengths to reflect subsequent edits.
The text buffer uses text differencing to minimize the tracking impact of text buffer reloads which do not significantly change the text (e.g., minor external edits or VCS checkouts). The handling depends somewhat on undocumented text buffer implementation details. In particular, the tracker assumes that between RELOAD_STARTED and RELOAD_ENDED, the text buffer will issue a single remove event for the old text (unless the old text is empty), followed by a single insert event for the new text (unless the new text is empty).
Text buffers that are managed by TextNode
may be garbage collected
and later reloaded into a new text buffer which retains the listeners of
the original text buffer. In this case, the tracker assumes that between
the RELOAD_STARTED and RELOAD_ENDED, it will only see the insert event and
not the remove event. To distinguish this case from a normal reload starting
from an empty buffer, the tracker uses its history of the buffer length.
A text node that is closed without saving has to be tracked as a reversion, because if it is reopened every thing will be out of sync otherwise. The dirty flag is cleared by the time the nodeClosed event is fired, so the nodeWillClose event is used.
Field Summary |
---|
Fields inherited from interface oracle.javatools.buffer.TextBufferListener |
---|
EOL_TYPE_ATTRIBUTE, MODIFIED_ATTRIBUTE, READ_ONLY_ATTRIBUTE, RELOAD_END_ATTRIBUTE, RELOAD_START_ATTRIBUTE |
Method Summary | |
---|---|
boolean |
adjustOffsetLength(int offset,
int length,
int version,
int[] adjusted)
Adjusts a region of the tracked buffer to reflect modifications since a version. |
void |
attributeUpdate(TextBuffer buffer,
int attribute)
Provides notification regarding a change to one of the buffer attributes. |
static TextBufferTracker |
getTracker(TextNode node)
Gets the text buffer tracker for a text node. |
int |
getVersion()
Gets the current version of the tracked buffer. |
void |
insertUpdate(TextBuffer buffer,
int offset,
int count,
char[] text)
Provides notification about an insertion into the TextBuffer . |
boolean |
isModified(int version)
Gets whether the tracked buffer has been modified since a version. |
boolean |
isModified(int offset,
int length,
int version)
Gets whether a region of the tracked buffer has been modified since a version. |
void |
nodeClosed(NodeEvent event)
Called after a Node has been closed. |
void |
nodeDeleted(NodeEvent e)
Called after a Node has been deleted from disk and removed from the NodeFactory cache. |
void |
nodeDirtyStateChanged(NodeEvent e,
boolean dirty)
Called when the dirty state of a Node has just changed. |
void |
nodeOpened(NodeEvent event)
Called after a Node has been opened. |
void |
nodeRenamed(NodeEvent e,
java.net.URL oldURL,
java.net.URL newURL)
Called after a Node has been renamed and recached under the new URL in the NodeFactory. |
void |
nodeReverted(NodeEvent e)
Called when a Node has been reverted (reloaded) to its last saved state. |
void |
nodeSaved(NodeEvent e)
Called after a Node has been saved. |
void |
nodeWillBeSaved(NodeEvent e)
Called before a Node is about to be saved. |
void |
nodeWillClose(NodeEvent e)
Called when a Node is about to be closed. |
void |
nodeWillOpen(NodeEvent e)
Called when a Node is about to be opened. |
void |
removeUpdate(TextBuffer buffer,
int offset,
int count,
char[] text)
Provides notification about a removal from the TextBuffer . |
void |
replaceText(TextBuffer buffer,
char[] fromText,
char[] toText)
|
java.lang.String |
toString()
|
Methods inherited from class oracle.ide.model.NodeListener |
---|
invokeLaterIfNeeded |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static TextBufferTracker getTracker(TextNode node)
node
- The TextNode
to track.public int getVersion()
public boolean adjustOffsetLength(int offset, int length, int version, int[] adjusted)
offset
- The offset of the region when the version was current.length
- The length of the region when the version was current.version
- The version from which to adjust.adjusted
- A two element int array for the adjusted offset and length.
public boolean isModified(int version)
version
- The version from which to compare.public boolean isModified(int offset, int length, int version)
offset
- The offset of the region when the version was current.length
- The length of the region when the version was current.version
- The version from which to compare.
adjustOffsetLength(int, int, int, int[])
public java.lang.String toString()
toString
in class java.lang.Object
public void nodeWillOpen(NodeEvent e)
NodeListener
nodeWillOpen
in class NodeListener
e
- the object containing information about this eventpublic void nodeOpened(NodeEvent event)
NodeListener
nodeOpened
in class NodeListener
event
- the object containing information about this eventpublic void nodeDirtyStateChanged(NodeEvent e, boolean dirty)
NodeListener
nodeDirtyStateChanged
in class NodeListener
e
- the object containing information about this eventdirty
- true
if the Node's dirty flag has
just been set; false
if the Node's dirty flag has
just been cleared.public void nodeWillClose(NodeEvent e)
NodeListener
nodeWillClose
in class NodeListener
e
- the object containing information about this eventpublic void nodeClosed(NodeEvent event)
NodeListener
nodeClosed
in class NodeListener
event
- the object containing information about this eventpublic void nodeWillBeSaved(NodeEvent e)
NodeListener
nodeWillBeSaved
in class NodeListener
e
- the object containing information about this eventpublic void nodeSaved(NodeEvent e)
NodeListener
nodeSaved
in class NodeListener
e
- the object containing information about this eventpublic void nodeReverted(NodeEvent e)
NodeListener
nodeReverted
in class NodeListener
e
- the object containing information about this eventpublic void nodeDeleted(NodeEvent e)
NodeListener
nodeDeleted
in class NodeListener
e
- the object containing information about this eventpublic void nodeRenamed(NodeEvent e, java.net.URL oldURL, java.net.URL newURL)
NodeListener
nodeRenamed
in class NodeListener
e
- the object containing information about this event.
Calling e.getNode()
will return the
old Node
. To get the new Node, call
NodeFactory.find(newURL)
. Both old and new Nodes
remain available while NodeListeners are being called with
the nodeRenamed event. In the case where renaming did not cause
the Node type to change, both old Node and new Node will be the
exact same object, so using the oldURL
parameter
is the only reliable way to know the URL of the Node before it
was renamed. If the Node type did change, the old Node is
removed from the NodeFactory cache immediately after all
NodeListeners have been called with the nodeRenamed event.oldURL
- the old URL of the Node before the renamenewURL
- the new URL of the Node after the renamepublic void attributeUpdate(TextBuffer buffer, int attribute)
TextBufferListener
attributeUpdate
in interface TextBufferListener
buffer
- the TextBuffer
that changed.attribute
- the attribute that changedpublic void insertUpdate(TextBuffer buffer, int offset, int count, char[] text)
TextBufferListener
TextBuffer
.
insertUpdate
in interface TextBufferListener
buffer
- the TextBuffer
that changed.offset
- the offset where the insert took placecount
- the number of characters inserted (insertedData.length)text
- an array of the removed characters.public void removeUpdate(TextBuffer buffer, int offset, int count, char[] text)
TextBufferListener
TextBuffer
.
removeUpdate
in interface TextBufferListener
buffer
- the TextBuffer
that changed.offset
- the offset of the first removed character.count
- the number of characters removed (removedData.length)text
- an array of the removed characterspublic void replaceText(TextBuffer buffer, char[] fromText, char[] toText)
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1) E13403-03 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |