at.spardat.xma.mdl.table
Class TableRow

java.lang.Object
  extended byat.spardat.xma.mdl.table.TableRow

public class TableRow
extends java.lang.Object

Represents a row in a TableWM. The constructor must be used if a new row is to be inserted in a table. TableWM.getRow is used to retrieve a particular row, which may be updated immediately after calling getRow.

Rows become invalid if the table is modified in any way. All methods in this class will throw an IllegalStateException if a TableRow object is accessed again after the table has been modified.


Constructor Summary
TableRow(ITableWM table, int rowIndex, java.lang.String key, java.lang.Object[] cells, int imageId)
          Creates a new row using the provided parameters and inserts it at a given index.
TableRow(ITableWM table, java.lang.String key, java.lang.Object[] cells, int imageId)
          Creates a new row using the provided parameters and inserts it at the end of the table.
 
Method Summary
 Atom getCell(int colIndex)
          Returns the cell at a provided column index.
 int getImageId()
          Returns the image id if one has been set before or 0 if none has been set.
 java.lang.String getKey()
          Returns the key or null if it has not been set yet.
 int getUIRowIndex()
          At the client side, this TableRow has a representation in a UI library if the UI is already created.
 void setCell(int colIndex, java.lang.Object value)
          Sets the value of a cell from a provided object.
 void setCells(java.lang.Object[] values)
          Sets the value of all cells of this rows from the objects provided in an array.
 void setImageId(int imageId)
          Sets the image id of this row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableRow

public TableRow(ITableWM table,
                int rowIndex,
                java.lang.String key,
                java.lang.Object[] cells,
                int imageId)
Creates a new row using the provided parameters and inserts it at a given index.

Parameters:
table - the table where the row should be inserted.
rowIndex - the zero based row index. Must be greater than zero and less than or equal to table.size().
key - the key of the new row.
cells - array of objects to store in the cells. The objects may be either AtomicAttrVals (if used at the server) or a JDK object as defined in newInstance.
imageId - an id of an image that should be displayed in front of the row. Use zero to indicate that no image should be used.
Throws:
java.lang.IllegalArgumentException - if rowIndex is out of range, the key is already in the table or cells contains to few values.

TableRow

public TableRow(ITableWM table,
                java.lang.String key,
                java.lang.Object[] cells,
                int imageId)
Creates a new row using the provided parameters and inserts it at the end of the table.

Parameters:
table - the table where the row should be inserted.
key - the key of the new row.
cells - array of objects to store in the cells.
imageId - an id of an image that should be displayed in front of the row. Use zero to indicate that no image should be used.
Throws:
java.lang.IllegalArgumentException - if a row with key is already in the table or cells contains to few values.
Method Detail

setImageId

public void setImageId(int imageId)
Sets the image id of this row. An image may be used to be displayed at a row level, i.e, different rows may have different images. The images must be registered in the component.

Parameters:
imageId - which identifies an image at the component level.
Throws:
java.lang.IllegalStateException - if the table was modified after retrieving this row.

getImageId

public int getImageId()
Returns the image id if one has been set before or 0 if none has been set.

Throws:
java.lang.IllegalStateException - if the table was modified after retrieving this row.

getCell

public Atom getCell(int colIndex)
Returns the cell at a provided column index. This method is intended to be used at the client side of XMA, if the user wants to extract the value of a particular cell.

Parameters:
colIndex - zero based column index
Returns:
Atom representing the value of the cell or null, if the cell value has not been set.
Throws:
java.lang.IllegalArgumentException - if colIndex invalid
java.lang.IllegalStateException - if the table was modified after retrieving this row.

setCell

public void setCell(int colIndex,
                    java.lang.Object value)
Sets the value of a cell from a provided object. Do not use this method if you want to update many cells of a row. In this case, use setCells instead.

Parameters:
colIndex - zero based index of the column
value - the value to set. May be either an AtomicAttrVal (if used at the server) or a JDK object as defined in newInstance. If value is null, the cell is reset.
Throws:
java.lang.IllegalArgumentException - if value is of unsupported type or colIndex is invalid.
java.lang.IllegalStateException - if the table was modified after retrieving this row.

setCells

public void setCells(java.lang.Object[] values)
Sets the value of all cells of this rows from the objects provided in an array. This method has the same effect as calling setCell on each array entry.

Parameters:
values - array of objects. The length of the array must be equal to the number of columns in the table.
Throws:
java.lang.IllegalArgumentException - if value is of unsupported type or the length of values is less than the number of columns.
java.lang.IllegalStateException - if the table was modified after retrieving this row.

getKey

public java.lang.String getKey()
Returns the key or null if it has not been set yet.

Throws:
java.lang.IllegalStateException - if the table was modified after retrieving this row.

getUIRowIndex

public int getUIRowIndex()
At the client side, this TableRow has a representation in a UI library if the UI is already created. In the case of SWT, every TableRow has a SWT TableItem assigned, that may also be accessed by a zero based offset in the SWT table. If you want to set some visual attributes on the TableItem, you may call this method and retrieve a TableItem from the SWT table in order to change some visual attributes. Warnings:

Returns:
If your code is running at the client side and you have a constructed UI this method returns the SWT row index of this row. Otherwise -1 is returned.