public interface EditorCookie extends LineCookie
LineCookie
because all implementations of editors should support access
by lines.
The cookie provides interfaces for opening the file, closing the editor, background loading, saving of the document, and notification of modification.
Warning: it is not guaranteed that the document
returned from this cookie will persist for the full lifetime of the
cookie. That is, if the editor window is closed and then reopened,
it is possible for the document to change.
The
allows listening to
changes of the state of the document. You should do this
if you are listening to changes in the document itself, as otherwise
you would get no notifications from a reopened document.EditorCookie.Observable
Modifier and Type | Interface and Description |
---|---|
static interface |
EditorCookie.Observable
The interface extends EditorCookie and allows observing changes
in state of the text document.
|
Modifier and Type | Method and Description |
---|---|
boolean |
close()
Closes all opened editors (if the user agrees) and
flushes content of the document to file.
|
StyledDocument |
getDocument()
Get the document (but do not block).
|
JEditorPane[] |
getOpenedPanes()
Get a list of all editor panes opened on this object.
|
boolean |
isModified()
Test whether the document is modified.
|
void |
open()
Instructs an editor to be opened.
|
StyledDocument |
openDocument()
Get the document (and wait).
|
Task |
prepareDocument()
Should load the document into memory.
|
void |
saveDocument()
Save the document.
|
getLineSet
void open()
boolean close()
false
if the operation has been cancelledTask prepareDocument()
Note that this does not involve opening the actual Editor window.
For that, use EditorCookie.open()
.
StyledDocument openDocument() throws IOException
Editor API
for details on how this document should behave.
If the document is not yet loaded the method blocks until it is.
Note that this does not involve opening the actual Editor window.
For that, use EditorCookie.open()
.
Method will throw UserQuestionException
exception
if file size is too big. This exception could be caught and
its method UserQuestionException.confirmed()
can be used for confirmation. You need to call EditorCookie.openDocument()
}
one more time after confirmation.
IOException
- if the document could not be loadedStyledDocument getDocument()
Note that this does not involve opening the actual Editor window.
For that, use EditorCookie.open()
.
null
if it has not yet been loadedvoid saveDocument() throws IOException
IOException
- on I/O errorboolean isModified()
true
if the document is in memory and is modified; false
otherwiseJEditorPane[] getOpenedPanes()
The resulting panes are useful for a range of tasks;
most commonly, getting the current cursor position or text selection,
including the Caret
object.
This method may also be used to test whether an object is already open in an editor, without actually opening it.
null
if no pane is open from this file.
In no case is an empty array returned.