SMACS

smacs.xngr.browser.editor
Class XmlDocument

java.lang.Object
  extended byjavax.swing.text.AbstractDocument
      extended byjavax.swing.text.PlainDocument
          extended bysmacs.xngr.browser.editor.XmlDocument
All Implemented Interfaces:
Document, Serializable

public class XmlDocument
extends PlainDocument

The XML Document is responsible for handling the user insertions and deletions, for changing the tab characters to spaces and to automatically indent the text correctly.

Note: The XML Editor package is based on the JavaEditorKit example as described in the article 'Customizing a Text Editor' by Timothy Prinzing. See: http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/

Author:
Edwin Dankert
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
 
Field Summary
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
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
XmlDocument(XmlEditorPane editor)
          Constructs the XML Document with a new GapContent buffer.
 
Method Summary
 int getTagEnd(int p)
          Gets the location where the last significant tag ended, this location can be used as a start for the scanner.
 void insertString(int off, String str, AttributeSet set)
          Inserts some content into the document.
 void setLoading(boolean loading)
          Lets the document know that it is being loaded, don't attempt to do any text conversion.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, 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, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, 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
 

Constructor Detail

XmlDocument

public XmlDocument(XmlEditorPane editor)
Constructs the XML Document with a new GapContent buffer.

Method Detail

setLoading

public void setLoading(boolean loading)
Lets the document know that it is being loaded, don't attempt to do any text conversion.


getTagEnd

public int getTagEnd(int p)
Gets the location where the last significant tag ended, this location can be used as a start for the scanner. If the current element is a comment, the last significant tag is before the begin of the comment.

Parameters:
p - the preferred start position.
Returns:
the position where the last significant tag ended or 0.

insertString

public void insertString(int off,
                         String str,
                         AttributeSet set)
                  throws BadLocationException
Inserts some content into the document. When the content is a tab character, the character will be replaced by spaces. When the content is a new line character, an indentation will be added to the content.

Throws:
BadLocationException

SMACS