de.esprit.common.gui

## Class ZListModel<E>

- java.lang.Object
- - javax.swing.AbstractListModel<E>
  - - javax.swing.DefaultListModel<E>
    - - de.esprit.common.gui.ZListModel<E>

- All Implemented Interfaces:
    java.io.Serializable, javax.swing.ListModel<E>
  Direct Known Subclasses:
    ActivityListModel, ClientListModel, ClientZListModel, DBRecordListModel, JavaVersionListModel, PathRegistrationListModel

      public class ZListModel<E>
      extends javax.swing.DefaultListModel<E>

  Base class for all `ListModel`s. It extends the Java `DefaultListModel` by a `ModifyFlag` which is set when any of the data in the model has been changed. It is cleared when the list is freshly reloaded.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

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

      `listenerList`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ZListModel()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addItem(E item)`
    `int` | `addItem(int index, E item)`
    `void` | `addItems(java.util.Collection<E> items)`
    `void` | `addItems(E[] items)`
    `void` | `clear()`
    `void` | `fireContentsChanged()` Tell the GUI that the model has changed.
    `protected void` | `fireContentsChanged(java.lang.Object source, int index0, int index1)` Overridden not to fire in numb state
    `protected void` | `fireIntervalAdded(java.lang.Object source, int index0, int index1)` Overridden not to fire in numb state
    `protected void` | `fireIntervalRemoved(java.lang.Object source, int index0, int index1)` Overridden not to fire in numb state
    `java.util.List<E>` | `getAllItems()`
    `java.util.Comparator` | `getComparator()`
    `E` | `getElementAt(int index)`
    `E` | `getFirstItem()` Returns the first item in the model - or null if the model is empty.
    `E` | `getItem(int index)`
    `java.lang.Object` | `getItem(java.lang.Object item)`
    `int` | `getItemCount()`
    `E` | `getLastItem()` Returns the last item in the model - or null if the model is empty.
    `ModifyFlag` | `getModifyFlag()` Returns the internal ModifyFlag.
    `boolean` | `isModified()` Tells whether the data have changed.
    `boolean` | `isNumb()` Tells whether the ListModel is in numb state
    `boolean` | `isSortAscending()`
    `void` | `load()` This method does nothing - it is supposed to be overridden by subclasses
    `void` | `loadFrom(java.util.Collection list)` Clears and reloads the model.
    `void` | `loadFrom(E[] array)` Clears and reloads the model.
    `void` | `removeItem(int index)`
    `int` | `removeItem(java.lang.Object item)`
    `int` | `replaceItem(E item)` Replaces the item in the list.
    `int` | `replaceOrAddItem(E item)`
    `void` | `setComparator(java.util.Comparator<E> cmp)`
    `void` | `setItem(int index, E item)`
    `void` | `setModified(boolean isModified)` Marks the list data as being changed.
    `void` | `setModifyFlag(ModifyFlag flag)` Allows for setting the ModifyFlag from outside.
    `void` | `setNumb(boolean isNumb)` Sets the ListModel in a numb state where it does not fire any events.
    `void` | `setSortAscending(boolean isAscending)`

    - ### 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

    - #### ZListModel

          public ZListModel()

  - ### Method Detail

    - #### setComparator

          public void setComparator(java.util.Comparator<E> cmp)

    - #### getComparator

          public java.util.Comparator getComparator()

    - #### isSortAscending

          public boolean isSortAscending()

    - #### setSortAscending

          public void setSortAscending(boolean isAscending)

    - #### removeItem

          public int removeItem(java.lang.Object item)

    - #### replaceItem

          public int replaceItem(E item)

      Replaces the item in the list.
      Returns:
        the index where the item was added or replaced.

    - #### replaceOrAddItem

          public int replaceOrAddItem(E item)

    - #### removeItem

          public void removeItem(int index)

    - #### getItem

          public E getItem(int index)

    - #### getFirstItem

          public E getFirstItem()

      Returns the first item in the model - or null if the model is empty.

    - #### getLastItem

          public E getLastItem()

      Returns the last item in the model - or null if the model is empty.

    - #### getElementAt

          public E getElementAt(int index)

      Specified by:
        `getElementAt` in interface `javax.swing.ListModel<E>`
      Overrides:
        `getElementAt` in class `javax.swing.DefaultListModel<E>`

    - #### getItem

          public java.lang.Object getItem(java.lang.Object item)

    - #### setItem

          public void setItem(int index,
                     E item)

    - #### getItemCount

          public int getItemCount()

    - #### getAllItems

          public java.util.List<E> getAllItems()

    - #### loadFrom

          public void loadFrom(java.util.Collection list)

      Clears and reloads the model. The ModifyFlag is being reset.

    - #### loadFrom

          public void loadFrom(E[] array)

      Clears and reloads the model. The ModifyFlag is being reset.

    - #### addItems

          public void addItems(E[] items)

    - #### addItems

          public void addItems(java.util.Collection<E> items)

    - #### addItem

          public int addItem(int index,
                    E item)

    - #### addItem

          public int addItem(E item)

    - #### clear

          public void clear()

      Overrides:
        `clear` in class `javax.swing.DefaultListModel<E>`

    - #### setModified

          public void setModified(boolean isModified)

      Marks the list data as being changed. All ModifyEvent.Listeners are notified.

    - #### setModifyFlag

          public void setModifyFlag(ModifyFlag flag)

      Allows for setting the ModifyFlag from outside.

    - #### getModifyFlag

          public ModifyFlag getModifyFlag()

      Returns the internal ModifyFlag. May be null if not set.

    - #### isModified

          public boolean isModified()

      Tells whether the data have changed.

    - #### load

          public void load()
                    throws java.lang.Exception

      This method does nothing - it is supposed to be overridden by subclasses
      Throws:
        `java.lang.Exception`

    - #### setNumb

          public void setNumb(boolean isNumb)

      Sets the ListModel in a numb state where it does not fire any events. This increases performance on mass-manipulations.

    - #### isNumb

          public boolean isNumb()

      Tells whether the ListModel is in numb state

    - #### fireContentsChanged

          protected void fireContentsChanged(java.lang.Object source,
                                 int index0,
                                 int index1)

      Overridden not to fire in numb state
      Overrides:
        `fireContentsChanged` in class `javax.swing.AbstractListModel<E>`

    - #### fireIntervalAdded

          protected void fireIntervalAdded(java.lang.Object source,
                               int index0,
                               int index1)

      Overridden not to fire in numb state
      Overrides:
        `fireIntervalAdded` in class `javax.swing.AbstractListModel<E>`

    - #### fireIntervalRemoved

          protected void fireIntervalRemoved(java.lang.Object source,
                                 int index0,
                                 int index1)

      Overridden not to fire in numb state
      Overrides:
        `fireIntervalRemoved` in class `javax.swing.AbstractListModel<E>`

    - #### fireContentsChanged

          public void fireContentsChanged()

      Tell the GUI that the model has changed. This is intentionally public just for initiating a repaint from within the model.

Copyright © 2014 EsprIT-Systems. All Rights Reserved.