com.japisoft.xmlpad.editor
Class XMLEditor

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.text.JTextComponent
                  extended byjavax.swing.JEditorPane
                      extended bycom.japisoft.xmlpad.editor.XMLEditor
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.CaretListener, ErrorListener, ErrorSelectionListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable

public class XMLEditor
extends javax.swing.JEditorPane
implements javax.swing.event.CaretListener, java.awt.event.FocusListener, ErrorListener, ErrorSelectionListener

Main class for the XMLEditor. This class uses an XMLEditorKit for working.

This class is a part of the XMLContainer. It manages a standard swing document and a view for XML

For general usage, you MUST use the XMLContainer rather than this class.

UIManager properties :

 - xmlpad.editor.font 
 - xmlpad.editor.dtdNotationColor
 - xmlpad.editor.dtdElementColor - xmlpad.editor.dtdAttributeColor
 - xmlpad.editor.dtdEntityColor - xmlpad.editor.tagBorderLineColor
 - xmlpad.editor.cdataColor - xmlpad.editor.entityColor
 - xmlpad.editor.commentColor - xmlpad.editor.declarationColor
 - xmlpad.editor.docTypeColor - xmlpad.editor.literalColor
 - xmlpad.editor.tagColor - xmlpad.editor.invalidColor
 - xmlpad.editor.textColor - xmlpad.editor.attributeColor
 - xmlpad.editor.attributeSeparatorColor
 - xmlpad.editor.selectionHighlightColor - xmlpad.editor.backgroundColor
 - xmlpad.editor.focusBorder - xmlpad.editor.tagBackground
 - xmlpad.editor.declarationBackground - xmlpad.editor.entityBackground
 - xmlpad.editor.commentBackground - xmlpad.editor.docTypeBackground
 - xmlpad.editor.cdataBackground
 

Version:
3.0
Author:
(c)JAPISoft 2002,2003,2004
See Also:
XMLContainer, XMLEditorKit, JEditorPane, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JEditorPane
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport
 
