01: /* ListDataEvent.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Wed Aug 17 18:03:55 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zul.event;
20:
21: import org.zkoss.zul.ListModel;
22:
23: /**
24: * Defines an event that encapsulates changes to a list.
25: *
26: * @author tomyeh
27: */
28: public class ListDataEvent {
29: /** Identifies one or more changes in the lists contents. */
30: public static final int CONTENTS_CHANGED = 0;
31: /** Identifies the addition of one or more contiguous items to the list. */
32: public static final int INTERVAL_ADDED = 1;
33: /** Identifies the removal of one or more contiguous items from the list. */
34: public static final int INTERVAL_REMOVED = 2;
35:
36: private final ListModel _model;
37: private final int _type, _index0, _index1;
38:
39: /** Contructor.
40: *
41: * @param type one of {@link #CONTENTS_CHANGED},
42: * {@link #INTERVAL_ADDED}, or {@link #INTERVAL_REMOVED}.
43: * @param index0 the lower index of the change range.
44: * For simple element, index0 is the same as index1.
45: * -1 means the first element (the same as 0).
46: * @param index1 the upper index of the change range.
47: * -1 means the last element.
48: */
49: public ListDataEvent(ListModel model, int type, int index0,
50: int index1) {
51: if (model == null)
52: throw new NullPointerException();
53: _model = model;
54: _type = type;
55: _index0 = index0;
56: _index1 = index1;
57: }
58:
59: /** Returns the list model that fires this event.
60: */
61: public ListModel getModel() {
62: return _model;
63: }
64:
65: /** Returns the event type. One of {@link #CONTENTS_CHANGED},
66: * {@link #INTERVAL_ADDED}, or {@link #INTERVAL_REMOVED}.
67: */
68: public int getType() {
69: return _type;
70: }
71:
72: /** Returns the lower index of the change range.
73: * For a single element, this value is the same as that returned by
74: * {@link #getIndex1}.
75: */
76: public int getIndex0() {
77: return _index0;
78: }
79:
80: /** Returns the upper index of the change range.
81: * For a single element, this value is the same as that returned by
82: * {@link #getIndex0}.
83: */
84: public int getIndex1() {
85: return _index1;
86: }
87:
88: //Object//
89: public String toString() {
90: return "[Event type=" + _type + ", index=" + _index0 + ", "
91: + _index1 + ']';
92: }
93: }
|