oracle.xml.srcviewer
Class XMLSourceView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--oracle.xml.srcviewer.XMLSourceView

public class XMLSourceView
extends javax.swing.JPanel
implements java.io.Serializable

Shows an XML document. Recognizes the following XML token types: Tag, Attribute Name, Attribute Value, Comment, CDATA, PCDATA, PI Data, PI Name and NOTATION Symbol. Each token type has a foreground color and font. The default color/font settings can be changed by the user. Takes as input an org.w3c.dom.Document object.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  Document inputDOMDocument
           
protected  javax.swing.JScrollPane jScrollPane
           
protected  javax.swing.JTextPane jTextPane
           
protected  oracle.xml.srcviewer.XMLStyledDocument xmlStyledDocument
           
 
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
 
Constructor Summary
XMLSourceView()
          The class constructor.
 
Method Summary
static java.awt.Font fontGet(javax.swing.text.AttributeSet attributeset)
          Extracts and returns the font from a given attributeset.
static void fontSet(javax.swing.text.MutableAttributeSet mutableattributeset, java.awt.Font font)
          Sets the mutableattributeset font.
 java.awt.Font getAttributeNameFont()
          Returns the Attribute Value font.
 java.awt.Color getAttributeNameForeground()
          Returns the Attribute Name foreground color.
 java.awt.Font getAttributeValueFont()
          Returns the Attribute Value font.
 java.awt.Color getAttributeValueForeground()
          Returns the Attribute Value foreground color.
 java.awt.Color getBackground()
          Returns the background color.
 java.awt.Font getCDATAFont()
          Returns the CDATA font.
 java.awt.Color getCDATAForeground()
          Returns the CDATA foreground color.
 java.awt.Font getCommentDataFont()
          Returns the Comment Data font.
 java.awt.Color getCommentDataForeground()
          Returns the Comment Data foreground color.
 java.awt.Font getDTDFont()
          Returns the DTD reference font.
 java.awt.Color getDTDForeground()
          Returns the DTD reference foreground color.
 java.awt.Font getDTDInternalFont()
          Returns the internal DTD font.
 java.awt.Color getDTDInternalForeground()
          Returns the internal DTD reference foreground color.
 java.lang.String getEditedText()
          Returns the edited text.
 javax.swing.JTextPane getJTextPane()
          Returns the viewer JTextPane component.
 java.awt.Dimension getMinimumSize()
          Returns the XMLSourceView minimal size.
 Node getNodeAtOffset(int i)
          Returns the XML node at a given offset.
 java.awt.Font getPCDATAFont()
          Returns the PCDATA font.
 java.awt.Color getPCDATAForeground()
          Returns the PCDATA foreground color.
 java.awt.Font getPIDataFont()
          Returns the PI Data font.
 java.awt.Color getPIDataForeground()
          Returns the PI Data foreground color.
 java.awt.Font getPINameFont()
          Returns the PI Name font.
 java.awt.Color getPINameForeground()
          Returns the PI Data foreground color.
 java.awt.Font getSymbolFont()
          Returns the NOTATION Symbol font.
 java.awt.Color getSymbolForeground()
          Returns the NOTATION Symbol foreground color.
 java.awt.Font getTagFont()
          Returns the Tag font.
 java.awt.Color getTagForeground()
          Returns the Tag foreground color.
 java.lang.String getText()
          Returns the XML document as a String.
 boolean isEditable()
          Returns boolean to indicate whether this object is editable.
 void selectNodeAt(int i)
          Moves the cursor to XML Node at offset i.
 void setAttributeNameFont(java.awt.Font font)
          Sets the Attribute Name font.
 void setAttributeNameForeground(java.awt.Color color)
          Sets the Attribute Name foreground color.
 void setAttributeValueFont(java.awt.Font font)
          Sets the Attribute Value font.
 void setAttributeValueForeground(java.awt.Color color)
          Sets the Attribute Value foreground color.
 void setBackground(java.awt.Color color)
          Sets the background color.
 void setCDATAFont(java.awt.Font font)
          Sets the CDATA font.
 void setCDATAForeground(java.awt.Color color)
          Sets the CDATA foreground color.
 void setCommentDataFont(java.awt.Font font)
          Sets the Comment font.
 void setCommentDataForeground(java.awt.Color color)
          Sets the Comment foreground color.
 void setDTDFont(java.awt.Font font)
          Sets the DTD reference font.
 void setDTDForeground(java.awt.Color color)
          Sets the DTD reference foreground color.
 void setDTDInternalFont(java.awt.Font font)
          Sets the internal DTD font.
 void setDTDInternalForeground(java.awt.Color color)
          Sets the internal DTD foreground color.
 void setEditable(boolean edit)
          Sets the specified boolean to indicate whether this object should be editable.
 void setPCDATAFont(java.awt.Font font)
          Sets the PCDATA font.
 void setPCDATAForeground(java.awt.Color color)
          Sets the PCDATA foreground color.
 void setPIDataFont(java.awt.Font font)
          Sets the PI Data font.
 void setPIDataForeground(java.awt.Color color)
          Sets the PI Data foreground color.
 void setPINameFont(java.awt.Font font)
          Sets the PI Name font.
 void setPINameForeground(java.awt.Color color)
          Sets the PI Name foreground color.
 void setSelectedNode(Node node)
          Sets the cursor position at the selected XML node.
 void setSymbolFont(java.awt.Font font)
          Sets the NOTATION Symbol font.
 void setSymbolForeground(java.awt.Color color)
          Sets the NOTATION Symbol foreground color.
 void setTagFont(java.awt.Font font)
          Sets the Tag font.
 void setTagForeground(java.awt.Color color)
          Sets the Tag foreground color.
 void setXMLDocument(Document document)
          Associates the XMLviewer with a XML document.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

