Class DefaultListModel<T>

java.lang.Object
de.hybris.platform.cockpit.model.listview.AbstractListModel<T>
de.hybris.platform.cockpit.model.general.impl.DefaultListModel<T>
All Implemented Interfaces:
ListModel<T>

public class DefaultListModel<T> extends AbstractListModel<T>
  • Field Details

    • elements

      protected List<T> elements
    • movableElements

      protected ListSelectionModel movableElements
    • removableElements

      protected ListSelectionModel removableElements
    • editable

      protected boolean editable
  • Constructor Details

    • DefaultListModel

      public DefaultListModel()
  • Method Details

    • add

      public void add(T element)
      Adds element to the list and marks it as not removable and not movable. Same as calling add(element, false, false).
      Parameters:
      element - the element to be added
      See Also:
    • add

      public void add(T element, boolean removable, boolean movable)
      Adds element to the list.
      Parameters:
      element - the element to be added
      removable - whether element should be marked as removable or not
      movable - whether element should be marked as movable or not
    • add

      public void add(int index, T element) throws IndexOutOfBoundsException
      Throws:
      IndexOutOfBoundsException
    • add

      public void add(int index, T element, boolean removable, boolean movable) throws IndexOutOfBoundsException
      Throws:
      IndexOutOfBoundsException
    • addAll

      public void addAll(Collection<T> elements)
      Parameters:
      elements -
      See Also:
    • addAll

      public void addAll(Collection<T> elements, boolean removable, boolean movable)
      Appends all of the elements in elements to the end of this list. Any registered ListDataListeners will be notified that an interval has been added.
      Parameters:
      elements - elements to be appended
      removable - whether the elements are removable or not
      movable - whether the elements are movable or not
    • clearAndAddAll

      public void clearAndAddAll(Collection<? extends T> elements, boolean removable, boolean movable)
      Clears all the elements of the current list, then adds the elements of elements and finally fires a ListDataEvent.CONTENTS_CHANGED event i.e. no add and/or remove events are sent.

      Same as clearAndAddAll(elements, false, false, true).
      Parameters:
      elements - the elements to add
      removable - whether the elements are removable or not
      movable - whether the elements are movable or not
      See Also:
    • clearAndAddAll

      public void clearAndAddAll(Collection<? extends T> elements, boolean removable, boolean movable, boolean fireEvent)
      Clears all the elements of the current list, then adds the elements of elements and, if fireEvent is true, finally fires a ListDataEvent.CONTENTS_CHANGED event i.e. no add and/or remove events are sent.
      Parameters:
      elements - the elements to add
      removable - whether the elements are removable or not
      movable - whether the elements are movable or not
      fireEvent - whether an event should be fired or not
      See Also:
    • clearAndAddAll

      public void clearAndAddAll(Collection<T> elements)
      Parameters:
      elements - the elements to add
      See Also:
    • set

      public void set(int index, T element) throws IndexOutOfBoundsException
      Throws:
      IndexOutOfBoundsException
    • set

      public T set(int index, T element, boolean removable, boolean movable)
    • removeRange

      public void removeRange(int fromIndex, int toIndex) throws ArrayIndexOutOfBoundsException, IllegalArgumentException
      Removes elements in the range [fromIndex toIndex].
      Parameters:
      fromIndex - (inclusive) index of the first element in the range
      toIndex - (inclusive) index of the last element in the range
      Throws:
      ArrayIndexOutOfBoundsException - if either fromIndex or toIndex is invalid
      IllegalArgumentException - if fromIndex is greater than toIndex
    • remove

      public T remove(int index) throws IndexOutOfBoundsException
      Throws:
      IndexOutOfBoundsException
    • remove

      public boolean remove(T element)
    • removeAll

      public void removeAll(Collection<T> elements)
    • clear

      public void clear()
      See Also:
    • elementAt

      public T elementAt(int index) throws IndexOutOfBoundsException
      Description copied from interface: ListModel
      Returns the element at position index.
      Parameters:
      index - position of the element to get
      Returns:
      the element at position index
      Throws:
      IndexOutOfBoundsException - if there is no element at position index
    • getElements

      public List<T> getElements()
      Description copied from interface: ListModel
      Returns all elements.
      Returns:
      list containing all elements
    • size

      public int size()
      Description copied from interface: ListModel
      Returns the size of this list i.e. the number of elements stored.
      Returns:
      this list's size
    • setEditable

      public void setEditable(boolean editable)
    • isEditable

      public boolean isEditable()
      Description copied from interface: ListModel
      Returns whether this list is marked as _editable_ or not.
      Returns:
      true if this list is marked as editable, false otherwise
    • setMovable

      public void setMovable(int index, boolean movable)
    • isMovable

      public boolean isMovable(int index) throws IndexOutOfBoundsException
      Description copied from interface: ListModel
      Returns whether the element at position index is movable or not.
      Parameters:
      index - position of the element
      Returns:
      true if the element is movable, false otherwise
      Throws:
      IndexOutOfBoundsException - if there is no element at position index
    • setRemovable

      public void setRemovable(int index, boolean removable)
    • isRemovable

      public boolean isRemovable(int index) throws IndexOutOfBoundsException
      Description copied from interface: ListModel
      Returns whether the element at position index is removable or not.
      Parameters:
      index - position of the element
      Returns:
      true if the element is removable, false otherwise
      Throws:
      IndexOutOfBoundsException - if there is no element at position index
    • setMovableElementsModel

      public void setMovableElementsModel(ListSelectionModel model)
    • setRemovableElementsModel

      public void setRemovableElementsModel(ListSelectionModel model)
    • moveElement

      public void moveElement(int fromIndex, int toIndex)
      Moves an element from position fromIndex to position toIndex. Implicitly fires event since it calls add(int, Object, boolean, boolean) and remove(int)
      Parameters:
      fromIndex - the current position index of the item to move
      toIndex - the new position index of the item
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isEmpty

      public boolean isEmpty()