Class AbstractDocumentProvider
- All Implemented Interfaces:
- IDocumentProvider,- IDocumentProviderExtension,- IDocumentProviderExtension2,- IDocumentProviderExtension3,- IDocumentProviderExtension4,- IDocumentProviderExtension5
- Direct Known Subclasses:
- StorageDocumentProvider
 Subclasses must implement createDocument,
 createAnnotationModel, and doSaveDocument.
 
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classOperation created by the document provider and to be executed by the providers runnable context.protected classCollection of all information managed for a connected element.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreates a new document provider.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaboutToChange(Object element) TheAbstractDocumentProviderimplementation of thisIDocumentProvidermethod does nothing.voidaddElementStateListener(IElementStateListener listener) Adds the given element state listener to this document provider.protected voidCalled on initial creation and when the dirty state of the element changes tofalse.booleancanSaveDocument(Object element) Returns whether the document provided for the given element differs from its original state which would required that it be saved.voidTheAbstractDocumentProviderimplementation of thisIDocumentProvidermethod does nothing.final voidConnects the given element to this document provider.protected voidThis hook method is called when this provider starts managing documents for elements.protected abstract IAnnotationModelcreateAnnotationModel(Object element) Creates an annotation model for the given element.protected abstract IDocumentcreateDocument(Object element) Creates the document for the given element.protected AbstractDocumentProvider.ElementInfocreateElementInfo(Object element) Creates a new element info object for the given element.final voiddisconnect(Object element) Disconnects the given element from this document provider.protected voidThis hook method is called when this provider stops managing documents for element.protected voiddisposeElementInfo(Object element, AbstractDocumentProvider.ElementInfo info) Disposes of the given element info object.protected voiddoResetDocument(Object element, IProgressMonitor monitor) Executes the actual work of reseting the given elements document.protected abstract voiddoSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) Performs the actual work of saving the given document provided for the given element.protected voiddoSynchronize(Object element, IProgressMonitor monitor) Performs the actual work of synchronizing the given element.protected voiddoUpdateStateCache(Object element) Hook method for updating the state of the given element.protected voiddoValidateState(Object element, Object computationContext) Hook method for validating the state of the given element.protected voidexecuteOperation(AbstractDocumentProvider.DocumentProviderOperation operation, IProgressMonitor monitor) Executes the given operation in the providers runnable context.protected voidInforms all registered element state listeners about an impending replace of the given element's content.protected voidfireElementContentReplaced(Object element) Informs all registered element state listeners about the just-completed replace of the given element's content.protected voidfireElementDeleted(Object element) Informs all registered element state listeners about the deletion of the given element.protected voidfireElementDirtyStateChanged(Object element, boolean isDirty) Informs all registered element state listeners about a change in the dirty state of the given element.protected voidfireElementMoved(Object originalElement, Object movedElement) Informs all registered element state listeners about a move.protected voidfireElementStateChangeFailed(Object element) Informs all registered element state listeners about the failed state change of the elementprotected voidfireElementStateChanging(Object element) Informs all registered element state listeners about the current state change of the elementprotected voidfireElementStateValidationChanged(Object element, boolean isStateValidated) Informs all registered element state listeners about a change in the state validation of the given element.getAnnotationModel(Object element) Returns the annotation model for the given element.Enumerates the elements connected via this document provider.getContentType(Object element) Returns the content type of for the given element ornullif none could be determined.getDocument(Object element) Returns the document for the given element.protected AbstractDocumentProvider.ElementInfogetElementInfo(Object element) Returns the element info object for the given element.longgetModificationStamp(Object element) Returns the modification stamp of the given element.protected abstract IRunnableContextgetOperationRunner(IProgressMonitor monitor) Returns the runnable context for this document provider.Returns this providers progress monitor.protected ISchedulingRulegetResetRule(Object element) Returns the scheduling rule required for executingreseton the given element.protected ISchedulingRulegetSaveRule(Object element) Returns the scheduling rule required for executingsaveon the given element.Returns the status of the given element.longgetSynchronizationStamp(Object element) Returns the time stamp of the last synchronization of the given element and its provided document.protected ISchedulingRulegetSynchronizeRule(Object element) Returns the scheduling rule required for executingsynchronizeon the given element.protected ISchedulingRulegetValidateStateRule(Object element) Returns the scheduling rule required for executingvalidateStateon the given element.protected booleaninvalidatesState(Object element, boolean wasReadOnly) Returns whether the state of the element must be invalidated given its previous read-only state.booleanReturns whether the given element has been deleted.booleanisModifiable(Object element) Returns whether the document provider thinks that the given element can persistently be modified.booleanisNotSynchronizedException(Object element, CoreException ex) Tells whether the given core exception is exactly the exception which is thrown for a non-synchronized element.booleanisReadOnly(Object element) Returns whether the document provider thinks that the given element is read-only.booleanisStateValidated(Object element) Returns whethervalidateStatehas been called for the given element since the element's state has potentially been invalidated.booleanisSynchronized(Object element) Returns whether the information provided for the given element is in sync with the element.booleanmustSaveDocument(Object element) Returns whether the document provided for the given element must be saved.voidRemoves the given element state listener from this document provider.protected voidCalled when the given element gets dirty.final voidresetDocument(Object element) Resets the given element's document to its last saved state.final voidsaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) Saves the given document provided for the given element.voidsetCanSaveDocument(Object element) Marks the document managed for the given element as savable.voidsetProgressMonitor(IProgressMonitor progressMonitor) Sets this providers progress monitor.final voidsynchronize(Object element) Synchronizes the document provided for the given element with the given element.final voidupdateStateCache(Object element) Updates the state cache for the given element.voidvalidateState(Object element, Object computationContext) Validates the state of the given element.
- 
Field Details- 
PR10806_UC5_ENABLEDprotected static final boolean PR10806_UC5_ENABLEDEnables a certain behavior. Indicates whether this provider should behave as described in use case 5 of http://bugs.eclipse.org/bugs/show_bug.cgi?id=10806. Current value:truesince 3.0- Since:
- 2.0
- See Also:
 
