org.scopemvc.view.swing
Class SModelAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--org.scopemvc.view.swing.SAction
              |
              +--org.scopemvc.view.swing.SModelAction
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, ModelBindable, PropertyView, Refreshable, java.io.Serializable, SwingSubView, View

public class SModelAction
extends SAction
implements ModelBindable, PropertyView, Refreshable

An SAction that is bound to a property and performs a test on the value of the property to determine its active state.

A comparable object is used to perform the test on the view value. This action is active when the comparable object returns a value greater than 0 when passed the view value in its compareTo() method.

Note: it is convenient to use the Comparable interface to perform tests because it is already implemented in many places (natural ordering). For example, to have this SModelAction enabled when the view value is an Integer less than 1, then do:
setValueTest(new Integer(1))
because new Integer(1).compareTo(value) will return 1 if value is an Integer less than 1

If the comparison fails because of an exception coming from the Comparable test, then this action is disabled.

Version:
$Revision: 1.2 $ $Date: 2002/09/13 17:03:50 $
Author:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
SModelAction(java.lang.String inControlID)
          Constructor for the ModelAction object.
SModelAction(java.lang.String inControlID, SwingView inView, Selector inSelector)
          Constructor for the SModelAction object.
SModelAction(java.lang.String inControlID, SwingView inView, Selector inSelector, java.lang.Comparable inValueTest)
          Constructor for the SModelAction object.
 
Method Summary
protected  Control createControl()
          Now overwrite the firing of the control to include the additional information of the model
 java.lang.Object getBoundModel()
          Gets the bound model
 Selector getSelector()
          Gets the selector
 java.lang.Comparable getValueTest()
          Returns the Comparable used to test the view value.
 java.lang.Object getViewValue()
          Get the current value (what would be set as a property of the bound model object) being presented on the View.
 void refresh()
          Update the widget with the current state of the bound model.
 void setBoundModel(java.lang.Object inModel)
          Sets the bound model
 void setSelector(Selector inSelector)
          Sets the selector
 void setSelectorString(java.lang.String inSelectorString)
          Sets the selector string
 void setValueTest(java.lang.Comparable inValueTest)
          Sets the Comparable used to test the view value.
 void updateFromProperty(java.lang.Object inValue, boolean inReadOnly)
          Use the passed property value and read-only state to update the View.
 void validationFailed(java.lang.Exception inException)
          Validation failed while getting a value from View into the bound model object.
 void validationSuccess()
          Clear previous validation failure.
 
Methods inherited from class org.scopemvc.view.swing.SAction
actionPerformed, getAcceleratorKey, getControlID, getController, getLongDescription, getMnemonicKey, getName, getOwner, getShortDescription, getSmallIcon, issueControl, setAcceleratorKey, setControlID, setController, setLongDescription, setMnemonicKey, setName, setOwner, setShortDescription, setSmallIcon, unsetOwner
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.scopemvc.core.View
getController, issueControl, setController
 

Constructor Detail

SModelAction

public SModelAction(java.lang.String inControlID)
Constructor for the ModelAction object.
It defines a test that will activate the action if the view value is not null.

Parameters:
inControlID - The control ID to be issued by this Action

SModelAction

public SModelAction(java.lang.String inControlID,
                    SwingView inView,
                    Selector inSelector)
Constructor for the SModelAction object.
It defines a test that will activate the action if the view value is not null.

Parameters:
inControlID - The control ID to be issued by this Action
inView - The view owning this Action; its bound controller will receive the Controls issued by this Action.
inSelector - The selector for the property

SModelAction

public SModelAction(java.lang.String inControlID,
                    SwingView inView,
                    Selector inSelector,
                    java.lang.Comparable inValueTest)
Constructor for the SModelAction object.

Parameters:
inControlID - The control ID to be issued by this Action
inView - The view owning this Action; its bound controller will receive the Controls issued by this Action.
inSelector - The selector for the property
inValueTest - The test for the enabled state. If the compareTo() method returns a value greater than 0, then this action is active.
Method Detail

getBoundModel

public final java.lang.Object getBoundModel()
Gets the bound model

Specified by:
getBoundModel in interface View
Overrides:
getBoundModel in class SAction
Returns:
The boundModel value

getSelector

public final Selector getSelector()
Gets the selector

Specified by:
getSelector in interface PropertyView
Returns:
The selector value

getViewValue

public final java.lang.Object getViewValue()
Get the current value (what would be set as a property of the bound model object) being presented on the View.

Specified by:
getViewValue in interface ModelBindable
Returns:
property's value from the UI.

getValueTest

public java.lang.Comparable getValueTest()
Returns the Comparable used to test the view value.

Returns:
The valueTest value

setSelector

public final void setSelector(Selector inSelector)
Sets the selector

Specified by:
setSelector in interface PropertyView
Parameters:
inSelector - The new selector value

setSelectorString

public final void setSelectorString(java.lang.String inSelectorString)
Sets the selector string

Parameters:
inSelectorString - The new selectorString value

setValueTest

public void setValueTest(java.lang.Comparable inValueTest)
Sets the Comparable used to test the view value.
This action is enabled when the compareTo() method of the test returns a value greater than 0 when the passed value is the model value bound to this SModelAction.

Parameters:
inValueTest - The new valueTest value

setBoundModel

public void setBoundModel(java.lang.Object inModel)
Sets the bound model

Specified by:
setBoundModel in interface View
Overrides:
setBoundModel in class SAction
Parameters:
inModel - The new boundModel value

updateFromProperty

public void updateFromProperty(java.lang.Object inValue,
                               boolean inReadOnly)
Use the passed property value and read-only state to update the View.
Ignores inReadOnly.

Specified by:
updateFromProperty in interface ModelBindable
Parameters:
inValue - The new value of the property in the bound model
inReadOnly - The new read-only state of the property

validationFailed

public void validationFailed(java.lang.Exception inException)
Validation failed while getting a value from View into the bound model object.
Does nothing here.

Specified by:
validationFailed in interface ModelBindable
Parameters:
inException - The exception causing the validation failure

validationSuccess

public void validationSuccess()
Clear previous validation failure.
Does nothing here.

Specified by:
validationSuccess in interface ModelBindable
See Also:
ModelBindable.validationFailed(java.lang.Exception)

refresh

public void refresh()
Update the widget with the current state of the bound model.

Specified by:
refresh in interface Refreshable

createControl

protected Control createControl()
Now overwrite the firing of the control to include the additional information of the model

Overrides:
createControl in class SAction
Returns:
The Control to fire


Copyright © 2000-2002 The Scope Team. All Rights Reserved.