de.esprit.common.gui.list

## Class AbstractObjectListModel<T>

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

- All Implemented Interfaces:
    java.io.Serializable, javax.swing.ListModel
  Direct Known Subclasses:
    ActivityListModel, PathRegistrationListModel

      public class AbstractObjectListModel<T>
      extends javax.swing.DefaultListModel
      implements java.io.Serializable

  Base class for all ListModels. 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
    `AbstractObjectListModel()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addObject(int index, T o)`
    `int` | `addObject(T obj)`
    `void` | `addObjects(java.util.Collection<T> objects)`
    `void` | `addObjects(T[] objects)`
    `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<T>` | `getAllObjects()`
    `java.util.Comparator` | `getComparator()`
    `ModifyFlag` | `getModifyFlag()` Returns the internal ModifyFlag.
    `T` | `getObject(int index)`
    `T` | `getObject(java.lang.Object obj)`
    `int` | `getObjectCount()`
    `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<T> list)` Clears and reloads the model.
    `void` | `loadFrom(T[] array)` Clears and reloads the model.
    `void` | `removeObject(int index)`
    `int` | `removeObject(T obj)`
    `int` | `replaceObject(T obj)`
    `int` | `replaceOrAddObject(T obj)`
    `void` | `setComparator(java.util.Comparator cmp)`
    `void` | `setModified(boolean b)` 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` | `setObject(int index, T o)`
    `void` | `setSortAscending(boolean isAscending)`

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

      `add, addElement, capacity, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, 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

    - #### AbstractObjectListModel

          public AbstractObjectListModel()

  - ### Method Detail

    - #### setComparator

          public final void setComparator(java.util.Comparator cmp)

    - #### getComparator

          public final java.util.Comparator getComparator()

    - #### isSortAscending

          public final boolean isSortAscending()

    - #### setSortAscending

          public final void setSortAscending(boolean isAscending)

    - #### removeObject

          public int removeObject(T obj)

    - #### replaceObject

          public int replaceObject(T obj)

    - #### replaceOrAddObject

          public int replaceOrAddObject(T obj)

    - #### removeObject

          public void removeObject(int index)

    - #### getObject

          public final T getObject(int index)

    - #### getObject

          public final T getObject(java.lang.Object obj)

    - #### setObject

          public final void setObject(int index,
                       T o)

    - #### getObjectCount

          public final int getObjectCount()

    - #### getAllObjects

          public final java.util.List<T> getAllObjects()

    - #### loadFrom

          public final void loadFrom(java.util.Collection<T> list)

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

    - #### loadFrom

          public final void loadFrom(T[] array)

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

    - #### addObjects

          public void addObjects(T[] objects)

    - #### addObjects

          public void addObjects(java.util.Collection<T> objects)

    - #### addObject

          public int addObject(int index,
                      T o)

    - #### addObject

          public int addObject(T obj)

    - #### clear

          public void clear()

      Overrides:
        `clear` in class `javax.swing.DefaultListModel`

    - #### setModified

          public void setModified(boolean b)

      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`

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

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

    - #### 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 © 2011 EsprIT-Systems. All Rights Reserved.