|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.ui.texteditor.AbstractDocumentProvider
public abstract class AbstractDocumentProvider
An abstract implementation of a sharable document provider.
Subclasses must implement createDocument,
createAnnotationModel, and doSaveDocument.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractDocumentProvider.DocumentProviderOperation
Operation created by the document provider and to be executed by the providers runnable context. |
protected class |
AbstractDocumentProvider.ElementInfo
Collection of all information managed for a connected element. |
| Field Summary | |
|---|---|
protected static boolean |
PR10806_UC5_ENABLED
Enables a certain behavior. |
protected static boolean |
PR14469_ENABLED
Enables a certain behavior. |
protected static IStatus |
STATUS_ERROR
Constant for representing the error status. |
protected static IStatus |
STATUS_OK
Deprecated. As of 3.6, replaced by Status.OK_STATUS |
| Constructor Summary | |
|---|---|
protected |
AbstractDocumentProvider()
Creates a new document provider. |
| Method Summary | |
|---|---|
void |
aboutToChange(java.lang.Object element)
The AbstractDocumentProvider implementation of this
IDocumentProvider method does nothing. |
void |
addElementStateListener(IElementStateListener listener)
Adds the given element state listener to this document provider. |
protected void |
addUnchangedElementListeners(java.lang.Object element,
AbstractDocumentProvider.ElementInfo info)
Called on initial creation and when the dirty state of the element changes to false. |
boolean |
canSaveDocument(java.lang.Object element)
Returns whether the document provided for the given element differs from its original state which would required that it be saved. |
void |
changed(java.lang.Object element)
The AbstractDocumentProvider implementation of this
IDocumentProvider method does nothing. |
void |
connect(java.lang.Object element)
Connects the given element to this document provider. |
protected void |
connected()
This hook method is called when this provider starts managing documents for elements. |
protected abstract IAnnotationModel |
createAnnotationModel(java.lang.Object element)
Creates an annotation model for the given element. |
protected abstract IDocument |
createDocument(java.lang.Object element)
Creates the document for the given element. |
protected AbstractDocumentProvider.ElementInfo |
createElementInfo(java.lang.Object element)
Creates a new element info object for the given element. |
void |
disconnect(java.lang.Object element)
Disconnects the given element from this document provider. |
protected void |
disconnected()
This hook method is called when this provider stops managing documents for element. |
protected void |
disposeElementInfo(java.lang.Object element,
AbstractDocumentProvider.ElementInfo info)
Disposes of the given element info object. |
protected void |
doResetDocument(java.lang.Object element,
IProgressMonitor monitor)
Executes the actual work of reseting the given elements document. |
protected abstract void |
doSaveDocument(IProgressMonitor monitor,
java.lang.Object element,
IDocument document,
boolean overwrite)
Performs the actual work of saving the given document provided for the given element. |
protected void |
doSynchronize(java.lang.Object element,
IProgressMonitor monitor)
Performs the actual work of synchronizing the given element. |
protected void |
doUpdateStateCache(java.lang.Object element)
Hook method for updating the state of the given element. |
protected void |
doValidateState(java.lang.Object element,
java.lang.Object computationContext)
Hook method for validating the state of the given element. |
protected void |
executeOperation(AbstractDocumentProvider.DocumentProviderOperation operation,
IProgressMonitor monitor)
Executes the given operation in the providers runnable context. |
protected void |
fireElementContentAboutToBeReplaced(java.lang.Object element)
Informs all registered element state listeners about an impending replace of the given element's content. |
protected void |
fireElementContentReplaced(java.lang.Object element)
Informs all registered element state listeners about the just-completed replace of the given element's content. |
protected void |
fireElementDeleted(java.lang.Object element)
Informs all registered element state listeners about the deletion of the given element. |
protected void |
fireElementDirtyStateChanged(java.lang.Object element,
boolean isDirty)
Informs all registered element state listeners about a change in the dirty state of the given element. |
protected void |
fireElementMoved(java.lang.Object originalElement,
java.lang.Object movedElement)
Informs all registered element state listeners about a move. |
protected void |
fireElementStateChangeFailed(java.lang.Object element)
Informs all registered element state listeners about the failed state change of the element |
protected void |
fireElementStateChanging(java.lang.Object element)
Informs all registered element state listeners about the current state change of the element |
protected void |
fireElementStateValidationChanged(java.lang.Object element,
boolean isStateValidated)
Informs all registered element state listeners about a change in the state validation of the given element. |
IAnnotationModel |
getAnnotationModel(java.lang.Object element)
Returns the annotation model for the given element. |
protected java.util.Iterator |
getConnectedElements()
Enumerates the elements connected via this document provider. |
IContentType |
getContentType(java.lang.Object element)
Returns the content type of for the given element or null if none could be determined. |
IDocument |
getDocument(java.lang.Object element)
Returns the document for the given element. |
protected AbstractDocumentProvider.ElementInfo |
getElementInfo(java.lang.Object element)
Returns the element info object for the given element. |
long |
getModificationStamp(java.lang.Object element)
Returns the modification stamp of the given element. |
protected abstract IRunnableContext |
getOperationRunner(IProgressMonitor monitor)
Returns the runnable context for this document provider. |
IProgressMonitor |
getProgressMonitor()
Returns this providers progress monitor. |
protected ISchedulingRule |
getResetRule(java.lang.Object element)
Returns the scheduling rule required for executing reset on the given element. |
protected ISchedulingRule |
getSaveRule(java.lang.Object element)
Returns the scheduling rule required for executing save on the given element. |
IStatus |
getStatus(java.lang.Object element)
Returns the status of the given element. |
long |
getSynchronizationStamp(java.lang.Object element)
Returns the time stamp of the last synchronization of the given element and it's provided document. |
protected ISchedulingRule |
getSynchronizeRule(java.lang.Object element)
Returns the scheduling rule required for executing synchronize on the given element. |
protected ISchedulingRule |
getValidateStateRule(java.lang.Object element)
Returns the scheduling rule required for executing validateState on the given element. |
protected boolean |
invalidatesState(java.lang.Object element,
boolean wasReadOnly)
Returns whether the state of the element must be invalidated given its previous read-only state. |
boolean |
isDeleted(java.lang.Object element)
Returns whether the given element has been deleted. |
boolean |
isModifiable(java.lang.Object element)
Returns whether the document provider thinks that the given element can persistently be modified. |
boolean |
isNotSynchronizedException(java.lang.Object element,
CoreException ex)
Tells whether the given core exception is exactly the exception which is thrown for a non-synchronized element. |
boolean |
isReadOnly(java.lang.Object element)
Returns whether the document provider thinks that the given element is read-only. |
boolean |
isStateValidated(java.lang.Object element)
Returns whether validateState has been called for the given element
since the element's state has potentially been invalidated. |
boolean |
isSynchronized(java.lang.Object element)
Returns whether the information provided for the given element is in sync with the element. |
boolean |
mustSaveDocument(java.lang.Object element)
Returns whether the document provided for the given element must be saved. |
void |
removeElementStateListener(IElementStateListener listener)
Removes the given element state listener from this document provider. |
protected void |
removeUnchangedElementListeners(java.lang.Object element,
AbstractDocumentProvider.ElementInfo info)
Called when the given element gets dirty. |
void |
resetDocument(java.lang.Object element)
Resets the given element's document to its last saved state. |
void |
saveDocument(IProgressMonitor monitor,
java.lang.Object element,
IDocument document,
boolean overwrite)
Saves the given document provided for the given element. |
void |
setCanSaveDocument(java.lang.Object element)
Marks the document managed for the given element as savable. |
void |
setProgressMonitor(IProgressMonitor progressMonitor)
Sets this providers progress monitor. |
void |
synchronize(java.lang.Object element)
Synchronizes the document provided for the given element with the given element. |
void |
updateStateCache(java.lang.Object element)
Updates the state cache for the given element. |
void |
validateState(java.lang.Object element,
java.lang.Object computationContext)
Validates the state of the given element. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final boolean PR10806_UC5_ENABLED
true since 3.0
protected static final boolean PR14469_ENABLED
PR10806_UC5_ENABLED.
Current value: false since 3.0
protected static final IStatus STATUS_OK
Status.OK_STATUS
protected static final IStatus STATUS_ERROR
| Constructor Detail |
|---|
protected AbstractDocumentProvider()
| Method Detail |
|---|
protected abstract IDocument createDocument(java.lang.Object element)
throws CoreException
Subclasses must implement this method.
element - the element
CoreException - if the document could not be created
protected abstract IAnnotationModel createAnnotationModel(java.lang.Object element)
throws CoreException
Subclasses must implement this method.
element - the element
null if none
CoreException - if the annotation model could not be created
protected abstract void doSaveDocument(IProgressMonitor monitor,
java.lang.Object element,
IDocument document,
boolean overwrite)
throws CoreException
Subclasses must implement this method.
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 abstract IRunnableContext getOperationRunner(IProgressMonitor monitor)
monitor - a progress monitor to track the operation
protected ISchedulingRule getSynchronizeRule(java.lang.Object element)
synchronize on the given element. This default
implementation returns null.
element - the element
synchronizeprotected ISchedulingRule getValidateStateRule(java.lang.Object element)
validateState on the given element. This default
implementation returns null.
element - the element
validateStateprotected ISchedulingRule getSaveRule(java.lang.Object element)
save on the given element. This default
implementation returns null.
element - the element
saveprotected ISchedulingRule getResetRule(java.lang.Object element)
reset on the given element. This default
implementation returns null.
element - the element
resetprotected AbstractDocumentProvider.ElementInfo getElementInfo(java.lang.Object element)
element - the element
null if none
protected AbstractDocumentProvider.ElementInfo createElementInfo(java.lang.Object element)
throws CoreException
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.
element - the element
CoreException - if the document or annotation model could not be created
protected void disposeElementInfo(java.lang.Object element,
AbstractDocumentProvider.ElementInfo info)
This method is called when an element info is disposed. The
AbstractDocumentProvider implementation of this
method does nothing. Subclasses may reimplement.
element - the elementinfo - the element info object
protected void addUnchangedElementListeners(java.lang.Object element,
AbstractDocumentProvider.ElementInfo info)
false. Adds all listeners which must be
active as long as the element is not dirty. This method is called
before fireElementDirtyStateChanged or
fireElementContentReplaced is called.
Subclasses may extend.
element - the elementinfo - the element info object
protected void removeUnchangedElementListeners(java.lang.Object element,
AbstractDocumentProvider.ElementInfo info)
fireElementDirtyStateChanged
or fireElementContentReplaced is called.
Subclasses may extend.
element - the elementinfo - the element info objectprotected java.util.Iterator getConnectedElements()
Object)
public final void connect(java.lang.Object element)
throws CoreException
IDocumentProviderdisconnect(Object) this provider can assume to know the
correct number of clients working with the document provided for that
domain model element.
The given element must not be null.
connect in interface IDocumentProviderelement - the element
CoreException - if the textual representation or the annotation model
of the element could not be createdprotected void connected()
public final void disconnect(java.lang.Object element)
IDocumentProviderconnect(Object) and of this method this provider can assume to
know the correct number of clients working with the document provided for that
domain model element.
The given element must not be null.
disconnect in interface IDocumentProviderelement - the elementprotected void disconnected()
public IDocument getDocument(java.lang.Object element)
IDocumentProvider
getDocument in interface IDocumentProviderelement - the element, or null
null if nonepublic boolean mustSaveDocument(java.lang.Object element)
IDocumentProvider
mustSaveDocument in interface IDocumentProviderelement - the element, or null
true if the document must be saved, and
false otherwise (including the element is null)public IAnnotationModel getAnnotationModel(java.lang.Object element)
IDocumentProvider
getAnnotationModel in interface IDocumentProviderelement - the element, or null
null if nonepublic boolean canSaveDocument(java.lang.Object element)
IDocumentProvider
canSaveDocument in interface IDocumentProviderelement - the element, or null
true if the document can be saved, and
false otherwise (including the element is null)
protected void doResetDocument(java.lang.Object element,
IProgressMonitor monitor)
throws CoreException
element - the elementmonitor - the progress monitor
CoreException - if resetting fails
protected void executeOperation(AbstractDocumentProvider.DocumentProviderOperation operation,
IProgressMonitor monitor)
throws CoreException
operation - the operation to be executesmonitor - the progress monitor
CoreException - the operation's core exception
public final void resetDocument(java.lang.Object element)
throws CoreException
IDocumentProviderelementContentAboutToBeReplaced)
and after (elementContentReplaced) the content is changed.
resetDocument in interface IDocumentProviderelement - the element, or null
CoreException - if document could not be reset for the given element
public final void saveDocument(IProgressMonitor monitor,
java.lang.Object element,
IDocument document,
boolean overwrite)
throws CoreException
IDocumentProvider
saveDocument in interface IDocumentProvidermonitor - a progress monitor to report progress and request cancelationelement - the element, or nulldocument - the documentoverwrite - indicates whether overwrite should be performed
while saving the given element if necessary
CoreException - if document could not be stored to the given elementpublic void aboutToChange(java.lang.Object element)
AbstractDocumentProvider implementation of this
IDocumentProvider method does nothing. Subclasses may
reimplement.
aboutToChange in interface IDocumentProviderelement - the elementpublic void changed(java.lang.Object element)
AbstractDocumentProvider implementation of this
IDocumentProvider method does nothing. Subclasses may
reimplement.
changed in interface IDocumentProviderelement - the elementpublic void addElementStateListener(IElementStateListener listener)
IDocumentProvider
addElementStateListener in interface IDocumentProviderlistener - the listenerpublic void removeElementStateListener(IElementStateListener listener)
IDocumentProvider
removeElementStateListener in interface IDocumentProviderlistener - the listener
protected void fireElementDirtyStateChanged(java.lang.Object element,
boolean isDirty)
element - the elementisDirty - the new dirty stateIElementStateListener.elementDirtyStateChanged(Object, boolean)protected void fireElementContentAboutToBeReplaced(java.lang.Object element)
element - the elementIElementStateListener.elementContentAboutToBeReplaced(Object)protected void fireElementContentReplaced(java.lang.Object element)
element - the elementIElementStateListener.elementContentReplaced(Object)protected void fireElementDeleted(java.lang.Object element)
element - the elementIElementStateListener.elementDeleted(Object)
protected void fireElementMoved(java.lang.Object originalElement,
java.lang.Object movedElement)
originalElement - the element before the movemovedElement - the element after the moveIElementStateListener.elementMoved(Object, Object)public long getModificationStamp(java.lang.Object element)
IDocumentProvider
getModificationStamp in interface IDocumentProviderelement - the element
public long getSynchronizationStamp(java.lang.Object element)
IDocumentProvider
getSynchronizationStamp in interface IDocumentProviderelement - the element
public boolean isDeleted(java.lang.Object element)
IDocumentProvider
isDeleted in interface IDocumentProviderelement - the element
true if the element has been deletedpublic boolean isReadOnly(java.lang.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 IDocumentProviderExtensionelement - the element
true if the given element is read-only, false otherwisepublic boolean isModifiable(java.lang.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 IDocumentProviderExtensionelement - the element
true if the given element is modifiable, false otherwisepublic boolean isStateValidated(java.lang.Object element)
validateState has been called for the given element
since the element's state has potentially been invalidated.
isStateValidated in interface IDocumentProviderExtensionelement - the element
validateState has been called for the given element
protected void doValidateState(java.lang.Object element,
java.lang.Object computationContext)
throws CoreException
element - the elementcomputationContext - the context in which validation happens
CoreException - in case validation fails
public void validateState(java.lang.Object element,
java.lang.Object computationContext)
throws CoreException
IDocumentProviderExtensionisReadOnly and isModifiable. If the
given element is not connected to this document provider, the effect is undefined.
validateState in interface IDocumentProviderExtensionelement - the elementcomputationContext - the context in which the computation is performed, e.g., a SWT shell
CoreException - if validating fails
protected void doUpdateStateCache(java.lang.Object element)
throws CoreException
element - the element
CoreException - in case state cache updating fails
protected boolean invalidatesState(java.lang.Object element,
boolean wasReadOnly)
element - the elementwasReadOnly - the previous read-only state
true if the state of the given element must be invalidated
public final void updateStateCache(java.lang.Object element)
throws CoreException
IDocumentProviderExtensionisReadOnly and isModifiable. If the given element is not
connected to this document provider, the effect is undefined.
updateStateCache in interface IDocumentProviderExtensionelement - the element
CoreException - if validating failspublic void setCanSaveDocument(java.lang.Object element)
IDocumentProviderExtensioncanBeSaved(element) will return true
afterwards.
setCanSaveDocument in interface IDocumentProviderExtensionelement - the element
protected void fireElementStateValidationChanged(java.lang.Object element,
boolean isStateValidated)
element - the elementisStateValidated - the flag indicating whether state validation is doneIElementStateListenerExtension.elementStateValidationChanged(Object, boolean)protected void fireElementStateChanging(java.lang.Object element)
element - the elementIElementStateListenerExtension.elementStateChanging(Object)protected void fireElementStateChangeFailed(java.lang.Object element)
element - the elementIElementStateListenerExtension.elementStateChangeFailed(Object)public IStatus getStatus(java.lang.Object element)
IDocumentProviderExtension
getStatus in interface IDocumentProviderExtensionelement - the element
protected void doSynchronize(java.lang.Object element,
IProgressMonitor monitor)
throws CoreException
element - the elementmonitor - the progress monitor
CoreException - in the case that synchronization fails
public final void synchronize(java.lang.Object element)
throws CoreException
IDocumentProviderExtensiongetSynchronizationTimeStamp
and getModificationTimeStamp return the same value.
synchronize in interface IDocumentProviderExtensionelement - the element
CoreException - if the synchronization could not be performedpublic IProgressMonitor getProgressMonitor()
IDocumentProviderExtension2
getProgressMonitor in interface IDocumentProviderExtension2public void setProgressMonitor(IProgressMonitor progressMonitor)
IDocumentProviderExtension2
setProgressMonitor in interface IDocumentProviderExtension2progressMonitor - the progress monitorpublic boolean isSynchronized(java.lang.Object element)
IDocumentProviderExtension3
isSynchronized in interface IDocumentProviderExtension3element - the element
true if the information is in sync with the element, false otherwise
public boolean isNotSynchronizedException(java.lang.Object element,
CoreException ex)
IDocumentProviderExtension5
isNotSynchronizedException in interface IDocumentProviderExtension5element - the elementex - the core exception
true iff the given core exception is exactly the
exception which is thrown for a non-synchronized element
public IContentType getContentType(java.lang.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 IDocumentProviderExtension4element - the element
null
CoreException - if reading or accessing the underlying store
fails
|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.