public class StorageDocumentProvider extends AbstractDocumentProvider implements IStorageDocumentProvider
IStorages.| Modifier and Type | Class and Description |
|---|---|
protected class |
StorageDocumentProvider.StorageInfo
Bundle of all required information to allow
IStorage as underlying document resources. |
AbstractDocumentProvider.DocumentProviderOperation, AbstractDocumentProvider.ElementInfo| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_FILE_SIZE
Default file size.
|
PR10806_UC5_ENABLED, PR14469_ENABLED, STATUS_ERROR, STATUS_OK| Constructor and Description |
|---|
StorageDocumentProvider()
Creates a new document provider.
|
| Modifier and Type | Method and Description |
|---|---|
protected IAnnotationModel |
createAnnotationModel(Object element)
Creates an annotation model for the given element.
|
protected IDocument |
createDocument(Object element)
Creates the document for the given element.
|
protected AbstractDocumentProvider.ElementInfo |
createElementInfo(Object element)
Creates a new element info object for the given element.
|
protected IDocument |
createEmptyDocument()
Factory method for creating empty documents.
|
protected void |
doSaveDocument(IProgressMonitor monitor,
Object element,
IDocument document,
boolean overwrite)
Performs the actual work of saving the given document provided for the
given element.
|
protected void |
doUpdateStateCache(Object element)
Hook method for updating the state of the given element.
|
IContentType |
getContentType(Object element)
Returns the content type of for the given element or
null if none could be determined. |
String |
getDefaultEncoding()
Returns the default character encoding used by this provider.
|
String |
getEncoding(Object element)
Returns the character encoding for the given element, or
null if the element is not managed by this provider. |
protected IRunnableContext |
getOperationRunner(IProgressMonitor monitor)
Returns the runnable context for this document provider.
|
protected String |
getPersistedEncoding(Object element)
Returns the persisted encoding for the given element.
|
protected void |
handleCoreException(CoreException exception,
String message)
Defines the standard procedure to handle
CoreExceptions. |
boolean |
isModifiable(Object element)
Returns whether the document provider thinks that the given element can persistently be modified.
|
boolean |
isNotSynchronizedException(Object element,
CoreException ex)
Tells whether the given core exception is exactly the
exception which is thrown for a non-synchronized element.
|
boolean |
isReadOnly(Object element)
Returns whether the document provider thinks that the given element is read-only.
|
protected void |
persistEncoding(Object element,
String encoding)
Persists the given encoding for the given element.
|
protected boolean |
setDocumentContent(IDocument document,
IEditorInput editorInput)
Deprecated.
use the encoding based version instead
|
protected boolean |
setDocumentContent(IDocument document,
IEditorInput editorInput,
String encoding)
Initializes the given document from the given editor input using the given character encoding.
|
protected void |
setDocumentContent(IDocument document,
InputStream contentStream)
Deprecated.
use encoding based version instead
|
protected void |
setDocumentContent(IDocument document,
InputStream contentStream,
String encoding)
Initializes the given document with the given stream using the given encoding.
|
void |
setEncoding(Object element,
String encoding)
Sets the encoding for the given element.
|
protected void |
setupDocument(Object element,
IDocument document)
Sets up the given document as it would be provided for the given element.
|
protected void |
updateCache(IStorageEditorInput input)
Updates the internal cache for the given input.
|
aboutToChange, addElementStateListener, addUnchangedElementListeners, canSaveDocument, changed, connect, connected, disconnect, disconnected, disposeElementInfo, doResetDocument, doSynchronize, doValidateState, executeOperation, fireElementContentAboutToBeReplaced, fireElementContentReplaced, fireElementDeleted, fireElementDirtyStateChanged, fireElementMoved, fireElementStateChangeFailed, fireElementStateChanging, fireElementStateValidationChanged, getAnnotationModel, getConnectedElements, getDocument, getElementInfo, getModificationStamp, getProgressMonitor, getResetRule, getSaveRule, getStatus, getSynchronizationStamp, getSynchronizeRule, getValidateStateRule, invalidatesState, isDeleted, isStateValidated, isSynchronized, mustSaveDocument, removeElementStateListener, removeUnchangedElementListeners, resetDocument, saveDocument, setCanSaveDocument, setProgressMonitor, synchronize, updateStateCache, validateStateprotected static final int DEFAULT_FILE_SIZE
public StorageDocumentProvider()
protected void setDocumentContent(IDocument document, InputStream contentStream) throws CoreException
document - the document to be initializedcontentStream - the stream which delivers the document contentCoreException - if the given stream can not be readprotected void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException
document - the document to be initializedcontentStream - the stream which delivers the document contentencoding - the character encoding for reading the given streamCoreException - if the given stream can not be readprotected boolean setDocumentContent(IDocument document, IEditorInput editorInput) throws CoreException
document - the document to be initializededitorInput - the input from which to derive the content of the documenttrue if the document content could be set, false otherwiseCoreException - if the given editor input cannot be accessedprotected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException
document - the document to be initializededitorInput - the input from which to derive the content of the documentencoding - the character encoding used to read the editor inputtrue if the document content could be set, false otherwiseCoreException - if the given editor input cannot be accessedprotected IAnnotationModel createAnnotationModel(Object element) throws CoreException
AbstractDocumentProviderSubclasses must implement this method.
createAnnotationModel in class AbstractDocumentProviderelement - the elementnull if noneCoreException - if the annotation model could not be createdprotected IDocument createEmptyDocument()
protected IDocument createDocument(Object element) throws CoreException
AbstractDocumentProviderSubclasses must implement this method.
createDocument in class AbstractDocumentProviderelement - the elementCoreException - if the document could not be createdprotected void setupDocument(Object element, IDocument document)
element - the blue-print elementdocument - the document to set upprotected AbstractDocumentProvider.ElementInfo createElementInfo(Object element) throws CoreException
AbstractDocumentProvider
This method is called from connect when an element info needs
to be created. The AbstractDocumentProvider implementation
of this method returns a new element info object whose document and
annotation model are the values of createDocument(element)
and createAnnotationModel(element), respectively. Subclasses
may override.
createElementInfo in class AbstractDocumentProviderelement - the elementCoreException - if the document or annotation model could not be createdprotected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException
AbstractDocumentProviderSubclasses must implement this method.
doSaveDocument in class AbstractDocumentProvidermonitor - a progress monitor to report progress and request cancelationelement - the elementdocument - the documentoverwrite - indicates whether an overwrite should happen if necessaryCoreException - if document could not be stored to the given elementprotected void handleCoreException(CoreException exception, String message)
CoreExceptions. Exceptions
are written to the plug-in log.exception - the exception to be loggedmessage - the message to be loggedprotected void updateCache(IStorageEditorInput input) throws CoreException
input - the input whose cache will be updatedCoreException - if the storage cannot be retrieved from the inputpublic boolean isReadOnly(Object element)
IDocumentProviderExtensiontrue, saveDocument could fail.
This method does not say anything about the document constructed from the given
element. If the given element is not connected to this document provider, the return
value is undefined. Document providers are allowed to use a cache to answer this
question, i.e. there can be a difference between the "real" state of the element and
the return value.isReadOnly in interface IDocumentProviderExtensionisReadOnly in class AbstractDocumentProviderelement - the elementtrue if the given element is read-only, false otherwisepublic boolean isNotSynchronizedException(Object element, CoreException ex)
IDocumentProviderExtension5isNotSynchronizedException in interface IDocumentProviderExtension5isNotSynchronizedException in class AbstractDocumentProviderelement - the elementex - the core exceptiontrue iff the given core exception is exactly the
exception which is thrown for a non-synchronized elementpublic boolean isModifiable(Object element)
IDocumentProviderExtensionisReadOnly as read-only elements may be modifiable and
writable elements may not be modifiable. If the given element is not connected to this document
provider, the result is undefined. Document providers are allowed to use a cache to answer this
question, i.e. there can be a difference between the "real" state of the element and the return
value.isModifiable in interface IDocumentProviderExtensionisModifiable in class AbstractDocumentProviderelement - the elementtrue if the given element is modifiable, false otherwiseprotected void doUpdateStateCache(Object element) throws CoreException
AbstractDocumentProviderdoUpdateStateCache in class AbstractDocumentProviderelement - the elementCoreException - in case state cache updating failspublic String getDefaultEncoding()
IStorageDocumentProvidergetDefaultEncoding in interface IStorageDocumentProviderpublic String getEncoding(Object element)
IStorageDocumentProvidernull if the element is not managed by this provider.getEncoding in interface IStorageDocumentProviderelement - the elementpublic void setEncoding(Object element, String encoding)
IStorageDocumentProviderencoding
is null the workbench's character encoding should be used.setEncoding in interface IStorageDocumentProviderelement - the elementencoding - the encoding to be usedpublic IContentType getContentType(Object element) throws CoreException
IDocumentProviderExtension4null if none could be determined. If the element's
document can be saved, the returned content type is determined by the
document's current content.getContentType in interface IDocumentProviderExtension4getContentType in class AbstractDocumentProviderelement - the elementnullCoreException - if reading or accessing the underlying store
failsprotected String getPersistedEncoding(Object element)
element - the element for which to get the persisted encodingprotected void persistEncoding(Object element, String encoding) throws CoreException
element - the element for which to store the persisted encodingencoding - the encodingCoreException - if the operation failsprotected IRunnableContext getOperationRunner(IProgressMonitor monitor)
AbstractDocumentProvidergetOperationRunner in class AbstractDocumentProvidermonitor - a progress monitor to track the operationGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.