|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.EventObject javax.swing.event.ListDataEvent com.jidesoft.list.CompoundListDataEvent
public class CompoundListDataEvent
Compound ListDataEvent to contain multiple subevents and the original event.
We introduce this event to handle some duplicated scenario which is hard to fire one single event. For example, if a sorted SortableListModel receives a row updated event from its underlying table model, the updated row could change its position. In this case, JList needs to get a INTERVAL_REMOVED event for the original position and another INTERVAL_ADDED event for the new position. However, it's not appropriate to fire two separate events for one action. It will also impact the performance if we simply fire CONTENTS_CHANGED event for all entries. That's why we introduce this class. Another advantage for CompoundListDataEvent is that, by invoking CompoundListDataEvent#getOriginalEvent(), you could now get if the table model event is triggered by the real data modification in the original list model level or it's simply triggered by actions like sorting/filtering. If JIDE fires thisCompoundListDataEvent
with two or more child events embedded in, the event itself will
represent as a CONTENTS_CHANGED event. That means, if you don't try to distinguish it with plain ListDataEvent, it
will fall into the branch you handle CONTENTS_CHANGED event. However, it doesn't mean that
CompoundListDataEvent has to be a CONTENTS_CHANGED event. You could fire whichever event you want following the instruction
of ListDataEvent
.
You could invoke getEvents()
to get the embedded child events inside the event. The order of those child events
inside the CompoundListDataEvent
matters. The listener is expected to handle the embedded events one by one.
For example, if a CompoundListDataEvent contains two events, the first one is INTERVAL_ADDED at 2 while the other
one is INTERVAL_REMOVED at 5, you need insert first then delete. Otherwise, you may get a wrong result.
Field Summary |
---|
Fields inherited from class javax.swing.event.ListDataEvent |
---|
CONTENTS_CHANGED, INTERVAL_ADDED, INTERVAL_REMOVED |
Fields inherited from class java.util.EventObject |
---|
source |
Constructor Summary | |
---|---|
CompoundListDataEvent(Object source,
int type,
int index0,
int index1)
The constructor. |
Method Summary | |
---|---|
void |
addEvent(int index,
ListDataEvent event)
Adds a new child event in designated position. |
void |
addEvent(ListDataEvent event)
Adds a new child event to the end. |
static void |
fireListDataEvent(EventFireListModel listModel,
ListDataEvent e)
Fires a list data event. |
ListDataEvent[] |
getEvents()
Gets all child events of this CompoundListDataEvent. |
ListDataEvent |
getOriginalEvent()
Gets the original event from received list data event. |
boolean |
isDebug()
Gets the flag indicating if the event is in debug mode. |
boolean |
isOriginalChanged()
Gets the flag indicating if the original list model is changed or not which causes this event. |
protected String |
printDebugInfo()
Prints debug information to a string. |
void |
removeEvent(int index)
Removes the event at a position |
void |
setDebug(boolean debug)
Sets the flag indicating if the event is in debug mode. |
void |
setOriginalEvent(ListDataEvent originalEvent)
Sets the original event from received list data event. |
Methods inherited from class javax.swing.event.ListDataEvent |
---|
getIndex0, getIndex1, getType, toString |
Methods inherited from class java.util.EventObject |
---|
getSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CompoundListDataEvent(Object source, int type, int index0, int index1)
source
- the list modeltype
- the event typeindex0
- the start indexindex1
- the end indexMethod Detail |
---|
public void addEvent(ListDataEvent event)
event
- the child event to be addedpublic void addEvent(int index, ListDataEvent event)
index
- the event indexevent
- the child event to be addedpublic void removeEvent(int index)
index
- the event index to be removedpublic ListDataEvent[] getEvents()
protected String printDebugInfo()
public static void fireListDataEvent(EventFireListModel listModel, ListDataEvent e)
listModel
- the list model to fire list data evente
- the list model event to be firedpublic boolean isOriginalChanged()
public ListDataEvent getOriginalEvent()
setOriginalEvent(javax.swing.event.ListDataEvent)
public void setOriginalEvent(ListDataEvent originalEvent)
originalEvent
- the original eventpublic boolean isDebug()
setDebug(boolean)
public void setDebug(boolean debug)
debug
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |