LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.control.form
Class LyFieldController

java.lang.Object
  extended by leon.control.LyController
      extended by leon.control.form.LyFieldController
All Implemented Interfaces:
LyGetSessionInterface, LyGuiListener, LyEvaluator, LyDemandListener
Direct Known Subclasses:
LyFieldConsultController, LyRelationFieldController

public class LyFieldController
extends LyController

Default field controller.

See Also:
LyFormController

Field Summary
static java.lang.String __VERSION
          File version
static java.lang.String FORM_FIELD_SEP
          Separator used to build form field identifiers.
static java.lang.String OLD_FORM_FIELD_SEP
          Old form field sep
 
Fields inherited from class leon.control.LyController
_nbControllers, _nextId, CONTROLLER_ID_SEP, DEFAULT_IMAGE_FORMAT, DEMAND_HELP, ID_SEP
 
Constructor Summary
LyFieldController(LyAreaController parent, LyFieldInfo fieldInfo)
          Constructor.
 
Method Summary
 void actionDemand(LyActionDemand demand)
          Invoked when an action occurs.
 void clearViewCache()
          Clears all cached data for this controller (especially the view and the component).
 void free()
          Free this controller.
 LyAction getAction()
          Get the current action
 LyAreaController getAreaController()
          Gets the specific areaController for the given field info.
 LyBehaviorInterface getBehavior()
          Accessor to controller behavior A behavior is associated to a controller to let the Developer specify application logic in the behavior.
 LyClassInfo getClassInfo()
          Get the classInfo associated with this controller
 LyComponent getComponent()
          Accessor to the view component instance.
 LyUnit getDefaultFieldUnit()
          Get the default unit for the current field
 LyUnit getDefaultFieldUnit(LyFieldInfo fieldInfo)
          Get the default unit for the given field
 LyEnvironment getEnvironment()
          Get the environment of the parent form controller
 LyFieldController getFieldController(int index)
          Get the field controller at the given index.
 LyFieldInfo getFieldInfo()
          Get the field associated with this controller
 LyValue getFieldValue()
          Extract current value for the specified fieldInfo in the form.
 LyFormController getFormController()
          Get the form controller
 LyFormField getFormField()
          Accessor to the formField (View component) associated to the fieldInfo.
 LyFormField getFormField(LyFieldInfo fieldInfo)
          Accessor to the formField (View component) associated to the fieldInfo.
 java.lang.String getImage(LyObject object)
          Get the name of the image (key or path) representing an object instance.
 LyInfoLabel getInfoLabel(LyClassInfo classInfo, LyInfoLabel.Type type)
          Gets info label of the given type for specified class info.
 LyInfoLabel getInfoLabel(LyFieldInfo fieldInfo, LyInfoLabel.Type type)
          Gets info label of the given type for specified field info.
 java.lang.String getLabel(LyObject object, LyFieldInfo fieldInfo, java.lang.Object fieldValue)
          Gets label of an object, for specified field info and value.
 LyObject getObject()
          Get the edited object
 short getState()
          Accessor to the state for a field in the form.
 LyViewController getViewController()
          Accessor to the view controller (Frame or dialog controller) which is the container of this view.
 boolean hasMark(LyFieldInfo fieldInfo, int mark)
          Checks if a mark is set for the given fieldInfo in the context of the form action.
 void invokeTransverseAction(LyAction action, LyClassInfo classInfo)
          Internal method to invoke on a relation a transverse action for a given classInfo.
 boolean isIdle()
          Check idle status of the field controller.
 void menuDemand(LyMenuDemand demand)
          Invoked when an menu item notification is sent to this listener.
 void propagate(java.lang.Object value)
          Impact of a value change of a fieldInfo.
 void resetFromValue(java.lang.Object value, boolean freeOldValue, boolean createNewValue)
          Sets the field content from the specified value Any value modified by the user is the form is lost.
 boolean restore(LyFieldSave fieldSave)
          Restore field input.
 LyFieldSave save(boolean full)
          Save field input.
 void setAreaNoScroll(LyComponent component)
          Method used to set no scrolling to the component in type change case if it's a LyArea component or a LyTabs component.
 void setFieldValue(LyValue newValue, boolean propagate)
          Sets the value of a fieldInfo This methods extracts the value and calls updateFieldItem.
 void setFieldValue(java.lang.Object value, boolean propagate)
          Sets the value of a fieldInfo.
 void setFormField(LyFormField formField)
          Sets formField.
 void setState(short status)
          Sets the valid status of a field in the form.
 java.lang.String toString()
          Get this controller as a string.
 void updateFieldItem(java.lang.Object newValue, java.lang.Object oldValue, boolean propagate)
          Update the value of a fieldInfo shown in the view.
 
Methods inherited from class leon.control.LyController
activateViewDemand, demandPerformed, dragDropDemand, getApplication, getBehaviorInterface, getBuilder, getClassInfo, getId, getImage, getImage, getImage, getImageFromPrefix, getImageFromPrefix, getImageFromPrefix, getKeyValue, getLastModified, getName, getObjectId, getParent, getSession, getUserData, getView, getViewManager, hasViewController, helpDemand, hideView, hideView, isFreed, selectionDemand, setBuilder, setBuilderClass, setIdle, setLastModified, setName, setUserData, showError, showError, showView, showWarning, updateViewFromValues
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version

