ix.iface.ui
Class AbstractIFormModel

java.lang.Object
  |
  +--ix.iface.ui.AbstractIFormModel
All Implemented Interfaces:
IFormModel
Direct Known Subclasses:
GenericIFormModel

public abstract class AbstractIFormModel
extends java.lang.Object
implements IFormModel

An abstract model class to be used to fill an IFormPanel.


Field Summary
protected  java.lang.Object baseObject
           
(package private)  java.lang.Class baseObjectClass
           
(package private)  java.util.List displayFields
           
(package private)  java.util.HashMap fieldClasses
           
(package private)  java.util.HashMap fieldNames
           
(package private)  boolean isUpdating
           
(package private)  java.util.HashSet listeners
           
(package private)  java.util.List nameFields
           
 
Constructor Summary
AbstractIFormModel(java.lang.Class objectClass)
           
AbstractIFormModel(java.lang.Object object)
           
 
Method Summary
static java.util.Collection addIfField(java.util.Collection fields, java.lang.Class c, java.lang.String sField)
           
 void addModelListener(FormModelListener l)
           
 void clearData()
          Clears the model of its data;
protected  void deriveClasses()
          Collects name and display fields and calls deriveClasses(fields).
protected abstract  void deriveClasses(java.util.List fields)
          Derives the classes of the given fields and puts them into HashMap fieldClasses.
protected abstract  java.util.List deriveDisplayFields()
          Derives the fields to be used for displaying the object information
protected abstract  java.util.List deriveNameFields()
          Derives the fields to be used for displaying the object name(s)
protected  void deriveNames()
          Collects name and display fields and calls deriveNames(fields).
