org.openide.src
Class MultiPropertyChangeEvent
java.lang.Object
|
+--java.util.EventObject
|
+--java.beans.PropertyChangeEvent
|
+--org.openide.src.MultiPropertyChangeEvent
- All Implemented Interfaces:
- Serializable
- public class MultiPropertyChangeEvent
- extends PropertyChangeEvent
This class is much like the ordinary PropertyChange event, but refines the message
so it carry diff between the old and the new contents. There are several operations
that can be made on a multivalued property:
- add - new items were introduced into the property.
- remove - items were removed from the property.
- change - some items were atomically replaced by new ones.
- reorder - no items were removed or added, but only reordered within the multivalued
property.
ADD operation only introduces new items. For ordered multivalued properties,
there's a index array with positions for each newly inserted element.
REMOVE only mentiones elements that are being removed.
CHANGE event specifies what items are being removed and what are replacing them.
REORDER can specify:
- a permutation describing the reorder operation
- old and new state of the whole property
- old state and the permutation
- new state and the permutation
Note: this event is not particularly useful for indexed properties with primitive
values since the values does not have an identity and would need to be converted to
wrapper Objects which is not cheap anyway.
- Since:
- 24/11/2000
- See Also:
- Serialized Form
Field Summary |
static int |
TYPE_ADD
Items are being added to the container. |
static int |
TYPE_COMPOUND
Compound event, resulting from a generic change and comparisons |
static int |
TYPE_MODIFY
Items are being replaced. |
static int |
TYPE_REMOVE
Items are being removed from the container. |
static int |
TYPE_REORDER
Items are being reordered. |
TYPE_ADD
public static final int TYPE_ADD
- Items are being added to the container.
TYPE_REMOVE
public static final int TYPE_REMOVE
- Items are being removed from the container.
TYPE_MODIFY
public static final int TYPE_MODIFY
- Items are being replaced.
TYPE_REORDER
public static final int TYPE_REORDER
- Items are being reordered.
TYPE_COMPOUND
public static final int TYPE_COMPOUND
- Compound event, resulting from a generic change and comparisons
MultiPropertyChangeEvent
public MultiPropertyChangeEvent(Object source,
String propName,
Object oldVal,
Object newVal)
makeInsertion
public void makeInsertion(Collection items,
int[] indices)
makeRemoval
public void makeRemoval(Collection items,
int[] indices)
makeRemoval
public void makeRemoval(Collection items)
makeReorder
public void makeReorder(int[] permutation)
makeReplacement
public void makeReplacement(Collection old,
Collection n,
int[] indices)
makeCompound
public void makeCompound(Collection partialChanges,
int[] offsets)
checkUninitialized
protected void checkUninitialized()
getAffectedItems
public Collection getAffectedItems()
- Returns items affected by the operation. For add and remove operations, these
are items added to or removed from the container, respectively. For change operation,
the collection contains items that are being replaced in the container.
- Returns:
- collection of affected items. The collection is read-only.
getComponents
public Collection getComponents()
getReplacement
public Collection getReplacement()
throws IllegalStateException
- Returns items that will replace
getAffectedItems()
in the container.
- Returns:
- r/o collection of new items that are being inserted in the container.
getPermutation
public int[] getPermutation()
throws IllegalStateException
- Returns the permutation that describes the REORDER operation.
- Returns:
- array of item's indexes in the new property's state. The array is indexed by positions in the old state.
getIndices
public int[] getIndices()
- Returns array of relevant indices. For ADD operation, these are indexes which
the elements are inserted at (0-based, one position beyond item count permitted).
for REMOVE operation, indices are indexes to elements which are to be removed
(indexes are computed prior to the removing any of the affected items).
For MODIFY operation, this represents positions of elements which were replaced
by another ones. Last, REORDER operation uses indices as a permutation that
describes the reorder operation.
- Returns:
- array of (integer) indices
getEventType
public final int getEventType()
getIterator
public Iterator getIterator()
- Returns iterator over partial operations collection in a compound change event.
If the event is simple, the returned iterator will return the event itself.
Built on December 12 2001. | Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.