LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.control
Class LyFormController

java.lang.Object
  extended by leon.control.LyController
      extended by leon.control.LyAreaController
          extended by leon.control.LyMultiAreaController
              extended by leon.control.LyFormController
All Implemented Interfaces:
LyGetSessionInterface, LyContextInterface, LyGetActionInterface, LySelectFileListenerInterface, LyAdvancedWorkSpaceListener, LyGuiListener, LyWorkSpaceListener, LyGetClassInfoInterface, LyInfoListener, LyEvaluator, LyDemandListener
Direct Known Subclasses:
LyChartController, LyConsultController, LyOutlineController, LySimpleFilterController

public abstract class LyFormController
extends LyMultiAreaController
implements LyAdvancedWorkSpaceListener, LyGetClassInfoInterface

The form controller is an area which describes a dialog view with a set of fields and values. User may just consult or modify data. Usually (not necessary) the form is associated to one or several Leonardi objects (LyObjects).

This class is specialized in consult/create/set and other controllers.

Services offered at this level of implementation :

The form controller is also receiving updates notification on object changes and may refresh the information shown to the user : titlebar, toobar, field values ...

The behavior associated to a LyFormController is shared by several implementation of this controller : the behavior must implement LyFormBehaviorInterface and is usually an instance of LyClassBehavior.

See Also:
LyFormBehaviorInterface, LyClassBehavior

Field Summary
static java.lang.String __VERSION
          File Version
static java.lang.String DEMAND_APPLY
          Interaction code on the command bar button : Apply inputs.
static java.lang.String DEMAND_NEXT_OBJECT
          User action on toolbar : Show next object.
static java.lang.String DEMAND_NEXT_STEP
          Show next window.
static java.lang.String DEMAND_PREVIOUS_OBJECT
          User action on toolbar : Show previous object.
static java.lang.String DEMAND_PREVIOUS_STEP
          Show previous window.
static java.lang.String DEMAND_SAVE
          Interaction code on the command bar button : Save inputs.
static java.lang.String DEMAND_SELECTION
          User action on toolbar : select an object in the list.
static java.lang.String DEMAND_VALIDATE
          Interaction code on the command bar button : Validate inputs.
static java.lang.String FORM_FIELD_SEP
          Separator used to build form field identifiers.
 
Fields inherited from class leon.control.LyAreaController
DEFAULT_MENU_ITEM_IMAGE_SIZE, DEMAND_CANCEL, DEMAND_CLOSE, DEMAND_CREATE_CHART, DEMAND_DELETE_CHART, DEMAND_DELETE_OBJECTINFOS, DEMAND_DELETE_PREFERENCE, DEMAND_UPDATE_VIEW
 
