public class ProjectionDocument extends AbstractDocument
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.
IDocumentExtension.IReplace
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE
DEFAULT_PARTITIONING
UNKNOWN_MODIFICATION_STAMP
Constructor and Description |
---|
ProjectionDocument(IDocument masterDocument)
Creates a projection document for the given master document.
|
Modifier and Type | Method and Description |
---|---|
protected 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.
|
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.
|
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 |
fireDocumentAboutToBeChanged(DocumentEvent event)
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.
|
String |
getDefaultLineDelimiter()
Returns this document's default line delimiter.
|
IDocumentInformationMapping |
getDocumentInformationMapping()
Returns the projection mapping used by this document.
|
protected Position[] |
getFragments()
Returns the fragments of the master documents.
|
IDocument |
getMasterDocument()
Returns the master document of this projection document.
|
ProjectionMapping |
getProjectionMapping()
Deprecated.
As of 3.4, replaced by
getDocumentInformationMapping() |
protected Position[] |
getSegments()
Returns the segments of this projection document.
|
protected boolean |
isUpdating()
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 |
registerPostNotificationReplace(IDocumentListener owner,
IDocumentExtension.IReplace replace)
Callback for document listeners to be used inside
documentChanged
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 |
replace(int offset,
int length,
String text)
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 |
set(String text)
Replaces the content of the document with the given text.
|
void |
setAutoExpandMode(boolean autoExpandMode)
Sets the auto expand mode for this document.
|
protected void |
updateDocumentStructures(DocumentEvent event)
Updates document partitioning and document positions according to the
specification given by the document event.
|
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
public ProjectionDocument(IDocument masterDocument)
masterDocument
- the master documentpublic void dispose()
protected final Position[] getFragments()
protected final Position[] getSegments()
public ProjectionMapping getProjectionMapping()
getDocumentInformationMapping()
public IDocumentInformationMapping getDocumentInformationMapping()
public IDocument getMasterDocument()
public String getDefaultLineDelimiter()
IDocumentExtension4
This default line delimiter should be used by clients who want unique delimiters (e.g. 'CR's) in the document.
getDefaultLineDelimiter
in interface IDocumentExtension4
getDefaultLineDelimiter
in class AbstractDocument
null
if nonepublic final IRegion[] computeUnprojectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException
offsetInMaster
- the range offset in the master documentlengthInMaster
- the range length in the master documentBadLocationException
- in case the given range is invalid in the
master documentpublic void addMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException
offsetInMaster
- the offset of the master document rangelengthInMaster
- the length of the master document rangeBadLocationException
- in case the master event is not validpublic void removeMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException
offsetInMaster
- the offset of the master document rangelengthInMaster
- the length of the master document rangeBadLocationException
- in case the master event is not validpublic final IRegion[] computeProjectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException
null
if no such
regions exist.offsetInMaster
- the range offset in the master documentlengthInMaster
- the range length in the master documentnull
BadLocationException
- in case the given range is invalid in the master documentprotected boolean isUpdating()
true
if the document is updatingpublic void replace(int offset, int length, String text) throws BadLocationException
IDocument
DocumentEvent
to all registered IDocumentListener
.replace
in interface IDocument
replace
in class AbstractDocument
offset
- the document offsetlength
- the length of the specified rangetext
- the substitution textBadLocationException
- if the offset is invalid in this documentDocumentEvent
,
IDocumentListener
public void set(String text)
IDocument
DocumentEvent
to all registered IDocumentListener
.
This method is a convenience method for replace(0, getLength(), text)
.set
in interface IDocument
set
in class AbstractDocument
text
- the new content of the documentDocumentEvent
,
IDocumentListener
protected final boolean adaptProjectionToMasterChange(DocumentEvent masterEvent) throws BadLocationException
masterEvent
- the master document eventtrue
if masterEvent affects this projection documentBadLocationException
- in case the master event is not validpublic void masterDocumentAboutToBeChanged(DocumentEvent masterEvent)
masterEvent
- the master document eventpublic void masterDocumentChanged(DocumentEvent masterEvent)
masterEvent
- the master document eventprotected void fireDocumentAboutToBeChanged(DocumentEvent event)
AbstractDocument
fireDocumentAboutToBeChanged
in class AbstractDocument
event
- the event to be sent outprotected void fireDocumentChanged(DocumentEvent event)
fireDocumentChanged
in class AbstractDocument
event
- the event to be ignoredprotected void updateDocumentStructures(DocumentEvent event)
AbstractDocument
updateDocumentStructures
in class AbstractDocument
event
- the document event describing the change to which structures must be adaptedpublic void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace)
IDocumentExtension
documentChanged
to register a post notification replace operation on the document notifying them.registerPostNotificationReplace
in interface IDocumentExtension
registerPostNotificationReplace
in class AbstractDocument
owner
- the owner of the replace operationreplace
- the replace operation to be executedpublic void setAutoExpandMode(boolean autoExpandMode)
autoExpandMode
- true
if auto-expandingpublic void replaceMasterDocumentRanges(int offsetInMaster, int lengthInMaster) throws BadLocationException
offsetInMaster
- the offset in the master documentlengthInMaster
- the length in the master documentBadLocationException
- if the given range of the master document is not valid
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.