net.xoetrope.optional.data
Class XTableModelAdapter

java.lang.Object
  extended by net.xoetrope.optional.data.XTableModelAdapter
All Implemented Interfaces:
XModelAdapter
Direct Known Subclasses:
DatabaseTableModelAdapter

public class XTableModelAdapter
extends java.lang.Object
implements XModelAdapter

Adapts an XModel to provide access to child nodes as a list. This class is intended to facilitate uses of tables and combo boxes or list components

Copyright: Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt $Revision: 2.2 $ License: see license.txt


Constructor Summary
XTableModelAdapter()
          Create a new adapter for a model node
XTableModelAdapter(XModel src)
          Create a new adapter for a model node
 
Method Summary
 int find(java.lang.String key, int keyColumnIdx)
          Locate a key value in the underlying data source
 java.lang.Object get(int i)
          Gets the individual list item value
 java.lang.Object get(int i, int fieldIdx)
          Gets the individual list item value
 XModel getModel()
          Get the adapter source
 int getNumChildren()
          Get the number of children that the model node has
 java.lang.Object getSelected()
          Gets the value of the selected item from the list.
 java.lang.Object getSelected(int fieldIdx)
          Gets the value of the selected item from the list.
 void set(java.lang.Object o)
          Set the value of the listitem
 void setModel(XModel src)
          Set the adapter source
 void setOutputField(int fieldIdx)
          Set the field to return for lists;
 void sync()
          Force a sync/update of the table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XTableModelAdapter

public XTableModelAdapter(XModel src)
Create a new adapter for a model node

Parameters:
src - the node to adapt

XTableModelAdapter

public XTableModelAdapter()
Create a new adapter for a model node

Method Detail

getNumChildren

public int getNumChildren()
Get the number of children that the model node has

Specified by:
getNumChildren in interface XModelAdapter
Returns:
the number of children

get

public java.lang.Object get(int i)
Gets the individual list item value

Specified by:
get in interface XModelAdapter
Parameters:
i - The index of the listitem
Returns:
The value of the listitem

get

public java.lang.Object get(int i,
                            int fieldIdx)
Gets the individual list item value

Parameters:
i - The index of the listitem
fieldIdx - the field index
Returns:
The value of the listitem

set

public void set(java.lang.Object o)
Set the value of the listitem

Specified by:
set in interface XModelAdapter
Parameters:
o - The new value

getSelected

public java.lang.Object getSelected()
Gets the value of the selected item from the list.

Specified by:
getSelected in interface XModelAdapter
Returns:
the field value from the current row/record

getSelected

public java.lang.Object getSelected(int fieldIdx)
Gets the value of the selected item from the list.

Parameters:
fieldIdx - the index (zero based) of the database table's field or column
Returns:
the field value

setOutputField

public void setOutputField(int fieldIdx)
Set the field to return for lists;

Parameters:
fieldIdx - the field index (zero based)

getModel

public XModel getModel()
Get the adapter source

Specified by:
getModel in interface XModelAdapter
Returns:
the model node that holds the table (the DatabaseTableMode node)

setModel

public void setModel(XModel src)
Set the adapter source

Specified by:
setModel in interface XModelAdapter
Parameters:
src - the model

find

public int find(java.lang.String key,
                int keyColumnIdx)
Locate a key value in the underlying data source

Parameters:
key - the key to locate
keyColumnIdx - the index of the key column
Returns:
the row/record index taht contains the first instance of the key, or -1 if the key is not found

sync

public void sync()
Force a sync/update of the table