org.merlotxml.merlot
Class GenericDOMEditPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.merlotxml.merlot.GenericDOMEditPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, MerlotConstants, java.io.Serializable
Direct Known Subclasses:
CommentEditPanel, ProcInstructionEditPanel, TextEditPanel

public class GenericDOMEditPanel
extends javax.swing.JPanel
implements MerlotConstants

This is a generic node editing panel which provides a component for each attribute listed with the element it's created to edit, along with a text box for PCDATA.

This class can be extended to change what the user sees for each attribute field. Typically the easiest methods to overload for this type of custom editors are getEditComponent() and sometimes save().

Author:
Kelly Campbell
See Also:
Serialized Form

Nested Class Summary
 class GenericDOMEditPanel.GenericComponent
           
static class GenericDOMEditPanel.ScrollablePanel
           
protected  class GenericDOMEditPanel.StandardAttributeChecker
          Checks attributes according to their type.
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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
protected  java.util.Hashtable _attrComponents
          Map of attribute names to attribute components (key is String, val is JComponent)
protected  java.util.Hashtable _dtd_attributes
          Map of attribute names to their DTDAttribute declaration
protected  MerlotDOMNode _node
          The node this editor was created for
protected  org.w3c.dom.NamedNodeMap _node_attributes
          The attributes and their values from this node
protected  javax.swing.JComponent _prev
           
protected static java.util.Hashtable _readonlyAttrs
          Similar to the hidable attributes, except these are displayed, but can't be changed
protected static javax.swing.Icon _requiredAttrIcon
          The icon to use for required attribute labels
protected  MerlotDOMText _subtext
          A node which is the child #text element for this node
protected  javax.swing.JTextField _target
           
protected  javax.swing.JTextArea _text
           
static int ALIGN_BOTTOM
           
static int ALIGN_MIDDLE
           
static int ALIGN_TOP
           
static boolean NAMESPACES
           
 
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 org.merlotxml.merlot.MerlotConstants
ACTION_MENU_ACCELERATOR, ACTION_MENU_ICON, ACTION_NAME, ACTION_SHORT_DESCRIPTION, ACTION_SMALL_ICON, AFTER, BEFORE, ERR, INTO, UI, XML
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GenericDOMEditPanel()
           
GenericDOMEditPanel(MerlotDOMNode node)
           
 
Method Summary
protected  void addAttribute(DTDAttribute a)
           
protected  void addAttributeComponent(javax.swing.JLabel l, javax.swing.JComponent c, int align)
           
protected  void addTextPanel()
          Add a text editing panel if required
 void addVetoableChangeListener(java.beans.VetoableChangeListener l)
           
protected  void buildPanel()
           
static char checkIdChars(java.lang.String id)
          Check to see if a string is a valid ID according to [5] in the XML 1.0 Recommendation
static char checkNCNameChars(java.lang.String ncName)
          Check to see if a string is a valid NCName according to [4] from the XML Namespaces 1.0 Recommendation
static char checkNmtokenChars(java.lang.String nmtoken)
          Check to see if a string is a valid Nmtoken according to [7] in the XML 1.0 Recommendation
 void fireVetoableChange(java.beans.PropertyChangeEvent evt)
           
protected  java.lang.String getDisplayTextForAttribute(MerlotDOMNode idRefNode, java.lang.String idRefAttrName, MerlotDOMNode idNode, java.lang.String idAttrName)
          Returns the text which represents the referenced node in an IDREF comboBox
protected  javax.swing.JComponent getEditComponent(DTDAttribute attr)
          Create a component based on the attribute type, and get the default from the node, or if the node doesn't have it set, get the default value from the attribute definition itself
protected  FieldNode getFieldNode(GrammarSimpleType simpleType)
           
protected  javax.swing.JComponent getIdComponent(MerlotDOMNode node, java.lang.String attrName)
          Returns a component aimed at editing the ID attribute from a DOM node.
 java.lang.String getIdForNode(MerlotDOMNode node)
           
protected  IDManager getIdManager()
           
protected  javax.swing.JComponent getIdRefComponent(MerlotDOMNode targetNode, java.lang.String targetAttrName)
          Returns a component aimed at editing the IDREF attribute from a DOM node.
protected  javax.swing.JComponent getIdRefsComponent(DTDAttribute attr)
           
protected  javax.swing.JComponent getNmtokensComponent(DTDAttribute attr)
          Gets the nmtokensComponent attribute of the GenericDOMEditPanel object
protected  javax.swing.Icon getRequiredAttrIcon()
           
 void grabFocus()
           
 boolean IdAttributesAreCompatible(MerlotDOMNode idRefNode, java.lang.String idRefAttrName, MerlotDOMNode IdNode, java.lang.String idAttrName)
          Returns whether or not the value of an ID attribute can be used as a value of a target IDREF attribute.
protected  void init()
           
protected  void initPanelLayout()
           
 void removeVetoableChangeListener(java.beans.VetoableChangeListener l)
           
 void save()
          Saves any changes back to the DOM
protected  void save(java.util.HashMap attributes)
           
protected  void setupHideTable()
           
protected  void setupPanel()
           
protected  void setupReadonlyTable()
           
protected  boolean suppressAttribute(DTDAttribute a)
          returns true if the attribute doesn't show in the editor display
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, 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, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, 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, addInputMethodListener, 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, getInputMethodRequests, 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, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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

ALIGN_TOP

public static final int ALIGN_TOP
See Also:
Constant Field Values

ALIGN_MIDDLE

public static final int ALIGN_MIDDLE
See Also:
Constant Field Values

ALIGN_BOTTOM

public static final int ALIGN_BOTTOM
See Also:
Constant Field Values

NAMESPACES

public static final boolean NAMESPACES
See Also:
Constant Field Values

_requiredAttrIcon

protected static javax.swing.Icon _requiredAttrIcon
The icon to use for required attribute labels


_node

protected MerlotDOMNode _node
The node this editor was created for


_subtext

protected MerlotDOMText _subtext
A node which is the child #text element for this node


_node_attributes

protected org.w3c.dom.NamedNodeMap _node_attributes
The attributes and their values from this node


_dtd_attributes

protected java.util.Hashtable _dtd_attributes
Map of attribute names to their DTDAttribute declaration


_attrComponents

protected java.util.Hashtable _attrComponents
Map of attribute names to attribute components (key is String, val is JComponent)


_prev

protected javax.swing.JComponent _prev

_text

protected javax.swing.JTextArea _text

_target

protected javax.swing.JTextField _target

_readonlyAttrs

protected static java.util.Hashtable _readonlyAttrs
Similar to the hidable attributes, except these are displayed, but can't be changed

Constructor Detail

GenericDOMEditPanel

public GenericDOMEditPanel()

GenericDOMEditPanel

public GenericDOMEditPanel(MerlotDOMNode node)
Method Detail

buildPanel

protected void buildPanel()

init

protected void init()

initPanelLayout

protected void initPanelLayout()

setupPanel

protected void setupPanel()

addTextPanel

protected void addTextPanel()
Add a text editing panel if required


suppressAttribute

protected boolean suppressAttribute(DTDAttribute a)
returns true if the attribute doesn't show in the editor display


setupHideTable

protected void setupHideTable()

setupReadonlyTable

protected void setupReadonlyTable()

addAttribute

protected void addAttribute(DTDAttribute a)

getRequiredAttrIcon

protected javax.swing.Icon getRequiredAttrIcon()

addAttributeComponent

protected void addAttributeComponent(javax.swing.JLabel l,
                                     javax.swing.JComponent c,
                                     int align)

getEditComponent

protected javax.swing.JComponent getEditComponent(DTDAttribute attr)
Create a component based on the attribute type, and get the default from the node, or if the node doesn't have it set, get the default value from the attribute definition itself


save

public void save()
          throws java.beans.PropertyVetoException
Saves any changes back to the DOM

Throws:
java.beans.PropertyVetoException

save

protected void save(java.util.HashMap attributes)
             throws java.beans.PropertyVetoException
Throws:
java.beans.PropertyVetoException

grabFocus

public void grabFocus()

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener l)

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener l)

fireVetoableChange

public void fireVetoableChange(java.beans.PropertyChangeEvent evt)
                        throws java.beans.PropertyVetoException
Throws:
java.beans.PropertyVetoException

getIdManager

protected IDManager getIdManager()

getIdComponent

protected javax.swing.JComponent getIdComponent(MerlotDOMNode node,
                                                java.lang.String attrName)
Returns a component aimed at editing the ID attribute from a DOM node.

Parameters:
node - the node for which to generate the ID editing component
attrName - the name of the ID attribute for which to generate the ID editing component

getIdRefComponent

protected javax.swing.JComponent getIdRefComponent(MerlotDOMNode targetNode,
                                                   java.lang.String targetAttrName)
Returns a component aimed at editing the IDREF attribute from a DOM node.


getIdRefsComponent

protected javax.swing.JComponent getIdRefsComponent(DTDAttribute attr)

getNmtokensComponent

protected javax.swing.JComponent getNmtokensComponent(DTDAttribute attr)
Gets the nmtokensComponent attribute of the GenericDOMEditPanel object

Parameters:
attr - Description of the Parameter
Returns:
The nmtokensComponent value

getIdForNode

public java.lang.String getIdForNode(MerlotDOMNode node)

IdAttributesAreCompatible

public boolean IdAttributesAreCompatible(MerlotDOMNode idRefNode,
                                         java.lang.String idRefAttrName,
                                         MerlotDOMNode IdNode,
                                         java.lang.String idAttrName)
Returns whether or not the value of an ID attribute can be used as a value of a target IDREF attribute. By default in XML 1.0 specification, all ID values can be used for IDREFs. This decision can be constrained by subclassing this method.

Parameters:
idRefNode - node containing the IDREF attribute
idRefAttrName - name of the IDREF attribute
idAttrName - name of the ID attribute

getDisplayTextForAttribute

protected java.lang.String getDisplayTextForAttribute(MerlotDOMNode idRefNode,
                                                      java.lang.String idRefAttrName,
                                                      MerlotDOMNode idNode,
                                                      java.lang.String idAttrName)
Returns the text which represents the referenced node in an IDREF comboBox


checkNmtokenChars

public static char checkNmtokenChars(java.lang.String nmtoken)
Check to see if a string is a valid Nmtoken according to [7] in the XML 1.0 Recommendation

Parameters:
nmtoken - string to checj
Returns:
the first invalid char or 0

checkNCNameChars

public static char checkNCNameChars(java.lang.String ncName)
Check to see if a string is a valid NCName according to [4] from the XML Namespaces 1.0 Recommendation

Returns:
true if name is a valid NCName

checkIdChars

public static char checkIdChars(java.lang.String id)
Check to see if a string is a valid ID according to [5] in the XML 1.0 Recommendation

Returns:
the first invalid char or 0

getFieldNode

protected FieldNode getFieldNode(GrammarSimpleType simpleType)