- 
PR14469_ENABLEDprotected static final boolean PR14469_ENABLEDEnables a certain behavior. Indicates whether this provider should behave as described in http://bugs.eclipse.org/bugs/show_bug.cgi?id=14469 Notes: This contradictsPR10806_UC5_ENABLED. Current value:falsesince 3.0- Since:
- 2.0
- See Also:
 
- 
STATUS_OKDeprecated.As of 3.6, replaced byStatus.OK_STATUSConstant for representing the OK status. This is considered a value object.- Since:
- 2.0
 
- 
STATUS_ERRORConstant for representing the error status. This is considered a value object.- Since:
- 2.0
 
 
- 
- 
Constructor Details- 
AbstractDocumentProviderprotected AbstractDocumentProvider()Creates a new document provider.
 
- 
- 
Method Details- 
createDocumentCreates the document for the given element.Subclasses must implement this method. - Parameters:
- element- the element
- Returns:
- the document
- Throws:
- CoreException- if the document could not be created
 
- 
createAnnotationModelCreates an annotation model for the given element.Subclasses must implement this method. - Parameters:
- element- the element
- Returns:
- the annotation model or nullif none
- Throws:
- CoreException- if the annotation model could not be created
 
- 
doSaveDocumentprotected abstract void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException Performs the actual work of saving the given document provided for the given element.Subclasses must implement this method. - Parameters:
- monitor- a progress monitor to report progress and request cancelation
- element- the element
- document- the document
- overwrite- indicates whether an overwrite should happen if necessary
- Throws:
- CoreException- if document could not be stored to the given element
 
- 
getOperationRunnerReturns the runnable context for this document provider.- Parameters:
- monitor- a progress monitor to track the operation
- Returns:
- the runnable context for this document provider
- Since:
- 3.0
 
- 
getSynchronizeRuleReturns the scheduling rule required for executingsynchronizeon the given element. This default implementation returnsnull.- Parameters:
- element- the element
- Returns:
- the scheduling rule for synchronize
- Since:
- 3.0
 
- 
getValidateStateRuleReturns the scheduling rule required for executingvalidateStateon the given element. This default implementation returnsnull.- Parameters:
- element- the element
- Returns:
- the scheduling rule for validateState
- Since:
- 3.0
 
- 
getSaveRuleReturns the scheduling rule required for executingsaveon the given element. This default implementation returnsnull.- Parameters:
- element- the element
- Returns:
- the scheduling rule for save
- Since:
- 3.0
 
- 
getResetRuleReturns the scheduling rule required for executingreseton the given element. This default implementation returnsnull.- Parameters:
- element- the element
- Returns:
- the scheduling rule for reset
- Since:
- 3.0
 
- 
getElementInfoReturns the element info object for the given element.- Parameters:
- element- the element
- Returns:
- the element info object, or nullif none
 
