com.jgoodies.validation.view
Class ValidationResultViewFactory

java.lang.Object
  extended by com.jgoodies.validation.view.ValidationResultViewFactory

public final class ValidationResultViewFactory
extends Object

A factory class that vends views that present the state and contents of ValidationResults. The validation views are composed from user interface components like text areas, lists, labels, etc. Most factory methods require a ValidationResultModel that notifies the view about changes in an underlying ValidationResult.

Version:
$Revision: 1.16 $
Author:
Karsten Lentzsch
See Also:
ValidationResult, ValidationMessage

Nested Class Summary
static class ValidationResultViewFactory.MessageStateChangeHandler
          Sets the component visible iff the validation result has messages.
 
Method Summary
static JLabel createReportIconAndTextLabel(ValidationResultModel model)
          Creates and returns a label with icon and text that indicates the validation state and displays the first message text with the highest severity.
static JComponent createReportIconAndTextPane(ValidationResultModel model)
          Creates and returns a transparent panel that consists of a report label and a transparent report text area.
static JLabel createReportIconLabel(ValidationResultModel model)
          Creates and returns an icon label that indicates the validation severity.
static JComponent createReportList(ValidationResultModel model)
          Creates and returns a list that presents validation messages.
static JComponent createReportList(ValidationResultModel model, Color backgroundColor)
          Creates and returns a list wrapped in a scroll pane that presents validation messages.
static JTextArea createReportTextArea(ValidationResultModel model)
          Creates and returns a text area that is intended to show validation messages.
static JTextArea createReportTextArea(ValidationResultModel model, Color backgroundColor)
          Creates and returns a text area that is intended to show validation messages.
static JComponent createReportTextPane(ValidationResultModel model)
          Creates and returns a text area wrapped by a scroll pane that is intended to show validation messages.
static JComponent createReportTextPane(ValidationResultModel model, Color backgroundColor)
          Creates and returns a text area wrapped by a scroll pane that is intended to show validation messages.
static ImageIcon getCheckIcon()
          Returns a check icon useful to indicate good vs.
static ImageIcon getErrorIcon()
          Returns a default error icon useful to indicate validation errors.
static Icon getIcon(Severity severity)
          Returns the warning icon for warnings, the error icon for errors and null otherwise.
static ImageIcon getInfoIcon()
          Returns a default information icon useful to indicate input hints.
static ImageIcon getSmallErrorIcon()
          Returns a small default error icon useful to indicate validation errors attached to UI components.
static Icon getSmallIcon(Severity severity)
          Returns the small warning icon for warnings, the small error icon for errors and null otherwise.
static ImageIcon getSmallInfoIcon()
          Returns a small default information icon useful to indicate input hints.
static ImageIcon getSmallWarningIcon()
          Returns a small default warning icon useful to indicate validation warnings attached to UI components.
static ImageIcon getWarningIcon()
          Returns a default warnings icon useful to indicate validation warnings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createReportIconLabel

public static JLabel createReportIconLabel(ValidationResultModel model)
Creates and returns an icon label that indicates the validation severity. A handler updates the label's visibility and icon each time the severity of the given validation result model changes.

Parameters:
model - the model that provides the observable validation result
Returns:
a label with an icon that presents the validation severity

createReportIconAndTextLabel

public static JLabel createReportIconAndTextLabel(ValidationResultModel model)
Creates and returns a label with icon and text that indicates the validation state and displays the first message text with the highest severity.

Parameters:
model - the model that provides the observable validation result
Returns:
a label with text and icon that shows the validation severity and the first validation message text

createReportIconAndTextPane

public static JComponent createReportIconAndTextPane(ValidationResultModel model)
Creates and returns a transparent panel that consists of a report label and a transparent report text area. Both components are bound to the given ValidationResultModel: the text content presents the validation result message text and the whole panel is visible if and only if the model has messages.

Parameters:
model - the model that provides the observable validation result
Returns:
a panel with icon and text area bound to a validation result

createReportList

public static JComponent createReportList(ValidationResultModel model)
Creates and returns a list that presents validation messages. The list content is bound to the given ValidationResultModel using a ValidationResultListAdapter.

Parameters:
model - the model that provides the observable validation result
Returns:
a JList that shows validation messages

createReportList

public static JComponent createReportList(ValidationResultModel model,
                                          Color backgroundColor)
Creates and returns a list wrapped in a scroll pane that presents validation messages. The list content is bound to the given ValidationResultModel using a ValidationResultListAdapter.

Parameters:
model - the model that provides the observable validation result
backgroundColor - the color used to paint the area's background
Returns:
a JList that shows validation messages

createReportTextArea

public static JTextArea createReportTextArea(ValidationResultModel model)
Creates and returns a text area that is intended to show validation messages. The area is bound to the given ValidationResultModel: the text content reflects the validation result message text and the component is visible if and only if the model has messages.

Parameters:
model - the model that provides the observable validation result
Returns:
a text area intended to show validation messages

createReportTextArea

public static JTextArea createReportTextArea(ValidationResultModel model,
                                             Color backgroundColor)
Creates and returns a text area that is intended to show validation messages. The area is bound to the given ValidationResultModel: the text content reflects the validation result message text, and the component is visible if and only if the model has messages.

Parameters:
model - the model that provides the observable validation result
backgroundColor - the color used to paint the area's background
Returns:
a text area intended to show validation messages

createReportTextPane

public static JComponent createReportTextPane(ValidationResultModel model)
Creates and returns a text area wrapped by a scroll pane that is intended to show validation messages. The component is bound to the given ValidationResultModel: the text content reflects the validation result message text and the component is visible if and only if the model has messages.

Parameters:
model - the model that provides the observable validation result
Returns:
a scrollable text component intended to show validation messages

createReportTextPane

public static JComponent createReportTextPane(ValidationResultModel model,
                                              Color backgroundColor)
Creates and returns a text area wrapped by a scroll pane that is intended to show validation messages. The component is bound to the given ValidationResultModel: the text content reflects the validation result message text and the component is visible if and only if the model has messages.

Parameters:
model - the model that provides the observable validation result
backgroundColor - the color used to paint the area's background
Returns:
a scrollable text component intended to show validation messages

getErrorIcon

public static ImageIcon getErrorIcon()
Returns a default error icon useful to indicate validation errors.

Returns:
a default error icon

getWarningIcon

public static ImageIcon getWarningIcon()
Returns a default warnings icon useful to indicate validation warnings.

Returns:
a default warning icon

getSmallErrorIcon

public static ImageIcon getSmallErrorIcon()
Returns a small default error icon useful to indicate validation errors attached to UI components.

Returns:
a small default error icon

getSmallWarningIcon

public static ImageIcon getSmallWarningIcon()
Returns a small default warning icon useful to indicate validation warnings attached to UI components.

Returns:
a small default warning icon

getInfoIcon

public static ImageIcon getInfoIcon()
Returns a default information icon useful to indicate input hints.

Returns:
a default information icon

getSmallInfoIcon

public static ImageIcon getSmallInfoIcon()
Returns a small default information icon useful to indicate input hints.

Returns:
a small default information icon

getCheckIcon

public static ImageIcon getCheckIcon()
Returns a check icon useful to indicate good vs. no good.

Returns:
a check icon

getIcon

public static Icon getIcon(Severity severity)
Returns the warning icon for warnings, the error icon for errors and null otherwise.

Parameters:
severity - the severity used to lookup the icon
Returns:
the warning icon for warnings, error icon for errors, null otherwise
See Also:
getWarningIcon(), getErrorIcon(), getSmallIcon(Severity)

getSmallIcon

public static Icon getSmallIcon(Severity severity)
Returns the small warning icon for warnings, the small error icon for errors and null otherwise.

Parameters:
severity - the severity used to lookup the icon
Returns:
the small warning icon for warnings, the small error icon for errors, null otherwise
See Also:
getSmallWarningIcon(), getSmallErrorIcon(), getIcon(Severity)


Copyright © 2003-2011 JGoodies Karsten Lentzsch. All Rights Reserved.