protected abstract  void deriveNames(java.util.List fields)
          Derives the names of the given fields and puts them into HashMap fieldNames.
 void endUpdate()
           
 void fireModelChanged(java.lang.String change)
           
 java.util.List getDisplayClasses()
          Get the classes of the object's display fields (e.g.
 java.util.List getDisplayFields()
          Get the fields of the object that are to be displayed (exc.
 java.util.List getDisplayNames()
          Get the titles to use for the object's display fields
 java.lang.Class getFieldClass(java.lang.String field)
          Gets the class of the object's given field name (e.g.
 java.lang.String getFieldName(java.lang.String field)
          Gets the title to use for the object's given field (e.g.
 double getFieldWeight(java.lang.String field)
          Gets the weight of the object's given field name to establish its portion of the display.
 java.util.List getNameClasses()
          Get the classes of the object's name fields (e.g.
 java.util.List getNameFields()
          Get the fields that correspond to the object's name (e.g.
 java.util.List getNameNames()
          Get the titles to use for the object's name fields (e.g.
 java.lang.Object getObject()
          Get the model's current base object
 java.lang.Class getObjectClass()
          Get the class of the model's base object
 java.lang.Object getValue(java.lang.String field)
          Get the current object's value for the given field.
 void ignoreUpdate()
           
 boolean isEditable(java.lang.String field)
          Determines whether a field is editable (can be changed by the user) or not.
protected  java.util.List lookupFieldClasses(java.util.List fields)
           
protected  java.util.List lookupFieldNames(java.util.List fields)
           
 void setDisplayFields(java.util.List fields)
          Sets the fields of the object that are to be displayed (exc.
 void setDisplayFields(java.lang.String[] fields)
          Sets the fields of the object that are to be shown as its name.
 void setFields()
          Derives the name fields, display fields and the field names and classes.
 void setNameFields(java.util.List fields)
          Sets the fields of the object that are to be shown as its name.
 void setNameFields(java.lang.String[] fields)
          Sets the fields of the object that are to be shown as its name.
 void setObject(java.lang.Object o)
          Set the model's base object
 void setObjectClass(java.lang.Class c)
          Set the class of the model's base object
 void setValue(java.lang.Object object, java.lang.String field, java.lang.Object value)
          Sets the given object's given field to the given value.
 void setValue(java.lang.String field, java.lang.Object value)
          Sets the current object's given field to the given value.
 void startUpdate()
           
 java.lang.reflect.Field stringToField(java.lang.Class oClass, java.lang.String field)
           
 java.lang.reflect.Field stringToField(java.lang.String field)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nameFields

java.util.List nameFields

displayFields

java.util.List displayFields

fieldNames

java.util.HashMap fieldNames

fieldClasses

java.util.HashMap fieldClasses

baseObject

protected java.lang.Object baseObject

baseObjectClass

java.lang.Class baseObjectClass

listeners

java.util.HashSet listeners

isUpdating

boolean isUpdating
Constructor Detail

AbstractIFormModel

public AbstractIFormModel(java.lang.Class objectClass)

AbstractIFormModel

public AbstractIFormModel(java.lang.Object object)
Method Detail

clearData

public void clearData()
Description copied from interface: IFormModel
Clears the model of its data;
Specified by:
clearData in interface IFormModel

getFieldName

public java.lang.String getFieldName(java.lang.String field)
Description copied from interface: IFormModel
Gets the title to use for the object's given field (e.g. "Name", "Id")
Specified by:
getFieldName in interface IFormModel

getFieldClass

public java.lang.Class getFieldClass(java.lang.String field)
Description copied from interface: IFormModel
Gets the class of the object's given field name (e.g. String.class, Object.class)
Specified by:
getFieldClass in interface IFormModel

getFieldWeight

public double getFieldWeight(java.lang.String field)
Description copied from interface: IFormModel
Gets the weight of the object's given field name to establish its portion of the display.
Specified by:
getFieldWeight in interface IFormModel

setNameFields

public void setNameFields(java.util.List fields)
Description copied from interface: IFormModel
Sets the fields of the object that are to be shown as its name.
Specified by:
setNameFields in interface IFormModel
Following copied from interface: ix.iface.ui.IFormModel
Parameters:
nameFields - a list of strings; the field names

setNameFields

public void setNameFields(java.lang.String[] fields)
Description copied from interface: IFormModel
Sets the fields of the object that are to be shown as its name.
Specified by:
setNameFields in interface IFormModel
Following copied from interface: ix.iface.ui.IFormModel
Parameters:
nameFields - an array of strings; the field names

setDisplayFields

public void setDisplayFields(java.util.List fields)
Description copied from interface: IFormModel
Sets the fields of the object that are to be displayed (exc. names)
Specified by:
setDisplayFields in interface IFormModel
Following copied from interface: ix.iface.ui.IFormModel
Parameters:
nameFields - a list of strings; the field names

setDisplayFields

public void setDisplayFields(java.lang.String[] fields)
Description copied from interface: IFormModel
Sets the fields of the object that are to be shown as its name.
Specified by:
setDisplayFields in interface IFormModel
Following copied from interface: ix.iface.ui.IFormModel
Parameters:
nameFields - an array of strings; the field names

getNameFields

public java.util.List getNameFields()
Get the fields that correspond to the object's name (e.g. "name", "id")
Specified by:
getNameFields in interface IFormModel

getNameNames

public java.util.List getNameNames()
Get the titles to use for the object's name fields (e.g. "Name", "Id"). Derive them if they are not there.

getNameClasses

public java.util.List getNameClasses()
Get the classes of the object's name fields (e.g. String.class, Object.class)

getDisplayFields

public java.util.List getDisplayFields()
Get the fields of the object that are to be displayed (exc. names)
Specified by:
getDisplayFields in interface IFormModel

getDisplayNames

public java.util.List getDisplayNames()
Get the titles to use for the object's display fields

getDisplayClasses

public java.util.List getDisplayClasses()
Get the classes of the object's display fields (e.g. String.class, Object.class, Collection.class)

setObject

public void setObject(java.lang.Object o)
Description copied from interface: IFormModel
Set the model's base object
Specified by:
setObject in interface IFormModel

getObject

public java.lang.Object getObject()
Description copied from interface: IFormModel
Get the model's current base object
Specified by:
getObject in interface IFormModel

setObjectClass

public void setObjectClass(java.lang.Class c)
Set the class of the model's base object

getObjectClass

public java.lang.Class getObjectClass()
Get the class of the model's base object
Specified by:
getObjectClass in interface IFormModel

getValue

public java.lang.Object getValue(java.lang.String field)
Get the current object's value for the given field.
Specified by:
getValue in interface IFormModel

setValue

public void setValue(java.lang.String field,
                     java.lang.Object value)
Description copied from interface: IFormModel
Sets the current object's given field to the given value.
Specified by:
setValue in interface IFormModel

setValue

public void setValue(java.lang.Object object,
                     java.lang.String field,
                     java.lang.Object value)
Description copied from interface: IFormModel
Sets the given object's given field to the given value.
Specified by:
setValue in interface IFormModel

stringToField

public java.lang.reflect.Field stringToField(java.lang.String field)
                                      throws java.lang.NoSuchFieldException,
                                             java.lang.IllegalAccessException

stringToField

public java.lang.reflect.Field stringToField(java.lang.Class oClass,
                                             java.lang.String field)
                                      throws java.lang.NoSuchFieldException,
                                             java.lang.IllegalAccessException

setFields

public void setFields()
Derives the name fields, display fields and the field names and classes.

lookupFieldNames

protected java.util.List lookupFieldNames(java.util.List fields)

lookupFieldClasses

protected java.util.List lookupFieldClasses(java.util.List fields)

deriveNames

protected void deriveNames()
Collects name and display fields and calls deriveNames(fields).

deriveClasses

protected void deriveClasses()
Collects name and display fields and calls deriveClasses(fields).

deriveNames

protected abstract void deriveNames(java.util.List fields)
Derives the names of the given fields and puts them into HashMap fieldNames.

deriveClasses

protected abstract void deriveClasses(java.util.List fields)
Derives the classes of the given fields and puts them into HashMap fieldClasses.

deriveNameFields

protected abstract java.util.List deriveNameFields()
Derives the fields to be used for displaying the object name(s)

deriveDisplayFields

protected abstract java.util.List deriveDisplayFields()
Derives the fields to be used for displaying the object information

addIfField

public static java.util.Collection addIfField(java.util.Collection fields,
                                              java.lang.Class c,
                                              java.lang.String sField)

isEditable

public boolean isEditable(java.lang.String field)
Description copied from interface: IFormModel
Determines whether a field is editable (can be changed by the user) or not.
Specified by:
isEditable in interface IFormModel

startUpdate

public void startUpdate()
Specified by:
startUpdate in interface IFormModel

endUpdate

public void endUpdate()
Specified by:
endUpdate in interface IFormModel

ignoreUpdate

public void ignoreUpdate()
Specified by:
ignoreUpdate in interface IFormModel

fireModelChanged

public void fireModelChanged(java.lang.String change)

addModelListener

public void addModelListener(FormModelListener l)
Specified by:
addModelListener in interface IFormModel