Fields inherited from class leon.control.LyController
_nbControllers, _nextId, CONTROLLER_ID_SEP, DEFAULT_IMAGE_FORMAT, DEMAND_HELP, ID_SEP
 
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).
 boolean contains(LyFieldInfo fieldInfo)
          Checks if the given fieldInfo is present in the controlled form.
 LyFieldController fieldControllerFactory(LyFieldInfo fieldInfo, boolean forceConsult)
          Factory for constructing the field controller of a field info.
 LyFormField findFormField(LyFieldInfo fieldInfo)
          Find recursively the formField corresponding to the given fieldInfo.
 void free(LyController controller)
          Free this controller on request of the specified controller.
 LyAreaController getAreaController(LyFieldInfo fieldInfo)
          Gets the specific areaController for the given field info.
 java.lang.Class<?> getBehaviorInterface()
          Method that gives the interface that must be implemented by the behavior associated to this controller.
 LyClassInfo getClassInfo()
          Gets associated classInfo.
 LyRelationFieldInfo getCompositionRelation()
          Gets the composition relation managed by this form.
 LyObjectList getContent()
          Gets content of this controller.
 LyUnit getDefaultFieldUnit(LyFieldInfo fieldInfo)
          Get the default unit for the given fieldInfo.
 LyEnvironment getEnvironment()
          Accessor to the current Environment instance (shortcut for getSession().getEnvironment()).
 LyFieldController getFieldController(LyFieldInfo fieldInfo)
          Get the field controller of the given fieldInfo.
 java.util.BitSet getFieldMarks()
          Accessor to the field marks required on fields added in the view of this controller.
 LyInfoList<LyFieldInfo> getFields()
          Gets the list of fields being displayed in the form.
 LyValue getFieldValue(LyFieldInfo fieldInfo)
          Extract current value for the specified fieldInfo in the form.
 LyValue getFieldValue(java.lang.String id)
          Extract current value for the specified fieldInfo in the form.
 LyFormField getFormField(LyFieldInfo fieldInfo)
          Accessor to the formField (View component) associated to the fieldInfo.
 java.lang.String getImage()
          Gets image associated with this form.
 java.lang.String getImage(LyObject object)
          Get the name of the image (key or path) representing an object instance.
 java.lang.Object getKeyValue(java.lang.String key)
          Retrieves a value from a registered key.
 LyObject getObject()
          Access to object currently beeing shown in the view.
 LyObjectList getObjectList()
          Accessor to the list of objects associated with this form.
 LyObjectList getSelection()
          Gets selection of this controller.
 short getState(LyFieldInfo fieldInfo)
          Accessor to the state for a field in the form.
 LyTabs getTabs()
          Retrieves the tabs component of this controller view.
 boolean isChangingObject()
          Indicates if the controller is changing its object.
 boolean isComposition(LyFieldInfo fieldInfo)
          Tests if the specified fieldInfo must be represented as a composition relation in forms.
 boolean isDisplayed(LyFieldInfo fieldInfo)
          Utility method to know if a fieldInfo is displayed in this form or not.
 boolean isViewResizable()
          Indicates if the view for this form controller is resizable.
 void menuDemand(LyMenuDemand demand)
          Invoked when a menu demand occurs.
 boolean objectAdded(LyWorkSpaceEvent event)
          Called when an object is added in the dynamic object list.
 boolean objectChanged(LyWorkSpaceEvent event)
          Called when an object has changed in the dynamic object list.
 boolean objectRemoved(LyWorkSpaceEvent event)
          Called when an object is removed from the dynamic object list.
 boolean objectStateChanged(LyAdvancedWorkSpaceEvent event)
          Called when an object state is changed.
 boolean objectUserEvent(LyAdvancedWorkSpaceEvent event)
          Called when an object user event occured.
 void reset(boolean full)
          Reset all the content of the view.
 void resetFormContent()
          Reset form content.
 void resetFromObject(LyObject object, boolean freeOldValue, boolean createNewValue)
          Internal use.
 void setActiveField(LyFieldInfo fieldInfo)
          Activates a field.
 void setCompositionRelation(LyRelationFieldInfo relation)
          Sets composition relation : this method is invoked when this form manages a relation in another form.
 boolean setContext(LyWorkSpace context)
          Set current controller context.
 void setFieldMarks(java.util.BitSet fieldMarks)
          Set field marks required on fields added in the view of this controller.
 boolean setObjects(LyObjectList objects)
          Accessor to the list of objects associated with this form.
 void setState(LyFieldInfo fieldInfo, short status)
          Sets the valid status of a field in the form.
 void showError(LyObject object, LyError error)
          Show an error for the specified object.
 boolean workSpaceEventsGrouped(java.util.ArrayList<LyWorkSpaceEvent> events)
          Called when grouped events are sent.
 
Methods inherited from class leon.control.LyMultiAreaController
addAreaController, addAreaControllerStack, canClose, getAreaController, getAreaController, getAreaControllersCount, getAreaControllerStack, getAreaControllerStackCount, getFinalAreaControllers, getLastModified, openSubAreaController, removeAreaController, removeAreaControllerStack, setAction, setContextClient, setIdle, setViewController, update
 
Methods inherited from class leon.control.LyAreaController
canFree, completeMenuBar, completeMessages, free, getAction, getAreaStackController, getBehavior, getBuilder, getContext, getContextClient, getContextTitle, getDefaultAction, getFastEditionAction, getHelpFile, getImageTooltip, getInfoLabel, getInfoLabel, getLabel, getMenuItemImage, getName, getParameter, getParameter, getParameterMarks, getParent, getParent, getParentAreaController, getRefreshTime, getShortLabel, getTarget, getTitle, getViewController, getViewController, hasMark, hasNotMark, hasViewController, hideView, infoEvent, initialize, isInitialized, isOutlined, reset, selectFileDemand, setContext, setPreference, showView, showView, testParameter, toString, updateTitleBar
 
