com.jgoodies.validation.util
Class ValidationResultModelContainer

java.lang.Object
  extended by com.jgoodies.common.bean.AbstractBean
      extended by com.jgoodies.validation.util.AbstractValidationResultModel
          extended by com.jgoodies.validation.util.DefaultValidationResultModel
              extended by com.jgoodies.validation.util.ValidationResultModelContainer
All Implemented Interfaces:
com.jgoodies.common.bean.ObservableBean, com.jgoodies.common.bean.ObservableBean2, ValidationResultModel, Serializable

public class ValidationResultModelContainer
extends DefaultValidationResultModel

A validation result model that holds multiple validation results. These can be concatenated or collapsed, see setExpanded(boolean), getCollapsedValidationResult().

TODO: The collapsed validation result shall honor the severity as reported by the expanded validation result.

TODO: The expanded validation result shall be cached.

Version:
$Revision: 1.15 $
Author:
Karsten Lentzsch
See Also:
DefaultValidationResultModel, Serialized Form

Field Summary
static String PROPERTYNAME_EXPANDED
          The name of the bound read-write property for the expansion state.
 
Fields inherited from class com.jgoodies.common.bean.AbstractBean
changeSupport
 
Fields inherited from interface com.jgoodies.validation.ValidationResultModel
PROPERTY_ERRORS, PROPERTY_MESSAGES, PROPERTY_RESULT, PROPERTY_SEVERITY, PROPERTYNAME_ERRORS, PROPERTYNAME_MESSAGES, PROPERTYNAME_RESULT, PROPERTYNAME_SEVERITY
 
Constructor Summary
ValidationResultModelContainer(ValidationMessage collapsedMessage)
          Constructs a ValidationResultModelContainer using the given validation message for the collapsed state.
 
Method Summary
 void add(ValidationResultModel resultModel)
          Adds the given ValidationResultModel to this container's list of children and registers the container to listen for changes in the child.
 ValidationResult getCollapsedValidationResult()
          Returns the collapsed validation result, i.
 ValidationResult getExpandedValidationResult()
          Returns the concatenation of all validation results that are held by this container.
 boolean isExpanded()
          Returns if this container is in expanded or collapsed state.
 void remove(ValidationResultModel resultModel)
          Removes the given ValidationResultModel from this container's list of children.
 void setExpanded(boolean newExpanded)
          Sets the container state to expanded or collapsed.
 void setResult(ValidationResult newResult)
          Rejects to set a new validation result.
 
Methods inherited from class com.jgoodies.validation.util.DefaultValidationResultModel
getResult
 
Methods inherited from class com.jgoodies.validation.util.AbstractValidationResultModel
firePropertyChanges, getSeverity, hasErrors, hasMessages
 
Methods inherited from class com.jgoodies.common.bean.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPropertyChangeSupport, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean2
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

PROPERTYNAME_EXPANDED

public static final String PROPERTYNAME_EXPANDED
The name of the bound read-write property for the expansion state.

See Also:
isExpanded(), setExpanded(boolean), Constant Field Values
Constructor Detail

ValidationResultModelContainer

public ValidationResultModelContainer(ValidationMessage collapsedMessage)
Constructs a ValidationResultModelContainer using the given validation message for the collapsed state. The initial state is expanded.

Parameters:
collapsedMessage - the ValidationMessage used if the container is in collapsed state
Throws:
NullPointerException - if the collapsed message is null
Method Detail

isExpanded

public boolean isExpanded()
Returns if this container is in expanded or collapsed state.

Returns:
true if expanded
See Also:
setExpanded(boolean)

setExpanded

public void setExpanded(boolean newExpanded)
Sets the container state to expanded or collapsed.

Parameters:
newExpanded - true to expand, false to collapse
See Also:
isExpanded()

getCollapsedValidationResult

public ValidationResult getCollapsedValidationResult()
Returns the collapsed validation result, i. e. a ValidationResult that just consists of a single ValidationMessage; in this case the collapsed validation message.

TODO: Consider changing the implementation to

 ValidationResult wrapper = new ValidationResult();
 if (getExpandedValidationResult().hasMessages()) {
     wrapper.add(collapsedMessage);
 }
  return wrapper;
 

Returns:
the collapsed validation result
See Also:
getExpandedValidationResult()

getExpandedValidationResult

public ValidationResult getExpandedValidationResult()
Returns the concatenation of all validation results that are held by this container.

Returns:
the concatenation of all validation results that are held by this container
See Also:
getCollapsedValidationResult()

add

public void add(ValidationResultModel resultModel)
Adds the given ValidationResultModel to this container's list of children and registers the container to listen for changes in the child.

Parameters:
resultModel - the ValidationResultModel to be added
See Also:
remove(ValidationResultModel)

remove

public void remove(ValidationResultModel resultModel)
Removes the given ValidationResultModel from this container's list of children. Also unregisters this container to no longer listen for changes in the child.

Parameters:
resultModel - the ValidationResultModel to be removed
See Also:
add(ValidationResultModel)

setResult

public final void setResult(ValidationResult newResult)
Rejects to set a new validation result. The validation result of this container will be computed. Therefore API users are prevented from executing this method; throws an UnsupportedOperationException.

Specified by:
setResult in interface ValidationResultModel
Overrides:
setResult in class DefaultValidationResultModel
Parameters:
newResult - the validation result to be set (ignored)
Throws:
UnsupportedOperationException - always
See Also:
DefaultValidationResultModel.getResult()


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