|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.ui.texteditor.AbstractDocumentProvider | +--org.eclipse.ui.editors.text.StorageDocumentProvider
Shareable document provider specialized for IStorage
s.
Nested Class Summary | |
protected class |
StorageDocumentProvider.StorageInfo
Bundle of all required information to allow IStorage as underlying document resources. |
Nested classes inherited from class org.eclipse.ui.texteditor.AbstractDocumentProvider |
|
Field Summary |
Fields inherited from class org.eclipse.ui.texteditor.AbstractDocumentProvider |
PR10806_UC5_ENABLED, PR14469_ENABLED, STATUS_ERROR, STATUS_OK |
Constructor Summary | |
StorageDocumentProvider()
Creates a new document provider. |
Method Summary | |
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 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. |
String |
getDefaultEncoding()
Returns the default character encoding used by this provider for reading. |
String |
getEncoding(Object element)
Returns the character encoding for reading the given element, or null if the element is not managed by this provider. |
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 |
isReadOnly(Object element)
Returns whether the document provider thinks that the given element is read-only. |
protected boolean |
setDocumentContent(IDocument document,
IEditorInput editorInput)
Deprecated. use the encoding based version instead |
protected boolean |
setDocumentContent(IDocument document,
IEditorInput editorInput,
String encoding)
Intitializes 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)
Intitializes the given document with the given stream using the given encoding. |
void |
setEncoding(Object element,
String encoding)
Sets the encoding for reading the given element. |
protected void |
updateCache(IStorageEditorInput input)
Updates the internal cache for the given input. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StorageDocumentProvider()
Method Detail |
protected void setDocumentContent(IDocument document, InputStream contentStream) throws CoreException
document
- the document to be initializedcontentStream
- the stream which delivers the document content
CoreException
- 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 stream
CoreException
- 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 document
true
if the document content could be set, false
otherwise
CoreException
- 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 input
true
if the document content could be set, false
otherwise
CoreException
- if the given editor input cannot be accessedprotected IAnnotationModel createAnnotationModel(Object element) throws CoreException
AbstractDocumentProvider
Subclasses must implement this method.
createAnnotationModel
in class AbstractDocumentProvider
element
- the element
CoreException
- if the annotation model could not be createdprotected IDocument createDocument(Object element) throws CoreException
AbstractDocumentProvider
Subclasses must implement this method.
createDocument
in class AbstractDocumentProvider
element
- the element
CoreException
- if the document could not be createdprotected 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 AbstractDocumentProvider
element
- the element
CoreException
- if the document or annotation model could not be createdprotected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException
AbstractDocumentProvider
Subclasses must implement this method.
doSaveDocument
in class AbstractDocumentProvider
monitor
- a progress monitor to report progress and request cancelationelement
- the elementdocument
- the documentoverwrite
- indicates whether an overwrite should happen if necessary
CoreException
- if document could not be stored to the given elementprotected void handleCoreException(CoreException exception, String message)
CoreExceptions
. Exceptions
are written to the plugin 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 updated
CoreException
public boolean isReadOnly(Object element)
IDocumentProviderExtension
true
, 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 IDocumentProviderExtension
isReadOnly
in class AbstractDocumentProvider
element
- the element
true
if the given element is read-only, false
otherwisepublic boolean isModifiable(Object element)
IDocumentProviderExtension
isReadOnly
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 IDocumentProviderExtension
isModifiable
in class AbstractDocumentProvider
element
- the element
true
if the given element is modifiable, false
otherwiseprotected void doUpdateStateCache(Object element) throws CoreException
AbstractDocumentProvider
doUpdateStateCache
in class AbstractDocumentProvider
element
- the element
CoreException
- in case state cache updating failspublic String getDefaultEncoding()
IStorageDocumentProvider
getDefaultEncoding
in interface IStorageDocumentProvider
public String getEncoding(Object element)
IStorageDocumentProvider
null
if the element is not managed by this provider.
getEncoding
in interface IStorageDocumentProvider
element
- the element
public void setEncoding(Object element, String encoding)
IStorageDocumentProvider
encoding
is null
the workbench's character encoding should be used.
setEncoding
in interface IStorageDocumentProvider
element
- the elementencoding
- the encoding to be used
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |