Eclipse Platform
2.1

org.eclipse.jface.text
Class ChildDocumentManager

java.lang.Object
  |
  +--org.eclipse.jface.text.ChildDocumentManager
All Implemented Interfaces:
IDocumentListener, ISlaveDocumentManager

public final class ChildDocumentManager
extends Object
implements IDocumentListener, ISlaveDocumentManager

ChildDocumentManager is one particular implementation of ISlaveDocumentManager. This manager creates so called child documents as slave documents for given master documents.

A child document represents a particular range of the parent document and is accordingly adapted to changes of the parent document. Vice versa, the parent document is accordingly adapted to changes of its child documents. The manager does not maintain any particular management structure but utilizes mechanisms given by IDocument such as position categories and position updaters.

For internal use only.


Field Summary
static String CHILDDOCUMENTS
          Name of the position category used to keep track of the ranges of the parent documents that correspond to child documents.
 
Constructor Summary
ChildDocumentManager()
           
 
Method Summary
 IDocumentInformationMapping createMasterSlaveMapping(IDocument slave)
          Creates a new document information mapping between the given slave document and its master document.
 IDocument createSlaveDocument(IDocument master)
          Creates a new slave document for the given master document.
 void documentAboutToBeChanged(DocumentEvent event)
          The manipulation described by the document event will be performed.
 void documentChanged(DocumentEvent event)
          The manipulation described by the document event has been performed.
protected  void fireDocumentEvent(boolean about, DocumentEvent event)
          Informs all child documents of the document which issued this document event.
 void freeSlaveDocument(IDocument slave)
          Frees the given slave document.
protected  IPositionUpdater getChildPositionUpdater()
          Returns the child position updater.
 IDocument getMasterDocument(IDocument slave)
          Returns the master document of the given slave document or null if the given document is unknown to this slave document manager.
 boolean isSlaveDocument(IDocument document)
          Returns whether the given document is a slave document known to this slave document manager.
 void setAutoExpandMode(IDocument slaveDocument, boolean autoExpand)
          Sets the given slave document's auto expand mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHILDDOCUMENTS

public static final String CHILDDOCUMENTS
Name of the position category used to keep track of the ranges of the parent documents that correspond to child documents.
Constructor Detail

ChildDocumentManager

public ChildDocumentManager()
Method Detail

getChildPositionUpdater

protected IPositionUpdater getChildPositionUpdater()
Returns the child position updater. If necessary, it is dynamically created.
Returns:
the child position updater

createSlaveDocument

public IDocument createSlaveDocument(IDocument master)
Description copied from interface: ISlaveDocumentManager
Creates a new slave document for the given master document. The slave document is causally connected to its master document until freeSlaveDocument is called. The connection between the newly created slave document and the master document is managed by this slave document manager.
Specified by:
createSlaveDocument in interface ISlaveDocumentManager
Following copied from interface: org.eclipse.jface.text.ISlaveDocumentManager
Parameters:
master - the master document
Returns:
the newly created slave document
See Also:
ISlaveDocumentManager.freeSlaveDocument(IDocument)

freeSlaveDocument

public void freeSlaveDocument(IDocument slave)
Description copied from interface: ISlaveDocumentManager
Frees the given slave document. If the given document is not a slave document known to this slave document manager, this call does not have any effect. A slave document is known to this slave document manager if it has been created by this manager using createSlaveDocument.
Specified by:
freeSlaveDocument in interface ISlaveDocumentManager
Following copied from interface: org.eclipse.jface.text.ISlaveDocumentManager
Parameters:
slave - the slave document to be freed

createMasterSlaveMapping

public IDocumentInformationMapping createMasterSlaveMapping(IDocument slave)
Description copied from interface: ISlaveDocumentManager
Creates a new document information mapping between the given slave document and its master document. Returns null if the given document is unknown to this slave document manager.
Specified by:
createMasterSlaveMapping in interface ISlaveDocumentManager
Following copied from interface: org.eclipse.jface.text.ISlaveDocumentManager
Parameters:
slave - the slave document
Returns:
a document information mapping between the slave document and its master document or null

getMasterDocument

public IDocument getMasterDocument(IDocument slave)
Description copied from interface: ISlaveDocumentManager
Returns the master document of the given slave document or null if the given document is unknown to this slave document manager.
Specified by:
getMasterDocument in interface ISlaveDocumentManager
Following copied from interface: org.eclipse.jface.text.ISlaveDocumentManager
Parameters:
slave - the slave document
Returns:
the master document of the given slave document or null

isSlaveDocument

public boolean isSlaveDocument(IDocument document)
Description copied from interface: ISlaveDocumentManager
Returns whether the given document is a slave document known to this slave document manager. A slave document is known to this slave document manager, if the document has been created by this manager.
Specified by:
isSlaveDocument in interface ISlaveDocumentManager
Following copied from interface: org.eclipse.jface.text.ISlaveDocumentManager
Parameters:
document - the document to be checked whether it is a slave document known to this manager
Returns:
true if the document is a slave document, false otherwise

fireDocumentEvent

protected void fireDocumentEvent(boolean about,
                                 DocumentEvent event)
Informs all child documents of the document which issued this document event.
Parameters:
about - indicates whether the change is about to happen or alread happend
event - the document event which will be processed to inform child documents

documentChanged

public void documentChanged(DocumentEvent event)
Description copied from interface: IDocumentListener
The manipulation described by the document event has been performed.
Specified by:
documentChanged in interface IDocumentListener
Following copied from interface: org.eclipse.jface.text.IDocumentListener
Parameters:
event - the document event describing the document change

documentAboutToBeChanged

public void documentAboutToBeChanged(DocumentEvent event)
Description copied from interface: IDocumentListener
The manipulation described by the document event will be performed.
Specified by:
documentAboutToBeChanged in interface IDocumentListener
Following copied from interface: org.eclipse.jface.text.IDocumentListener
Parameters:
event - the document event describing the document change

setAutoExpandMode

public void setAutoExpandMode(IDocument slaveDocument,
                              boolean autoExpand)
Description copied from interface: ISlaveDocumentManager
Sets the given slave document's auto expand mode. In auto expand mode, a slave document is automatically adapted to reflect all changes applied to it's master document. Assume a master document contains 30 lines and the slave is defined to contain the lines 11-20. In auto expand mode, when the master document is changed at line 8, the slave document is expanded to contain the lines 8-20.

This call is without effect if the given document is unknown to this slave document manager.

Specified by:
setAutoExpandMode in interface ISlaveDocumentManager
Following copied from interface: org.eclipse.jface.text.ISlaveDocumentManager
Parameters:
slave - the slave whose auto expand mode should be set
autoExpand - true for auto expand, false otherwise

Eclipse Platform
2.1

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