Module org.autogui
Package org.autogui.swing.util
Class ValueListPane.ValueListModel<ValueType,PaneType extends JComponent>
java.lang.Object
javax.swing.AbstractListModel<ValueListPane.ValueListElementPane<ValueType,PaneType>>
org.autogui.swing.util.ValueListPane.ValueListModel<ValueType,PaneType>
- Type Parameters:
ValueType
- the value type of the sourcePaneType
- the element-pane type
- All Implemented Interfaces:
Serializable
,ListModel<ValueListPane.ValueListElementPane<ValueType,
PaneType>>
- Enclosing class:
ValueListPane<ValueType,
PaneType extends JComponent>
public static class ValueListPane.ValueListModel<ValueType,PaneType extends JComponent>
extends AbstractListModel<ValueListPane.ValueListElementPane<ValueType,PaneType>>
the list-model for element-panes
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<ValueListPane.ValueListElementPane<ValueType, PaneType>> created element-panesprotected ValueListPane
<ValueType, PaneType> the owner paneFields inherited from class javax.swing.AbstractListModel
listenerList
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
called fromgetElementAt(int)
if the index is over the element-panes.getElementAt
(int index) int
getSize()
int
indexOf
(ValueListPane.ValueListElementPane<?, ?> pane) protected ValueListPane.ValueListElementPane
<ValueType, PaneType> protected void
the callback when an element-pane is removedvoid
checks differences between element-panes and the source-list.protected void
updateSource
(Runnable task) protected void
void
updateSourceWithMoving
(int targetIndex, int... movedIndicesSorted) moving the selected-panes to the target-index andupdateSource()
void
updateSourceWithRemoving
(int... removedIndices) remove element panes, fire a model-removing event andupdateSource()
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
Field Details
-
owner
the owner pane -
elementPanes
protected List<ValueListPane.ValueListElementPane<ValueType,PaneType extends JComponent>> elementPanescreated element-panes
-
-
Constructor Details
-
ValueListModel
- Parameters:
owner
- the pane of the list, non-null
-
-
Method Details
-
getSize
public int getSize() -
indexOf
- Parameters:
pane
- the pane in the list- Returns:
- index of the pane
-
getElementAt
-
addNewElementPane
protected void addNewElementPane()called fromgetElementAt(int)
if the index is over the element-panes.- it creates a pane by
newElementPane()
and add it to the list of panes (fix the index of the pane) ValueListPane.ValueListElementPane.setContentPane(JComponent)
withValueListPane.newElementPane(int, ValueListElementPane)
ValueListPane.ValueListElementPane.updateIndex()
ValueListPane.updateSourceValueToElementPane(int, Object, ValueListElementPane)
- fire a model event for adding
- it creates a pane by
-
newElementPane
- Returns:
- create an element-pane (without the content-pane)
-
updateSourceWithRemoving
public void updateSourceWithRemoving(int... removedIndices) remove element panes, fire a model-removing event andupdateSource()
- Parameters:
removedIndices
- moved indices of panes
-
removeElementPane
the callback when an element-pane is removed- Parameters:
pane
- remove the pane
-
updateSourceWithMoving
public void updateSourceWithMoving(int targetIndex, int... movedIndicesSorted) moving the selected-panes to the target-index andupdateSource()
- Parameters:
targetIndex
- the target-index before movingmovedIndicesSorted
- indices of selected-panes
-
updateSource
public void updateSource()checks differences between element-panes and the source-list.- if element-panes are over the size of the source-list, remove panes
ValueListPane.ValueListElementPane.updateIndex()
andValueListPane.updateSourceValueToElementPane(int, Object, ValueListElementPane)
; if updated, fire a change-event- if the source-list is over the panes, create new panes
- fire events for removing and adding panes
-
updateSource
-
updateSourceBody
protected void updateSourceBody()
-