Nested classes inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.Class _locationJobClass
           
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
XMLEditor(EditorContext context)
           
 
Method Summary
 void addNotify()
          This method will call the init method
 void asynchronousHighlightLine(int line)
          Highlight the line with an invokeLater
 void caretUpdate(javax.swing.event.CaretEvent e)
          Structure computing
 javax.swing.text.EditorKit createDefaultEditorKit()
           
 void dispose()
           
 void errorSelected(java.lang.String source, int line, java.lang.String message)
          An error has been selected by the user
 void focusGained(java.awt.event.FocusEvent e)
          Each time the editor take the focus.
 void focusLost(java.awt.event.FocusEvent e)
          For the moment, nothing is done
 java.awt.Color getBackgroundColorForPrefix(java.lang.String prefix)
           
 java.awt.Color getColorCommentBackground()
           
 java.awt.Color getColorForAttribute()
          Colorize attribute <tag ATTRIBUTE="..." ...
 java.awt.Color getColorForAttribute(java.lang.String attribute)
           
 java.awt.Color getColorForAttributeSeparator()
          Colorize '='
 java.awt.Color getColorForCDATA()
          Color for CDATA section
 java.awt.Color getColorForCDATABackground()
          Colofr for CDATA Background
 java.awt.Color getColorForCDATAEnd()
          Color for ]]>
 java.awt.Color getColorForCDATAStart()
          Color for <!
 java.awt.Color getColorForComment()
          Colorize XML comment <!
 java.awt.Color getColorForCommentEnd()
          Color for --!
 java.awt.Color getColorForCommentStart()
          Color for <!
 java.awt.Color getColorForDeclaration()
          Colorize XML declaration <?
 java.awt.Color getColorForDeclarationBackground()
           
 java.awt.Color getColorForDeclarationEnd()
          Color for ?
 java.awt.Color getColorForDeclarationStart()
          Color for <?
 java.awt.Color getColorForDocType()
          Colorize DocType declaration <!
 java.awt.Color getColorForDocTypeBackground()
          Colorize DocType declaration <!
 java.awt.Color getColorForDocTypeEnd()
          Colorize &>
 java.awt.Color getColorForDocTypeStart()
          Colorize <!
 java.awt.Color getColorForDTDAttribute()
           
 java.awt.Color getColorForDTDElement()
           
 java.awt.Color getColorForDTDEntity()
           
 java.awt.Color getColorForDTDNotation()
           
 java.awt.Color getColorForEntity()
          Colorize entity &ENTITY;
 java.awt.Color getColorForEntityBackground()
           
 java.awt.Color getColorForInvalid()
          Colorize error
 java.awt.Color getColorForLineError()
          Color for a line error
 java.awt.Color getColorForLineSelection()
          Color for a line selection
 java.awt.Color getColorForLiteral()
          Colorize literal "..."
 java.awt.Color getColorForNameSpace()
          Colorize NameSpace
 java.awt.Color getColorForPrefix(java.lang.String prefix)
           
 java.awt.Color getColorForTag()
          Colorize tag <Tag...
 java.awt.Color getColorForTag(java.lang.String tag)
           
 java.awt.Color getColorForTagBackground()
           
 java.awt.Color getColorForTagBorderLine()
           
 java.awt.Color getColorForTagDelimiter()
          Colorize tag delimiter < or >
 java.awt.Color getColorForTagEnd()
          Colorize '/'
 java.awt.Color getColorForTagUnderline()
          Color for tag underline
 java.awt.Color getColorForText()
          Colorize text
 SimpleNode getCurrentNodeLocation()
           
 javax.swing.text.Document getDocument()
           
 javax.swing.text.EditorKit getEditorKit()
           
 XMLEntityResolver getEntityResolver()
           
 int getLineEnd(int caret)
           
 int getLineStart(int caret)
           
 java.awt.Color getSelectionHighlightColor()
           
 java.lang.String getText()
           
 java.lang.String getText(int from)
           
 javax.swing.undo.UndoManager getUndoManager()
           
 XMLContainer getXMLContainer()
           
 XMLDocument getXMLDocument()
           
 boolean hasBackgroundColorForPrefix(java.lang.String prefix)
           
 boolean hasColorForAttribute(java.lang.String attribute)
           
 boolean hasColorForPrefix(java.lang.String prefix)
           
 boolean hasColorForTag(java.lang.String tag)
           
 void highlightErrorLine(int line)
          Show the error line without auto scrolling
 void highlightErrorLine(int lineStart, boolean autoScroll)
          Show the error line
 void highlightLine(int line)
          Highlight the line with the "selectionColor" property
 void highlightNodes(java.util.List list)
          Highlight the following list of node : SimpleNode
 void initErrorProcessing()
          This is called once before checking the whole document
 void initKeymap()
           
