public final class TextEditorBuffer extends java.lang.Object implements IBuffer
IBuffer backed by an ITextEditor.
An instance of this class is safe for use by multiple threads, provided that the underlying text editor's document is thread-safe. However, certain operations can only be executed by the UI thread:
saveisDirtyapplyChange -
if save is requested| Constructor and Description |
|---|
TextEditorBuffer(org.eclipse.ui.texteditor.ITextEditor editor)
Creates a new buffer instance and connects it to the given text editor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRef()
Spawns a new independent ownership of this object.
|
IBufferChange |
applyChange(IBufferChange change,
org.eclipse.core.runtime.IProgressMonitor monitor)
Applies the given change to this buffer.
|
org.eclipse.jface.text.source.IAnnotationModel |
getAnnotationModel()
Returns the annotation model of this buffer, if any.
|
org.eclipse.jface.text.IDocument |
getDocument()
Returns the underlying document of this buffer.
|
ISnapshot |
getSnapshot()
Returns the current snapshot of this buffer.
|
boolean |
isDirty()
Returns whether this buffer has been modified since the last time
it was opened or saved.
|
void |
release()
Relinquishes an independent ownership of this object.
|
void |
save(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
Saves this buffer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic TextEditorBuffer(org.eclipse.ui.texteditor.ITextEditor editor)
throws org.eclipse.core.runtime.CoreException
It is the client responsibility to release
the created buffer after it is no longer needed.
This constructor can only be executed by the UI thread.
editor - not nullorg.eclipse.core.runtime.CoreException - if the buffer could not be connectedpublic org.eclipse.jface.text.IDocument getDocument()
IBuffergetDocument in interface IBuffernull)public org.eclipse.jface.text.source.IAnnotationModel getAnnotationModel()
IBuffer
The default method implementation always returns null.
getAnnotationModel in interface IBuffernull if nonepublic ISnapshot getSnapshot()
IBuffer
Note that it is possible to obtain a non-expiring
snapshot from the buffer, although protractedly holding on non-expiring
snapshots is not recommended as they may potentially consume large amount
of space.
getSnapshot in interface IBuffergetSnapshot in interface ISnapshotProvidernull)public IBufferChange applyChange(IBufferChange change, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
IBuffer
Note that an update conflict may occur if the buffer's contents have
changed since the inception of the snapshot on which the change is based.
In that case, a StaleSnapshotException is thrown.
applyChange in interface IBufferchange - a buffer change (not null)monitor - a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done() having been called by the receivernullorg.eclipse.core.runtime.CoreException - if the change's edit tree is not in a valid state,
or if one of the edits in the tree could not be executed, or if save
is requested by the change but the buffer could not be savedpublic void save(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
IBuffersave in interface IBuffercontext - the operation context (not null)monitor - a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done() having been called by the receiverorg.eclipse.core.runtime.CoreException - if the buffer could not be savedpublic boolean isDirty()
IBufferpublic void addRef()
IReferenceCountableaddRef() must ultimately be
followed by exactly one call to IReferenceCountable.release().addRef in interface IBufferaddRef in interface ISnapshotProvideraddRef in interface IReferenceCountablepublic void release()
IReferenceCountablerelease in interface IBufferrelease in interface ISnapshotProviderrelease in interface IReferenceCountableIReferenceCountable.close()Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0