org.springframework.richclient.form
Class FormGuard

java.lang.Object
  extended by org.springframework.richclient.form.FormGuard
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class FormGuard
extends Object
implements PropertyChangeListener

Actually enables/disables registered 'guarded' objects based on the state of a ValidatingFormModel. One instance of this FormGuard supports multiple guarded objects on one formModel. Each guarded object can specify upon which state of the formModel it wants to be enabled:


Field Summary
static int FORMERROR_GUARDED
          Guard-registration mask-pattern indicating enabled() will be set only if the formmodel is both enabled and has no errors.
static int LIKE_COMMITCOMMAND
          Guard-registration mask-pattern indicating enabled() will be set just like is the case for the commit command.
static int LIKE_NEWFORMOBJCOMMAND
          Guard-registration mask-pattern indicating enabled() will be set just like is the case for the new-form command.
static int LIKE_REVERTCOMMAND
          Guard-registration mask-pattern indicating enabled() will be set just like is the case for the revert command.
static int ON_ENABLED
          Guard-registration mask-bit indicating enabled() will be set only if the formmodel is enabled.
static int ON_ISDIRTY
          Guard-registration mask-bit indicating enabled() will be set only if the formmodel has changes (is dirty).
static int ON_NOERRORS
          Guard-registration mask-bit indicating enabled() will be set only if the formmodel has no errors.
 
Constructor Summary
FormGuard(ValidatingFormModel formModel)
          Creates the FormGuard monitoring the passed formModel.
FormGuard(ValidatingFormModel formModel, Guarded guarded)
          Creates the FormGuard monitoring the passed formModel, and adds the passed guarded-object.
FormGuard(ValidatingFormModel formModel, Guarded guarded, int mask)
          Creates the FormGuard monitoring the passed formModel, and adds the passed guarded-object using the specified mask.
 
Method Summary
 void addGuarded(Guarded newGuarded, int mask)
          Adds a guarded object to be guarded by this FormGuard
 void propertyChange(PropertyChangeEvent e)
           
 boolean removeGuarded(Guarded toRemove)
          Removes the guarded object from the management of this FormGuard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ON_NOERRORS

public static final int ON_NOERRORS
Guard-registration mask-bit indicating enabled() will be set only if the formmodel has no errors.

See Also:
Constant Field Values

ON_ISDIRTY

public static final int ON_ISDIRTY
Guard-registration mask-bit indicating enabled() will be set only if the formmodel has changes (is dirty).

See Also:
Constant Field Values

ON_ENABLED

public static final int ON_ENABLED
Guard-registration mask-bit indicating enabled() will be set only if the formmodel is enabled.

See Also:
Constant Field Values

LIKE_NEWFORMOBJCOMMAND

public static final int LIKE_NEWFORMOBJCOMMAND
Guard-registration mask-pattern indicating enabled() will be set just like is the case for the new-form command. i.e. as soon as the formmodel is enabled.

See Also:
Constant Field Values

LIKE_REVERTCOMMAND

public static final int LIKE_REVERTCOMMAND
Guard-registration mask-pattern indicating enabled() will be set just like is the case for the revert command. i.e. only if the formmodel is enabled AND uncommitted changes are present.

See Also:
Constant Field Values

LIKE_COMMITCOMMAND

public static final int LIKE_COMMITCOMMAND
Guard-registration mask-pattern indicating enabled() will be set just like is the case for the commit command. i.e. only if the formmodel is enabled AND uncomitted changes are presenent AND the model is valid.

See Also:
Constant Field Values

FORMERROR_GUARDED

public static final int FORMERROR_GUARDED
Guard-registration mask-pattern indicating enabled() will be set only if the formmodel is both enabled and has no errors.

See Also:
Constant Field Values
Constructor Detail

FormGuard

public FormGuard(ValidatingFormModel formModel)
Creates the FormGuard monitoring the passed formModel.

Parameters:
formModel - which state-changes should be passed to registered guarded objects.

FormGuard

public FormGuard(ValidatingFormModel formModel,
                 Guarded guarded)
Creates the FormGuard monitoring the passed formModel, and adds the passed guarded-object. For backwards compatibility this assumes the FORMERROR_GUARDED mask.

Parameters:
formModel - which state-changes should be passed to registered guarded objects.
guarded - object that will get en/dis-abled

FormGuard

public FormGuard(ValidatingFormModel formModel,
                 Guarded guarded,
                 int mask)
Creates the FormGuard monitoring the passed formModel, and adds the passed guarded-object using the specified mask.

Parameters:
formModel - which state-changes should be passed to registered guarded objects.
guarded - object that will get en/dis-abled
mask - specifying what formModel state should enable the guarded object.
Method Detail

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

addGuarded

public void addGuarded(Guarded newGuarded,
                       int mask)
Adds a guarded object to be guarded by this FormGuard

Parameters:
newGuarded - object to be guarded
mask - indicating which state of the formModel should enable the guarded obhject

removeGuarded

public boolean removeGuarded(Guarded toRemove)
Removes the guarded object from the management of this FormGuard.

Parameters:
toRemove - object that no longer should be managed
Returns:
false if the object toRemove was not present in the list of managed guarded objects.


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.