jTextPane

protected javax.swing.JTextPane jTextPane

jScrollPane

protected javax.swing.JScrollPane jScrollPane

inputDOMDocument

protected Document inputDOMDocument

xmlStyledDocument

protected oracle.xml.srcviewer.XMLStyledDocument xmlStyledDocument
Constructor Detail

XMLSourceView

public XMLSourceView()
The class constructor. Creates an object of type XMLSourceView.
Method Detail

getAttributeNameFont

public java.awt.Font getAttributeNameFont()
Returns the Attribute Value font.
Returns:
The Font object.

getAttributeNameForeground

public java.awt.Color getAttributeNameForeground()
Returns the Attribute Name foreground color.
Returns:
The Color object.

getAttributeValueFont

public java.awt.Font getAttributeValueFont()
Returns the Attribute Value font.
Returns:
The Font object.

getAttributeValueForeground

public java.awt.Color getAttributeValueForeground()
Returns the Attribute Value foreground color.
Returns:
The Color object.

getBackground

public java.awt.Color getBackground()
Returns the background color.
Overrides:
getBackground in class java.awt.Component
Returns:
The Color object.

getCDATAFont

public java.awt.Font getCDATAFont()
Returns the CDATA font.
Returns:
The Font object.

getCDATAForeground

public java.awt.Color getCDATAForeground()
Returns the CDATA foreground color.
Returns:
The Color object.

getCommentDataFont

public java.awt.Font getCommentDataFont()
Returns the Comment Data font.
Returns:
The Font object.

getCommentDataForeground

public java.awt.Color getCommentDataForeground()
Returns the Comment Data foreground color.
Returns:
The Color object.

getJTextPane

public javax.swing.JTextPane getJTextPane()
Returns the viewer JTextPane component.
Returns:
The JTextPane object used by XMLSourceViewer

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the XMLSourceView minimal size.
Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
The Dimension object containing the XMLSourceView minimum size.

getNodeAtOffset

public Node getNodeAtOffset(int i)
                     throws javax.swing.text.BadLocationException
Returns the XML node at a given offset.
Parameters:
i - The node offset.
Returns:
The Node object from offset i.

getPCDATAFont