- 
createElementInfoprotected AbstractDocumentProvider.ElementInfo createElementInfo(Object element) throws CoreException Creates a new element info object for the given element.This method is called from connectwhen an element info needs to be created. TheAbstractDocumentProviderimplementation of this method returns a new element info object whose document and annotation model are the values ofcreateDocument(element)andcreateAnnotationModel(element), respectively. Subclasses may override.- Parameters:
- element- the element
- Returns:
- a new element info object
- Throws:
- CoreException- if the document or annotation model could not be created
 
- 
disposeElementInfoDisposes of the given element info object.This method is called when an element info is disposed. The AbstractDocumentProviderimplementation of this method does nothing. Subclasses may reimplement.- Parameters:
- element- the element
- info- the element info object
 
- 
addUnchangedElementListenersprotected void addUnchangedElementListeners(Object element, AbstractDocumentProvider.ElementInfo info) Called on initial creation and when the dirty state of the element changes tofalse. Adds all listeners which must be active as long as the element is not dirty. This method is called beforefireElementDirtyStateChangedorfireElementContentReplacedis called. Subclasses may extend.- Parameters:
- element- the element
- info- the element info object
 
- 
removeUnchangedElementListenersprotected void removeUnchangedElementListeners(Object element, AbstractDocumentProvider.ElementInfo info) Called when the given element gets dirty. Removes all listeners which must be active only when the element is not dirty. This method is called beforefireElementDirtyStateChangedorfireElementContentReplacedis called. Subclasses may extend.- Parameters:
- element- the element
- info- the element info object
 
- 
getConnectedElementsEnumerates the elements connected via this document provider.- Returns:
- the list of elements
 
