org.ceryle.ui
Class FormPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.ceryle.ui.FormPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FormPanel
extends JPanel

Provided with an XML document as a form template, generates a JPanel form that can be queried for its content as an XML document which fills out the template.

Since:
JDK1.4
Version:
$Id: FormPanel.java,v 3.27 2007-06-20 01:28:16 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
 class FormPanel.DialogDisposer
           
protected  class FormPanel.FormFieldPanel
          A subclass of JPanel providing a form component containing a field title, editable field or text area, and optionally a pair of control buttons to allow addition of similar fields to the form layout.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static boolean autoBibRef
          When true, updates an empty biblio ref field from the author and year fields.
static int DEFAULT_COLUMN_WIDTH
          The default column width (in characters) for text fields.
static int DEFAULT_LABEL_WIDTH
          The default width (in pixels) for field labels.
static String defImgExt
          The file extension for the default image format ("gif").
protected  Document doc
          The DOM Document used to generate and contain form information.
static int FIELD_BROWSE
          A constant indicating that the link reference should be changed.
static int FIELD_CLONE
          A constant indicating that a field should be cloned and added to the panel.
static int FIELD_GO
          A constant indicating that a link should be traversed.
static int FIELD_REMOVE
          A constant indicating that a field should be removed from the panel.
protected  Element root
          The DOM Element serving as the Document root (or "document element").
 
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
FormPanel(Object o, Element root, String cid, String nid)
          Constructor for form panel, provided with a reference to its parent and the root element of an XML document providing its specifications.
 
Method Summary
static boolean disallowedNodeID(String nid)
          Returns true if the supplied node ID is disallowed (by being either the template ID or starting with an underscore).
protected  void dispose()
          If the parent dialog has been set non-null, this assumes it is a JDialog (or extension) and calls its dispose() method.
protected  void editPanel(FormPanel.FormFieldPanel ffp, int action)
          Called when a "+" or "-" button next to a form field panel ffp is activated, indicating either the cloning or removal of a field.
protected  int getNextId()
          Returns a unique ID (simply an incremental counter).
 XNodeID getStoredXNodeID()
          If an XNode has been written, this will return an XNodeID corresponding to the Collection and Node IDs, null otherwise.
protected  int getTotalFieldHeight()
          Return total height of form fields, not including the space between.
protected  void link(FormPanel.FormFieldPanel ffp, int action)
          Called when either of the "Browse..." or "Go" buttons next to a form field panel ffp are activated, indicating either the browsing for a new URL or traversing the existing link.
 boolean setFormFieldContent(Element elt, String type, String content)
          Scans the provided Element (which is expected to be an XHTML-based form), setting the character data value of the first-encountered <p> element having a class attributes whose value is type.
 boolean setFormResult()
          Processes the form content based upon the current dialog contents, building an XML document within a StringBuffer.
 boolean setFormTitle(Element elt, String content)
          Sets the content of the <title> element of the XHTML document backing up the form.
 boolean setNID(String nid, boolean strict)
          Sets the content of the Node ID field, checking to be sure that it is a valid XML Name if strict is true.
protected  void setPreferredWidth(int width)
          Sets preferred sizes of the form and wrapper panes based on the supplied width.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

autoBibRef

public static boolean autoBibRef
When true, updates an empty biblio ref field from the author and year fields. Default is true.


DEFAULT_COLUMN_WIDTH

public static int DEFAULT_COLUMN_WIDTH
The default column width (in characters) for text fields.


DEFAULT_LABEL_WIDTH

public static int DEFAULT_LABEL_WIDTH
The default width (in pixels) for field labels.


FIELD_CLONE

public static final int FIELD_CLONE
A constant indicating that a field should be cloned and added to the panel.

See Also:
Constant Field Values

FIELD_REMOVE

public static final int FIELD_REMOVE
A constant indicating that a field should be removed from the panel.

See Also:
Constant Field Values

FIELD_BROWSE

public static final int FIELD_BROWSE
A constant indicating that the link reference should be changed.

See Also:
Constant Field Values

FIELD_GO

public static final int FIELD_GO
A constant indicating that a link should be traversed.

See Also:
Constant Field Values

defImgExt

public static String defImgExt
The file extension for the default image format ("gif").


doc

protected Document doc
The DOM Document used to generate and contain form information. If the form template is derived from an XNode, this will be its xnode:Envelope element, not the original source Document.


root

protected Element root
The DOM Element serving as the Document root (or "document element").

Constructor Detail

FormPanel

public FormPanel(Object o,
                 Element root,
                 String cid,
                 String nid)
          throws DocumentException,
                 ProcessException
Constructor for form panel, provided with a reference to its parent and the root element of an XML document providing its specifications. Will set the size and location according to the provided Dimension size and location respectively. If either are null, default size and upper-center placement will be used. The Strings cid and nid are respectively the Collection and Node ID of the dialog source.

Parameters:
o - the optional parent Object: either a FormDialog or a DocumentView
root - the root of the form document
cid - the collection ID of the source record
nid - the node ID of the source record
Throws:
DocumentException - when unable to generate a form from the provided content
ProcessException - when an error occurs during either generation or processing of the form
Method Detail

disallowedNodeID

public static boolean disallowedNodeID(String nid)
Returns true if the supplied node ID is disallowed (by being either the template ID or starting with an underscore).


setNID

public boolean setNID(String nid,
                      boolean strict)
Sets the content of the Node ID field, checking to be sure that it is a valid XML Name if strict is true. If the String nid is null and strict is false, the field is set to an empty string.

Returns:
true iff the ID is valid and strict is true

setFormResult

public boolean setFormResult()
Processes the form content based upon the current dialog contents, building an XML document within a StringBuffer. This is written directly to the database upon confirmation.

Returns:
true if the form is empty or it is written successfully

getStoredXNodeID

public XNodeID getStoredXNodeID()
If an XNode has been written, this will return an XNodeID corresponding to the Collection and Node IDs, null otherwise.


setFormTitle

public boolean setFormTitle(Element elt,
                            String content)
Sets the content of the <title> element of the XHTML document backing up the form.


setFormFieldContent

public boolean setFormFieldContent(Element elt,
                                   String type,
                                   String content)
Scans the provided Element (which is expected to be an XHTML-based form), setting the character data value of the first-encountered <p> element having a class attributes whose value is type. The value is set to a single Text node with character data of value. Any previous value is removed. A null value for content will leave a Text node containing an empty String. E.g., type = "CF.BibRef", value = "Mishima 1968".

Returns:
true if the action was successful.

setPreferredWidth

protected void setPreferredWidth(int width)
Sets preferred sizes of the form and wrapper panes based on the supplied width. This is generally called by the parent dialog with its own width as a parameter.


getTotalFieldHeight

protected int getTotalFieldHeight()
Return total height of form fields, not including the space between.


editPanel

protected void editPanel(FormPanel.FormFieldPanel ffp,
                         int action)
Called when a "+" or "-" button next to a form field panel ffp is activated, indicating either the cloning or removal of a field. action should either be FIELD_CLONE ("+") or FIELD_REMOVE ("-").


link

protected void link(FormPanel.FormFieldPanel ffp,
                    int action)
Called when either of the "Browse..." or "Go" buttons next to a form field panel ffp are activated, indicating either the browsing for a new URL or traversing the existing link. action should either be FIELD_BROWSE or FIELD_GO.


getNextId

protected int getNextId()
Returns a unique ID (simply an incremental counter).


dispose

protected void dispose()
If the parent dialog has been set non-null, this assumes it is a JDialog (or extension) and calls its dispose() method. If the parent is a DocumentView, this panel is removed from its auxiliary card.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.