|
Eclipse Platform 2.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.eclipse.ui.texteditor.AbstractDocumentProvider
An abstract implementation of a shareable document provider.
Subclasses must implement createDocument,
createAnnotationModel, and doSaveDocument.
| Nested Class Summary | |
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
Constant for representing the ok status. |
| Constructor Summary | |
protected |
AbstractDocumentProvider()
Creates a new document provider. |
| Method Summary | |
void |
aboutToChange(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(Object element,
AbstractDocumentProvider.ElementInfo info)
Called on initial creation and when the dirty state of the element changes to false. |
boolean |
canSaveDocument(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(Object element)
The AbstractDocumentProvider implementation of this
IDocumentProvider method does nothing. |
void |
connect(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(Object element)
Creates an annotation model for the given element. |
protected abstract 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. |
void |
disconnect(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(Object element,
AbstractDocumentProvider.ElementInfo info)
Disposes of the given element info object. |
protected abstract 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. |
protected void |
doValidateState(Object element,
Object computationContext)
Hook method for validating the state of the given element. |
protected void |
fireElementContentAboutToBeReplaced(Object element)
Informs all registered element state listeners about an impending replace of the given element's content. |
protected void |
fireElementContentReplaced(Object element)
Informs all registered element state listeners about the just-completed replace of the given element's content. |
protected void |
fireElementDeleted(Object element)
Informs all registered element state listeners about the deletion of the given element. |
protected void |
fireElementDirtyStateChanged(Object element,
boolean isDirty)
Informs all registered element state listeners about a change in the dirty state of the given element. |
protected void |
fireElementMoved(Object originalElement,
Object movedElement)
Informs all registered element state listeners about a move. |
protected void |
fireElementStateChangeFailed(Object element)
Informs all registered element state listeners about the failed state change of the element |
protected void |
fireElementStateChanging(Object element)
Informs all registered element state listeners about the current state change of the element |
protected void |
fireElementStateValidationChanged(Object element,
boolean isStateValidated)
Informs all registered element state listeners about a change in the state validation of the given element. |
IAnnotationModel |
getAnnotationModel(Object element)
Returns the annotation model for the given element. |
protected Iterator |
getConnectedElements()
Enumerates the elements connected via this document provider. |
IDocument |
getDocument(Object element)
Returns the document for the given element. |
protected AbstractDocumentProvider.ElementInfo |
getElementInfo(Object element)
Returns the element info object for the given element. |
long |
getModificationStamp(Object element)
Returns the modification stamp of the given element. |
IProgressMonitor |
getProgressMonitor()
Returns this providers progress monitor. |
IStatus |
getStatus(Object element)
Returns the status of the given element. |
long |
getSynchronizationStamp(Object element)
Returns the time stamp of the last synchronization of the given element and it's provided document. |
protected boolean |
invalidatesState(Object element,
boolean wasReadOnly)
Returns whether the state of the element must be invalidated given its previous read-only state. |
boolean |
isDeleted(Object element)
Returns whether the given element has been deleted. |
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. |
boolean |
isStateValidated(Object element)
Returns whether validateState has been called for the given element
since the element's state has potentially been invalidated. |
boolean |
mustSaveDocument(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(Object element,
AbstractDocumentProvider.ElementInfo info)
Called when the given element gets dirty. |
void |
resetDocument(Object element)
Resets the given element's document to its last saved state. |
void |
saveDocument(IProgressMonitor monitor,
Object element,
IDocument document,
boolean overwrite)
Saves the given document provided for the given element. |
void |
setCanSaveDocument(Object element)
Marks the document managed for the given element as saveable. |
void |
setProgressMonitor(IProgressMonitor progressMonitor)
Sets this providers progress monitor. |
void |
synchronize(Object element)
Synchronizes the document provided for the given element with the given element. |
void |
updateStateCache(Object element)
Updates the state cache for the given element. |
void |
validateState(Object element,
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
false
protected static final boolean PR14469_ENABLED
PR10806_UC5_ENABLED.
Current value: true
protected static final IStatus STATUS_OK
protected static final IStatus STATUS_ERROR
| Constructor Detail |
protected AbstractDocumentProvider()
| Method Detail |
protected abstract IDocument createDocument(Object element)
throws CoreException
Subclasses must implement this method.
element - the element
CoreException - if the document could not be created
protected abstract IAnnotationModel createAnnotationModel(Object element)
throws CoreException
Subclasses must implement this method.
element - the element
CoreException - if the annotation model could not be created
protected abstract void doSaveDocument(IProgressMonitor monitor,
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 AbstractDocumentProvider.ElementInfo getElementInfo(Object element)
element - the element
null if none
protected AbstractDocumentProvider.ElementInfo createElementInfo(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(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(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(Object element,
AbstractDocumentProvider.ElementInfo info)
fireElementDirtyStateChanged
or fireElementContentReplaced is called.
Subclasses may extend.
element - the elementinfo - the element info objectprotected Iterator getConnectedElements()
Object)
public final void connect(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(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(Object element)
IDocumentProvider
getDocument in interface IDocumentProviderelement - the element, or null
null if nonepublic boolean mustSaveDocument(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(Object element)
IDocumentProvider
getAnnotationModel in interface IDocumentProviderelement - the element, or null
null if nonepublic boolean canSaveDocument(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)
public void resetDocument(Object element)
throws CoreException
IDocumentProviderelementContentAboutToBeReplaced)
and after (elementContentReplaced) the content is changed.
resetDocument in interface IDocumentProviderelement - the element, or null
CoreException
public void saveDocument(IProgressMonitor monitor,
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(Object element)
AbstractDocumentProvider implementation of this
IDocumentProvider method does nothing. Subclasses may
reimplement.
aboutToChange in interface IDocumentProviderelement - the elementpublic void changed(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(Object element,
boolean isDirty)
element - the elementisDirty - the new dirty stateIElementStateListener.elementDirtyStateChanged(Object, boolean)protected void fireElementContentAboutToBeReplaced(Object element)
element - the elementIElementStateListener.elementContentAboutToBeReplaced(Object)protected void fireElementContentReplaced(Object element)
element - the elementIElementStateListener.elementContentReplaced(Object)protected void fireElementDeleted(Object element)
element - the elementIElementStateListener.elementDeleted(Object)
protected void fireElementMoved(Object originalElement,
Object movedElement)
originalElement - the element before the movemovedElement - the element after the moveIElementStateListener.elementMoved(Object, Object)public long getModificationStamp(Object element)
IDocumentProvider
getModificationStamp in interface IDocumentProviderelement - the element
public long getSynchronizationStamp(Object element)
IDocumentProvider
getSynchronizationStamp in interface IDocumentProviderelement - the element
public boolean isDeleted(Object element)
IDocumentProvider
isDeleted in interface IDocumentProviderelement - the element
true if the element has been deletedpublic 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 IDocumentProviderExtensionelement - the element
true if the given element is read-only, false otherwisepublic 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 IDocumentProviderExtensionelement - the element
true if the given element is modifiable, false otherwisepublic boolean isStateValidated(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(Object element,
Object computationContext)
throws CoreException
element - the elementcomputationContext - the context in which validation happens
ValidateStateException - in case validation succeeds, but the state cannot be changed
CoreException - in case validation fails
public final void validateState(Object element,
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(Object element)
throws CoreException
element - the element
CoreException - in case state cache updating fails
protected boolean invalidatesState(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(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(Object element)
IDocumentProviderExtensioncanBeSaved(element) will return true
afterwards.
setCanSaveDocument in interface IDocumentProviderExtensionelement - the element
protected void fireElementStateValidationChanged(Object element,
boolean isStateValidated)
element - the elementisStateValidated - IElementStateListenerExtension.elementStateValidationChanged(Object, boolean)protected void fireElementStateChanging(Object element)
element - the elementIElementStateListenerExtension.elementStateChanging(Object)protected void fireElementStateChangeFailed(Object element)
element - the elementIElementStateListenerExtension.elementStateChangeFailed(Object)public IStatus getStatus(Object element)
IDocumentProviderExtension
getStatus in interface IDocumentProviderExtensionelement - the element
public void synchronize(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 -
|
Eclipse Platform 2.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||