- 
connectDescription copied from interface:IDocumentProviderConnects the given element to this document provider. This tells the provider that caller of this method is interested to work with the document provided for the given domain model element. By counting the invocations of this method anddisconnect(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.- Specified by:
- connectin interface- IDocumentProvider
- Parameters:
- element- the element
- Throws:
- CoreException- if the textual representation or the annotation model of the element could not be created
 
- 
connectedprotected void connected()This hook method is called when this provider starts managing documents for elements. I.e. it is called when the first element gets connected to this provider. Subclasses may extend.- Since:
- 2.0
 
- 
disconnectDescription copied from interface:IDocumentProviderDisconnects the given element from this document provider. This tells the provider that the caller of this method is no longer interested in working with the document provided for the given domain model element. By counting the invocations ofconnect(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.- Specified by:
- disconnectin interface- IDocumentProvider
- Parameters:
- element- the element
 
- 
disconnectedprotected void disconnected()This hook method is called when this provider stops managing documents for element. I.e. it is called when the last element gets disconnected from this provider. Subclasses may extend.- Since:
- 2.0
 
- 
getDocumentDescription copied from interface:IDocumentProviderReturns the document for the given element. Usually the document contains a textual presentation of the content of the element, or is the element itself.- Specified by:
- getDocumentin interface- IDocumentProvider
- Parameters:
- element- the element, or- null
- Returns:
- the document, or nullif none
 
- 
mustSaveDocumentDescription copied from interface:IDocumentProviderReturns whether the document provided for the given element must be saved.- Specified by:
- mustSaveDocumentin interface- IDocumentProvider
- Parameters:
- element- the element, or- null
- Returns:
- trueif the document must be saved, and- falseotherwise (including the element is- null)
 
- 
getAnnotationModelDescription copied from interface:IDocumentProviderReturns the annotation model for the given element.- Specified by:
- getAnnotationModelin interface- IDocumentProvider
- Parameters:
- element- the element, or- null
- Returns:
- the annotation model, or nullif none
 
- 
canSaveDocumentDescription copied from interface:IDocumentProviderReturns whether the document provided for the given element differs from its original state which would required that it be saved.- Specified by:
- canSaveDocumentin interface- IDocumentProvider
- Parameters:
- element- the element, or- null
- Returns:
- trueif the document can be saved, and- falseotherwise (including the element is- null)
 
- 
doResetDocumentExecutes the actual work of reseting the given elements document.- Parameters:
- element- the element
- monitor- the progress monitor
- Throws:
- CoreException- if resetting fails
- Since:
- 3.0
 
- 
executeOperationprotected void executeOperation(AbstractDocumentProvider.DocumentProviderOperation operation, IProgressMonitor monitor) throws CoreException Executes the given operation in the providers runnable context.- Parameters:
- operation- the operation to be executes
- monitor- the progress monitor
- Throws:
- CoreException- the operation's core exception
- Since:
- 3.0
 
- 
resetDocumentDescription copied from interface:IDocumentProviderResets the given element's document to its last saved state. Element state listeners are notified both before (elementContentAboutToBeReplaced) and after (elementContentReplaced) the content is changed.- Specified by:
- resetDocumentin interface- IDocumentProvider
- Parameters:
- element- the element, or- null
- Throws:
- CoreException- if document could not be reset for the given element
 
- 
saveDocumentpublic final void saveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException Description copied from interface:IDocumentProviderSaves the given document provided for the given element.- Specified by:
- saveDocumentin interface- IDocumentProvider
- Parameters:
- monitor- a progress monitor to report progress and request cancelation
- element- the element, or- null
- document- the document
- overwrite- indicates whether overwrite should be performed while saving the given element if necessary
- Throws:
- CoreException- if document could not be stored to the given element
 
- 
aboutToChangeTheAbstractDocumentProviderimplementation of thisIDocumentProvidermethod does nothing. Subclasses may reimplement.- Specified by:
- aboutToChangein interface- IDocumentProvider
- Parameters:
- element- the element
 
- 
changedTheAbstractDocumentProviderimplementation of thisIDocumentProvidermethod does nothing. Subclasses may reimplement.- Specified by:
- changedin interface- IDocumentProvider
- Parameters:
- element- the element
 
- 
addElementStateListenerDescription copied from interface:IDocumentProviderAdds the given element state listener to this document provider. Has no effect if an identical listener is already registered.- Specified by:
- addElementStateListenerin interface- IDocumentProvider
- Parameters:
- listener- the listener
 
- 
removeElementStateListenerDescription copied from interface:IDocumentProviderRemoves the given element state listener from this document provider. Has no effect if an identical listener is not registered.- Specified by:
- removeElementStateListenerin interface- IDocumentProvider
- Parameters:
- listener- the listener
 
- 
fireElementDirtyStateChangedInforms all registered element state listeners about a change in the dirty state of the given element.- Parameters:
- element- the element
- isDirty- the new dirty state
- See Also:
 
- 
fireElementContentAboutToBeReplacedInforms all registered element state listeners about an impending replace of the given element's content.- Parameters:
- element- the element
- See Also:
 
- 
fireElementContentReplacedInforms all registered element state listeners about the just-completed replace of the given element's content.- Parameters:
- element- the element
- See Also:
 
- 
fireElementDeletedInforms all registered element state listeners about the deletion of the given element.- Parameters:
- element- the element
- See Also:
 
- 
fireElementMovedInforms all registered element state listeners about a move.- Parameters:
- originalElement- the element before the move
- movedElement- the element after the move
- See Also:
 
- 
getModificationStampDescription copied from interface:IDocumentProviderReturns the modification stamp of the given element.- Specified by:
- getModificationStampin interface- IDocumentProvider
- Parameters:
- element- the element
- Returns:
- the modification stamp of the given element
 
- 
getSynchronizationStampDescription copied from interface:IDocumentProviderReturns the time stamp of the last synchronization of the given element and its provided document.- Specified by:
- getSynchronizationStampin interface- IDocumentProvider
- Parameters:
- element- the element
- Returns:
- the synchronization stamp of the given element
 
- 
isDeletedDescription copied from interface:IDocumentProviderReturns whether the given element has been deleted.- Specified by:
- isDeletedin interface- IDocumentProvider
- Parameters:
- element- the element
- Returns:
- trueif the element has been deleted
 
- 
isReadOnlyDescription copied from interface:IDocumentProviderExtensionReturns whether the document provider thinks that the given element is read-only. If this method returnstrue,saveDocumentcould 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.- Specified by:
- isReadOnlyin interface- IDocumentProviderExtension
- Parameters:
- element- the element
- Returns:
- trueif the given element is read-only,- falseotherwise
 
- 
isModifiableDescription copied from interface:IDocumentProviderExtensionReturns whether the document provider thinks that the given element can persistently be modified. This is orthogonal toisReadOnlyas 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.- Specified by:
- isModifiablein interface- IDocumentProviderExtension
- Parameters:
- element- the element
- Returns:
- trueif the given element is modifiable,- falseotherwise
 
- 
isStateValidatedReturns whethervalidateStatehas been called for the given element since the element's state has potentially been invalidated.- Specified by:
- isStateValidatedin interface- IDocumentProviderExtension
- Parameters:
- element- the element
- Returns:
- whether validateStatehas been called for the given element
- Since:
- 2.0
 
- 
doValidateStateHook method for validating the state of the given element. Must not take care of cache updating etc. Default implementation is empty.- Parameters:
- element- the element
- computationContext- the context in which validation happens
- Throws:
- CoreException- in case validation fails
- Since:
- 2.0
 
- 
validateStateDescription copied from interface:IDocumentProviderExtensionValidates the state of the given element. This method may change the "real" state of the element. If using, it also updates the internal caches, so that this method may also change the results returned byisReadOnlyandisModifiable. If the given element is not connected to this document provider, the effect is undefined.- Specified by:
- validateStatein interface- IDocumentProviderExtension
- Parameters:
- element- the element
- computationContext- the context in which the computation is performed, e.g., a SWT shell
- Throws:
- CoreException- if validating fails
 
- 
doUpdateStateCacheHook method for updating the state of the given element. Default implementation is empty.- Parameters:
- element- the element
- Throws:
- CoreException- in case state cache updating fails
- Since:
- 2.0
 
- 
invalidatesStateReturns whether the state of the element must be invalidated given its previous read-only state.- Parameters:
- element- the element
- wasReadOnly- the previous read-only state
- Returns:
- trueif the state of the given element must be invalidated
- Since:
- 2.0
 
- 
updateStateCacheDescription copied from interface:IDocumentProviderExtensionUpdates the state cache for the given element. This method may change the result returned byisReadOnlyandisModifiable. If the given element is not connected to this document provider, the effect is undefined.- Specified by:
- updateStateCachein interface- IDocumentProviderExtension
- Parameters:
- element- the element
- Throws:
- CoreException- if validating fails
 
- 
setCanSaveDocumentDescription copied from interface:IDocumentProviderExtensionMarks the document managed for the given element as savable. I.e.canBeSaved(element)will returntrueafterwards.- Specified by:
- setCanSaveDocumentin interface- IDocumentProviderExtension
- Parameters:
- element- the element
 
- 
fireElementStateValidationChangedInforms all registered element state listeners about a change in the state validation of the given element.- Parameters:
- element- the element
- isStateValidated- the flag indicating whether state validation is done
- Since:
- 2.0
- See Also:
 
- 
fireElementStateChangingInforms all registered element state listeners about the current state change of the element- Parameters:
- element- the element
- Since:
- 2.0
- See Also:
 
- 
fireElementStateChangeFailedInforms all registered element state listeners about the failed state change of the element- Parameters:
- element- the element
- Since:
- 2.0
- See Also:
 
- 
getStatusDescription copied from interface:IDocumentProviderExtensionReturns the status of the given element.- Specified by:
- getStatusin interface- IDocumentProviderExtension
- Parameters:
- element- the element
- Returns:
- the status of the given element
 
- 
doSynchronizePerforms the actual work of synchronizing the given element.- Parameters:
- element- the element
- monitor- the progress monitor
- Throws:
- CoreException- in the case that synchronization fails
- Since:
- 3.0
 
- 
synchronizeDescription copied from interface:IDocumentProviderExtensionSynchronizes the document provided for the given element with the given element. After that callgetSynchronizationTimeStampandgetModificationTimeStampreturn the same value.- Specified by:
- synchronizein interface- IDocumentProviderExtension
- Parameters:
- element- the element
- Throws:
- CoreException- if the synchronization could not be performed
 
- 
getProgressMonitorDescription copied from interface:IDocumentProviderExtension2Returns this providers progress monitor.- Specified by:
- getProgressMonitorin interface- IDocumentProviderExtension2
- Returns:
- IProgressMonitor
 
- 
setProgressMonitorDescription copied from interface:IDocumentProviderExtension2Sets this providers progress monitor.- Specified by:
- setProgressMonitorin interface- IDocumentProviderExtension2
- Parameters:
- progressMonitor- the progress monitor
 
- 
isSynchronizedDescription copied from interface:IDocumentProviderExtension3Returns whether the information provided for the given element is in sync with the element.- Specified by:
- isSynchronizedin interface- IDocumentProviderExtension3
- Parameters:
- element- the element
- Returns:
- trueif the information is in sync with the element,- falseotherwise
 
- 
isNotSynchronizedExceptionDescription copied from interface:IDocumentProviderExtension5Tells whether the given core exception is exactly the exception which is thrown for a non-synchronized element.- Specified by:
- isNotSynchronizedExceptionin interface- IDocumentProviderExtension5
- Parameters:
- element- the element
- ex- the core exception
- Returns:
- trueiff the given core exception is exactly the exception which is thrown for a non-synchronized element
 
- 
getContentTypeDescription copied from interface:IDocumentProviderExtension4Returns the content type of for the given element ornullif none could be determined. If the element's document can be saved, the returned content type is determined by the document's current content.- Specified by:
- getContentTypein interface- IDocumentProviderExtension4
- Parameters:
- element- the element
- Returns:
- the content type or null
- Throws:
- CoreException- if reading or accessing the underlying store fails
 
 
- 
Status.OK_STATUS