protected  void initOnce()
          Connect listeners to inner parts.
 void insertText(java.lang.String text)
          Insert a string at the current caret location
 boolean isAutoCloseTag()
          Does the closing tag is inserted automatically :true by default
 boolean isAutoResetAction()
           
 boolean isDocumentModified()
           
 boolean isEnabledRealTimeStructureChanged()
          Notify in real time any tree structure change.
 boolean isEnabledTreeLocationForCaret()
          Is Enabled the current tree location for a caret change ?.
 boolean isEnabledXPathLocation()
           
 void notifyCaretLocation()
           
 void notifyCurrentLocation()
          Notify to listener the current document location from the caret position.
 void notifyError(java.lang.Object context, boolean localError, java.lang.String sourceLocation, int line, int col, int offset, java.lang.String message, boolean onTheFly)
          Notify an XML error found while parsing
 void notifyNoError(boolean onTheFly)
          Notify the document is correct
 void notifyStructureChanged()
          Notify that the structure has changed.
 void paint(java.awt.Graphics gc)
           
 void redo()
          Redo last action
 void removeHighlightedErrorLine()
          Remove error line
 void removeHighlightedLines()
          Remove all highlighted lines
 void removeNotify()
          This method will call the dispose method
 void resetDefaultLook()
          Reset the default color of the editor
 void resetDocument(XMLDocument doc)
           
 void resetDocumentState(boolean modified)
          Only for internal usage.
 void select(int selectionStart, int selectionEnd)
          Override of the standard JTextComponent.select Move caret to the start of the selection instead of the end
 void setAction(javax.swing.KeyStroke key, javax.swing.Action a)
           
 void setAutoCloseTag(boolean autoClose)
          Insert the closing tag while the user inserts the opening tag : true by default
 void setAutoResetAction(boolean reset)
          By default to true.
 void setBackgroundColorForPrefix(java.lang.String prefix, java.awt.Color c)
          Choose a particular background color for this namespace prefix.
 boolean setCaretPositionWithoutNotification(int caret)
          Reset the caret location without updating the current tree location
 void setColorForAttribute(java.awt.Color color)
          Colorize attribute <tag ATTRIBUTE="..." ...
 void setColorForAttribute(java.lang.String attribute, java.awt.Color c)
          Choose a particular color for this attribute.
 void setColorForAttributeSeparator(java.awt.Color color)
          Colorize '='
 void setColorForCDATA(java.awt.Color color)
          Colorize CDATA section
 void setColorForCDATABackground(java.awt.Color color)
          Colorize CDATA section background
 void setColorForCDATAEnd(java.awt.Color color)
          Color for ]]>
 void setColorForCDATAStart(java.awt.Color color)
          Color for <!
 void setColorForComment(java.awt.Color color)
          Colorize XML comment <!
 void setColorForCommentBackground(java.awt.Color color)
          Colorize a comment background
 void setColorForCommentEnd(java.awt.Color color)
          Color for --!
 void setColorForCommentStart(java.awt.Color color)
          Color for <!
 void setColorForDeclaration(java.awt.Color color)
          Colorize XML declaration <?
 void setColorForDeclarationBackground(java.awt.Color color)
          Colorize a declaration background
 void setColorForDeclarationEnd(java.awt.Color color)
          Color for ?
 void setColorForDeclarationStart(java.awt.Color color)
          Color for <?
 void setColorForDocType(java.awt.Color color)
          Colorize DocType declaration <!
 void setColorForDocTypeBackground(java.awt.Color color)
          Colorize DocType declaration background <!
 void setColorForDocTypeEnd(java.awt.Color color)
          Colorize >
 void setColorForDocTypeStart(java.awt.Color color)
          Colorize <!
 void setColorForDTDAttribute(java.awt.Color color)
          Colorize !
 void setColorForDTDElement(java.awt.Color color)
          Colorize !
 void setColorForDTDEntity(java.awt.Color color)
          Colorize !
 void setColorForDTDNotation(java.awt.Color color)
           
 void setColorForEntity(java.awt.Color color)
          Colorize entity &ENTITY;
 void setColorForEntityBackground(java.awt.Color color)
          Colorize an entity background
 void setColorForInvalid(java.awt.Color color)
          Colorize error
 void setColorForLineError(java.awt.Color color)
          Colorize a line error
 void setColorForLineSelection(java.awt.Color color)
          Colorize a line selection
 void setColorForLiteral(java.awt.Color color)
          Colorize literal "..."
 void setColorForNameSpace(java.awt.Color color)
          Colorize NameSpace
 void setColorForPrefix(java.lang.String prefix, java.awt.Color c)
          Choose a particular color for this namespace prefix.
 void setColorForTag(java.awt.Color color)
          Colorize tag <Tag...
 void setColorForTag(java.lang.String tag, java.awt.Color c)
          Choose a particular color for this tag.
 void setColorForTagBackground(java.awt.Color color)
          Colorize a tag background
 void setColorForTagBorderLine(java.awt.Color color)
          Colorize the border line for tag delimiter
 void setColorForTagDelimiter(java.awt.Color color)
          Colorize tag delimiter < or >
 void setColorForTagEnd(java.awt.Color color)
          Colorize '/'
 void setColorForTagUnderline(java.awt.Color color)
          Colorize underline for current selection
 void setColorForText(java.awt.Color color)
          Colorize text
 void setEnabledRealTimeStructureChanged(boolean support)
          Notify in real time any tree structure change.
 void setEnabledTreeLocationForCaret(boolean rt)
          Enabled the current tree location for a caret change.
 void setEnabledXPathLocation(boolean enabled)
          Enabled XPath location each time the cursor change.
 void setEntityResolver(XMLEntityResolver resolver)
          Update the current entity resolver, it is useful for traducing char to entity while reading and the contrary when getting the current text
 void setErrorLineRenderer(LineRenderer renderer)
          Reset the renderer for error line.
 void setLineNumber(int num)
          reset the caret to the current line number
 void setSelectionHighlightColor(java.awt.Color selectionHighlightColor)
           
 void setSelectionLineRenderer(LineRenderer renderer)
          Reset the renderer for error line.
 void setText(java.io.InputStream input)
          Note : You must use setText on the XMLContainer rather than on this class Load the text from the inputstream.
 void setText(java.lang.String newText)
          Note : You must use setText on the XMLContainer rather than on this class
 void setUndoManager(javax.swing.undo.UndoManager undo)
          Reset the undo manager
 void setXMLContainer(XMLContainer container)
          Reset the container for this editor
 void setXPathLineRenderer(LineRenderer renderer)
           
 void stopErrorProcessing()
          This is called once after checking the whole document
 void synchronousCurrentLocation(boolean waitTreeSynchro)
          Synchronous action for refreshing the current document location from the caret position
 void undo()
          Undo last action
 void unhighlightLine()
          Remove the highlight of the current line