See Also:
Constant Field Values

FORM_FIELD_SEP

public static final java.lang.String FORM_FIELD_SEP
Separator used to build form field identifiers.

See Also:
Constant Field Values

OLD_FORM_FIELD_SEP

public static final java.lang.String OLD_FORM_FIELD_SEP
Old form field sep

See Also:
Constant Field Values
Constructor Detail

LyFieldController

public LyFieldController(LyAreaController parent,
                         LyFieldInfo fieldInfo)
Constructor.

Parameters:
parent - parent controller (or null for 'root' controller).
fieldInfo - the associated field handled by this controller
Method Detail

free

public void free()
Free this controller.

Overrides:
free in class LyController

clearViewCache

public void clearViewCache()
Clears all cached data for this controller (especially the view and the component).

This method may be invoked for memory optimization, but the controller is still valid and may be used. (Unlike free) Further usage, needs to rebuild internal component & view which may be time consuming.

Overrides:
clearViewCache in class LyController

getBehavior

public LyBehaviorInterface getBehavior()
Description copied from class: LyController
Accessor to controller behavior A behavior is associated to a controller to let the Developer specify application logic in the behavior.

Overrides:
getBehavior in class LyController
Returns:
associated behavior
See Also:
LyController.getBehavior()

getViewController

public LyViewController getViewController()
Description copied from class: LyController
Accessor to the view controller (Frame or dialog controller) which is the container of this view. This method must be implemented in subclasses depending on the nature of the component.

Specified by:
getViewController in class LyController
Returns:
the reference to a view controller, never returns null if the controller is associated to a view.
See Also:
LyController.getViewController()

getFieldInfo

public LyFieldInfo getFieldInfo()
Get the field associated with this controller

Returns:
the associated field

getClassInfo

public LyClassInfo getClassInfo()
Get the classInfo associated with this controller

Returns:
the classInfo

getObject

public LyObject getObject()
Get the edited object

Returns:
the edited object

getAction

public LyAction getAction()
Get the current action

Returns:
the action

getEnvironment

public final LyEnvironment getEnvironment()
Get the environment of the parent form controller

Overrides:
getEnvironment in class LyController
Returns:
current environment instance.
See Also:
LyController.getEnvironment()

getFormController

public LyFormController getFormController()
Get the form controller

Returns:
the form controller

getImage

public java.lang.String getImage(LyObject object)
Get the name of the image (key or path) representing an object instance.
Call the parent form controller method.

Overrides:
getImage in class LyController
Parameters:
object - source object for image association.
Returns:
the image path or key code.

getInfoLabel

public LyInfoLabel getInfoLabel(LyClassInfo classInfo,
                                LyInfoLabel.Type type)
Gets info label of the given type for specified class info.

Parameters:
classInfo - the classInfo
type - the type of label
Returns:
The info label if found, null otherwise.

getInfoLabel

public LyInfoLabel getInfoLabel(LyFieldInfo fieldInfo,
                                LyInfoLabel.Type type)
Gets info label of the given type for specified field info.

Parameters:
fieldInfo - a fieldInfo
type - the type of label
Returns:
The info label if found, null otherwise.

getLabel

public java.lang.String getLabel(LyObject object,
                                 LyFieldInfo fieldInfo,
                                 java.lang.Object fieldValue)
Gets label of an object, for specified field info and value.

Parameters:
object - Object for which a label is required.
fieldInfo - field info.
fieldValue - value of the field.
Returns:
Label as a string.

actionDemand

