com.japisoft.xmlpad.editor
Class XMLDocument

java.lang.Object
  extended byjavax.swing.text.AbstractDocument
      extended byjavax.swing.text.PlainDocument
          extended bycom.japisoft.xmlpad.editor.XMLDocument
All Implemented Interfaces:
javax.swing.text.Document, java.io.Serializable

public class XMLDocument
extends javax.swing.text.PlainDocument

(c) 2003 JAPISoft Main document for the XMLEditor bean

Version:
1.3
See Also:
Serialized Form

Nested Class Summary
 class XMLDocument.XMLDocumentListener
          An implementation of DocumentListener that inserts and deletes lines from the token marker's state.remove
 
Nested classes 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
 
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(XMLEditor editor)
          Creates a new DefaultXMLDocument instance.
 
Method Summary
 void enableStructureDamagedSupport(boolean structure)
          Support notification for an XML structure tree change like adding or removing a tag
 boolean forceLocation()
          For inner usage only.
 int[] getAttributeValueLocation(int offset)
           
 java.lang.Integer[] getCommentDelimiters(int offset)
          The starting and stopping comment position or null if no comment is found
 java.lang.StringBuffer getCompletionBuffer()
          For inner usage
 XMLContainer getContainer()
           
 XMLEditor getCurrentEditor()
           
 java.lang.String[] getElementsFromDTD()
           
 java.lang.String getForwardAttributeName(XMLDocument document, int offset)
           
 java.awt.Point getLastDTDLocation()
           
 java.lang.String getPreviousOpeningTag(int offset)
           
 java.lang.String getPreviousOpeningTagInsideATagPart(int offset)
           
 java.lang.String getPreviousOpeningTagInsideATagPartWithoutPrefix(int offset)
           
 java.lang.String getWordAt(int from)
          Extract a word at this location
 SimpleNode getXMLPath(int location)
           
 void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet a)
          Insert a string at this offset showing if needed a syntax popup helper
 void insertStringWithoutHelper(int offset, java.lang.String str, javax.swing.text.AttributeSet a)
          Insert a string at this offset ignore syntax popup helper
 void insertStringWithoutHelper(int offset, java.lang.String str, javax.swing.text.AttributeSet a, boolean caretMoved)
           
 void insertStringWithoutStructureDamaged(int offset, java.lang.String str, javax.swing.text.AttributeSet a)
          Insert a string at this offset ignoring the tree synchronization
 boolean isAutoCloseTag()
          by default true
 boolean isBetweenTagDelimiters(int offset)
          Check for usage between < or >
 boolean isEnableStructureDamagedSupport()
          Support notification for an XML structure tree change like adding or removing a tag
 boolean isInProlog(int offset)
           
 boolean isInsideAttributeValue(int offset)
           
 boolean isInsideCDATA(int offset)
          Editing in a CDATA section ?
 boolean isInsideComment(int offset)
          Editing in a Comment section ?
 boolean isInsideDTDAttributeDefinition(int offset)
          Inside <!
 boolean isInsideDTDElementDefinition(int offset)
          Inside <!
 boolean isInsideTag(int offset)
           
 boolean isInsideTag(int offset, boolean exceptAttributeValue, boolean exceptEndTag)
           
 boolean isInsideTagExceptAttributeValue(int offset)
           
 boolean isSyntaxPopup()
          Enable a popup for < and &, by default true
 boolean manageCompletion(boolean insertBefore, int offset, java.lang.String str)
           
 int nextTag(int from)
          Find the location of the next tag
 boolean parseDTD()
          Search and parse document DTD on the current document
 boolean parseSchema()
          Search and parse an XML on the current document schema
 void remove(int offs, int len)
          Remove a text at this offset.
 void removeWithoutStructureDamaged(int offset, int len)
          Remove a text at this offset, it will not synchronize the tree
 void resetCompletionMode(boolean enabled)
          For inner usage
 void setAutoCloseTag(boolean autoClose)
          Support for automatically closing the current inserted tag
 void setEditor(XMLEditor editor)
           
 void setStructureDamagedListener(StructureDamagedListener listener)
          Listener for XML tree changes
 void setSyntaxPopup(boolean popup)
          Enable a popup while entering < or &
protected  void structureDamaged()
          Fire an event that the XML document has not the same structure
 java.awt.Point updateElement(java.lang.String startElement, java.lang.String endElement, int startOffset, int endOffset)
          Used mainly by the elementView for updating the element content
 void updateNode(SimpleNode sn, java.lang.String newContent)
          Replace this node by this new content
 void updateNodeOpeningClosing(SimpleNode node)
          Update the node changed inside the editor.
 
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, 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(XMLEditor editor)
Creates a new DefaultXMLDocument instance.

Method Detail

getCurrentEditor

public XMLEditor getCurrentEditor()
Returns:
the editor using this document

setEditor

public void setEditor(XMLEditor editor)

getContainer

public XMLContainer getContainer()
Returns:
the main container for this document

structureDamaged

protected void structureDamaged()
Fire an event that the XML document has not the same structure


setStructureDamagedListener

public void setStructureDamagedListener(StructureDamagedListener listener)
Listener for XML tree changes


isInsideComment

public boolean isInsideComment(int offset)
Editing in a Comment section ?


isInsideCDATA

public boolean isInsideCDATA(int offset)
Editing in a CDATA section ?


nextTag

public int nextTag(int from)
Find the location of the next tag


getWordAt

public java.lang.String getWordAt(int from)
Extract a word at this location


getForwardAttributeName

public java.lang.String getForwardAttributeName(XMLDocument document,
                                                int offset)
Returns:
the previous attribute name at this location

getXMLPath

public SimpleNode getXMLPath(int location)
Returns:
the XMLPath from the caret location

enableStructureDamagedSupport

public void enableStructureDamagedSupport(boolean structure)
Support notification for an XML structure tree change like adding or removing a tag


isEnableStructureDamagedSupport

public boolean isEnableStructureDamagedSupport()
Support notification for an XML structure tree change like adding or removing a tag


setAutoCloseTag

public void setAutoCloseTag(boolean autoClose)
Support for automatically closing the current inserted tag


isAutoCloseTag

public boolean isAutoCloseTag()
by default true


setSyntaxPopup

public void setSyntaxPopup(boolean popup)
Enable a popup while entering < or &


isSyntaxPopup

public boolean isSyntaxPopup()
Enable a popup for < and &, by default true


getAttributeValueLocation

public int[] getAttributeValueLocation(int offset)
Returns:
the starting and the end offset inside an attribute value from the offset parameter

isInProlog

public boolean isInProlog(int offset)
Returns:
true if this offset is before the root node

isInsideAttributeValue

public boolean isInsideAttributeValue(int offset)

isInsideTagExceptAttributeValue

public boolean isInsideTagExceptAttributeValue(int offset)
Returns:
true if the offset is inside a tag and not in an attribute value

isInsideTag

public boolean isInsideTag(int offset)

isInsideTag

public boolean isInsideTag(int offset,
                           boolean exceptAttributeValue,
                           boolean exceptEndTag)

getCommentDelimiters

public java.lang.Integer[] getCommentDelimiters(int offset)
The starting and stopping comment position or null if no comment is found

Parameters:
offset - Current document location
Returns:
start and stop location

resetCompletionMode

public void resetCompletionMode(boolean enabled)
For inner usage


getCompletionBuffer

public java.lang.StringBuffer getCompletionBuffer()
For inner usage


manageCompletion

public boolean manageCompletion(boolean insertBefore,
                                int offset,
                                java.lang.String str)

insertStringWithoutStructureDamaged

public void insertStringWithoutStructureDamaged(int offset,
                                                java.lang.String str,
                                                javax.swing.text.AttributeSet a)
Insert a string at this offset ignoring the tree synchronization


insertStringWithoutHelper

public void insertStringWithoutHelper(int offset,
                                      java.lang.String str,
                                      javax.swing.text.AttributeSet a)
Insert a string at this offset ignore syntax popup helper


insertStringWithoutHelper

public void insertStringWithoutHelper(int offset,
                                      java.lang.String str,
                                      javax.swing.text.AttributeSet a,
                                      boolean caretMoved)

insertString

public void insertString(int offset,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException
Insert a string at this offset showing if needed a syntax popup helper

Throws:
javax.swing.text.BadLocationException

getPreviousOpeningTagInsideATagPartWithoutPrefix

public java.lang.String getPreviousOpeningTagInsideATagPartWithoutPrefix(int offset)
                                                                  throws javax.swing.text.BadLocationException
Returns:
the opening tag part from this offset inside an opening tag part with the namespace prefix
Throws:
javax.swing.text.BadLocationException

getPreviousOpeningTagInsideATagPart

public java.lang.String getPreviousOpeningTagInsideATagPart(int offset)
                                                     throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException

getPreviousOpeningTag

public java.lang.String getPreviousOpeningTag(int offset)
                                       throws javax.swing.text.BadLocationException
Returns:
the opening tag part from this offset with the namespace prefix
Throws:
javax.swing.text.BadLocationException

forceLocation

public boolean forceLocation()
For inner usage only. Don't call it


parseSchema

public boolean parseSchema()
Search and parse an XML on the current document schema


parseDTD

public boolean parseDTD()
Search and parse document DTD on the current document


getLastDTDLocation

public java.awt.Point getLastDTDLocation()
Returns:
the last DTD declaration location

isBetweenTagDelimiters

public boolean isBetweenTagDelimiters(int offset)
Check for usage between < or >


isInsideDTDElementDefinition

public boolean isInsideDTDElementDefinition(int offset)
Inside <!ELEMENT> definition


isInsideDTDAttributeDefinition

public boolean isInsideDTDAttributeDefinition(int offset)
Inside <!ATTRIBUTE> definition


getElementsFromDTD

public java.lang.String[] getElementsFromDTD()
Returns:
the available >!ELEMENT name

removeWithoutStructureDamaged

public void removeWithoutStructureDamaged(int offset,
                                          int len)
Remove a text at this offset, it will not synchronize the tree


remove

public void remove(int offs,
                   int len)
            throws javax.swing.text.BadLocationException
Remove a text at this offset. It will synchronize the tre

Throws:
javax.swing.text.BadLocationException

updateElement

public java.awt.Point updateElement(java.lang.String startElement,
                                    java.lang.String endElement,
                                    int startOffset,
                                    int endOffset)
Used mainly by the elementView for updating the element content


updateNode

public void updateNode(SimpleNode sn,
                       java.lang.String newContent)
Replace this node by this new content


updateNodeOpeningClosing

public void updateNodeOpeningClosing(SimpleNode node)
Update the node changed inside the editor. Only the opening part and the closing part will be updated. The content of this node WILL not be updated

Parameters:
node - Note to update


Copyright © 2006 JAPISoft. All Rights Reserved.