Class XMLDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
net.simplace.ui.xmleditorkit.XMLDocument
- All Implemented Interfaces:
Serializable, Document, StyledDocument
Styled document holding an XML structure as nested tag elements (see
XMLReader). The document is read-only
for the user: text is only inserted or removed while user changes are switched
off.- Author:
- Stanislav Lapitsky
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class DefaultStyledDocument
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElementNested classes/interfaces inherited from class AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic SimpleAttributeSetstyle of attribute names (bold)static SimpleAttributeSetstyle of attribute values (italic, blue)static SimpleAttributeSetstyle of brackets,=and quotesstatic SimpleAttributeSetstyle of comments (smaller, gray, italic)static SimpleAttributeSetstyle of text content (smaller, dark gray)static Stringelement name of a tag (start row, children, end row)static Stringelement name of the end row of a tagstatic Stringelement name of the start row of a tag and of text/comment rowsstatic SimpleAttributeSetstyle of tag names (bold, dark green)Fields inherited from class DefaultStyledDocument
buffer, BUFFER_SIZE_DEFAULTFields inherited from class AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementNameFields inherited from interface Document
StreamDescriptionProperty, TitleProperty -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidinsert(int offset, DefaultStyledDocument.ElementSpec[] data) Inserts the element structure (made accessible forXMLReader).voidinsertString(int offs, String str, AttributeSet a) Inserts the text only if user changes are switched off, otherwise does nothing.booleanvoidremove(int offs, int len) Removes the text only if user changes are switched off, otherwise does nothing.voidsetUserChanges(boolean userChanges) Methods inherited from class DefaultStyledDocument
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insertUpdate, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChangedMethods inherited from class 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, postRemoveUpdate, putProperty, readLock, readUnlock, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlockMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Document
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeUndoableEditListener, render
-
Field Details
-
TAG_ELEMENT
element name of a tag (start row, children, end row) -
TAG_ROW_START_ELEMENT
element name of the start row of a tag and of text/comment rows -
TAG_ROW_END_ELEMENT
element name of the end row of a tag -
BRACKET_ATTRIBUTES
style of brackets,=and quotes -
TAGNAME_ATTRIBUTES
style of tag names (bold, dark green) -
ATTRIBUTENAME_ATTRIBUTES
style of attribute names (bold) -
ATTRIBUTEVALUE_ATTRIBUTES
style of attribute values (italic, blue) -
PLAIN_ATTRIBUTES
style of text content (smaller, dark gray) -
COMMENT_ATTRIBUTES
style of comments (smaller, gray, italic)
-
-
Constructor Details
-
XMLDocument
public XMLDocument()Creates an empty document.
-
-
Method Details
-
insertString
Inserts the text only if user changes are switched off, otherwise does nothing.- Specified by:
insertStringin interfaceDocument- Overrides:
insertStringin classAbstractDocument- Parameters:
offs- the offsetstr- the texta- the attributes of the text- Throws:
BadLocationException- if the offset is invalid
-
remove
Removes the text only if user changes are switched off, otherwise does nothing.- Specified by:
removein interfaceDocument- Overrides:
removein classAbstractDocument- Parameters:
offs- the offsetlen- number of characters- Throws:
BadLocationException- if the range is invalid
-
isUserChanges
public boolean isUserChanges()- Returns:
trueif changes are treated as user changes and ignored
-
setUserChanges
public void setUserChanges(boolean userChanges) - Parameters:
userChanges-falseto allow programmatic changes,trueto block changes again
-
insert
protected void insert(int offset, DefaultStyledDocument.ElementSpec[] data) throws BadLocationException Inserts the element structure (made accessible forXMLReader).- Overrides:
insertin classDefaultStyledDocument- Parameters:
offset- the offsetdata- the element specs- Throws:
BadLocationException- if the offset is invalid
-