|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.EventObject
org.eclipse.jpt.utility.model.event.ChangeEvent
org.eclipse.jpt.utility.model.event.ListChangeEvent
public class ListChangeEvent
A "list change" event gets delivered whenever a model changes a "bound" or "constrained" list. A ListChangeEvent is sent as an argument to the ListChangeListener. Normally a ListChangeEvent is accompanied by the list name, the items that were added to or removed from the changed list, and the index of where the items are or were in the list. Design options: - create a list to wrap a single added or removed item (this is the option we implemented below and in collaborating code) since there is no way to optimize downstream code for single items, we take another performance hit by building a list each time (@see Collections#singletonList(Object)) and forcing downstream code to use a list iterator every time - fire a separate event for each item added or removed eliminates any potential for optimizations to downstream code - add protocol to support both single items and collections adds conditional logic to downstream code Provisional API: This class is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Constructor Summary | |
---|---|
ListChangeEvent(Model source,
java.lang.String listName)
Construct a new list change event. |
|
ListChangeEvent(Model source,
java.lang.String listName,
int targetIndex,
int sourceIndex,
int length)
Construct a new list change event for a list of moved items. |
|
ListChangeEvent(Model source,
java.lang.String listName,
int index,
java.util.List<?> items)
Construct a new list change event for a list of added or removed items. |
|
ListChangeEvent(Model source,
java.lang.String listName,
int index,
java.util.List<?> items,
java.util.List<?> replacedItems)
Construct a new list change event for a list of replaced items. |
Method Summary | |
---|---|
ListChangeEvent |
cloneWithSource(Model newSource)
Return a copy of the event with the specified source replacing the current source. |
ListChangeEvent |
cloneWithSource(Model newSource,
java.lang.String newListName)
Return a copy of the event with the specified source and list name replacing the current source and list name. |
ListChangeEvent |
cloneWithSource(Model newSource,
java.lang.String newListName,
int offset)
Return a copy of the event with the specified source and list name replacing the current source and list name and displacing the index by the specified amount. |
java.lang.String |
getAspectName()
Return the name of the aspect of the source that changed. |
int |
getIndex()
Return the index at which the items were added to, removed from, or replaced in the list. |
java.lang.String |
getListName()
Return the programmatic name of the list that was changed. |
int |
getMoveLength()
In the case of "moved" items, this will be the number of items moved. |
int |
getSourceIndex()
In the case of "moved" items, this will be the "source" index. |
int |
getTargetIndex()
In the case of "moved" items, this will be the "target" index. |
java.util.ListIterator<?> |
items()
Return a list iterator on the items that were added to or removed from the list. |
int |
itemsSize()
Return the number of items that were added to, removed from, or replaced in the list. |
java.util.ListIterator<?> |
replacedItems()
Return a list iterator on the items in the list that were replaced. |
Methods inherited from class org.eclipse.jpt.utility.model.event.ChangeEvent |
---|
getSource, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ListChangeEvent(Model source, java.lang.String listName, int index, java.util.List<?> items, java.util.List<?> replacedItems)
source
- The object on which the event initially occurred.listName
- The programmatic name of the list that was changed.index
- The index at which the items in the list were replaced.items
- The new items in the list.replacedItems
- The items in the list that were replaced.public ListChangeEvent(Model source, java.lang.String listName, int index, java.util.List<?> items)
source
- The object on which the event initially occurred.listName
- The programmatic name of the list that was changed.index
- The index at which the items were added to or removed from the list.items
- The items that were added to or removed from the list.public ListChangeEvent(Model source, java.lang.String listName, int targetIndex, int sourceIndex, int length)
source
- The object on which the event initially occurred.listName
- The programmatic name of the list that was changed.targetIndex
- The index to which the items were moved.sourceIndex
- The index from which the items were moved.public ListChangeEvent(Model source, java.lang.String listName)
source
- The object on which the event initially occurred.listName
- The programmatic name of the list that was changed.Method Detail |
---|
public java.lang.String getListName()
public java.lang.String getAspectName()
ChangeEvent
getAspectName
in class ChangeEvent
public int getIndex()
public java.util.ListIterator<?> items()
public int itemsSize()
public java.util.ListIterator<?> replacedItems()
public int getTargetIndex()
public int getSourceIndex()
public int getMoveLength()
public ListChangeEvent cloneWithSource(Model newSource)
cloneWithSource
in class ChangeEvent
public ListChangeEvent cloneWithSource(Model newSource, java.lang.String newListName)
public ListChangeEvent cloneWithSource(Model newSource, java.lang.String newListName, int offset)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |