|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ReorderableListModel<E>
ReorderableListModel is a data model of a list of items that can be manipulated in a variety of ways, specifically aimed for a GUI that allows reordering, creating, and deleting items. It will have the following features: 1) Handle list actions – create items in the list, remove items in the list. 1.newItem() returns a new ReorderableListItem that can be inserted into anywhere in the list. 2.deleteItem(ReorderableListItem, int oldIndex) deletes the item from the list. 2) Allow listeners, ReorderableListListener which can listen for: 1.Any changes (and must know what the change is or what the change's source was) 3) It can return the list of items in a List<ReorderableListItem>. Each item is a ReorderableListItem. 1.Each item should have a renderer that can be referred to for getting the item out of the list into a GUI. This is a different interface, ReorderableListItemRenderer (extends JComponent). In general, the GUI should not actually move/delete/insert anything on its own. It should only issue the move/delete/insert command to this model and then wait until it gets an event via ReorderableChangeListener. That way, if there's a bug in this model for some reason and the operation can't be done, the operation can be cancelled. (Whether the operation worked is duplicated in the return of each move method -- so theoretically you could use that, but it won't be quite as clean).
Field Summary | |
---|---|
static int |
INSERTED_FROM_DELETED_HERE
When you've deleted a object from this list, and are inserting it back into this list, pass INSERTED_FROM_DELETED_HERE into itemMovedToIndex() as the second parameter -- oldIndexInThisList. |
static int |
INSERTED_FROM_ELSEWHERE
|
Method Summary | |
---|---|
void |
addReorderableChangeListener(ReorderableChangeListener<E> reorderableChangeListener)
|
boolean |
canItemBeMovedElsewhere()
Removed means can it be moved to somewhere else, NOT deleted -- it must always be deletable. |
boolean |
deleteItem(E item,
int oldIndex)
Call this when an item has been deleted. |
int |
getItemCount()
|
E |
insertNewItemAt(int indexAt)
Creates a new item for the list and puts it into the index that it's listed as. |
java.util.Iterator<E> |
iterator()
Get the items. |
boolean |
moveItemElsewhere(E item,
int oldIndex)
Removed means it was moved to somewhere else, NOT deleted. |
boolean |
moveItemToIndex(E item,
java.lang.Integer oldIndexInThisList,
int newIndex)
Items are moved around in the list, or added to the list this way, too. |
void |
removeReorderableChangeListener(ReorderableChangeListener<E> reorderableChangeListener)
|
Field Detail |
---|
static final int INSERTED_FROM_ELSEWHERE
static final int INSERTED_FROM_DELETED_HERE
Method Detail |
---|
boolean moveItemToIndex(E item, java.lang.Integer oldIndexInThisList, int newIndex)
item
- oldIndexInThisList
- The old index it had in this parent -- if it is new or dropped from another pane, oldIndex is null.newIndex
- The index it should be dropped into
boolean canItemBeMovedElsewhere()
boolean moveItemElsewhere(E item, int oldIndex)
item
- oldIndex
-
boolean deleteItem(E item, int oldIndex)
item
- oldIndex
-
E insertNewItemAt(int indexAt)
indexAt
-
java.util.Iterator<E> iterator()
int getItemCount()
void addReorderableChangeListener(ReorderableChangeListener<E> reorderableChangeListener)
void removeReorderableChangeListener(ReorderableChangeListener<E> reorderableChangeListener)
reorderableChangeListener
- the ReorderableChangeListener to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |