|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.AbstractAction | +--org.scopemvc.view.swing.SAction | +--org.scopemvc.view.swing.SModelAction
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.
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 |
public SModelAction(java.lang.String inControlID)
inControlID
- The control ID to be issued by this Actionpublic SModelAction(java.lang.String inControlID, SwingView inView, Selector inSelector)
inControlID
- The control ID to be issued by this ActioninView
- The view owning this Action; its bound controller will
receive the Controls issued by this Action.inSelector
- The selector for the propertypublic SModelAction(java.lang.String inControlID, SwingView inView, Selector inSelector, java.lang.Comparable inValueTest)
inControlID
- The control ID to be issued by this ActioninView
- The view owning this Action; its bound controller will
receive the Controls issued by this Action.inSelector
- The selector for the propertyinValueTest
- The test for the enabled state. If the compareTo()
method returns a value greater than 0, then this action is active.Method Detail |
public final java.lang.Object getBoundModel()
getBoundModel
in interface View
getBoundModel
in class SAction
public final Selector getSelector()
getSelector
in interface PropertyView
public final java.lang.Object getViewValue()
getViewValue
in interface ModelBindable
public java.lang.Comparable getValueTest()
public final void setSelector(Selector inSelector)
setSelector
in interface PropertyView
inSelector
- The new selector valuepublic final void setSelectorString(java.lang.String inSelectorString)
inSelectorString
- The new selectorString valuepublic void setValueTest(java.lang.Comparable inValueTest)
inValueTest
- The new valueTest valuepublic void setBoundModel(java.lang.Object inModel)
setBoundModel
in interface View
setBoundModel
in class SAction
inModel
- The new boundModel valuepublic void updateFromProperty(java.lang.Object inValue, boolean inReadOnly)
updateFromProperty
in interface ModelBindable
inValue
- The new value of the property in the bound modelinReadOnly
- The new read-only state of the propertypublic void validationFailed(java.lang.Exception inException)
validationFailed
in interface ModelBindable
inException
- The exception causing the validation failurepublic void validationSuccess()
validationSuccess
in interface ModelBindable
ModelBindable.validationFailed(java.lang.Exception)
public void refresh()
refresh
in interface Refreshable
protected Control createControl()
createControl
in class SAction
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |