LineCookie
, org.openide.nodes.Node.Cookie
EditorCookie.Observable
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 | Description |
---|---|---|
static interface |
EditorCookie.Observable |
The interface extends EditorCookie and allows observing changes
in state of the text document.
|
Modifier and Type | Method | 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).
|
org.openide.util.Task |
prepareDocument() |
Should load the document into memory.
|
void |
saveDocument() |
Save the document.
|
getLineSet
void open()
boolean close()
false
if the operation has been cancelledorg.openide.util.Task prepareDocument()
Note that this does not involve opening the actual Editor window.
For that, use 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 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 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 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.Built on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.