gui.multisource
Class MultisourceDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.DefaultStyledDocument
          extended by gui.multisource.MultisourceDocument
All Implemented Interfaces:
java.io.Serializable, javax.swing.text.Document, javax.swing.text.StyledDocument

public class MultisourceDocument
extends javax.swing.text.DefaultStyledDocument

A MultisourceDocument is a document with segments that are attributed to different sources. The sources can be indicated with a MultisourceBorder.

See Also:
Serialized Form

Nested Class Summary
 class MultisourceDocument.SourceSegment
          A SourceSegment represents a contiguous, single source segment of text in a multisource document.
 
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument
javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
 
Field Summary
static java.lang.Object USER
          MultisourceDocument.USER is the source value for user entered text that has been committed.
 
Fields inherited from class javax.swing.text.DefaultStyledDocument
buffer, BUFFER_SIZE_DEFAULT
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
MultisourceDocument(TextConsumer tc)
          new MultisourceDocument(tc) returns a new MultisourceDocument with text consumer tc.
 
Method Summary
 void addText(java.lang.String txt, java.lang.Object src)
          msd.addText(txt, src) adds txt to msd with source src.
 void clear()
          msd.clear() removes all text from msd.
 void commitUserText()
          msd.commitUserText() commits the currently uncommitted user text in msd and sends the text to msd's text consumer.
 javax.swing.text.DefaultCaret getCaret()
          msd.getCaret() returns msd's edit caret.
 int getStartNewText()
          msd.getStartNewText() returns msd's start new text offset.
 java.util.Iterator<MultisourceDocument.SourceSegment> segments(int so, int eo)
          msd.segments() returns an iterator for the segments in msd that contain offsets from so to eo, inclusive.
 void setTextConsumer(TextConsumer tc)
          msd.setTextConsumer(tc) sets msd's text consumer to tc.
 
Methods inherited from class javax.swing.text.DefaultStyledDocument
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged
 
Methods inherited from class javax.swing.text.AbstractDocument
addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, insertString, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.Document
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeUndoableEditListener, render
 

Field Detail

USER

public static final java.lang.Object USER
MultisourceDocument.USER is the source value for user entered text that has been committed.

Constructor Detail

MultisourceDocument

public MultisourceDocument(TextConsumer tc)
new MultisourceDocument(tc) returns a new MultisourceDocument with text consumer tc.

Method Detail

segments

public java.util.Iterator<MultisourceDocument.SourceSegment> segments(int so,
                                                                      int eo)
msd.segments() returns an iterator for the segments in msd that contain offsets from so to eo, inclusive.


getStartNewText

public int getStartNewText()
msd.getStartNewText() returns msd's start new text offset.


getCaret

public javax.swing.text.DefaultCaret getCaret()
msd.getCaret() returns msd's edit caret.


setTextConsumer

public void setTextConsumer(TextConsumer tc)
msd.setTextConsumer(tc) sets msd's text consumer to tc.


commitUserText

public void commitUserText()
msd.commitUserText() commits the currently uncommitted user text in msd and sends the text to msd's text consumer.


addText

public void addText(java.lang.String txt,
                    java.lang.Object src)
msd.addText(txt, src) adds txt to msd with source src.


clear

public void clear()
msd.clear() removes all text from msd.