C# Class Habanero.Faces.Base.ControlMapper

A superclass to model a mapper that wraps a control in order to display and capture information for an individual property of a Business Object. Think of the Control Mappers as Binding on Steriods.
Inheritance: IControlMapper
Show file Open project: Chillisoft/habanero.faces Class Usage Examples

Protected Properties

Property Type Description
_attributes System.Collections.Hashtable
_businessObject IBusinessObject
_logger IHabaneroLogger

Private Properties

Property Type Description
AddCurrentBOPropHandlers void
AddKeyPressHandlers void
CheckReadWriteRules bool
DoesVirtualPropertyHaveSetter bool
IsPropertyReflective bool
IsPropertyViaRelationship bool
IsTypeOfIControlMapper bool
RemoveCurrentBOPropHandlers void

Public Methods

Method Description
ApplyChangesToBusinessObject ( ) : void

Updates the properties on the represented business object

BOPropValueUpdatedHandler ( object sender, EventArgs e ) : void

Handler to carry out changes where the value of a business object property has changed

Create ( IControlHabanero ctl, string propertyName ) : IControlMapper

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.

Create ( Type mapperType, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper

Create a Control Mapper based on the mapperType

Create ( string mapperTypeName, IControlHabanero ctl, string propertyName ) : IControlMapper

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.

Create ( string mapperTypeName, string mapperAssembly, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.

CurrentBOProp ( ) : IBOProp

Returns the IBOProp object being mapped to this control

GetErrorMessage ( ) : string

Returns the Error Provider's Error message.

SetPropertyAttributes ( Hashtable attributes ) : void

A form field can have attributes defined in the class definition. These attributes are passed to the control mapper via a hashtable so that the control mapper can adjust its behaviour accordingly.

UpdateControlValueFromBusinessObject ( ) : void

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject. This also updates the Error Provider with any Error Messages.

UpdateErrorProviderErrorMessage ( ) : void

Sets the Error Provider Error with the appropriate value for the property e.g. if it is invalid then sets the error provider with the invalid reason else sets the error provider with a zero length string.

Protected Methods

Method Description
ControlMapper ( IControlHabanero ctl, string propName, bool isReadOnly, IControlFactory factory ) : System

Constructor to instantiate a new instance of the class

GetPropertyValue ( ) : object

Returns the property value of the business object being mapped

InitialiseWithAttributes ( ) : void

Initialises the control using the attributes already provided, using SetPropertyAttributes.

InternalUpdateControlValueFromBo ( ) : void

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject.

IsPropertyVirtual ( ) : bool

is the property a virtual property i.e. is it loaded via reflection or via a relationship.

OnBusinessObjectChanged ( ) : void

An overridable method to provide custom logic to carry out when the business object is changed

SetError ( string errorMessage ) : void
SetPropertyValue ( object value ) : void

Sets the property value to that provided. If the property value is invalid, the error provider will be given the reason why the value is invalid.

UpdateControlVisualState ( bool editable ) : void

Update the Visual state of the control so as to differentiate between Editable and none editable controls.

UpdateIsEditable ( ) : void

Updates the isEditable flag and updates the control according to the current state

Private Methods

Method Description
AddCurrentBOPropHandlers ( ) : void
AddKeyPressHandlers ( ) : void
CheckReadWriteRules ( ) : bool
DoesVirtualPropertyHaveSetter ( ) : bool
IsPropertyReflective ( ) : bool
IsPropertyViaRelationship ( ) : bool
IsTypeOfIControlMapper ( Type mapperType ) : bool
RemoveCurrentBOPropHandlers ( ) : void

Method Details

ApplyChangesToBusinessObject() public abstract method

Updates the properties on the represented business object
public abstract ApplyChangesToBusinessObject ( ) : void
return void

BOPropValueUpdatedHandler() public method

Handler to carry out changes where the value of a business object property has changed
public BOPropValueUpdatedHandler ( object sender, EventArgs e ) : void
sender object The object that notified of the event
e System.EventArgs Attached arguments regarding the event
return void

ControlMapper() protected method

Constructor to instantiate a new instance of the class
protected ControlMapper ( IControlHabanero ctl, string propName, bool isReadOnly, IControlFactory factory ) : System
ctl IControlHabanero The control object to map
propName string The property name
isReadOnly bool Whether the control is read only. /// If so, it then becomes disabled. If not, /// handlers are assigned to manage key presses.
factory IControlFactory
return System

Create() public static method

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.
An exception is /// thrown if the mapperTypeName does not provide a type that is /// a subclass of the ControlMapper class.
public static Create ( IControlHabanero ctl, string propertyName ) : IControlMapper
ctl IControlHabanero The control to be mapped
propertyName string The property name
return IControlMapper

Create() public static method

Create a Control Mapper based on the mapperType
public static Create ( Type mapperType, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper
mapperType System.Type
ctl IControlHabanero The control to be mapped
propertyName string The property name
isReadOnly bool Whether the control is read-only
controlFactory IControlFactory The control factory that is being set on the Mapper
return IControlMapper

Create() public static method

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.
An exception is /// thrown if the mapperTypeName does not provide a type that is /// a subclass of the ControlMapper class.
public static Create ( string mapperTypeName, IControlHabanero ctl, string propertyName ) : IControlMapper
mapperTypeName string The class name of the mapper type /// (e.g. ComboBoxMapper). The current namespace of this /// ControlMapper class will then be prefixed to the name.
ctl IControlHabanero The control to be mapped
propertyName string The property name
return IControlMapper

Create() public static method

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.
An exception is /// thrown if the mapperTypeName does not provide a type that is /// a subclass of the ControlMapper class.
public static Create ( string mapperTypeName, string mapperAssembly, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper
mapperTypeName string The class name of the mapper type /// (e.g. ComboBoxMapper). The current namespace of this /// ControlMapper class will then be prefixed to the name.
mapperAssembly string The assembly where the mapper is /// located
ctl IControlHabanero The control to be mapped
propertyName string The property name
isReadOnly bool Whether the control is read-only
controlFactory IControlFactory The control factory
return IControlMapper

CurrentBOProp() public method

Returns the IBOProp object being mapped to this control
public CurrentBOProp ( ) : IBOProp
return IBOProp

GetErrorMessage() public method

Returns the Error Provider's Error message.
public GetErrorMessage ( ) : string
return string

GetPropertyValue() protected method

Returns the property value of the business object being mapped
protected GetPropertyValue ( ) : object
return object

InitialiseWithAttributes() protected method

Initialises the control using the attributes already provided, using SetPropertyAttributes.
protected InitialiseWithAttributes ( ) : void
return void

InternalUpdateControlValueFromBo() protected abstract method

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject.
protected abstract InternalUpdateControlValueFromBo ( ) : void
return void

IsPropertyVirtual() protected method

is the property a virtual property i.e. is it loaded via reflection or via a relationship.
protected IsPropertyVirtual ( ) : bool
return bool

OnBusinessObjectChanged() protected method

An overridable method to provide custom logic to carry out when the business object is changed
protected OnBusinessObjectChanged ( ) : void
return void

SetError() protected method

protected SetError ( string errorMessage ) : void
errorMessage string
return void

SetPropertyAttributes() public method

A form field can have attributes defined in the class definition. These attributes are passed to the control mapper via a hashtable so that the control mapper can adjust its behaviour accordingly.
public SetPropertyAttributes ( Hashtable attributes ) : void
attributes System.Collections.Hashtable A hashtable of attributes, which consists /// of name-value pairs, where name is the attribute name. This is usually /// set in the XML definitions for the class's user interface.
return void

SetPropertyValue() protected method

Sets the property value to that provided. If the property value is invalid, the error provider will be given the reason why the value is invalid.
protected SetPropertyValue ( object value ) : void
value object
return void

UpdateControlValueFromBusinessObject() public method

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject. This also updates the Error Provider with any Error Messages.
public UpdateControlValueFromBusinessObject ( ) : void
return void

UpdateControlVisualState() protected method

Update the Visual state of the control so as to differentiate between Editable and none editable controls.
protected UpdateControlVisualState ( bool editable ) : void
editable bool
return void

UpdateErrorProviderErrorMessage() public method

Sets the Error Provider Error with the appropriate value for the property e.g. if it is invalid then sets the error provider with the invalid reason else sets the error provider with a zero length string.
public UpdateErrorProviderErrorMessage ( ) : void
return void

UpdateIsEditable() protected method

Updates the isEditable flag and updates the control according to the current state
protected UpdateIsEditable ( ) : void
return void

Property Details

_attributes protected property

A Hash table of additional Attributes available for this Control Mapper e.g. for DateTimePickerMapper may have date format
protected Hashtable,System.Collections _attributes
return System.Collections.Hashtable

_businessObject protected property

The Business Object being mapped
protected IBusinessObject _businessObject
return IBusinessObject

_logger protected static property

the ILog used to log any messages for this class or its children
protected static IHabaneroLogger _logger
return IHabaneroLogger