Eclipse Platform
2.1

org.eclipse.jface.text
Class ChildDocument

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

public final class ChildDocument
extends AbstractDocument

A child document is one particular example of a slave document. Child documents are created by the ChildDocumentManager, an implementation of ISlaveDocumentManager.

A child document represents one consequetive range of its master document. The master document is called 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

Inner classes inherited from class org.eclipse.jface.text.IDocumentExtension
IDocumentExtension.IReplace
 
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.
 boolean isAutoExpandEvent(DocumentEvent event)
          Returns whether the given document might cause this document to auto expand.
 DocumentEvent normalize(DocumentEvent event)
          Transforms a document event of the parent document into a child document based document event.
 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 setAutoExpandMode(boolean autoExpand)
          Sets the auto expand mode of this document.
 void setParentDocumentRange(int offset, int length)
          Sets the child document's parent document range.
 
Methods inherited from class org.eclipse.jface.text.AbstractDocument
acceptPostNotificationReplaces, addDocumentListener, addDocumentPartitioningListener, addPosition, addPosition, addPositionCategory, addPositionUpdater, addPrenotifiedDocumentListener, completeInitialization, computeIndexInCategory, computeIndexInPositionList, computeNumberOfLines, computePartitioning, containsPosition, containsPositionCategory, doFireDocumentChanged, doFireDocumentChanged, 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, ignorePostNotificationReplaces, insertPositionUpdater, removeDocumentListener, removeDocumentPartitioningListener, removePosition, removePosition, removePositionCategory, removePositionUpdater, removePrenotifiedDocumentListener, resumeListenerNotification, resumePostNotificationProcessing, search, setDocumentPartitioner, setLineTracker, setTextStore, startSequentialRewrite, stopListenerNotification, 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

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

normalize

public DocumentEvent normalize(DocumentEvent event)

Transforms a document event of the parent document into a child document based document event. This method considers whether the document is in auto expand mode.

This method is public for test purposes only.
Parameters:
e - the parent document event
Returns:
the child document event

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 change 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
Following copied from class: org.eclipse.jface.text.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

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.
Overrides:
replace in class AbstractDocument
Following copied from interface: org.eclipse.jface.text.IDocument
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).
Overrides:
set in class AbstractDocument
Following copied from interface: org.eclipse.jface.text.IDocument
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.
Overrides:
registerPostNotificationReplace in class AbstractDocument
Following copied from interface: org.eclipse.jface.text.IDocumentExtension
Parameters:
owner - the owner of the replace operation
the - replace operation to be executed
Throws:
UnsupportedOperationException - if registerPostNotificationReplace is not supported by this document

setAutoExpandMode

public void setAutoExpandMode(boolean autoExpand)
Sets the auto expand mode of this document.
Parameters:
autoExpand - true if auto expanding, false otherwise
Since:
2.1

isAutoExpandEvent

public boolean isAutoExpandEvent(DocumentEvent event)
Returns whether the given document might cause this document to auto expand. This default implementation always answers with its auto expand state.
Parameters:
event - the document event
Returns:
true if the given event might cause this document to auto expand

Eclipse Platform
2.1

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