protected  void updateSelectionState()
           
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getUIClassID, paramString, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, replaceSelection, scrollToReference, setContentType, setEditorKit, setEditorKitForContentType, setPage, setPage
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_locationJobClass

public static java.lang.Class _locationJobClass
Constructor Detail

XMLEditor

public XMLEditor(EditorContext context)
Method Detail

dispose

public void dispose()

addNotify

public void addNotify()
This method will call the init method


select

public void select(int selectionStart,
                   int selectionEnd)
Override of the standard JTextComponent.select Move caret to the start of the selection instead of the end


initOnce

protected void initOnce()
Connect listeners to inner parts. Called by the addNotify method


removeNotify

public void removeNotify()
This method will call the dispose method


getCurrentNodeLocation

public SimpleNode getCurrentNodeLocation()
Returns:
the current document location from the caret position

setXMLContainer

public void setXMLContainer(XMLContainer container)
Reset the container for this editor


getXMLContainer

public XMLContainer getXMLContainer()
Returns:
the container for this editor

getXMLDocument

public XMLDocument getXMLDocument()

getDocument

public javax.swing.text.Document getDocument()

resetDocument

public void resetDocument(XMLDocument doc)

setAutoResetAction

public void setAutoResetAction(boolean reset)
By default to true. This method will enable to reset the ActionModel each time the current editor take the focus. Thus all XMLAction will work with the good one.


isAutoResetAction

public boolean isAutoResetAction()
Returns:
true if a focusGained resets the ActionModel

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Each time the editor take the focus. The actionModel wil be used to active all action on the current editor. User can change this behavior calling setAutoResetAction

Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
For the moment, nothing is done

Specified by:
focusLost in interface java.awt.event.FocusListener

setEnabledRealTimeStructureChanged

public void setEnabledRealTimeStructureChanged(boolean support)
Notify in real time any tree structure change. This is needed for real time tree synchronization


isEnabledRealTimeStructureChanged

public boolean isEnabledRealTimeStructureChanged()
Notify in real time any tree structure change. This is needed for real time tree synchronization


setAutoCloseTag

public void setAutoCloseTag(boolean autoClose)
Insert the closing tag while the user inserts the opening tag : true by default


isAutoCloseTag

public boolean isAutoCloseTag()
Does the closing tag is inserted automatically :true by default


resetDocumentState

public void resetDocumentState(boolean modified)
Only for internal usage. User shouldn't call it or override it


isDocumentModified

public boolean isDocumentModified()
Returns:
true if the current document has been modified once

