de.esprit.common.gui.list

## Class AbstractObjectList<T>

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JList
        - - de.esprit.common.gui.list.AbstractObjectList<T>

- All Implemented Interfaces:
    Steppable, Clearable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable
  Direct Known Subclasses:
    ActivityList, PathRegistrationList

      public class AbstractObjectList<T>
      extends javax.swing.JList
      implements Clearable, Steppable

  This is a special JList that implements There is also a set of convenience methods. You may also attach an ActionListener if you are interested in double-clicks.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class javax.swing.JList

      `javax.swing.JList.AccessibleJList, javax.swing.JList.DropLocation`

    - ### Nested classes/interfaces inherited from class javax.swing.JComponent

      `javax.swing.JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `java.awt.Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

  - ### Field Summary

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

      `HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP`

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

      `accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

    - ### Fields inherited from class java.awt.Component

      `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface java.awt.image.ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractObjectList(AbstractObjectListModel<T> model)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addActionListener(java.awt.event.ActionListener l)` Adds a listener to react on double clicks.
    `void` | `addAllObjects(T[] objects)`
    `void` | `addIndexChangeListener(IndexChangeEvent.Listener l)`
    `void` | `addListDataListener(javax.swing.event.ListDataListener l)`
    `int` | `addObject(int index, T obj)`
    `int` | `addObject(T o)`
    `void` | `adjustSelection(int rowIndex)` Adjusts the selection such that the given index is selected.
    `void` | `clear()` Clears the content
    `boolean` | `contains(T obj)`
    `protected javax.swing.ListSelectionModel` | `createSelectionModel()`
    `protected void` | `doOnDoubleClick(java.util.List<T> selectedValues)` This method is called when a mouse double-click was detected on the list component.
    `void` | `first()`
    `de.esprit.common.gui.list.AbstractObjectList.MyListClearAction` | `getActionClear()`
    `de.esprit.common.gui.list.AbstractObjectList.MyDeleteAction` | `getActionDelete()`
    `java.util.List<T>` | `getAllObjects()`
    `java.util.Comparator` | `getComparator()`
    `int` | `getCurrentIndex()`
    `AbstractObjectListModel<T>` | `getModel()`
    `ModifyFlag` | `getModifyFlag()`
    `T` | `getObject(int index)`
    `int` | `getObjectCount()`
    `int` | `getRecordCount()`
    `T` | `getSelectedObject()`
    `java.util.List<T>` | `getSelectedObjects()` Returns the selected Objects as an array.
    `IndexSelectionModel` | `getSelectionModel()`
    `int` | `indexOf(T obj)` Returns the index of the first occurrence of the given object.
    `boolean` | `isChangeConfirmed()`
    `boolean` | `isEmpty()`
    `boolean` | `isModified()`
    `boolean` | `isNumb()` Tells whether the ListModel is in numb state
    `boolean` | `isSortAscending()`
    `void` | `last()`
    `void` | `load()`
    `void` | `loadFrom(java.util.Collection objects)`
    `void` | `loadFrom(T[] objects)`
    `boolean` | `matchesTypedString(java.lang.Object obj, java.lang.String typedStr)`
    `boolean` | `next()`
    `boolean` | `previous()`
    `void` | `removeActionListener(java.awt.event.ActionListener l)` Removes a double click listener.
    `void` | `removeIndexChangeListener(IndexChangeEvent.Listener l)`
    `void` | `removeLater(T obj)` Removes the object delayed with EventQueue.invokeLater(Runnable).
    `void` | `removeListDataListener(javax.swing.event.ListDataListener l)`
    `void` | `removeObject(int index)` Deletes the object at the given index from the list.
    `void` | `removeObject(int index, boolean isAdjustSelection)` Same as `removeObject(int)` but adjusts the selection to the next available object.
    `int` | `removeObject(T obj)` Deletes the given object reference from the list.
    `int` | `removeObject(T obj, boolean isAdjustSelection)` Same as `removeObject(Object)` but adjusts the selection to the next available object.
    `void` | `removeSelectedObject(boolean isAdjustSelection)`
    `int` | `replaceObject(T obj)` Replaces the object in the list.
    `boolean` | `replaceOrAddObject(T o)` Replaces the object in the list or adds it if it could not be found.
    `void` | `scrollToRow(int rowIndex)` Scrolls to the given row index to make it visible.
    `void` | `selectObject(int index)`
    `void` | `selectObject(T obj)`
    `void` | `selectObjects(T[] objects)`
    `void` | `setComparator(java.util.Comparator cmp)`
    `boolean` | `setCurrentIndex(int i)`
    `void` | `setModified(boolean state)`
    `void` | `setModifyFlag(ModifyFlag flag)`
    `void` | `setNumb(boolean state)` Sets the underlying ListModel in a numb state where it does not fire any events.
    `void` | `setObject(int index, T o)` Sets the object at the given index
    `void` | `setSelectedIndex(int index)` Allows for programmatically selecting an object at the specified index.
    `void` | `setSortAscending(boolean isAscending)`

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

      `addListSelectionListener, addSelectionInterval, clearSelection, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectedValuesList, getSelectionBackground, getSelectionForeground, getSelectionMode, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, setPrototypeCellValue, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, updateUI`

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

      `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

    - ### Methods inherited from class java.awt.Container

      `add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree`

    - ### Methods inherited from class java.awt.Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

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

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

