org.apache.pivot.wtk
Class Form

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.Container
          extended by org.apache.pivot.wtk.Form
All Implemented Interfaces:
Iterable<Component>, Sequence<Component>, ConstrainedVisual, Visual

@DefaultProperty(value="sections")
public class Form
extends Container

A container that arranges field components in a form layout. Each field has an optional text label associated with it and may be flagged as requiring attention using one of several flag types and an optional flag message (for use during form validation, for example).


Nested Class Summary
static class Form.Flag
          Represents an message alert associated with a form field.
static class Form.Section
          Class representing a form section.
 class Form.SectionSequence
          Section sequence implementation.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Container
Container.EDT_Checker
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
 
Constructor Summary
Form()
          Creates a new form.
 
Method Summary
static void clearFlag(Component component)
           
 void clearFlags()
          Clears all field flags.
static Form.Section getEnclosingSection(Component component)
          Finds the Form.Section that the given component belongs to.
static Form.Flag getFlag(Component component)
           
 int getFlaggedFieldCount(MessageType messageType)
          Returns the number of fields that are flagged with a given message type.
 ListenerList<FormAttributeListener> getFormAttributeListeners()
          Returns the form attribute listener list.
 ListenerList<FormListener> getFormListeners()
          Returns the form listener list.
static String getLabel(Component component)
           
static Form.Section getSection(Component component)
          Finds the Form.Section that the given component belongs to.
 Form.SectionSequence getSections()
          Returns the form's field sequence.
static boolean isRequired(Component component)
           
 Sequence<Component> remove(int index, int count)
          Removes one or more items from the sequence.
 void scrollFirstFlagToVisible(MessageType messageType)
          Ensures that the first field with the given flag type is visible.
static void setFlag(Component component, Form.Flag flag)
           
static void setFlag(Component component, String flag)
           
static void setLabel(Component component, String label)
           
static void setRequired(Component component, boolean required)
           
 
Methods inherited from class org.apache.pivot.wtk.Container
add, assertEventDispatchThread, assertEventDispatchThread, clear, containsFocus, descendantAdded, descendantGainedFocus, descendantLostFocus, descendantRemoved, get, getComponentAt, getContainerListeners, getContainerMouseListeners, getDescendantAt, getFocusTraversalPolicy, getGraphics, getLength, getNamedComponent, indexOf, insert, invalidate, isAncestor, isDoubleBuffered, iterator, layout, load, mouseClick, mouseDown, mouseMove, mouseOut, mouseUp, mouseWheel, move, paint, remove, removeAll, repaint, requestFocus, setDoubleBuffered, setEventDispatchThreadChecker, setFocusTraversalPolicy, setParent, setVisible, store, transferFocus, update
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, contains, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseOver, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Form

public Form()
Creates a new form.

Method Detail

getSections

public Form.SectionSequence getSections()
Returns the form's field sequence.

Returns:
The form's field sequence.

clearFlags

public void clearFlags()
Clears all field flags.


getFlaggedFieldCount

public int getFlaggedFieldCount(MessageType messageType)
Returns the number of fields that are flagged with a given message type.

Parameters:
messageType - The message type to count, or null to return the count of all flagged fields regardless of message type.

scrollFirstFlagToVisible

public void scrollFirstFlagToVisible(MessageType messageType)
Ensures that the first field with the given flag type is visible.

Parameters:
messageType - The message type, or null to scroll the first flag of any type to visible.

remove

public Sequence<Component> remove(int index,
                                  int count)
Description copied from interface: Sequence
Removes one or more items from the sequence.

Specified by:
remove in interface Sequence<Component>
Overrides:
remove in class Container
Parameters:
index - The starting index to remove.
count - The number of items to remove, beginning with index.
Returns:
A sequence containing the items that were removed.

getFormListeners

public ListenerList<FormListener> getFormListeners()
Returns the form listener list.

Returns:
The form listener list.

getFormAttributeListeners

public ListenerList<FormAttributeListener> getFormAttributeListeners()
Returns the form attribute listener list.

Returns:
The form attribute listener list.

getSection

public static Form.Section getSection(Component component)
Finds the Form.Section that the given component belongs to. Only finds the section if the component is a direct child of the section.

See Also:
getEnclosingSection(Component)

getEnclosingSection

public static Form.Section getEnclosingSection(Component component)
Finds the Form.Section that the given component belongs to. Will search up the parent hierarchy in case the component is nested inside other containers inside the form.

Returns:
The form section this component (or one of its parents) belongs to or null if the component does not belong to a form.
See Also:
getSection(Component)

getLabel

public static String getLabel(Component component)

setLabel

public static void setLabel(Component component,
                            String label)

isRequired

public static boolean isRequired(Component component)

setRequired

public static void setRequired(Component component,
                               boolean required)

getFlag

public static Form.Flag getFlag(Component component)

setFlag

public static void setFlag(Component component,
                           Form.Flag flag)

setFlag

public static final void setFlag(Component component,
                                 String flag)

clearFlag

public static final void clearFlag(Component component)