notifyStructureChanged

public void notifyStructureChanged()
Notify that the structure has changed. This method should only appear in particular case like load a new document ...


paint

public void paint(java.awt.Graphics gc)

initErrorProcessing

public void initErrorProcessing()
Description copied from interface: ErrorListener
This is called once before checking the whole document

Specified by:
initErrorProcessing in interface ErrorListener

notifyError

public void notifyError(java.lang.Object context,
                        boolean localError,
                        java.lang.String sourceLocation,
                        int line,
                        int col,
                        int offset,
                        java.lang.String message,
                        boolean onTheFly)
Description copied from interface: ErrorListener
Notify an XML error found while parsing

Specified by:
notifyError in interface ErrorListener
Parameters:
context - the error context, it can be null and may be ignored
localError - a flag for knowing if the error is inside the current document (sometimes this is inside a DTD or a W3C Schema)
sourceLocation - The document location
line - The error line
col - The error column
offset - The error offset
message - The error message
onTheFly - Flag for informing if this is while the user inserts or no

notifyNoError

public void notifyNoError(boolean onTheFly)
Description copied from interface: ErrorListener
Notify the document is correct

Specified by:
notifyNoError in interface ErrorListener
Parameters:
onTheFly - for informing if this is while inserting characters

stopErrorProcessing

public void stopErrorProcessing()
Description copied from interface: ErrorListener
This is called once after checking the whole document

Specified by:
stopErrorProcessing in interface ErrorListener

errorSelected

public void errorSelected(java.lang.String source,
                          int line,
                          java.lang.String message)
Description copied from interface: ErrorSelectionListener
An error has been selected by the user

Specified by:
errorSelected in interface ErrorSelectionListener
Parameters:
source - The document location
line - The error line
message - The error message

resetDefaultLook

public void resetDefaultLook()
Reset the default color of the editor


getEditorKit

public javax.swing.text.EditorKit getEditorKit()

initKeymap

public void initKeymap()

setAction

public void setAction(javax.swing.KeyStroke key,
                      javax.swing.Action a)

setColorForAttribute

public void setColorForAttribute(java.lang.String attribute,
                                 java.awt.Color c)
Choose a particular color for this attribute. Use a null color for removing it


getColorForAttribute

public java.awt.Color getColorForAttribute(java.lang.String attribute)
Returns:
a custom color for this attribute

hasColorForAttribute

public boolean hasColorForAttribute(java.lang.String attribute)
Returns:
true if a custom color is available for this attribute

setColorForTag

public void setColorForTag(java.lang.String tag,
                           java.awt.Color c)
Choose a particular color for this tag. Use a null color for removing it


getColorForTag

public java.awt.Color getColorForTag(java.lang.String tag)
Returns:
a custom color for this tag

hasColorForTag

public boolean hasColorForTag(java.lang.String tag)
Returns:
true if a custom color is available for this tag

setColorForPrefix

public void setColorForPrefix(java.lang.String prefix,
                              java.awt.Color c)
Choose a particular color for this namespace prefix. Use a null color for removing it


getColorForPrefix

public java.awt.Color getColorForPrefix(java.lang.String prefix)
Returns:
a custom color for this prefix

hasColorForPrefix

public boolean hasColorForPrefix(java.lang.String prefix)
Returns:
true if a custom color exist for this prefix

setBackgroundColorForPrefix

public void setBackgroundColorForPrefix(java.lang.String prefix,
                                        java.awt.Color c)
Choose a particular background color for this namespace prefix. Use a null color for removing it


getBackgroundColorForPrefix

public java.awt.Color getBackgroundColorForPrefix(java.lang.String prefix)
Returns:
a custom background color for this prefix

hasBackgroundColorForPrefix

public boolean hasBackgroundColorForPrefix(java.lang.String prefix)
Returns:
true if a custom background color exist for this prefix

setColorForLineSelection

public void setColorForLineSelection(java.awt.Color color)
Colorize a line selection


setColorForLineError

public void setColorForLineError(java.awt.Color color)
Colorize a line error


