ix.iface.ui
Class AbstractIFormModel

java.lang.Object
  extended by ix.iface.ui.AbstractIFormModel
All Implemented Interfaces:
DataChangeListener, IFormModel
Direct Known Subclasses:
GenericIFormModel

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

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


Field Summary
protected  EditableObject baseObject
           
protected  java.lang.Class baseObjectClass
           
protected  java.util.HashSet dataListeners
           
protected  java.util.List displayFields
           
protected  java.util.HashMap fieldClasses
           
protected  java.util.HashMap fieldNames
           
protected  boolean isUpdating
           
protected  java.util.HashSet listeners
           
protected  java.util.List nameFields
           
protected  boolean settingData
           
 
Constructor Summary
AbstractIFormModel(java.lang.Class objectClass)
           
AbstractIFormModel(EditableObject object)
           
 
Method Summary
 void addDataListener(FormDataListener l)
           
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;
 void dataChanged(EditableObject eo, java.lang.String field, java.lang.Object oldValue, java.lang.Object newValue)
           
 void dataChanged(ObjectChangeEvent oce)
          Listening to changes to the object generated elsewhere.
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 fireDataChanged(java.lang.String field, java.lang.Object editedObject, java.lang.Object oldValue, java.lang.Object newValue)
          Notify listeners that data has changed.
 void fireModelChanged(java.lang.String change)
           
 void fireModelChanged(java.lang.String change, ObjectChangeEvent oce)
           
 java.util.HashSet getDataListeners()
           
 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. names)
 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.HashSet getModelListeners()
           
 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.
 EditableObject 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(EditableObject object, java.lang.String field)
           
 java.lang.Object getValue(java.lang.String field)
          Get the current object's value for the given field.
 void ignoreUpdate()
          End update without firing
 boolean isEditable(java.lang.String field)
          Determines whether a field is editable (can be changed by the user) or not.
 boolean isFieldShowing(java.lang.String field)
          Determines whether the given field is part of the model display.
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. names)
 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(EditableObject o)
          Set the model's base object
 void setObjectClass(java.lang.Class c)
          Set the class of the model's base object
 boolean setValue(EditableObject object, java.lang.String field, java.lang.Object value)
          Get the object to change its 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.String field)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nameFields

protected java.util.List nameFields

displayFields

protected java.util.List displayFields

fieldNames

protected java.util.HashMap fieldNames

fieldClasses

protected java.util.HashMap fieldClasses

baseObject

protected EditableObject baseObject

baseObjectClass

protected java.lang.Class baseObjectClass

listeners

protected java.util.HashSet listeners

dataListeners

protected java.util.HashSet dataListeners

isUpdating

protected boolean isUpdating

settingData

protected boolean settingData
Constructor Detail

AbstractIFormModel

public AbstractIFormModel(java.lang.Class objectClass)

AbstractIFormModel

public AbstractIFormModel(EditableObject 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
Parameters:
fields - 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
Parameters:
fields - 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
Parameters:
fields - 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
Parameters:
fields - 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)


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

setObject

public void setObject(EditableObject o)
Description copied from interface: IFormModel
Set the model's base object

Specified by:
setObject in interface IFormModel

getObject

public EditableObject getObject()
Description copied from interface: IFormModel
Get the model's current base object

Specified by:
getObject 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

getValue

public java.lang.Object getValue(EditableObject object,
                                 java.lang.String field)

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 boolean setValue(EditableObject object,
                        java.lang.String field,
                        java.lang.Object value)
Get the object to change its value.

Specified by:
setValue in interface IFormModel
Returns:
true if the value was changed, false if it was not.

stringToField

public java.lang.reflect.Field stringToField(java.lang.String field)
                                      throws java.lang.NoSuchFieldException,
                                             java.lang.IllegalAccessException
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)

isFieldShowing

public boolean isFieldShowing(java.lang.String field)
Description copied from interface: IFormModel
Determines whether the given field is part of the model display.

Specified by:
isFieldShowing in interface IFormModel

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()
End update without firing

Specified by:
ignoreUpdate in interface IFormModel

fireModelChanged

public void fireModelChanged(java.lang.String change,
                             ObjectChangeEvent oce)

fireModelChanged

public void fireModelChanged(java.lang.String change)

fireDataChanged

public void fireDataChanged(java.lang.String field,
                            java.lang.Object editedObject,
                            java.lang.Object oldValue,
                            java.lang.Object newValue)
Notify listeners that data has changed. Also fires ModelChanged. Make sure you only call this if data really has changed!


dataChanged

public void dataChanged(ObjectChangeEvent oce)
Listening to changes to the object generated elsewhere.


dataChanged

public void dataChanged(EditableObject eo,
                        java.lang.String field,
                        java.lang.Object oldValue,
                        java.lang.Object newValue)
Specified by:
dataChanged in interface DataChangeListener

addModelListener

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

addDataListener

public void addDataListener(FormDataListener l)
Specified by:
addDataListener in interface IFormModel

getModelListeners

public java.util.HashSet getModelListeners()
Specified by:
getModelListeners in interface IFormModel

getDataListeners

public java.util.HashSet getDataListeners()
Specified by:
getDataListeners in interface IFormModel