Class SourceFileDocumentProvider
- All Implemented Interfaces:
IWorkingCopyManager
,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
TextFileDocumentProvider
specialized for
working copy management of source files.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Subclass ofFileInfo
that can retain a reference to a working copy of 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
ConstructorDescriptionCreates 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. -
Method Summary
Modifier and TypeMethodDescriptionprotected ISourceFile
acquireWorkingCopy
(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
protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo
createFileInfo
(Object element) protected void
disposeFileInfo
(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) protected abstract ISourceFile
getSourceFile
(Object element) Returns the source file for the given element.Returns all working copies that are currently managed by this manager.getWorkingCopy
(Object element) Returns the working copy managed for the given element, ornull
if this manager does not currently manage a working copy for the element.getWorkingCopy
(org.eclipse.jface.text.IDocument document) Returns the working copy managed for the given document, ornull
if this manager does not currently manage a working copy for the document.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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.handly.ui.IWorkingCopyManager
connect, disconnect
-
Constructor Details
-
SourceFileDocumentProvider
public SourceFileDocumentProvider()Creates a new source file document provider with no parent. -
SourceFileDocumentProvider
public SourceFileDocumentProvider(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
-
getWorkingCopy
Returns the working copy managed for the given element, ornull
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)
.- Specified by:
getWorkingCopy
in interfaceIWorkingCopyManager
- Parameters:
element
- the element for which to find the working copy, ornull
- Returns:
- the working copy managed for the given element,
or
null
if none
-
getWorkingCopy
Returns the working copy managed for the given document, ornull
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.- Specified by:
getWorkingCopy
in interfaceIWorkingCopyManager
- Parameters:
document
- the document for which to find the working copy, ornull
- Returns:
- the working copy managed for the given document,
or
null
if none
-
getWorkingCopies
Returns all working copies that are currently managed by this manager.This implementation iterates over this provider's file info objects via
TextFileDocumentProvider.getFileInfosIterator()
and collects the working copies they retain.- Specified by:
getWorkingCopies
in interfaceIWorkingCopyManager
- Returns:
- the working copies currently managed by this manager
(never
null
)
-
getSourceFile
Returns the source file for the given element.- Parameters:
element
- the element- Returns:
- the source file for 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. It then attempts to
acquire
a working copy for the given element if the created object is an instance ofSourceFileInfo
and, if successful, stores a reference to the acquired working copy in the created file info.- 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 ISourceFile acquireWorkingCopy(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) throws org.eclipse.core.runtime.CoreException Attempts to acquire a working copy for the given element. A working copy acquired by this method must be released eventually via a call toreleaseWorkingCopy
.This implementation obtains a source file for the given element via
getSourceFile(Object)
and, if the source file implementsISourceFileImplExtension
, invokes
on it and returns the acquired working copy. Otherwise,becomeWorkingCopy_
(EMPTY_CONTEXT, null)null
is returned.- Parameters:
element
- the elementinfo
- the element info- Returns:
- the acquired working copy, or
null
if no working copy can be acquired for the given element - Throws:
org.eclipse.core.runtime.CoreException
- if the working copy could not be acquired successfully
-
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
-