KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > viewmodel > ModelEvent


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.spi.viewmodel;
21
22 import java.util.EventObject JavaDoc;
23
24
25 /**
26  * Encapsulates information describing changes to a model, and
27  * used to notify model listeners of the change.
28  *
29  * @author Jan Jancura
30  * @since 1.4
31  */

32 public class ModelEvent extends EventObject JavaDoc {
33
34     private ModelEvent (Object JavaDoc source) {
35         super (source);
36     }
37
38     /**
39      * Used to notify that whole content of tree has been changed.
40      *
41      * @since 1.4
42      */

43     public static class TreeChanged extends ModelEvent {
44
45         /**
46          * Creates a new instance of TreeChanged event.
47          *
48          * @param source a source if event.
49          *
50          * @since 1.4
51          */

52         public TreeChanged (Object JavaDoc source) {
53             super (source);
54         }
55     }
56     
57     /**
58      * Used to notify that one cell in table has been changed.
59      *
60      * @since 1.4
61      */

62     public static class TableValueChanged extends ModelEvent {
63         
64         private Object JavaDoc node;
65         private String JavaDoc columnID;
66         
67         /**
68          * Creates a new instance of TableValueChanged event.
69          *
70          * @param source a source if event.
71          * @param node a changed node instance
72          * @param columnID a changed column name
73          *
74          * @since 1.4
75          */

76         public TableValueChanged (
77             Object JavaDoc source,
78             Object JavaDoc node,
79             String JavaDoc columnID
80         ) {
81             super (source);
82             this.node = node;
83             this.columnID = columnID;
84         }
85         
86         /**
87          * Returns changed node instance.
88          *
89          * @return changed node instance
90          *
91          * @since 1.4
92          */

93         public Object JavaDoc getNode () {
94             return node;
95         }
96         
97         /**
98          * Returns changed column name.
99          *
100          * @return changed column name
101          *
102          * @since 1.4
103          */

104         public String JavaDoc getColumnID () {
105             return columnID;
106         }
107     }
108     
109     /**
110      * Used to notify that one node has been changed (icon, displayName and
111      * children).
112      *
113      * @since 1.4
114      */

115     public static class NodeChanged extends ModelEvent {
116         
117         /**
118          * The mask for display name change.
119          * @since 1.6
120          */

121         public static final int DISPLAY_NAME_MASK = 1;
122         /**
123          * The mask for icon change.
124          * @since 1.6
125          */

126         public static final int ICON_MASK = 2;
127         /**
128          * The mask for short description change.
129          * @since 1.6
130          */

131         public static final int SHORT_DESCRIPTION_MASK = 4;
132         /**
133          * The mask for children change.
134          * @since 1.6
135          */

136         public static final int CHILDREN_MASK = 8;
137         
138         private Object JavaDoc node;
139         private int change;
140         
141         /**
142          * Creates a new instance of NodeChanged event.
143          *
144          * @param source a source if event.
145          * @param node a changed node instance
146          *
147          * @since 1.4
148          */

149         public NodeChanged (
150             Object JavaDoc source,
151             Object JavaDoc node
152         ) {
153             this (source, node, 0xFFFFFFFF);
154         }
155         
156         /**
157          * Creates a new instance of NodeChanged event.
158          *
159          * @param source a source if event.
160          * @param node a changed node instance.
161          * @param change one of the *_MASK constant or their aggregation.
162          *
163          * @since 1.6
164          */

165         public NodeChanged(Object JavaDoc source, Object JavaDoc node, int change) {
166             super (source);
167             this.node = node;
168             this.change = change;
169         }
170         
171         /**
172          * Returns changed node instance.
173          *
174          * @return changed node instance
175          *
176          * @since 1.4
177          */

178         public Object JavaDoc getNode () {
179             return node;
180         }
181         
182         /**
183          * Get the change mask.
184          *
185          * @return the change mask, one of the *_MASK constant or their aggregation.
186          * @since 1.6
187          */

188         public int getChange() {
189             return change;
190         }
191     }
192 }
193
Popular Tags