Class DeferredSourceFileDocumentProvider
- All Implemented Interfaces:
org.eclipse.ui.editors.text.IStorageDocumentProvider
,org.eclipse.ui.texteditor.IDocumentProvider
,org.eclipse.ui.texteditor.IDocumentProviderExtension
,org.eclipse.ui.texteditor.IDocumentProviderExtension2
,org.eclipse.ui.texteditor.IDocumentProviderExtension3
,org.eclipse.ui.texteditor.IDocumentProviderExtension4
,org.eclipse.ui.texteditor.IDocumentProviderExtension5
SourceFileDocumentProvider
, which acquires a working
copy in the calling thread, this class defers working copy acquisition to a
worker thread.- Since:
- 1.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Subclass ofFileInfo
that can retain a reference to a source file.Nested classes/interfaces inherited from class org.eclipse.ui.editors.text.TextFileDocumentProvider
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 Summary
ConstructorsConstructorDescriptionCreates a new source file document provider with no parent.DeferredSourceFileDocumentProvider
(org.eclipse.ui.texteditor.IDocumentProvider parent) Creates a new source file document provider with the given parent. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acquireWorkingCopy
(ISourceFile sourceFile, Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info, org.eclipse.core.runtime.IProgressMonitor monitor) Attempts to acquire a working copy for the given source file.protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo
createFileInfo
(Object element) protected void
disposeFileInfo
(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) getConnectedSourceFile
(Object element) Returns the source file managed for the given element, ornull
if this provider does not currently manage a source file for the element.getConnectedSourceFile
(org.eclipse.jface.text.IDocument document) Returns the source file managed for the given document, ornull
if this provider does not currently manage a source file for the document.Returns all source files that are currently managed by this provider.protected abstract ISourceFile
getSourceFile
(Object element) Returns the source file that corresponds to the given element.protected void
releaseWorkingCopy
(ISourceFile workingCopy, Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) Releases the given working copy that was acquired via a call toacquireWorkingCopy
.Methods inherited from class org.eclipse.ui.editors.text.TextFileDocumentProvider
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
-
Constructor Details
-
DeferredSourceFileDocumentProvider
public DeferredSourceFileDocumentProvider()Creates a new source file document provider with no parent. -
DeferredSourceFileDocumentProvider
public DeferredSourceFileDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider parent) Creates a new source file document provider with the given parent.- Parameters:
parent
- the parent document provider
-
-
Method Details
-
getConnectedSourceFile
Returns the source file managed for the given element, ornull
if this provider does not currently manage a source file for the element.This implementation returns the source file retained by the file info for the given element. The file info is obtained via
TextFileDocumentProvider.getFileInfo(Object)
.- Parameters:
element
- the element for which to find the source file, ornull
- Returns:
- the source file managed for the given element,
or
null
if none
-
getConnectedSourceFile
Returns the source file managed for the given document, ornull
if this provider does not currently manage a source file for the document.Note: An implementation of this method may go through the list of source files and test whether the source file buffer's document equals the given document. Therefore, this method should not be used in performance critical code.
This implementation returns the source file 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.- Parameters:
document
- the document for which to find the source file, ornull
- Returns:
- the source file managed for the given document,
or
null
if none
-
getConnectedSourceFiles
Returns all source files that are currently managed by this provider.This implementation iterates over this provider's file info objects via
TextFileDocumentProvider.getFileInfosIterator()
and collects the source files they retain.- Returns:
- the source files currently managed by this provider
(never
null
)
-
getSourceFile
Returns the source file that corresponds to the given element.- Parameters:
element
- the element- Returns:
- the source file that corresponds to the given element,
or
null
if none
-
createEmptyFileInfo
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo createEmptyFileInfo()This implementation returns a new instance of
SourceFileInfo
.- Overrides:
createEmptyFileInfo
in classorg.eclipse.ui.editors.text.TextFileDocumentProvider
-
createFileInfo
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo createFileInfo(Object element) throws org.eclipse.core.runtime.CoreException This implementation invokes the superclass implementation to create the file info object. If the created object is an instance of
SourceFileInfo
, it stores a reference to the correspondingsource file
in the created file info, and then attempts toacquire
a working copy for the source file asynchronously.- Overrides:
createFileInfo
in classorg.eclipse.ui.editors.text.TextFileDocumentProvider
- Throws:
org.eclipse.core.runtime.CoreException
-
disposeFileInfo
protected void disposeFileInfo(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.- Overrides:
disposeFileInfo
in classorg.eclipse.ui.editors.text.TextFileDocumentProvider
-
acquireWorkingCopy
protected boolean acquireWorkingCopy(ISourceFile sourceFile, Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Attempts to acquire a working copy for the given source file. The working copy acquired by this method must be released eventually via a call toreleaseWorkingCopy
.If the given source file implements
ISourceFileImplExtension
, this implementation invokes
on it and returnsbecomeWorkingCopy_
(EMPTY_CONTEXT, monitor)true
. Otherwise,false
is returned.- Parameters:
sourceFile
- the source fileelement
- the elementinfo
- the element infomonitor
- a progress monitor, ornull
if progress reporting is not desired. The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Returns:
true
if a working copy has been acquired;false
if no working copy can be acquired for the given source file- Throws:
org.eclipse.core.runtime.CoreException
- if the working copy could not be acquired successfullyorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceled
-
releaseWorkingCopy
protected void releaseWorkingCopy(ISourceFile workingCopy, Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) Releases the given working copy that was acquired via a call toacquireWorkingCopy
.This implementation invokes
((ISourceFileImplExtension)workingCopy).
.releaseWorkingCopy_()
- Parameters:
workingCopy
- the working copy to releaseelement
- the elementinfo
- the element info
-