KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > core > util > ObjectListEvent


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.core.util;
21
22 import java.util.EventObject JavaDoc;
23
24 /**
25  * An event for changes in an ObjectList
26  *
27  * @author tl
28  */

29 public class ObjectListEvent extends EventObject JavaDoc {
30     /** a range of items was removed */
31     public static final int EVENT_REMOVED = 0;
32
33     /** new items added */
34     public static final int EVENT_ADDED = 1;
35
36     /** the objects changed completely */
37     public static final int EVENT_STRUCTURE_CHANGED = 2;
38
39     /** objects were just reordered. Not removed and not added. */
40     public static final int EVENT_REORDERED = 3;
41
42     private int op;
43     private int indices[];
44     private Object JavaDoc objects[];
45
46     /**
47      * Constructor
48      *
49      * @param source source for this event. Typically an ObjectList
50      * @param indices indices of the changed values. May be null if
51      * op == EVENT_REORDERED.
52      * @param objects changed values. May be null if
53      * op == EVENT_REORDERED.
54      * @param op Operation. One of the EVENT_* constants from this class
55      */

56     public ObjectListEvent(Object JavaDoc source, int op, int[] indices,
57             Object JavaDoc[] objects) {
58         super(source);
59
60         assert op == EVENT_ADDED || op == EVENT_REMOVED ||
61             op == EVENT_REORDERED || op == EVENT_STRUCTURE_CHANGED :
62             "Wrong operation"; // NOI18N
63

64         assert indices != null || op == EVENT_REORDERED;
65         assert objects != null || op == EVENT_REORDERED;
66
67         this.op = op;
68         this.indices = indices;
69         this.objects = objects;
70     }
71
72     /**
73      * Returns the type of the event
74      *
75      * @return one of the EVENT_* constants from this class
76      */

77     public int getType() {
78         return op;
79     }
80
81     /**
82      * Returns changed objects
83      *
84      * @return array of changed objects. May be null if
85      * op == EVENT_REORDERED
86      */

87     public Object JavaDoc[] getObjects() {
88         return objects;
89     }
90
91     /**
92      * Returns indices of changed objects
93      *
94      * @return indices. May be null if op == EVENT_REORDERED
95      */

96     public int[] getIndices() {
97         return indices;
98     }
99 }
100
Popular Tags