public java.awt.Font getPCDATAFont()
Returns the PCDATA font.
Returns:
The Font object.

getPCDATAForeground

public java.awt.Color getPCDATAForeground()
Returns the PCDATA foreground color.
Returns:
The Color object.

getPIDataFont

public java.awt.Font getPIDataFont()
Returns the PI Data font.
Returns:
The Font object

getPIDataForeground

public java.awt.Color getPIDataForeground()
Returns the PI Data foreground color.
Returns:
The Color object.

getPINameFont

public java.awt.Font getPINameFont()
Returns the PI Name font.
Returns:
The Font object.

getPINameForeground

public java.awt.Color getPINameForeground()
Returns the PI Data foreground color.
Returns:
The Color object.

getText

public java.lang.String getText()
Returns the XML document as a String.
Returns:
The String object containing the XML document.

getEditedText

public java.lang.String getEditedText()
Returns the edited text.
Returns:
The String object containing the edited text.

getSymbolFont

public java.awt.Font getSymbolFont()
Returns the NOTATION Symbol font.
Returns:
The Font object.

getSymbolForeground

public java.awt.Color getSymbolForeground()
Returns the NOTATION Symbol foreground color.
Returns:
The Color object.

getTagFont

public java.awt.Font getTagFont()
Returns the Tag font.
Returns:
The Font object.

getTagForeground

public java.awt.Color getTagForeground()
Returns the Tag foreground color.
Returns:
The Color object.

getDTDFont

public java.awt.Font getDTDFont()
Returns the DTD reference font.
Returns:
The Font object.

getDTDForeground

public java.awt.Color getDTDForeground()
Returns the DTD reference foreground color.
Returns:
The Color object.

getDTDInternalFont

public java.awt.Font getDTDInternalFont()
Returns the internal DTD font.
Returns:
The Font object.

getDTDInternalForeground

public java.awt.Color getDTDInternalForeground()
Returns the internal DTD reference foreground color.
Returns:
The Color object.

selectNodeAt

public void selectNodeAt(int i)
                  throws javax.swing.text.BadLocationException
Moves the cursor to XML Node at offset i.
Parameters:
i - The node offset.

setAttributeNameFont

public void setAttributeNameFont(java.awt.Font font)
                          throws java.lang.IllegalArgumentException
Sets the Attribute Name font.
Parameters:
font - The new Font for Attribute Name.

setAttributeNameForeground

public void setAttributeNameForeground(java.awt.Color color)
                                throws java.lang.IllegalArgumentException
Sets the Attribute Name foreground color.
Parameters:
color - The new Color for Attribute Name.

setAttributeValueFont

public void setAttributeValueFont(java.awt.Font font)
                           throws java.lang.IllegalArgumentException
Sets the Attribute Value font.
Parameters:
font - The new Font for Attribute Value.

setAttributeValueForeground

public void setAttributeValueForeground(java.awt.Color color)
                                 throws java.lang.IllegalArgumentException
Sets the Attribute Value foreground color.
Parameters:
color - The new Color for Attribute Value.

setBackground

public void setBackground(java.awt.Color color)
Sets the background color.
Overrides:
setBackground in class javax.swing.JComponent
Parameters:
color - The new background Color.

setCDATAFont

public void setCDATAFont(java.awt.Font font)
                  throws java.lang.IllegalArgumentException
Sets the CDATA font.
Parameters:
font - The new Font for CDATA.

setCDATAForeground

public void setCDATAForeground(java.awt.Color color)
                        throws java.lang.IllegalArgumentException
Sets the CDATA foreground color.
Parameters:
color - The new Color for CDATA.

setCommentDataFont

public void setCommentDataFont(java.awt.Font font)
                        throws java.lang.IllegalArgumentException
Sets the Comment font.
Parameters:
font - The new Font for the XML Comments.

setCommentDataForeground

public void setCommentDataForeground(java.awt.Color color)
                              throws java.lang.IllegalArgumentException
Sets the Comment foreground color.
Parameters:
color - The new Color for Comment.

setEditable

public void setEditable(boolean edit)
Sets the specified boolean to indicate whether this object should be editable.
Parameters:
doc - The new boolean value.

isEditable

public boolean isEditable()
Returns boolean to indicate whether this object is editable.

setXMLDocument

public void setXMLDocument(Document document)
Associates the XMLviewer with a XML document.
Parameters:
doc - The Document document to display.
See Also:
getText()

setPCDATAFont

public void setPCDATAFont(java.awt.Font font)
                   throws java.lang.IllegalArgumentException
Sets the PCDATA font.
Parameters:
font - The new Font for PCDATA.

setPCDATAForeground

public void setPCDATAForeground(java.awt.Color color)
                         throws java.lang.IllegalArgumentException
Sets the PCDATA foreground color.
Parameters:
color - The new Color for PCDATA.

setPIDataFont

public void setPIDataFont(java.awt.Font font)
                   throws java.lang.IllegalArgumentException
Sets the PI Data font.
Parameters:
font - The new Font for PI Data.

setPIDataForeground

public void setPIDataForeground(java.awt.Color color)
                         throws java.lang.IllegalArgumentException
Sets the PI Data foreground color.
Parameters:
color - The new Color for PI Data.

setPINameFont

public void setPINameFont(java.awt.Font font)
                   throws java.lang.IllegalArgumentException
Sets the PI Name font.
Parameters:
font - The new Font for the PI Names.

setPINameForeground

public void setPINameForeground(java.awt.Color color)
                         throws java.lang.IllegalArgumentException
Sets the PI Name foreground color.
Parameters:
color - The new Color for PI Name.

setSelectedNode

public void setSelectedNode(Node node)
Sets the cursor position at the selected XML node.
Parameters:
node - The selected node.

setSymbolFont

public void setSymbolFont(java.awt.Font font)
                   throws java.lang.IllegalArgumentException
Sets the NOTATION Symbol font.
Parameters:
color - The new Font for NOTATION Symbol.

setSymbolForeground

public void setSymbolForeground(java.awt.Color color)
                         throws java.lang.IllegalArgumentException
Sets the NOTATION Symbol foreground color.
Parameters:
color - The new Color for NOTATION Symbol.

setTagFont

public void setTagFont(java.awt.Font font)
                throws java.lang.IllegalArgumentException
Sets the Tag font.
Parameters:
font - The new Font for the XML Tags.

setTagForeground

public void setTagForeground(java.awt.Color color)
                      throws java.lang.IllegalArgumentException
Sets the Tag foreground color.
Parameters:
color - The new Color for the XML Tags.

setDTDFont

public void setDTDFont(java.awt.Font font)
                throws java.lang.IllegalArgumentException
Sets the DTD reference font.
Parameters:
font - The new Font for the XML Tags.

setDTDForeground

public void setDTDForeground(java.awt.Color color)
                      throws java.lang.IllegalArgumentException
Sets the DTD reference foreground color.
Parameters:
color - The new Color for the XML Tags.

setDTDInternalFont

public void setDTDInternalFont(java.awt.Font font)
                        throws java.lang.IllegalArgumentException
Sets the internal DTD font.
Parameters:
font - The new Font for the XML Tags.

setDTDInternalForeground

public void setDTDInternalForeground(java.awt.Color color)
                              throws java.lang.IllegalArgumentException
Sets the internal DTD foreground color.
Parameters:
color - The new Color for the XML Tags.

fontGet

public static java.awt.Font fontGet(javax.swing.text.AttributeSet attributeset)
Extracts and returns the font from a given attributeset.
Parameters:
attributeset - The source Attributeset.
Returns:
The extracted Font.

fontSet

public static void fontSet(javax.swing.text.MutableAttributeSet mutableattributeset,
                           java.awt.Font font)
Sets the mutableattributeset font.
Parameters:
mutableattributeset - The mutableattributeset to update.
font - The new Font for the mutableattributeset.


 

Copyright © 1997, 2004, Oracle. All rights reserved.