Class ProjectionDocument
- All Implemented Interfaces:
IDocument
,IDocumentExtension
,IDocumentExtension2
,IDocumentExtension3
,IDocumentExtension4
,IRepairableDocument
,IRepairableDocumentExtension
- Direct Known Subclasses:
ChildDocument
ProjectionDocument
represents a projection of its master
document. The contents of a projection document is a sequence of fragments of
the master document, i.e. the projection document can be thought as being
constructed from the master document by not copying the whole master document
but omitting several ranges of the master document.
The projection document indirectly utilizes its master document as
ITextStore
by means of a ProjectionTextStore
.
The content of a projection document can be changed in two ways. Either by a
text replace applied to the master document or the projection document. Or by
changing the projection between the master document and the projection
document. For the latter the two methods addMasterDocumentRange
and removeMasterDocumentRange
are provided. For any
manipulation, the projection document sends out a
ProjectionDocumentEvent
describing
the change.
Clients are not supposed to directly instantiate this class. In order to
obtain a projection document, a
ProjectionDocumentManager
should be
used. This class is not intended to be subclassed outside of its origin
package.
- Since:
- 3.0
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jface.text.IDocumentExtension
IDocumentExtension.IReplace
-
Field Summary
Fields inherited from interface org.eclipse.jface.text.IDocument
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE
Fields inherited from interface org.eclipse.jface.text.IDocumentExtension3
DEFAULT_PARTITIONING
Fields inherited from interface org.eclipse.jface.text.IDocumentExtension4
UNKNOWN_MODIFICATION_STAMP
-
Constructor Summary
ConstructorDescriptionProjectionDocument
(IDocument masterDocument) Creates a projection document for the given master document. -
Method Summary
Modifier and TypeMethodDescriptionprotected final boolean
adaptProjectionToMasterChange
(DocumentEvent masterEvent) Ensures that when the master event affects this projection document, that the whole region described by the event is part of this projection document.void
addMasterDocumentRange
(int offsetInMaster, int lengthInMaster) Ensures that the given range of the master document is part of this projection document.final IRegion[]
computeProjectedMasterRegions
(int offsetInMaster, int lengthInMaster) Returns the sequence of all master document regions with are contained in the given master document range and which are part of this projection document.final IRegion[]
computeUnprojectedMasterRegions
(int offsetInMaster, int lengthInMaster) Returns the sequence of all master document regions which are contained in the given master document range and which are not yet part of this projection document.void
dispose()
Disposes this projection document.protected void
Fires the given document event to all registers document listeners informing them about the forthcoming document manipulation.protected void
fireDocumentChanged
(DocumentEvent event) Ignores the given event and sends the semantically equal slave document event instead.Returns this document's default line delimiter.Returns the projection mapping used by this document.protected final Position[]
Returns the fragments of the master documents.Returns the master document of this projection document.Deprecated.protected final Position[]
Returns the segments of this projection document.protected boolean
Returns whether this projection is being updated.void
masterDocumentAboutToBeChanged
(DocumentEvent masterEvent) When called, this projection document is informed about a forthcoming change of its master document.void
masterDocumentChanged
(DocumentEvent masterEvent) When called, this projection document is informed about a change of its master document.void
Callback for document listeners to be used insidedocumentChanged
to register a post notification replace operation on the document notifying them.void
removeMasterDocumentRange
(int offsetInMaster, int lengthInMaster) Ensures that the given range of the master document is not part of this projection document.void
Substitutes the given text for the specified document range.void
replaceMasterDocumentRanges
(int offsetInMaster, int lengthInMaster) Replaces all master document ranges with the given master document range.void
Replaces the content of the document with the given text.void
setAutoExpandMode
(boolean autoExpandMode) Sets the auto expand mode for this document.protected void
Updates document partitioning and document positions according to the specification given by the document event.Methods inherited from class org.eclipse.jface.text.AbstractDocument
acceptPostNotificationReplaces, addDocumentListener, addDocumentPartitioningListener, addDocumentRewriteSessionListener, addPosition, addPosition, addPositionCategory, addPositionUpdater, addPrenotifiedDocumentListener, checkStateOfPartitioner, completeInitialization, computeIndexInCategory, computeIndexInPositionList, computeIndexInPositionList, computeNumberOfLines, computePartitioning, computePartitioning, containsPosition, containsPositionCategory, doFireDocumentChanged, doFireDocumentChanged, doFireDocumentChanged2, fireDocumentPartitioningChanged, fireDocumentPartitioningChanged, fireDocumentPartitioningChanged, fireRewriteSessionChanged, get, get, getActiveRewriteSession, getChar, getContentType, getContentType, getDocumentListeners, getDocumentManagedPositions, getDocumentPartitioner, getDocumentPartitioner, getDocumentPartitioningListeners, getLegalContentTypes, getLegalContentTypes, getLegalLineDelimiters, getLength, getLineDelimiter, getLineInformation, getLineInformationOfOffset, getLineLength, getLineOffset, getLineOfOffset, getModificationStamp, getNumberOfLines, getNumberOfLines, getPartition, getPartition, getPartitionings, getPositionCategories, getPositions, getPositions, getPositionUpdaters, getStore, getTracker, ignorePostNotificationReplaces, insertPositionUpdater, isLineInformationRepairNeeded, removeDocumentListener, removeDocumentPartitioningListener, removeDocumentRewriteSessionListener, removePosition, removePosition, removePositionCategory, removePositionUpdater, removePrenotifiedDocumentListener, repairLineInformation, replace, resumeListenerNotification, resumePostNotificationProcessing, search, set, setDocumentPartitioner, setDocumentPartitioner, setInitialLineDelimiter, setLineTracker, setTextStore, startRewriteSession, startRewriteSessionOnPartitioners, startSequentialRewrite, stopListenerNotification, stopPostNotificationProcessing, stopRewriteSession, stopRewriteSessionOnPartitioners, stopSequentialRewrite, updatePositions
-
Constructor Details
-
ProjectionDocument
Creates a projection document for the given master document.- Parameters:
masterDocument
- the master document
-
-
Method Details
-
dispose
public void dispose()Disposes this projection document. -
getFragments
Returns the fragments of the master documents.- Returns:
- the fragment of the master document
-
getSegments
Returns the segments of this projection document.- Returns:
- the segments of this projection document
-
getProjectionMapping
Deprecated.As of 3.4, replaced bygetDocumentInformationMapping()
Returns the projection mapping used by this document.- Returns:
- the projection mapping used by this document
-
getDocumentInformationMapping
Returns the projection mapping used by this document.- Returns:
- the projection mapping used by this document
- Since:
- 3.4
-
getMasterDocument
Returns the master document of this projection document.- Returns:
- the master document of this projection document
-
getDefaultLineDelimiter
Description copied from interface:IDocumentExtension4
Returns this document's default line delimiter.This default line delimiter should be used by clients who want unique delimiters (e.g. 'CR's) in the document.
- Specified by:
getDefaultLineDelimiter
in interfaceIDocumentExtension4
- Overrides:
getDefaultLineDelimiter
in classAbstractDocument
- Returns:
- the default line delimiter or
null
if none
-
computeUnprojectedMasterRegions
public final IRegion[] computeUnprojectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException Returns the sequence of all master document regions which are contained in the given master document range and which are not yet part of this projection document.- Parameters:
offsetInMaster
- the range offset in the master documentlengthInMaster
- the range length in the master document- Returns:
- the sequence of regions which are not yet part of the projection document
- Throws:
BadLocationException
- in case the given range is invalid in the master document
-
addMasterDocumentRange
public void addMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException Ensures that the given range of the master document is part of this projection document.- Parameters:
offsetInMaster
- the offset of the master document rangelengthInMaster
- the length of the master document range- Throws:
BadLocationException
- in case the master event is not valid
-
removeMasterDocumentRange
public void removeMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException Ensures that the given range of the master document is not part of this projection document.- Parameters:
offsetInMaster
- the offset of the master document rangelengthInMaster
- the length of the master document range- Throws:
BadLocationException
- in case the master event is not valid
-
computeProjectedMasterRegions
public final IRegion[] computeProjectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException Returns the sequence of all master document regions with are contained in the given master document range and which are part of this projection document. May returnnull
if no such regions exist.- Parameters:
offsetInMaster
- the range offset in the master documentlengthInMaster
- the range length in the master document- Returns:
- the sequence of regions which are part of the projection document or
null
- Throws:
BadLocationException
- in case the given range is invalid in the master document
-
isUpdating
protected boolean isUpdating()Returns whether this projection is being updated.- Returns:
true
if the document is updating
-
replace
Description copied from interface:IDocument
Substitutes the given text for the specified document range. Sends aDocumentEvent
to all registeredIDocumentListener
.- Specified by:
replace
in interfaceIDocument
- Overrides:
replace
in classAbstractDocument
- Parameters:
offset
- the document offsetlength
- the length of the specified rangetext
- the substitution text- Throws:
BadLocationException
- if the offset is invalid in this document- See Also:
-
set
Description copied from interface:IDocument
Replaces the content of the document with the given text. Sends aDocumentEvent
to all registeredIDocumentListener
. This method is a convenience method forreplace(0, getLength(), text)
.- Specified by:
set
in interfaceIDocument
- Overrides:
set
in classAbstractDocument
- Parameters:
text
- the new content of the document- See Also:
-
adaptProjectionToMasterChange
protected final boolean adaptProjectionToMasterChange(DocumentEvent masterEvent) throws BadLocationException Ensures that when the master event affects this projection document, that the whole region described by the event is part of this projection document.- Parameters:
masterEvent
- the master document event- Returns:
true
if masterEvent affects this projection document- Throws:
BadLocationException
- in case the master event is not valid
-
masterDocumentAboutToBeChanged
When called, this projection document is informed about a forthcoming change of its master document. This projection document checks whether the master document change affects it and if so informs all document listeners.- Parameters:
masterEvent
- the master document event
-
masterDocumentChanged
When called, this projection document is informed about a change of its master document. If this projection document is affected it informs all of its document listeners.- Parameters:
masterEvent
- the master document event
-
fireDocumentAboutToBeChanged
Description copied from class:AbstractDocument
Fires the given document event to all registers document listeners informing them about the forthcoming document manipulation. Uses a robust iterator.- Overrides:
fireDocumentAboutToBeChanged
in classAbstractDocument
- Parameters:
event
- the event to be sent out
-
fireDocumentChanged
Ignores the given event and sends the semantically equal slave document event instead.- Overrides:
fireDocumentChanged
in classAbstractDocument
- Parameters:
event
- the event to be ignored
-
updateDocumentStructures
Description copied from class:AbstractDocument
Updates document partitioning and document positions according to the specification given by the document event.- Overrides:
updateDocumentStructures
in classAbstractDocument
- Parameters:
event
- the document event describing the change to which structures must be adapted
-
registerPostNotificationReplace
public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) Description copied from interface:IDocumentExtension
Callback for document listeners to be used insidedocumentChanged
to register a post notification replace operation on the document notifying them.- Specified by:
registerPostNotificationReplace
in interfaceIDocumentExtension
- Overrides:
registerPostNotificationReplace
in classAbstractDocument
- Parameters:
owner
- the owner of the replace operationreplace
- the replace operation to be executed
-
setAutoExpandMode
public void setAutoExpandMode(boolean autoExpandMode) Sets the auto expand mode for this document.- Parameters:
autoExpandMode
-true
if auto-expanding
-
replaceMasterDocumentRanges
public void replaceMasterDocumentRanges(int offsetInMaster, int lengthInMaster) throws BadLocationException Replaces all master document ranges with the given master document range.- Parameters:
offsetInMaster
- the offset in the master documentlengthInMaster
- the length in the master document- Throws:
BadLocationException
- if the given range of the master document is not valid
-
getDocumentInformationMapping()