de.esprit.appsuite.database.dbgui.list

## Class DBRecordListModel<C extends ApplicationContext>

- java.lang.Object
- - javax.swing.AbstractListModel<E>
  - - javax.swing.DefaultListModel<E>
    - - de.esprit.common.gui.ZListModel
      - - de.esprit.appsuite.database.dbgui.list.DBRecordListModel<C>

- All Implemented Interfaces:
    ApplicationObject<C>, java.io.Serializable, javax.swing.ListModel
  Direct Known Subclasses:
    ClientRecordListModel

      public class DBRecordListModel<C extends ApplicationContext>
      extends ZListModel
      implements ApplicationObject<C>

  This ListModel just stores a list of `DBRecord`s. It provides methods for record manipulation like INSERT, UPDATE and DELETE. Those actions are in fact forwarded to the current `Database` instance, which may be a local or remote database. Note that his class is intentionally NOT generic, because it may contain a mixture of different sub-types of `DBRecord`.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class javax.swing.AbstractListModel

      `listenerList`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DBRecordListModel(C ctx, DBRecord master)`
    `DBRecordListModel(C ctx, DBRecord[] masters)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addRecord(DBRecord newRecord)`
    `C` | `getApplicationContext()`
    `DBRecord` | `getMasterRecord()` Returns the first record of the master records.
    `DBRecord[]` | `getMasterRecords()`
    `int` | `indexOf(DBRecord record)` Finds the index of the DBRecord stored in column 0 of the TableModel.
    `int` | `indexOf(java.lang.String recordId)` Finds the index of the DBRecord which has the given primary key value.
    `void` | `load()` This method loads all Records of the instantiation type available in the database
    `void` | `load(SqlCondition condition)`
    `void` | `load(SqlCondition condition, SqlOrder order)`
    `int` | `removeRecord(DBRecord record)`
    `boolean` | `replaceRecord(DBRecord record)`

    - ### Methods inherited from class de.esprit.common.gui.ZListModel

      `addItem, addItem, addItems, addItems, clear, fireContentsChanged, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getAllItems, getComparator, getElementAt, getFirstItem, getItem, getItem, getItemCount, getLastItem, getModifyFlag, isModified, isNumb, isSortAscending, loadFrom, loadFrom, removeItem, removeItem, replaceItem, replaceOrAddItem, setComparator, setItem, setModified, setModifyFlag, setNumb, setSortAscending`

    - ### Methods inherited from class javax.swing.DefaultListModel

      `add, addElement, capacity, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getSize, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAllElements, removeElement, removeElementAt, removeRange, set, setElementAt, setSize, size, toArray, toString, trimToSize`

    - ### Methods inherited from class javax.swing.AbstractListModel

      `addListDataListener, getListDataListeners, getListeners, removeListDataListener`

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

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

- - ### Constructor Detail

    - #### DBRecordListModel

          public DBRecordListModel(C ctx,
                           DBRecord master)

    - #### DBRecordListModel

          public DBRecordListModel(C ctx,
                           DBRecord[] masters)

  - ### Method Detail

    - #### getApplicationContext

          public final C getApplicationContext()

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

    - #### getMasterRecords

          public DBRecord[] getMasterRecords()

    - #### getMasterRecord

          public DBRecord getMasterRecord()

      Returns the first record of the master records.
      See Also:
        `getMasterRecords()`

    - #### removeRecord

          public int removeRecord(DBRecord record)

    - #### replaceRecord

          public boolean replaceRecord(DBRecord record)

    - #### indexOf

          public int indexOf(DBRecord record)

      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 recordId)

      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.

    - #### load

          public void load()
                    throws java.lang.Exception

      This method loads all Records of the instantiation type available in the database
      Overrides:
        `load` in class `ZListModel`
      Throws:
        `java.lang.Exception`

    - #### load

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

      Throws:
        `java.lang.Exception`

    - #### load

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

      Throws:
        `java.lang.Exception`

    - #### addRecord

          public int addRecord(DBRecord newRecord)

Copyright © 2014 EsprIT-Systems. All Rights Reserved.