Methods inherited from class leon.control.LyController
activateViewDemand, demandPerformed, dragDropDemand, getApplication, getClassInfo, getComponent, getId, getImage, getImage, getImage, getImageFromPrefix, getImageFromPrefix, getImageFromPrefix, getName, getObjectId, getSession, getUserData, getView, getViewManager, helpDemand, hideView, isFreed, isIdle, selectionDemand, setBuilder, setBuilderClass, setLastModified, setName, setUserData, showError, 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

DEMAND_VALIDATE

public static final java.lang.String DEMAND_VALIDATE
Interaction code on the command bar button : Validate inputs. Apply and close.


DEMAND_APPLY

public static final java.lang.String DEMAND_APPLY
Interaction code on the command bar button : Apply inputs. Do not close the view.


DEMAND_SAVE

public static final java.lang.String DEMAND_SAVE
Interaction code on the command bar button : Save inputs.


DEMAND_PREVIOUS_OBJECT

public static final java.lang.String DEMAND_PREVIOUS_OBJECT
User action on toolbar : Show previous object. (Available only if multiple objects are shown in the form)

See Also:
Constant Field Values

DEMAND_NEXT_OBJECT

public static final java.lang.String DEMAND_NEXT_OBJECT
User action on toolbar : Show next object. (Available only if multiple objects are shown in the form)

See Also:
Constant Field Values

DEMAND_SELECTION

public static final java.lang.String DEMAND_SELECTION
User action on toolbar : select an object in the list. (Available only if multiple objects are shown in the form)


DEMAND_PREVIOUS_STEP

public static final java.lang.String DEMAND_PREVIOUS_STEP
Show previous window.

See Also:
Constant Field Values

DEMAND_NEXT_STEP

public static final java.lang.String DEMAND_NEXT_STEP
Show next window.

See Also:
Constant Field Values
Method Detail

getBehaviorInterface

public java.lang.Class<?> getBehaviorInterface()
Method that gives the interface that must be implemented by the behavior associated to this controller.

Overrides:
getBehaviorInterface in class LyAreaController
Returns:
Class representing the behavior interface of this controller.

getFieldController

public LyFieldController getFieldController(LyFieldInfo fieldInfo)
Get the field controller of the given fieldInfo.

Parameters:
fieldInfo - a field
Returns:
the associated field controller

fieldControllerFactory

public LyFieldController fieldControllerFactory(LyFieldInfo fieldInfo,
                                                boolean forceConsult)
Factory for constructing the field controller of a field info.

Parameters:
fieldInfo - Field info for which a controller is built.
forceConsult - true to force consult mode
Returns:
The field controller of the given field.

setActiveField

public void setActiveField(LyFieldInfo fieldInfo)
Activates a field. Retrieve its tab and selects it. If there is no tab in the view this method does nothing.

Parameters:
fieldInfo - The field info that must be selected.

getTabs

public LyTabs getTabs()
Retrieves the tabs component of this controller view.

Returns:
The tabs component of the view or null if there is no tabs component in the controller view.

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 LyMultiAreaController

free

public void free(LyController controller)
Free this controller on request of the specified controller. This method invokes endAction.

Overrides:
free in class LyMultiAreaController
Parameters:
controller - controller instance which requested the freeing of this controller. If the controller is the parent, this controller is freed otherwise the method does nothing.
See Also:
LyAreaController.free()

actionDemand

public void actionDemand(LyActionDemand demand)
Invoked when an action occurs. At this level, the implementation manages

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

menuDemand

public void menuDemand(LyMenuDemand demand)
Invoked when a menu demand occurs. At this level, the implementation manages demands on objects represented by an hyperlink.

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

setCompositionRelation

public void setCompositionRelation(LyRelationFieldInfo relation)
Sets composition relation : this method is invoked when this form manages a relation in another form.

Parameters:
relation - the relation fieldInfo

getCompositionRelation

public LyRelationFieldInfo getCompositionRelation()
Gets the composition relation managed by this form.

