public abstract class SourceFileDocumentProvider extends org.eclipse.ui.editors.text.TextFileDocumentProvider implements IWorkingCopyManager
TextFileDocumentProvider
specialized for
working copy management of source files.Modifier and Type | Class and Description |
---|---|
protected static class |
SourceFileDocumentProvider.SourceFileInfo
Subclass of
FileInfo that can retain a reference to a working copy of a source file. |
org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileBufferListener, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo, org.eclipse.ui.editors.text.TextFileDocumentProvider.NullProvider
Constructor and Description |
---|
SourceFileDocumentProvider()
Creates a new source file document provider with no parent.
|
SourceFileDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider parent)
Creates a new source file document provider with the given parent.
|
Modifier and Type | Method and Description |
---|---|
protected ISourceFile |
acquireWorkingCopy(java.lang.Object element,
org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
Attempts to acquire a working copy for the given element.
|
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo |
createEmptyFileInfo() |
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo |
createFileInfo(java.lang.Object element) |
protected void |
disposeFileInfo(java.lang.Object element,
org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) |
protected abstract ISourceFile |
getSourceFile(java.lang.Object element)
Returns the source file for the given element.
|
ISourceFile[] |
getWorkingCopies()
Returns all working copies that are currently managed by this manager.
|
ISourceFile |
getWorkingCopy(org.eclipse.jface.text.IDocument document)
Returns the working copy managed for the given document,
or
null if this manager does not currently manage
a working copy for the document. |
ISourceFile |
getWorkingCopy(java.lang.Object element)
Returns the working copy managed for the given element,
or
null if this manager does not currently manage
a working copy for the element. |
protected void |
releaseWorkingCopy(ISourceFile workingCopy,
java.lang.Object element,
org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
Releases the given working copy that was acquired via a call to
acquireWorkingCopy . |
aboutToChange, addElementStateListener, canSaveDocument, changed, commitFileBuffer, computeSchedulingRule, connect, createAnnotationModel, createFileFromDocument, createSaveOperation, disconnect, executeOperation, fireElementStateChangeFailed, fireElementStateChanging, getAnnotationModel, getConnectedElementsIterator, getContentType, getDefaultEncoding, getDocument, getElements, getEncoding, getFileInfo, getFileInfosIterator, getFileStore, getModificationStamp, getOperationRunner, getParentProvider, getProgressMonitor, getStatus, getSynchronizationStamp, getSystemFile, handleCoreException, isDeleted, isModifiable, isNotSynchronizedException, isReadOnly, isStateValidated, isSynchronized, isSystemFileReadOnly, mustSaveDocument, removeElementStateListener, resetDocument, saveDocument, setCanSaveDocument, setEncoding, setParentDocumentProvider, setProgressMonitor, setUpSynchronization, synchronize, updateStateCache, validateState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connect, disconnect
public SourceFileDocumentProvider()
public SourceFileDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider parent)
parent
- the parent document providerpublic ISourceFile getWorkingCopy(java.lang.Object element)
null
if this manager does not currently manage
a working copy for the element.
This implementation returns the working copy retained by the file info for
the given element. The file info is obtained via TextFileDocumentProvider.getFileInfo(Object)
.
getWorkingCopy
in interface IWorkingCopyManager
element
- the element for which to find the working copy,
or null
null
if nonepublic ISourceFile getWorkingCopy(org.eclipse.jface.text.IDocument document)
null
if this manager does not currently manage
a working copy for the document.
Note: An implementation of this method may go through the list of working copies and test whether the working copy buffer's document equals the given document. Therefore, this method should not be used in performance critical code.
This implementation returns the working copy retained by the file info
for the given document. The file info is found by iterating over
this provider's file info objects via TextFileDocumentProvider.getFileInfosIterator()
and testing whether the document of the file info's text file buffer
equals the given document.
getWorkingCopy
in interface IWorkingCopyManager
document
- the document for which to find the working copy,
or null
null
if nonepublic ISourceFile[] getWorkingCopies()
This implementation iterates over this provider's file info objects
via TextFileDocumentProvider.getFileInfosIterator()
and collects the working copies
they retain.
getWorkingCopies
in interface IWorkingCopyManager
null
)protected abstract ISourceFile getSourceFile(java.lang.Object element)
element
- the elementnull
if noneprotected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo createEmptyFileInfo()
This implementation returns a new instance of
SourceFileInfo
.
createEmptyFileInfo
in class org.eclipse.ui.editors.text.TextFileDocumentProvider
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo createFileInfo(java.lang.Object element) throws org.eclipse.core.runtime.CoreException
This implementation invokes the superclass implementation to create the
file info object. It then attempts to acquire
a working copy for the
given element if the created object is an instance of SourceFileInfo
and,
if successful, stores a reference to the acquired working copy
in the created file info.
createFileInfo
in class org.eclipse.ui.editors.text.TextFileDocumentProvider
org.eclipse.core.runtime.CoreException
protected void disposeFileInfo(java.lang.Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
This implementation invokes the superclass implementation after trying to
release
the working copy retained by the given file info object.
disposeFileInfo
in class org.eclipse.ui.editors.text.TextFileDocumentProvider
protected ISourceFile acquireWorkingCopy(java.lang.Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) throws org.eclipse.core.runtime.CoreException
releaseWorkingCopy
.
This implementation obtains a source file for the given element via
getSourceFile(Object)
and, if the source file implements
ISourceFileImplExtension
, invokes
on it and returns the acquired working copy.
Otherwise, becomeWorkingCopy_
(EMPTY_CONTEXT,
null)null
is returned.
element
- the elementinfo
- the element infonull
if no working copy
can be acquired for the given elementorg.eclipse.core.runtime.CoreException
- if the working copy could not be acquired successfullyprotected void releaseWorkingCopy(ISourceFile workingCopy, java.lang.Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
acquireWorkingCopy
.
This implementation invokes ((ISourceFileImplExtension)workingCopy).
.
releaseWorkingCopy_()
workingCopy
- the working copy to releaseelement
- the elementinfo
- the element infoCopyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0