swingwtx.custom.validation
Class ValidatableComponent

java.lang.Object
  extended byswingwt.awt.Component
      extended byswingwt.awt.Container
          extended byswingwtx.swing.JComponent
              extended byswingwtx.swing.JPanel
                  extended byswingwtx.custom.validation.ValidatableComponent
All Implemented Interfaces:
ImageObserver, MenuContainer
Direct Known Subclasses:
ValidatableJComboBox, ValidatableJTextField

public abstract class ValidatableComponent
extends JPanel

This is the superclass of all components that can be validated through the ValidationGroup class. When a component fails validation, an icon is shown next to the component with a tooltip stating why the component failed validation.


Nested Class Summary
 
Nested classes inherited from class swingwtx.swing.JComponent
JComponent.InternalFrameSelectionListener
 
Field Summary
protected  JComponent comp
          The component we are holding
protected  java.lang.String errorMessage
           
protected  JLabel errorOutput
          The component that will display the icon/tooltip
protected  boolean isValid
          whether the component currently matches it's validation rules
protected  ValidationGroup validationGroup
          The validation group containing this component
protected  java.util.Vector validationListeners
          Validation listeners
 
Fields inherited from class swingwtx.swing.JPanel
opaque, ppeer
 
Fields inherited from class swingwtx.swing.JComponent
accessibleContext, actionMap, ancestorInputMap, border, clientProperties, descendantHasPeer, focusInputMap, internalFrameAdapter, internalFrameParent, propertyChangeListeners, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, windowInputMap
 
Fields inherited from class swingwt.awt.Container
composite, comps, containerListeners, layout, queuedValidateRequest
 
Fields inherited from class swingwt.awt.Component
actionCommand, actionListeners, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListeners, componentName, consumeAvailableHeight, consumeAvailableWidth, focusable, focusListeners, graphicsConfig, inputMethodListeners, isUserSetFont, keyListeners, layoutModifier, LEFT_ALIGNMENT, LOCK, mouseListeners, mouseMotionListeners, mouseWheelListeners, parent, pBackground, pCursor, pDoubleBuffered, peer, pEnabled, pFont, pForeground, pLayoutData, pLocation, pMaxSize, pMinSize, pPrefSize, pSize, pToolTipText, pVisible, RIGHT_ALIGNMENT, swingWTDefaultActionEventAdapter, swingWTEventAdapter, TOP_ALIGNMENT
 
Fields inherited from interface swingwt.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ValidatableComponent()
           
 
Method Summary
 void addActionListener(ActionListener l)
          Add an ActionListener to this component
 void addFocusListener(FocusListener l)
          Add a KeyListener to this component
 void addKeyListener(KeyListener l)
          Add a KeyListener to this component
 void addMouseListener(MouseListener l)
          Add a MouseListener to this component
 void addValidationListener(ValidationListener l)
           
 void dispose()
          Destroys the component
protected  void fireValidation(boolean forcePass)
          Sends the validation event to the component listeners.
 Color getBackground()
          Returns the background colour of the component
 JComponent getComponent()
           
 java.lang.String getErrorMessage()
           
 Font getFont()
          Returns the Font used on the component
 Color getForeground()
          Returns the foreground colour of the component
 java.lang.String getToolTipText()
          Returns the tooltip text used on the component
 ValidationGroup getValidationGroup()
          Getter for property validationGroup.
 void grabFocus()
          Forces keyboard focus to the component
 boolean isEnabled()
          Returns true if the component is enabled
 boolean isValid()
           
 boolean isVisible()
          Returns true if the component is visible
 void removeActionListener(ActionListener l)
          Remove an ActionListener from the component
 void removeFocusListener(FocusListener l)
          Remove an KeyListener from the component
 void removeKeyListener(KeyListener l)
          Remove an KeyListener from the component
 void removeMouseListener(MouseListener l)
          Remove an MouseListener from the component
 void removeValidationListener(ValidationListener l)
           
 void requestFocus()
          Requests the component receives the focus
 void setBackground(Color c)
          Sets the background colour of the component
 void setEnabled(boolean b)
          Change the enabled state of the component
 void setErrorMessage(java.lang.String s)
           
 void setFont(Font f)
          Sets the font used by the component
 void setForeground(Color c)
          Sets the foreground colour of the component
 void setIsValid(boolean b)
           
 void setToolTipText(java.lang.String text)
          Sets the tooltip text used on the component
 void setupComponent()
          Should be called by subclasses after component creation
 void setValidationGroup(ValidationGroup validationGroup)
          Setter for property validationGroup.
 void setVisible(boolean b)
          Change the visibility of the component
 
Methods inherited from class swingwtx.swing.JPanel
calculatePreferredSize, getHeight, getSize, getWidth, setBorder, setSwingWTParent
 
Methods inherited from class swingwtx.swing.JComponent
add, add, add, add, add, addPropertyChangeListener, addPropertyChangeListener, checkInternalFrameChild, getAccessibleContext, getActionMap, getAutoscrolls, getBorder, getClientProperty, getInputMap, getInsets, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isValidateRoot, paint, paintBackground, paintChildren, paintComponent, paintImmediately, paintImmediately, putClientProperty, remove, remove, removePropertyChangeListener, removePropertyChangeListener, repaint, revalidate, scrollRectToVisible, setActionMap, setAutoscrolls, setDoubleBuffered, setInputMap, setMargin, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled
 
Methods inherited from class swingwt.awt.Container
addComponentToLayout, addContainerListener, debug_showContainmentTree, doAdd, doLayout, getComponent, getComponentCount, getComponentOrientation, getComponents, getComposite, getLayout, getMaximumSize, getMinimumSize, getParent, getPreferredSize, invalidate, minimumSize, preferredSize, processContainerEvent, processEvent, queuedValidate, removeAll, removeComponentFromCache, removeContainerListener, setLayout, setLayoutImpl, validate
 
Methods inherited from class swingwt.awt.Component
add, addComponentListener, addInputMethodListener, addMouseMotionListener, addMouseWheelListener, addNotify, componentOnlyDispose, computePreferredSize, contains, contains, createImage, createListenerArrayFromVector, createVolatileImage, dispatchEvent, getActionCommand, getAlignmentX, getAlignmentY, getBounds, getCursor, getFontMetrics, getGraphics, getGraphicsConfiguration, getListeners, getLocation, getLocationOnScreen, getName, getPeer, getPeerSize, getSize, getSWTPeer, getToolkit, getTreeLock, getX, getY, hasFocus, hasSetFont, hide, imageUpdate, inside, isFocusable, isMinimumSizeSet, isShowing, processActionEvent, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, processTraverseEvent, registerActionEvents, registerComponentEvents, registerEvents, registerExtendedModifyEvents, registerFocusEvents, registerKeyEvents, registerModifyEvents, registerMouseEvents, registerPaintEvents, registerTraversalEvents, remove, removeComponentListener, removeInputMethodListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, repaint, repaint, setActionCommand, setAlignmentX, setAlignmentY, setBounds, setBounds, setCachedProperties, setComponentOrientation, setComponentRemoved, setCursor, setFocusable, setFocusTraversalKeysEnabled, setHeight, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setSize, setSize, setWidth, show, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comp

protected JComponent comp
The component we are holding


errorOutput

protected JLabel errorOutput
The component that will display the icon/tooltip


validationGroup

protected ValidationGroup validationGroup
The validation group containing this component


isValid

protected boolean isValid
whether the component currently matches it's validation rules


errorMessage

protected java.lang.String errorMessage

validationListeners

protected java.util.Vector validationListeners
Validation listeners

Constructor Detail

ValidatableComponent

public ValidatableComponent()
Method Detail

dispose

public void dispose()
Description copied from class: JComponent
Destroys the component

Overrides:
dispose in class JComponent

getComponent

public JComponent getComponent()

addValidationListener

public void addValidationListener(ValidationListener l)

removeValidationListener

public void removeValidationListener(ValidationListener l)

setupComponent

public void setupComponent()
Should be called by subclasses after component creation


setIsValid

