| threaddemo.util.DocumentParseSupport
DocumentParseSupport | abstract public class DocumentParseSupport extends TwoWaySupport (Code) | | Supports two-way parsing of an arbitrary model from a text document and
writing to the text document from the model.
The underlying model is a text document. The deltas to the underlying model
in this implementation are document text changes or reload events, though that
fact should not matter to subclasses. The derived model must be defined by the
subclass.
author: Jesse Glick |
Constructor Summary | |
protected | DocumentParseSupport(EditorCookie.Observable edit, RWLock lock) Create a support based on an editor cookie and lock. |
Method Summary | |
final protected DocumentParseSupportDelta | composeUnderlyingDeltas(DocumentParseSupportDelta underlyingDelta1, DocumentParseSupportDelta underlyingDelta2) In this implementation, deltas are either
PropertyChangeEvent s
of
org.openide.cookies.EditorCookie.Observable.PROP_DOCUMENT indicating that the whole
document changed (was reloaded, for example), or lists of
DocumentEvent s. | final protected DerivationResult<DM, DMD> | doDerive(DM oldValue, DocumentParseSupportDelta underlyingDelta) Parse the document. | abstract protected DerivationResult<DM, DMD> | doDerive(StyledDocument document, List<DocumentEvent> documentEvents, DM oldValue) Create the derived model from a text document. | final protected DM | doRecreate(DM oldValue, DMD derivedDelta) Regenerates the document. | abstract protected DM | doRecreate(StyledDocument document, DM oldValue, DMD derivedDelta) Update the text document to reflect changes in the derived model. | final protected void | initiating() In this implementation, prepares the document so that it will soon be loaded,
if it is not already. | protected boolean | requiresUnmodifiedDocument() Declare whether the support always requires a document object, even to
parse an unmodified file.
If true,
DocumentParseSupport.doDerive(StyledDocument,List,Object) is always given a
document; if the editor support had never been opened at all, it is
nonetheless opened (invisibly) just to provide this document to parse.
If false,
DocumentParseSupport.doDerive(StyledDocument,List,Object) may be passed null for
its document parameter, meaning that the editor support has
not yet loaded a document. | protected boolean | runAsUser(Object derivedDelta) Decide whether the given change to the derived model must occur in "user"
mode, that is, be prevented from modifying guard blocks. |
DocumentParseSupport | protected DocumentParseSupport(EditorCookie.Observable edit, RWLock lock)(Code) | | Create a support based on an editor cookie and lock.
Parameters: edit - the container for the document containing some parsable data Parameters: lock - a lock |
doDerive | abstract protected DerivationResult<DM, DMD> doDerive(StyledDocument document, List<DocumentEvent> documentEvents, DM oldValue) throws Exception(Code) | | Create the derived model from a text document.
Called with the read lock and with read access to the document.
Parameters: document - the text document to parse, or may be null ifDocumentParseSupport.requiresUnmodifiedDocument if false Parameters: documentEvents - a list of DocumentEvent that happened sincethe last parse, or null if unknown (do a full reparse) Parameters: oldValue - the last derived model value, or null the new derived model value plus the change made to it throws: Exception - (checked) in case of parsing problems |
doRecreate | abstract protected DM doRecreate(StyledDocument document, DM oldValue, DMD derivedDelta) throws Exception(Code) | | Update the text document to reflect changes in the derived model.
Called with the write lock and holding a document lock if possible.
Parameters: document - the document to modify Parameters: oldValue - the old derived model, if any Parameters: derivedDelta - the change to the derived model the new derived model See Also: org.openide.text.NbDocument.WriteLockable |
initiating | final protected void initiating()(Code) | | In this implementation, prepares the document so that it will soon be loaded,
if it is not already.
|
requiresUnmodifiedDocument | protected boolean requiresUnmodifiedDocument()(Code) | | Declare whether the support always requires a document object, even to
parse an unmodified file.
If true,
DocumentParseSupport.doDerive(StyledDocument,List,Object) is always given a
document; if the editor support had never been opened at all, it is
nonetheless opened (invisibly) just to provide this document to parse.
If false,
DocumentParseSupport.doDerive(StyledDocument,List,Object) may be passed null for
its document parameter, meaning that the editor support has
not yet loaded a document. In this case the support is expected to run the
parse from the editor cookie's underlying storage, e.g. a file. This style
is potentially much more efficient when performing model reads from a large
number of (unmodified) files.
Recreation always uses an open document regardless of this choice.
The default value is true, i.e. always open the document for parsing.
true to always parse from a real document, or false to permit fasterparses from underlying storage See Also: EditorCookie.getDocument See Also: EditorCookie.openDocument |
runAsUser | protected boolean runAsUser(Object derivedDelta)(Code) | | Decide whether the given change to the derived model must occur in "user"
mode, that is, be prevented from modifying guard blocks.
The default implementation always returns false.
true to run using NbDocument.runAtomicAsUser, false forNbDocument.runAtomic |
|
|