Eclipse Platform
2.0

org.eclipse.jface.text
Class ChildDocument

java.lang.Object
  |
  +--org.eclipse.jface.text.AbstractDocument
        |
        +--org.eclipse.jface.text.ChildDocument
All Implemented Interfaces:
IDocument, IDocumentExtension

public final class ChildDocument
extends AbstractDocument

A child document represent a range of its parent document. The child document is always in sync with its parent document by utilizing the parent document as its ITextStore. This class is for internal use only.

See Also:
ITextStore

Nested Class Summary
 
Nested classes inherited from class org.eclipse.jface.text.IDocumentExtension
IDocumentExtension.IReplace
 
Field Summary
 
Fields inherited from interface org.eclipse.jface.text.IDocument
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE
 
Constructor Summary
ChildDocument(IDocument parentDocument, Position range)
          Creates a child document for the given range of the given parent document.
 
Method Summary
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 similar child document event instead.
 IDocument getParentDocument()
          Returns parent document
 Position getParentDocumentRange()
          Returns the range of the parent document covered by this child document.
 void parentDocumentAboutToBeChanged(DocumentEvent event)
          When called this child document is informed about a forthcoming change of its parent document.
 void parentDocumentChanged(DocumentEvent event)
          When called this child document is informed about a change of its parent 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 replace(int offset, int length, String text)
          Subsitutes the given text for the specified document range.
 void set(String text)
          Replaces the content of the document with the given text.
 void setParentDocumentRange(int offset, int length)
          Sets the child document's parent document range.
 
Methods inherited from class org.eclipse.jface.text.AbstractDocument
addDocumentListener, addDocumentPartitioningListener, addPosition, addPosition, addPositionCategory, addPositionUpdater, addPrenotifiedDocumentListener, completeInitialization, computeIndexInCategory, computeIndexInPositionList, computeNumberOfLines, computePartitioning, containsPosition, containsPositionCategory, fireDocumentPartitioningChanged, fireDocumentPartitioningChanged, get, get, getChar, getContentType, getDocumentListeners, getDocumentManagedPositions, getDocumentPartitioner, getDocumentPartitioningListeners, getLegalContentTypes, getLegalLineDelimiters, getLength, getLineDelimiter, getLineInformation, getLineInformationOfOffset, getLineLength, getLineOffset, getLineOfOffset, getNumberOfLines, getNumberOfLines, getPartition, getPositionCategories, getPositions, getPositionUpdaters, getStore, getTracker, insertPositionUpdater, removeDocumentListener, removeDocumentPartitioningListener, removePosition, removePosition, removePositionCategory, removePositionUpdater, removePrenotifiedDocumentListener, resumePostNotificationProcessing, search, setDocumentPartitioner, setLineTracker, setTextStore, startSequentialRewrite, stopPostNotificationProcessing, stopSequentialRewrite, updateDocumentStructures, updatePositions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChildDocument

public ChildDocument(IDocument parentDocument,
                     Position range)
Creates a child document for the given range of the given parent document.

Parameters:
parentDocument - the parent Document
range - the parent document range covered by the child document
Method Detail

setParentDocumentRange

public void setParentDocumentRange(int offset,
                                   int length)
                            throws BadLocationException
Sets the child document's parent document range.

Parameters:
offset - the offset of the parent document range
length - the length of the parent document range
BadLocationException

getParentDocument

public IDocument getParentDocument()
Returns parent document

Returns:
the parent document

getParentDocumentRange

public Position getParentDocumentRange()
Returns the range of the parent document covered by this child document.

Returns:
the child document's parent document range

parentDocumentAboutToBeChanged

public void parentDocumentAboutToBeChanged(DocumentEvent event)
When called this child document is informed about a forthcoming change of its parent document. This child document checks whether the parent document changed affects it and if so informs all document listeners.

Parameters:
event - the parent document event

parentDocumentChanged

public void parentDocumentChanged(DocumentEvent event)
When called this child document is informed about a change of its parent document. If this child document is affected it informs all of its document listeners.

Parameters:
event - the parent document event

fireDocumentAboutToBeChanged

protected void fireDocumentAboutToBeChanged(DocumentEvent event)
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 class AbstractDocument
Parameters:
event - the event to be sent out

fireDocumentChanged

protected void fireDocumentChanged(DocumentEvent event)
Ignores the given event and sends the similar child document event instead.

Overrides:
fireDocumentChanged in class AbstractDocument
Parameters:
event - the event to be ignored
See Also:
IDocumentExtension

replace

public void replace(int offset,
                    int length,
                    String text)
             throws BadLocationException
Description copied from interface: IDocument
Subsitutes the given text for the specified document range. Sends a DocumentEvent to all registered IDocumentListener.

Specified by:
replace in interface IDocument
Overrides:
replace in class AbstractDocument
Parameters:
offset - the document offset
length - the length of the specified range
text - the substitution text
Throws:
BadLocationException - if the offset is invalid in this document
See Also:
DocumentEvent, IDocumentListener

set

public void set(String text)
Description copied from interface: IDocument
Replaces the content of the document with the given text. Sends a DocumentEvent to all registered IDocumentListener. This method is a convenience method for replace(0, getLength(), text).

Specified by:
set in interface IDocument
Overrides:
set in class AbstractDocument
Parameters:
text - the new content of the document
See Also:
DocumentEvent, IDocumentListener

registerPostNotificationReplace

public void registerPostNotificationReplace(IDocumentListener owner,
                                            IDocumentExtension.IReplace replace)
Description copied from interface: IDocumentExtension
Callback for document listeners to be used inside documentChanged to register a post notification replace operation on the document notifying them.

Specified by:
registerPostNotificationReplace in interface IDocumentExtension
Overrides:
registerPostNotificationReplace in class AbstractDocument
Parameters:
owner - the owner of the replace operation

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.