public void setIsValid(boolean b)

isValid

public boolean isValid()

setErrorMessage

public void setErrorMessage(java.lang.String s)

getErrorMessage

public java.lang.String getErrorMessage()

fireValidation

protected void fireValidation(boolean forcePass)
Sends the validation event to the component listeners. Monitors the validation event as it comes back and updates the object accordingly.

Parameters:
forcePass - If set to true, it is assumed that validation passes - even if it wouldn't, and the event is not called. This is used by the clearErrors() call to reset fields.

setVisible

public void setVisible(boolean b)
Description copied from class: Component
Change the visibility of the component

Overrides:
setVisible in class Component

isVisible

public boolean isVisible()
Description copied from class: Component
Returns true if the component is visible

Overrides:
isVisible in class Component

setEnabled

public void setEnabled(boolean b)
Description copied from class: Component
Change the enabled state of the component

Overrides:
setEnabled in class Component

isEnabled

public boolean isEnabled()
Description copied from class: Component
Returns true if the component is enabled

Overrides:
isEnabled in class Component

requestFocus

public void requestFocus()
Description copied from class: Component
Requests the component receives the focus

Overrides:
requestFocus in class Component

grabFocus

public void grabFocus()
Description copied from class: Component
Forces keyboard focus to the component

Overrides:
grabFocus in class Component

getBackground

public Color getBackground()
Description copied from class: Component
Returns the background colour of the component

Overrides:
getBackground in class Component

setBackground

public void setBackground(Color c)
Description copied from class: Component
Sets the background colour of the component

Overrides:
setBackground in class Component

getForeground

public Color getForeground()
Description copied from class: Component
Returns the foreground colour of the component

Overrides:
getForeground in class Component

setForeground

public void setForeground(Color c)
Description copied from class: Component
Sets the foreground colour of the component

Overrides:
setForeground in class Component

getFont

public Font getFont()
Description copied from class: Component
Returns the Font used on the component

Specified by:
getFont in interface MenuContainer
Overrides:
getFont in class Component

setFont

public void setFont(Font f)
Description copied from class: Component
Sets the font used by the component

Overrides:
setFont in class Component

getToolTipText

public java.lang.String getToolTipText()
Description copied from class: Component
Returns the tooltip text used on the component

Overrides:
getToolTipText in class Component

setToolTipText

public void setToolTipText(java.lang.String text)
Description copied from class: Component
Sets the tooltip text used on the component

Overrides:
setToolTipText in class Component

addActionListener

public void addActionListener(ActionListener l)
Description copied from class: Component
Add an ActionListener to this component

Overrides:
addActionListener in class Component

removeActionListener

public void removeActionListener(ActionListener l)
Description copied from class: Component
Remove an ActionListener from the component

Overrides:
removeActionListener in class Component

addMouseListener

public void addMouseListener(MouseListener l)
Description copied from class: Component
Add a MouseListener to this component

Overrides:
addMouseListener in class Component

removeMouseListener

public void removeMouseListener(MouseListener l)
Description copied from class: Component
Remove an MouseListener from the component

Overrides:
removeMouseListener in class Component

addKeyListener

public void addKeyListener(KeyListener l)
Description copied from class: Component
Add a KeyListener to this component

Overrides:
addKeyListener in class Component

removeKeyListener

public void removeKeyListener(KeyListener l)
Description copied from class: Component
Remove an KeyListener from the component

Overrides:
removeKeyListener in class Component

addFocusListener

public void addFocusListener(FocusListener l)
Description copied from class: Component
Add a KeyListener to this component

Overrides:
addFocusListener in class Component

removeFocusListener

public void removeFocusListener(FocusListener l)
Description copied from class: Component
Remove an KeyListener from the component

Overrides:
removeFocusListener in class Component

getValidationGroup

public ValidationGroup getValidationGroup()
Getter for property validationGroup.

Returns:
Value of property validationGroup.

setValidationGroup

public void setValidationGroup(ValidationGroup validationGroup)
Setter for property validationGroup.

Parameters:
validationGroup - New value of property validationGroup.