public void actionDemand(LyActionDemand demand)
Invoked when an action occurs. At this level, the implementation manages
DEMAND_VALIDATE demands. (demand.getType = LyActionDemand.TYPE_ACTION AND demand.getSource() = LyController.DEMAND_VALIDATE)
DEMAND_APPLY demands. (demand.getType = LyActionDemand.TYPE_ACTION AND demand.getSource() = LyController.DEMAND_APPLY)
Default action (double click)
Default action (double click)
VALUE_CHANGED demands. (demand.getType = LyActionDemand.TYPE_VALUE_CHANGED

Overrides:
actionDemand in class LyController
Parameters:
demand - the action demand
See Also:
LyController.demandPerformed(leon.view.event.LyDemand)

menuDemand

public void menuDemand(LyMenuDemand demand)
Invoked when an menu item notification is sent to this listener.

Overrides:
menuDemand in class LyController
Parameters:
demand - demand parameters sent by the view component.
See Also:
LyController.demandPerformed(leon.view.event.LyDemand)

invokeTransverseAction

public void invokeTransverseAction(LyAction action,
                                   LyClassInfo classInfo)
Internal method to invoke on a relation a transverse action for a given classInfo.

Parameters:
action - Transverse action.
classInfo - Class info on which the action is applied.

propagate

public void propagate(java.lang.Object value)
Impact of a value change of a fieldInfo.

Parameters:
value - new Value of the field.

getFieldValue

public LyValue getFieldValue()
Extract current value for the specified fieldInfo in the form.

Returns:
current value, or null if not found or field is disabled.

updateFieldItem

public void updateFieldItem(java.lang.Object newValue,
                            java.lang.Object oldValue,
                            boolean propagate)
Update the value of a fieldInfo shown in the view. The method sets the value of the associated fieldItem.

Parameters:
newValue - the new value of the field.
oldValue - former value of the field,or null if unknown.
propagate - Indicates whether the change is notified (propagated) to other fields or not.
See Also:
getFieldItem()

getFormField

public LyFormField getFormField()
Accessor to the formField (View component) associated to the fieldInfo. The formField contains a caption (label of the fieldInfo), a fieldItem (value of the fieldInfo) and the constraints definition (how the component are shown in the view).

Returns:
the formField corresponding to the given fieldInfo

getFormField

public LyFormField getFormField(LyFieldInfo fieldInfo)
Accessor to the formField (View component) associated to the fieldInfo. The formField contains a caption (label of the fieldInfo), a fieldItem (value of the fieldInfo) and the constraints definition (how the component are shown in the view).

Parameters:
fieldInfo - the fieldInfo which is associated to the view component.
Returns:
the formField corresponding to the given fieldInfo

setFormField

public void setFormField(LyFormField formField)
Sets formField. Called by LyFormFieldBuilder to avoid loops. Reserved for internal use.

Parameters:
formField - the form field to set

getAreaController

public LyAreaController getAreaController()
Gets the specific areaController for the given field info.

Returns:
Area controller corresponding to the given field info, null in most cases.

getComponent

public LyComponent getComponent()
Description copied from class: LyController
Accessor to the view component instance. (XML description of the view) This instance is created by the builder, and multiple calls to this method always return the same instance.

Overrides:
getComponent in class LyController
Returns:
the LyComponent instance of the view package, memory representation (parsed) of the XML description of the view.
See Also:
LyController.getComponent()

setAreaNoScroll

public void setAreaNoScroll(LyComponent component)
Method used to set no scrolling to the component in type change case if it's a LyArea component or a LyTabs component. If the component is a LyTabs, recall this method for the child component of each tab.

Parameters:
component - The component which we want set no scrollbar.

getFieldController

public LyFieldController getFieldController(int index)
Get the field controller at the given index.

Parameters:
index - an index
Returns:
null

toString

public java.lang.String toString()
Get this controller as a string.

Overrides:
toString in class LyController
Returns:
the name of this controller
See Also:
Object.toString()

setState

public void setState(short status)
Sets the valid status of a field in the form.

Parameters:
status - current validity status

getState

public short getState()
Accessor to the state for a field in the form.

Returns:
current field state

resetFromValue

public void resetFromValue(java.lang.Object value,
                           boolean freeOldValue,
                           boolean createNewValue)
Sets the field content from the specified value Any value modified by the user is the form is lost. Default implementation just call updateFieldItem but this may be overriden in subclasses.

Parameters:
value - new value to set in the field.
freeOldValue - indicates if the old value should be freed (deleted) when it is an object
createNewValue - indicates if a new empty value should created when object is null and when the value is an object

isIdle

public boolean isIdle()
Check idle status of the field controller.

Specified by:
isIdle in interface LyGuiListener
Overrides:
isIdle in class LyController
Returns:
boolean indicating if the idle mode is on or off.

setFieldValue

public void setFieldValue(java.lang.Object value,
                          boolean propagate)
Sets the value of a fieldInfo.

Parameters:
value - the new value of the field. This value may be null, a LyValue instance or the internal value associated to the fieldInfo. See LyValue.getValue()
propagate - Indicates whether the change is notified (propagated) to other fields or not. This is useless if you reset all fields for instance.
See Also:
getFieldValue(), LyValue.getValue()

setFieldValue

public void setFieldValue(LyValue newValue,
                          boolean propagate)
Sets the value of a fieldInfo This methods extracts the value and calls updateFieldItem.

Parameters:
newValue - the new value of the field. This value may be null to set the value to blank (empty).
propagate - Indicates whether the change is notified (propagated) to other fields or not. This is useless if you reset all fields for instance.
See Also:
getFieldValue()

hasMark

public boolean hasMark(LyFieldInfo fieldInfo,
                       int mark)
Checks if a mark is set for the given fieldInfo in the context of the form action.

Parameters:
fieldInfo - Field to be checked.
mark - Mark to be checked.
Returns:
True if the given field has the given mark, false otherwise.

save

public LyFieldSave save(boolean full)
Save field input.


restore

public boolean restore(LyFieldSave fieldSave)
Restore field input.


getDefaultFieldUnit

public LyUnit getDefaultFieldUnit()
Get the default unit for the current field

Returns:
the default unit (can be null)

getDefaultFieldUnit

public LyUnit getDefaultFieldUnit(LyFieldInfo fieldInfo)
Get the default unit for the given field

Parameters:
fieldInfo - a field
Returns:
a default unit

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com