- - ### Constructor Detail

    - #### AbstractObjectList

          public AbstractObjectList(AbstractObjectListModel<T> model)

  - ### Method Detail

    - #### isSortAscending

          public boolean isSortAscending()

    - #### setSortAscending

          public void setSortAscending(boolean isAscending)

    - #### setComparator

          public void setComparator(java.util.Comparator cmp)

    - #### getComparator

          public java.util.Comparator getComparator()

    - #### getActionDelete

          public de.esprit.common.gui.list.AbstractObjectList.MyDeleteAction getActionDelete()

    - #### getActionClear

          public de.esprit.common.gui.list.AbstractObjectList.MyListClearAction getActionClear()

    - #### createSelectionModel

          protected javax.swing.ListSelectionModel createSelectionModel()

      Overrides:
        `createSelectionModel` in class `javax.swing.JList`

    - #### getSelectionModel

          public IndexSelectionModel getSelectionModel()

      Overrides:
        `getSelectionModel` in class `javax.swing.JList`

    - #### addIndexChangeListener

          public void addIndexChangeListener(IndexChangeEvent.Listener l)

      Specified by:
        `addIndexChangeListener` in interface `Steppable`

    - #### removeIndexChangeListener

          public void removeIndexChangeListener(IndexChangeEvent.Listener l)

    - #### getModel

          public AbstractObjectListModel<T> getModel()

      Overrides:
        `getModel` in class `javax.swing.JList`

    - #### getModifyFlag

          public ModifyFlag getModifyFlag()

    - #### getObject

          public T getObject(int index)

    - #### getAllObjects

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

    - #### setModifyFlag

          public void setModifyFlag(ModifyFlag flag)

    - #### setModified

          public void setModified(boolean state)

    - #### load

          public void load()
                    throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### loadFrom

          public void loadFrom(java.util.Collection objects)

    - #### loadFrom

          public void loadFrom(T[] objects)

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Steppable`

    - #### isModified

          public boolean isModified()

    - #### getObjectCount

          public int getObjectCount()

    - #### contains

          public boolean contains(T obj)

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clears the content
      Specified by:
        `clear` in interface `Clearable`

    - #### addAllObjects

          public void addAllObjects(T[] objects)

    - #### addObject

          public int addObject(T o)

    - #### addObject

          public int addObject(int index,
                      T obj)

    - #### replaceObject

          public int replaceObject(T obj)

      Replaces the object in the list.
      Returns:
        the index where the object was found in the list.

    - #### replaceOrAddObject

          public boolean replaceOrAddObject(T o)

      Replaces the object in the list or adds it if it could not be found.
      Returns:
        true if the object was found in the list.

    - #### setObject

          public void setObject(int index,
                       T o)

      Sets the object at the given index

    - #### removeObject

          public int removeObject(T obj)

      Deletes the given object reference from the list.
      Returns:
        the index where the object was found

    - #### removeObject

          public int removeObject(T obj,
                         boolean isAdjustSelection)

      Same as `removeObject(Object)` but adjusts the selection to the next available object.

    - #### removeLater

          public void removeLater(T obj)

      Removes the object delayed with EventQueue.invokeLater(Runnable). This method needs to be called when removal is happening during event dispatching.
      See Also:
        `removeObject(Object)`

    - #### removeObject

          public void removeObject(int index)

      Deletes the object at the given index from the list. Any selection is adjusted accordingly.

    - #### removeObject

          public void removeObject(int index,
                          boolean isAdjustSelection)

      Same as `removeObject(int)` but adjusts the selection to the next available object.

    - #### removeSelectedObject

          public void removeSelectedObject(boolean isAdjustSelection)

    - #### indexOf

          public int indexOf(T obj)

      Returns the index of the first occurrence of the given object.

    - #### adjustSelection

          public void adjustSelection(int rowIndex)

      Adjusts the selection such that the given index is selected. If the given index does not exist (due to removal of an object) and a previous object exists, then that one will be selected.

    - #### setSelectedIndex

          public void setSelectedIndex(int index)

      Allows for programmatically selecting an object at the specified index. The list will automatically scroll to the selected object to make it visible.
      Overrides:
        `setSelectedIndex` in class `javax.swing.JList`

    - #### getSelectedObject

          public T getSelectedObject()

    - #### getSelectedObjects

          public java.util.List<T> getSelectedObjects()

      Returns the selected Objects as an array.

    - #### selectObject

          public void selectObject(int index)

    - #### selectObject

          public void selectObject(T obj)

    - #### selectObjects

          public void selectObjects(T[] objects)

    - #### setNumb

          public void setNumb(boolean state)

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

    - #### isNumb

          public boolean isNumb()

      Tells whether the ListModel is in numb state

    - #### addActionListener

          public void addActionListener(java.awt.event.ActionListener l)

      Adds a listener to react on double clicks.

    - #### removeActionListener

          public void removeActionListener(java.awt.event.ActionListener l)

      Removes a double click listener.

    - #### doOnDoubleClick

          protected void doOnDoubleClick(java.util.List<T> selectedValues)

      This method is called when a mouse double-click was detected on the list component.
      Parameters:
        `selectedValues` - the values currently selected in the list.

    - #### addListDataListener

          public void addListDataListener(javax.swing.event.ListDataListener l)

    - #### removeListDataListener

          public void removeListDataListener(javax.swing.event.ListDataListener l)

    - #### matchesTypedString

          public boolean matchesTypedString(java.lang.Object obj,
                                   java.lang.String typedStr)

    - #### getRecordCount

          public int getRecordCount()

      Specified by:
        `getRecordCount` in interface `Steppable`

    - #### isChangeConfirmed

          public boolean isChangeConfirmed()

      Specified by:
        `isChangeConfirmed` in interface `Steppable`

    - #### first

          public void first()

      Specified by:
        `first` in interface `Steppable`

    - #### last

          public void last()

      Specified by:
        `last` in interface `Steppable`

    - #### next

          public boolean next()

      Specified by:
        `next` in interface `Steppable`

    - #### previous

          public boolean previous()

      Specified by:
        `previous` in interface `Steppable`

    - #### setCurrentIndex

          public boolean setCurrentIndex(int i)

      Specified by:
        `setCurrentIndex` in interface `Steppable`

    - #### getCurrentIndex

          public int getCurrentIndex()

      Specified by:
        `getCurrentIndex` in interface `Steppable`

    - #### scrollToRow

          public void scrollToRow(int rowIndex)

      Scrolls to the given row index to make it visible.

Copyright © 2011 EsprIT-Systems. All Rights Reserved.