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 Summary
Fields Modifier and Type Field Description protected booleaneditableprotected java.util.List<T>elementsprotected ListSelectionModelmovableElementsprotected ListSelectionModelremovableElements-
Fields inherited from class de.hybris.platform.cockpit.model.listview.AbstractListModel
listEditorDataListeners
-
-
Constructor Summary
Constructors Constructor Description DefaultListModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, T element)voidadd(int index, T element, boolean removable, boolean movable)voidadd(T element)Addselementto the list and marks it as not removable and not movable.voidadd(T element, boolean removable, boolean movable)Addselementto the list.voidaddAll(java.util.Collection<T> elements)Same as callingaddAll(elements, false, false).voidaddAll(java.util.Collection<T> elements, boolean removable, boolean movable)Appends all of the elements inelementsto the end of this list.voidclear()voidclearAndAddAll(java.util.Collection<? extends T> elements, boolean removable, boolean movable)Clears all the elements of the current list, then adds the elements ofelementsand finally fires aListDataEvent.CONTENTS_CHANGEDevent i.e.voidclearAndAddAll(java.util.Collection<? extends T> elements, boolean removable, boolean movable, boolean fireEvent)Clears all the elements of the current list, then adds the elements ofelementsand, if fireEvent is true, finally fires aListDataEvent.CONTENTS_CHANGEDevent i.e.voidclearAndAddAll(java.util.Collection<T> elements)TelementAt(int index)Returns the element at positionindex.java.util.List<T>getElements()Returns all elements.booleanisEditable()Returns whether this list is marked as _editable_ or not.booleanisEmpty()booleanisMovable(int index)Returns whether the element at positionindexis movable or not.booleanisRemovable(int index)Returns whether the element at positionindexis removable or not.voidmoveElement(int fromIndex, int toIndex)Moves an element from positionfromIndexto positiontoIndex.Tremove(int index)booleanremove(T element)voidremoveAll(java.util.Collection<T> elements)voidremoveRange(int fromIndex, int toIndex)Removes elements in the range [fromIndextoIndex].voidset(int index, T element)Tset(int index, T element, boolean removable, boolean movable)voidsetEditable(boolean editable)voidsetMovable(int index, boolean movable)voidsetMovableElementsModel(ListSelectionModel model)voidsetRemovable(int index, boolean removable)voidsetRemovableElementsModel(ListSelectionModel model)intsize()Returns the size of this list i.e.java.lang.StringtoString()-
Methods inherited from class de.hybris.platform.cockpit.model.listview.AbstractListModel
addListModelDataListener, fireEvent, getListDataListeners, removeListModelDataListener
-
-
-
-
Field Detail
-
elements
protected java.util.List<T> elements
-
movableElements
protected ListSelectionModel movableElements
-
removableElements
protected ListSelectionModel removableElements
-
editable
protected boolean editable
-
-
Method Detail
-
add
public void add(T element)
Addselementto the list and marks it as not removable and not movable. Same as callingadd(element, false, false).- Parameters:
element- the element to be added- See Also:
add(Object, boolean, boolean)
-
add
public void add(T element, boolean removable, boolean movable)
Addselementto the list.- Parameters:
element- the element to be addedremovable- whetherelementshould be marked as removable or notmovable- whetherelementshould be marked as movable or not
-
add
public void add(int index, T element) throws java.lang.IndexOutOfBoundsException- Throws:
java.lang.IndexOutOfBoundsException
-
add
public void add(int index, T element, boolean removable, boolean movable) throws java.lang.IndexOutOfBoundsException- Throws:
java.lang.IndexOutOfBoundsException
-
addAll
public void addAll(java.util.Collection<T> elements)
Same as callingaddAll(elements, false, false).- Parameters:
elements-- See Also:
addAll(Collection, boolean, boolean)
-
addAll
public void addAll(java.util.Collection<T> elements, boolean removable, boolean movable)
Appends all of the elements inelementsto the end of this list. Any registeredListDataListeners will be notified that an interval has been added.- Parameters:
elements- elements to be appendedremovable- whether the elements are removable or notmovable- whether the elements are movable or not
-
clearAndAddAll
public void clearAndAddAll(java.util.Collection<? extends T> elements, boolean removable, boolean movable)
Clears all the elements of the current list, then adds the elements ofelementsand finally fires aListDataEvent.CONTENTS_CHANGEDevent i.e. no add and/or remove events are sent.
Same asclearAndAddAll(elements, false, false, true).- Parameters:
elements- the elements to addremovable- whether the elements are removable or notmovable- whether the elements are movable or not- See Also:
clearAndAddAll(Collection)
-
clearAndAddAll
public void clearAndAddAll(java.util.Collection<? extends T> elements, boolean removable, boolean movable, boolean fireEvent)
Clears all the elements of the current list, then adds the elements ofelementsand, if fireEvent is true, finally fires aListDataEvent.CONTENTS_CHANGEDevent i.e. no add and/or remove events are sent.- Parameters:
elements- the elements to addremovable- whether the elements are removable or notmovable- whether the elements are movable or notfireEvent- whether an event should be fired or not- See Also:
clearAndAddAll(Collection)
-
clearAndAddAll
public void clearAndAddAll(java.util.Collection<T> elements)
- Parameters:
elements- the elements to add- See Also:
clearAndAddAll(Collection, boolean, boolean)
-
set
public void set(int index, T element) throws java.lang.IndexOutOfBoundsException- Throws:
java.lang.IndexOutOfBoundsException
-
removeRange
public void removeRange(int fromIndex, int toIndex) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.IllegalArgumentExceptionRemoves elements in the range [fromIndextoIndex].- Parameters:
fromIndex- (inclusive) index of the first element in the rangetoIndex- (inclusive) index of the last element in the range- Throws:
java.lang.ArrayIndexOutOfBoundsException- if eitherfromIndexortoIndexis invalidjava.lang.IllegalArgumentException- iffromIndexis greater thantoIndex
-
remove
public T remove(int index) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
remove
public boolean remove(T element)
-
removeAll
public void removeAll(java.util.Collection<T> elements)
-
clear
public void clear()
- See Also:
clearAndAddAll(Collection)
-
elementAt
public T elementAt(int index) throws java.lang.IndexOutOfBoundsException
Description copied from interface:ListModelReturns the element at positionindex.- Parameters:
index- position of the element to get- Returns:
- the element at position
index - Throws:
java.lang.IndexOutOfBoundsException- if there is no element at positionindex
-
getElements
public java.util.List<T> getElements()
Description copied from interface:ListModelReturns all elements.- Returns:
- list containing all elements
-
size
public int size()
Description copied from interface:ListModelReturns 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:ListModelReturns whether this list is marked as _editable_ or not.- Returns:
trueif this list is marked as editable,falseotherwise
-
setMovable
public void setMovable(int index, boolean movable)
-
isMovable
public boolean isMovable(int index) throws java.lang.IndexOutOfBoundsExceptionDescription copied from interface:ListModelReturns whether the element at positionindexis movable or not.- Parameters:
index- position of the element- Returns:
trueif the element is movable,falseotherwise- Throws:
java.lang.IndexOutOfBoundsException- if there is no element at positionindex
-
setRemovable
public void setRemovable(int index, boolean removable)
-
isRemovable
public boolean isRemovable(int index) throws java.lang.IndexOutOfBoundsExceptionDescription copied from interface:ListModelReturns whether the element at positionindexis removable or not.- Parameters:
index- position of the element- Returns:
trueif the element is removable,falseotherwise- Throws:
java.lang.IndexOutOfBoundsException- if there is no element at positionindex
-
setMovableElementsModel
public void setMovableElementsModel(ListSelectionModel model)
-
setRemovableElementsModel
public void setRemovableElementsModel(ListSelectionModel model)
-
moveElement
public void moveElement(int fromIndex, int toIndex)Moves an element from positionfromIndexto positiontoIndex. Implicitly fires event since it callsadd(int, Object, boolean, boolean)andremove(int)- Parameters:
fromIndex- the current position index of the item to movetoIndex- the new position index of the item- See Also:
add(int, Object, boolean, boolean),remove(int)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isEmpty
public boolean isEmpty()
-
-