setColorForDTDElement

public void setColorForDTDElement(java.awt.Color color)
Colorize !ELEMENT DTD definition


getColorForDTDElement

public java.awt.Color getColorForDTDElement()
Returns:
ELEMENT DTD color

setColorForDTDAttribute

public void setColorForDTDAttribute(java.awt.Color color)
Colorize !ATTRIBUTE DTD definition


getColorForDTDAttribute

public java.awt.Color getColorForDTDAttribute()
Returns:
ATTRIBUTE DTD color

setColorForDTDEntity

public void setColorForDTDEntity(java.awt.Color color)
Colorize !ENTITY DTD definition


getColorForDTDEntity

public java.awt.Color getColorForDTDEntity()
Returns:
ENTITY DTD color

setColorForDTDNotation

public void setColorForDTDNotation(java.awt.Color color)

getColorForDTDNotation

public java.awt.Color getColorForDTDNotation()

setColorForTagBorderLine

public void setColorForTagBorderLine(java.awt.Color color)
Colorize the border line for tag delimiter


getColorForTagBorderLine

public java.awt.Color getColorForTagBorderLine()
Returns:
the color for the border line

setColorForCDATA

public void setColorForCDATA(java.awt.Color color)
Colorize CDATA section


setColorForCDATAStart

public void setColorForCDATAStart(java.awt.Color color)
Color for <![CDATA[[


getColorForCDATAStart

public java.awt.Color getColorForCDATAStart()
Color for <![CDATA[[


setColorForCDATAEnd

public void setColorForCDATAEnd(java.awt.Color color)
Color for ]]>


getColorForCDATAEnd

public java.awt.Color getColorForCDATAEnd()
Color for ]]>


setColorForCDATABackground

public void setColorForCDATABackground(java.awt.Color color)
Colorize CDATA section background


setColorForTagUnderline

public void setColorForTagUnderline(java.awt.Color color)
Colorize underline for current selection


setColorForEntity

public void setColorForEntity(java.awt.Color color)
Colorize entity &ENTITY;


setColorForComment

public void setColorForComment(java.awt.Color color)
Colorize XML comment <!-- ... -->


setColorForCommentStart

public void setColorForCommentStart(java.awt.Color color)
Color for <!--


getColorForCommentStart

public java.awt.Color getColorForCommentStart()
Color for <!--


setColorForCommentEnd

public void setColorForCommentEnd(java.awt.Color color)
Color for --!>


getColorForCommentEnd

public java.awt.Color getColorForCommentEnd()
Color for --!>


setColorForDeclarationStart

public void setColorForDeclarationStart(java.awt.Color color)
Color for <?


getColorForDeclarationStart

public java.awt.Color getColorForDeclarationStart()
Color for <?


setColorForDeclarationEnd

public void setColorForDeclarationEnd(java.awt.Color color)
Color for ?>


getColorForDeclarationEnd

public java.awt.Color getColorForDeclarationEnd()
Color for ?>


setColorForDeclaration

public void setColorForDeclaration(java.awt.Color color)
Colorize XML declaration <? ... ?>


setColorForDocType

public void setColorForDocType(java.awt.Color color)
Colorize DocType declaration <!DOCTYPE ... >


setColorForDocTypeStart

public void setColorForDocTypeStart(java.awt.Color color)
Colorize <!DOCTYPE


getColorForDocTypeStart

public java.awt.Color getColorForDocTypeStart()
Colorize <!DOCTYPE


setColorForDocTypeEnd

public void setColorForDocTypeEnd(java.awt.Color color)
Colorize >


getColorForDocTypeEnd

public java.awt.Color getColorForDocTypeEnd()
Colorize &>


setColorForDocTypeBackground

public void setColorForDocTypeBackground(java.awt.Color color)
Colorize DocType declaration background <!DOCTYPE ... >


setColorForLiteral

public void setColorForLiteral(java.awt.Color color)
Colorize literal "..."


setColorForTag

public void setColorForTag(java.awt.Color color)
Colorize tag <Tag...


setColorForInvalid

public void setColorForInvalid(java.awt.Color color)
Colorize error


setColorForText

public void setColorForText(java.awt.Color color)
Colorize text


setColorForAttribute

public void setColorForAttribute(java.awt.Color color)
Colorize attribute <tag ATTRIBUTE="..." ...


setColorForTagDelimiter

public void setColorForTagDelimiter(java.awt.Color color)
Colorize tag delimiter < or >


setColorForTagBackground

public void setColorForTagBackground(java.awt.Color color)
Colorize a tag background


setColorForDeclarationBackground

public void setColorForDeclarationBackground(java.awt.Color color)
Colorize a declaration background


setColorForEntityBackground

public void setColorForEntityBackground(java.awt.Color color)
Colorize an entity background


setColorForCommentBackground

public void setColorForCommentBackground(java.awt.Color color)
Colorize a comment background


setColorForAttributeSeparator

public void setColorForAttributeSeparator(java.awt.Color color)
Colorize '='


setColorForTagEnd

public void setColorForTagEnd(java.awt.Color color)
Colorize '/'


setColorForNameSpace

public void setColorForNameSpace(java.awt.Color color)
Colorize NameSpace


getColorForLineError

public java.awt.Color getColorForLineError()
Color for a line error


getColorForLineSelection

public java.awt.Color getColorForLineSelection()
Color for a line selection


getColorForCDATA

public java.awt.Color getColorForCDATA()
Color for CDATA section


getColorForCDATABackground

public java.awt.Color getColorForCDATABackground()
Colofr for CDATA Background


getColorForTagUnderline

public java.awt.Color getColorForTagUnderline()
Color for tag underline


getColorForNameSpace

public java.awt.Color getColorForNameSpace()
Colorize NameSpace


getColorForEntity

public java.awt.Color getColorForEntity()
Colorize entity &ENTITY;


getColorForComment

public java.awt.Color getColorForComment()
Colorize XML comment <!-- ... -->


getColorForDeclaration

public java.awt.Color getColorForDeclaration()
Colorize XML declaration <? ... ?>


getColorForDocType

public java.awt.Color getColorForDocType()
Colorize DocType declaration <!DOCTYPE ... >


getColorForDocTypeBackground

public java.awt.Color getColorForDocTypeBackground()
Colorize DocType declaration <!DOCTYPE ... >


getColorForLiteral

public java.awt.Color getColorForLiteral()
Colorize literal "..."


getColorForTag

public java.awt.Color getColorForTag()
Colorize tag <Tag...


getColorForInvalid

public java.awt.Color getColorForInvalid()
Colorize error


getColorForText

public java.awt.Color getColorForText()
Colorize text


getColorForAttribute

public java.awt.Color getColorForAttribute()
Colorize attribute <tag ATTRIBUTE="..." ...


getColorForTagDelimiter

public java.awt.Color getColorForTagDelimiter()
Colorize tag delimiter < or >


getColorForTagBackground

public java.awt.Color getColorForTagBackground()
Returns:
the color for the tag background

getColorForDeclarationBackground

public java.awt.Color getColorForDeclarationBackground()
Returns:
the color for a tag backgrond

getColorForEntityBackground

public java.awt.Color getColorForEntityBackground()
Returns:
the color for an entity background

getColorCommentBackground

public java.awt.Color getColorCommentBackground()
Returns:
the color for a comment bakground

getColorForAttributeSeparator

public java.awt.Color getColorForAttributeSeparator()
Colorize '='


getColorForTagEnd

public java.awt.Color getColorForTagEnd()
Colorize '/'


setUndoManager

public void setUndoManager(javax.swing.undo.UndoManager undo)
Reset the undo manager


getUndoManager

public javax.swing.undo.UndoManager getUndoManager()
Returns:
the current undo manager

undo

public void undo()
Undo last action


redo

public void redo()
Redo last action


setEntityResolver

public void setEntityResolver(XMLEntityResolver resolver)
Update the current entity resolver, it is useful for traducing char to entity while reading and the contrary when getting the current text


getEntityResolver

public XMLEntityResolver getEntityResolver()
Returns:
the current entity resolver

setText

public void setText(java.io.InputStream input)
             throws java.io.IOException
Note : You must use setText on the XMLContainer rather than on this class Load the text from the inputstream. The stream is closed after reading

Throws:
java.io.IOException

setText

public void setText(java.lang.String newText)
Note : You must use setText on the XMLContainer rather than on this class


getText

public java.lang.String getText(int from)
Returns:
a text starting from

getText

public java.lang.String getText()
Returns:
the current text

setLineNumber

public void setLineNumber(int num)
reset the caret to the current line number


insertText

public void insertText(java.lang.String text)
Insert a string at the current caret location


createDefaultEditorKit

public javax.swing.text.EditorKit createDefaultEditorKit()
Returns:
the current editor kit

unhighlightLine

public void unhighlightLine()
Remove the highlight of the current line


getLineStart

public int getLineStart(int caret)
Returns:
the start of the line for the caret position

getLineEnd

public int getLineEnd(int caret)
Returns:
the end of the line for the caret position

asynchronousHighlightLine

public void asynchronousHighlightLine(int line)
Highlight the line with an invokeLater


highlightLine

public void highlightLine(int line)
Highlight the line with the "selectionColor" property


removeHighlightedErrorLine

public void removeHighlightedErrorLine()
Remove error line


removeHighlightedLines

public void removeHighlightedLines()
Remove all highlighted lines


highlightNodes

public void highlightNodes(java.util.List list)
Highlight the following list of node : SimpleNode


highlightErrorLine

public void highlightErrorLine(int line)
Show the error line without auto scrolling


highlightErrorLine

public void highlightErrorLine(int lineStart,
                               boolean autoScroll)
Show the error line

Parameters:
lineStart - error line
autoScroll - if true it will scroll to the good line

setEnabledTreeLocationForCaret

public void setEnabledTreeLocationForCaret(boolean rt)
Enabled the current tree location for a caret change. This feature can reduce the velocity. So it should be disabled for heavy XML document


isEnabledTreeLocationForCaret

public boolean isEnabledTreeLocationForCaret()
Is Enabled the current tree location for a caret change ?. True by default


updateSelectionState

protected void updateSelectionState()

setEnabledXPathLocation

public void setEnabledXPathLocation(boolean enabled)
Enabled XPath location each time the cursor change. By default true


isEnabledXPathLocation

public boolean isEnabledXPathLocation()
Returns:
true if the xpath location is available on caret changes

notifyCurrentLocation

public void notifyCurrentLocation()
Notify to listener the current document location from the caret position. Note that this method shouldn't be called because this is done for caret changes and this is asynchronous. For instant action call rather reforceCurrentLocation


notifyCaretLocation

public void notifyCaretLocation()

synchronousCurrentLocation

public void synchronousCurrentLocation(boolean waitTreeSynchro)
Synchronous action for refreshing the current document location from the caret position

Parameters:
waitTreeSynchro - if true, the current thread will wait for a good text/tree synchro

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent e)
Structure computing

Specified by:
caretUpdate in interface javax.swing.event.CaretListener

setCaretPositionWithoutNotification

public boolean setCaretPositionWithoutNotification(int caret)
Reset the caret location without updating the current tree location

Returns:
true when the operation is correct

setErrorLineRenderer

public void setErrorLineRenderer(LineRenderer renderer)
Reset the renderer for error line. This invokation should be done inside the Look step


setXPathLineRenderer

public void setXPathLineRenderer(LineRenderer renderer)

setSelectionLineRenderer

public void setSelectionLineRenderer(LineRenderer renderer)
Reset the renderer for error line. This invokation should be done inside the Look step


getSelectionHighlightColor

public java.awt.Color getSelectionHighlightColor()
Returns:
the highlight color

setSelectionHighlightColor

public void setSelectionHighlightColor(java.awt.Color selectionHighlightColor)
Parameters:
selectionHighlightColor - Reset the highlight line color


Copyright © 2006 JAPISoft. All Rights Reserved.