Returns:
Composition relation managed by this form (may be null).

getFieldValue

public LyValue getFieldValue(java.lang.String id)
Extract current value for the specified fieldInfo in the form.

Parameters:
id - fieldInfo id associated to the requested value
Returns:
current value, or null if not found or field is disabled.

getFieldValue

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

Parameters:
fieldInfo - fieldInfo associated to the requested value
Returns:
current value, or null if not found or field is disabled.

getContent

public LyObjectList getContent()
Gets content of this controller.

Overrides:
getContent in class LyAreaController
Returns:
the current object in a list

getSelection

public LyObjectList getSelection()
Gets selection of this controller. The current implementation return getContent

Overrides:
getSelection in class LyAreaController
Returns:
return the current selection as a list
See Also:
getContent()

getObject

public LyObject getObject()
Access to object currently beeing shown in the view. Depending on nature of the controller, this object MAY be null.

Returns:
the reference to current object being shown or null if no objects are associated to this form.

getObjectList

public LyObjectList getObjectList()
Accessor to the list of objects associated with this form. This list may be null.

Returns:
the list of objects for this controller

setObjects

public boolean setObjects(LyObjectList objects)
Accessor to the list of objects associated with this form. The user may navigate through this list of objects.

Parameters:
objects - list of objects which could be shown in the form.
Returns:
true if successfull

getClassInfo

public LyClassInfo getClassInfo()
Gets associated classInfo. The classInfo is the class of the object if any, or null if no object is being shown.

Specified by:
getClassInfo in interface LyGetClassInfoInterface
Overrides:
getClassInfo in class LyAreaController
Returns:
the classInfo of current object or null if no object is specified.

getImage

public java.lang.String getImage()
Gets image associated with this form. The image is the image associated with the classInfo of current object.

Overrides:
getImage in class LyAreaController
Returns:
the image if an object or a classInfo is found, null otherwise.

getImage

public java.lang.String getImage(LyObject object)
Get the name of the image (key or path) representing an object instance. Default implementation returns the icon associated to the classInfo.

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

setContext

public boolean setContext(LyWorkSpace context)
Set current controller context.

Specified by:
setContext in interface LyContextInterface
Overrides:
setContext in class LyMultiAreaController
Parameters:
context - current context or null if none is specified
Returns:
true if successfull
See Also:
LyContextInterface.getContext()

setFieldMarks

public void setFieldMarks(java.util.BitSet fieldMarks)
Set field marks required on fields added in the view of this controller.

Parameters:
fieldMarks - the fieldMark list

getFields

public LyInfoList<LyFieldInfo> getFields()
Gets the list of fields being displayed in the form. The default implementation uses the specified fieldsMarks or if specified the lists of fields given by the setFields method.

Returns:
the list of fields being displayed

getFieldMarks

public java.util.BitSet getFieldMarks()
Accessor to the field marks required on fields added in the view of this controller.

Returns:
fieldMarks the fieldMark list, or null if none specified

isDisplayed

public boolean isDisplayed(LyFieldInfo fieldInfo)
Utility method to know if a fieldInfo is displayed in this form or not. Default implementation check if the specified fieldInfo has the marks requested in getFieldMark. If no marksList is specified (null), the method returns true.

Parameters:
fieldInfo - the fieldInfo which is tested for addition in the view.
Returns:
true if the field should be added, false if it should be skipped.

isViewResizable

public boolean isViewResizable()
Indicates if the view for this form controller is resizable.

Overrides:
isViewResizable in class LyMultiAreaController
Returns:
false since form views are not resizable.

contains

public boolean contains(LyFieldInfo fieldInfo)
Checks if the given fieldInfo is present in the controlled form. The field is present if a formField was created

Parameters:
fieldInfo - the field to check
Returns:
true if the field is added (shown) in the form, false otherwise.

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

objectAdded

public boolean objectAdded(LyWorkSpaceEvent event)
Called when an object is added in the dynamic object list. Default implementation does nothing, and returns false

Specified by:
objectAdded in interface LyWorkSpaceListener
Parameters:
event - event of adding object
Returns:
the event is used by the listener

objectRemoved

public boolean objectRemoved(LyWorkSpaceEvent event)
Called when an object is removed from the dynamic object list. Keep content consistent : go to next available object if any or close the view.

Specified by:
objectRemoved in interface LyWorkSpaceListener
Parameters:
event - event of removing object
Returns:
the event is used by the listener

objectChanged

public boolean objectChanged(LyWorkSpaceEvent event)
Called when an object has changed in the dynamic object list. Keep the content consistent and invoke when needed updateObjects and updateObject.

Specified by:
objectChanged in interface LyWorkSpaceListener
Parameters:
event - event of changing object
Returns:
the event is used by the listener

objectStateChanged

public boolean objectStateChanged(LyAdvancedWorkSpaceEvent event)
Called when an object state is changed.

Specified by:
objectStateChanged in interface LyAdvancedWorkSpaceListener
Parameters:
event - Event notifying object state change.
Returns:
True if the event is used by the listener, false otherwise.

objectUserEvent

public boolean objectUserEvent(LyAdvancedWorkSpaceEvent event)
Called when an object user event occured.

Specified by:
objectUserEvent in interface LyAdvancedWorkSpaceListener
Parameters:
event - Event notifying object user event.
Returns:
True if the event is used by the listener, false otherwise.

workSpaceEventsGrouped

public boolean workSpaceEventsGrouped(java.util.ArrayList<LyWorkSpaceEvent> events)
Called when grouped events are sent.

Specified by:
workSpaceEventsGrouped in interface LyAdvancedWorkSpaceListener
Parameters:
events - Sorted list of events.
Returns:
True if the events are used by the listener, false otherwise.

getAreaController

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

Parameters:
fieldInfo - Field info for which an area controller is requested.
Returns:
Area controller corresponding to the given field info, null in most cases.

isComposition

public boolean isComposition(LyFieldInfo fieldInfo)
Tests if the specified fieldInfo must be represented as a composition relation in forms.

Parameters:
fieldInfo -
Returns:
true if the fieldinfo is a composition field

resetFormContent

public void resetFormContent()
Reset form content.


setState

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

Parameters:
fieldInfo - the specified field
status - current validity status

getState

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

Parameters:
fieldInfo - the specified field
Returns:
current field state

isChangingObject

public boolean isChangingObject()
Indicates if the controller is changing its object.

Returns:
true if the object is changing

resetFromObject

public void resetFromObject(LyObject object,
                            boolean freeOldValue,
                            boolean createNewValue)
Internal use. Sets the form content from the specified object : all field controllers and form fields take the specified value. Any value modified by the user is the form is lost. Unlike setObject() and updateFielditem(), no control is done to prevent overriding existing values.

Parameters:
object - new object used to reset the view content.
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

findFormField

public LyFormField findFormField(LyFieldInfo fieldInfo)
Find recursively the formField corresponding to the given fieldInfo.

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

getEnvironment

public LyEnvironment getEnvironment()
Accessor to the current Environment instance (shortcut for getSession().getEnvironment()).

Overrides:
getEnvironment in class LyAreaController
Returns:
current environment instance.

reset

public void reset(boolean full)
Reset all the content of the view.

Overrides:
reset in class LyAreaController
Parameters:
full - Boolean indicating if a full reset (including reset of datas) is requiered or not (only reset graphical area).

getKeyValue

public java.lang.Object getKeyValue(java.lang.String key)
Retrieves a value from a registered key.

Specified by:
getKeyValue in interface LyEvaluator
Overrides:
getKeyValue in class LyAreaController
Parameters:
key - The key that must be used.
Returns:
The value stored with the key or null if the key is not registered.

showError

public void showError(LyObject object,
                      LyError error)
Show an error for the specified object.

Overrides:
showError in class LyController
Parameters:
object - The object in error
error - The error to show
See Also:
LyController.showError(String)

getDefaultFieldUnit

public LyUnit getDefaultFieldUnit(LyFieldInfo fieldInfo)
Get the default unit for the given fieldInfo. This method ask the session behavior to compute this unit. If the session behavior returns null, it will return the reference unit.

Parameters:
fieldInfo - a fieldInfo
Returns:
a unit (can be null)

(c) January 2013 - W4 S.A.

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