de.esprit.appsuite.database.dbgui.table

## Class DBRecordTableModel<C extends ApplicationContext,T extends DBRecord>

- java.lang.Object
- - javax.swing.table.AbstractTableModel
  - - de.esprit.common.gui.table.AbstractObjectTableModel<T>
    - - de.esprit.appsuite.database.dbgui.table.DBRecordTableModel<C,T>

- All Implemented Interfaces:
    ApplicationObject<C>, DataLoadEvent.Source, OrderChangeEvent.Source, Clearable, java.io.Serializable, javax.swing.table.TableModel
  Direct Known Subclasses:
    ABORecordTableModel, ClientRecordTableModel

      public class DBRecordTableModel<C extends ApplicationContext,T extends DBRecord>
      extends AbstractObjectTableModel<T>
      implements ApplicationObject<C>

  This TableModel stores a set of DBRecords and displays all of its fields.
  Author:
    Rainer Buesch
  See Also:
    `DBRecordTable`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from class javax.swing.table.AbstractTableModel

      `listenerList`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DBRecordTableModel(C ctx, T masterRec)` This TableModel allows only the given type of DBRecord to be added.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRecord(int index, T dbo)` Places the given DBRecord at the specified index into the TableModel only.
    `int` | `addRecord(T dbo)` Adds the given DBRecord to the TableModel only.
    `void` | `addRecords(T[] records)`
    `void` | `clear()` Clears the content
    `de.esprit.appsuite.database.dbgui.table.DBRecordTableModel.MyAsyncLoadAction` | `getActionLoadAsync()`
    `C` | `getApplicationContext()`
    `T` | `getMasterRecord()`
    `DBRecord` | `getParentRecord()`
    `T` | `getRecord(int index)` Returns the DBRecord at the given index.
    `T` | `getRecord(java.lang.String dboId)` Returns the DBRecord at the given index.
    `int` | `indexOf(java.lang.String dboId)` Finds the index of the DBRecord which has the given primary key value.
    `int` | `indexOf(T dbo)` Finds the index of the DBRecord stored in column 0 of the TableModel.
    `boolean` | `isFieldVisible(java.lang.String fieldName)` Is supposed to be overridden by subclasses in order to make particular fields invisible.
    `void` | `load()` Loads the table with all available records.
    `void` | `load(SqlCondition condition)` Loads the table with all records that match the given `SqlCondition`.
    `void` | `load(SqlCondition condition, SqlOrder order)` Loads the table the given `SqlCondition` and `SqlOrder`.
    `int` | `removeRecord(T dbo)` Performs a database request in order to delete the dbobject and - if successful - removes the record from the TableModel.
    `boolean` | `replaceRecord(T dbo)`
    `void` | `search(SqlCondition condition, SqlOrder order)` Loads the table content by performing a join on all involved tables if the the managed DBRecord is a ComposedRecord.
    `void` | `setParentRecord(DBRecord parentRec)`
    `void` | `setRecord(int index, T dbo)` Places the given DBRecord at the specified index into the TableModel only.

    - ### Methods inherited from class de.esprit.common.gui.table.AbstractObjectTableModel

      `addColumn, addColumn, addColumn, addColumn, addDataLoadListener, addObject, addObject, addObjects, addObjects, addOrderChangeListener, addRowData, addRowData, clearRowData, containsObject, dropRow, dropRow, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, getAllObjects, getColumnCount, getColumnName, getComparator, getObject, getRowCount, getValueAt, getValueAt, indexOf, isEmpty, isNumb, isSortAscending, removeColumn, removeDataLoadListener, removeObject, removeObject, removeOrderChangeListener, removeRowData, replaceObject, setComparator, setNumb, setObject, setSortAscending, setValueAt`

    - ### Methods inherited from class javax.swing.table.AbstractTableModel

      `addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DBRecordTableModel

          public DBRecordTableModel(C ctx,
                            T masterRec)

      This TableModel allows only the given type of DBRecord to be added. Any attempt to add an object which is not of this type will cause an IllegalArgumentException to be thrown.

  - ### Method Detail

    - #### getApplicationContext

          public final C getApplicationContext()

      Specified by:
        `getApplicationContext` in interface `ApplicationObject<C extends ApplicationContext>`

    - #### getParentRecord

          public DBRecord getParentRecord()

    - #### setParentRecord

          public void setParentRecord(DBRecord parentRec)

    - #### getActionLoadAsync

          public de.esprit.appsuite.database.dbgui.table.DBRecordTableModel.MyAsyncLoadAction getActionLoadAsync()

    - #### getMasterRecord

          public T getMasterRecord()

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clears the content
      Specified by:
        `clear` in interface `Clearable`
      Overrides:
        `clear` in class `AbstractObjectTableModel<T extends DBRecord>`

    - #### load

          public void load()
                    throws java.lang.Exception

      Loads the table with all available records.
      Overrides:
        `load` in class `AbstractObjectTableModel<T extends DBRecord>`
      Throws:
        `java.lang.Exception`

    - #### load

          public void load(SqlCondition condition)
                    throws java.lang.Exception

      Loads the table with all records that match the given `SqlCondition`.
      Throws:
        `java.lang.Exception`

    - #### load

          public void load(SqlCondition condition,
                  SqlOrder order)
                    throws java.lang.Exception

      Loads the table the given `SqlCondition` and `SqlOrder`. Note that if the the DBRecord is a `ComposedRecord` then the condition must only contain fields of the bottom subclass.
      Throws:
        `java.lang.Exception`
      See Also:
        `search(SqlCondition, SqlOrder)`

    - #### addRecords

          public void addRecords(T[] records)

    - #### search

          public void search(SqlCondition condition,
                    SqlOrder order)
                      throws java.lang.Exception

      Loads the table content by performing a join on all involved tables if the the managed DBRecord is a ComposedRecord. This kind of query allows every field of the ComposedRecord to appear in the SQL condition, but performance may be low.

      This call is identical to load() if the managed DBRecord is a DBObject.

      Throws:
        `java.lang.Exception`
      See Also:
        `load(SqlCondition, SqlOrder)`

    - #### indexOf

          public int indexOf(T dbo)

      Finds the index of the DBRecord stored in column 0 of the TableModel. Compares by the equals() method of DBRecord.

    - #### indexOf

          public int indexOf(java.lang.String dboId)

      Finds the index of the DBRecord which has the given primary key value. Appliccable only if the stored DBRecord has got a non-composed primary key.

    - #### getRecord

          public T getRecord(java.lang.String dboId)

      Returns the DBRecord at the given index.

    - #### getRecord

          public T getRecord(int index)

      Returns the DBRecord at the given index.

    - #### removeRecord

          public int removeRecord(T dbo)

      Performs a database request in order to delete the dbobject and - if successful - removes the record from the TableModel.

    - #### replaceRecord

          public boolean replaceRecord(T dbo)

    - #### setRecord

          public void setRecord(int index,
                       T dbo)

      Places the given DBRecord at the specified index into the TableModel only.

    - #### addRecord

          public int addRecord(T dbo)

      Adds the given DBRecord to the TableModel only.

    - #### addRecord

          public void addRecord(int index,
                       T dbo)

      Places the given DBRecord at the specified index into the TableModel only.

    - #### isFieldVisible

          public boolean isFieldVisible(java.lang.String fieldName)

      Is supposed to be overridden by subclasses in order to make particular fields invisible. Returns always true by default.
      Parameters:
        `fieldName` - Name of the field in the format table.column

Copyright © 2014 EsprIT-Systems. All Rights Reserved.