KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > app > event > TableModelEvent


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.app.event;
31
32 import java.util.EventObject JavaDoc;
33 import nextapp.echo2.app.table.TableModel;
34
35 /**
36  * An event describing a change to a <code>TableModel</code>.
37  */

38 public class TableModelEvent extends EventObject JavaDoc {
39
40     /**
41      * A value for <code>column</code> parameters indicating that all columns
42      * of the table were affected by the change.
43      */

44     public static final int ALL_COLUMNS = -2;
45
46     /**
47      * A value row-describing parameters/properties, (i.e., <code>row</code>,
48      * <code>firstRow</code>, and <code>lastRow</code>)
49      * indicating the table header was affected.
50      */

51     public static final int HEADER_ROW = -1;
52     
53     /**
54      * An event type indicating one or more table rows were deleted.
55      */

56     public static final int DELETE = 1;
57     
58     /**
59      * An event type indicating one or more table rows were inserted.
60      */

61     public static final int INSERT = 2;
62     
63     /**
64      * An event type indicating one or more table rows were updated.
65      */

66     public static final int UPDATE = 3;
67     
68     /**
69      * An event type indicating the table structure was modified.
70      */

71     public static final int STRUCTURE_CHANGED = 4;
72     
73     private int firstRow;
74     private int lastRow;
75     private int column;
76     private int type;
77
78     /**
79      * Creates a <code>TableModelEvent</code> describing a change to any or
80      * all rows of a table.
81      *
82      * @param source the changed <code>TableModel</code>
83      */

84     public TableModelEvent(TableModel source) {
85         this(source, ALL_COLUMNS, 0, Integer.MAX_VALUE, UPDATE);
86     }
87     
88     /**
89      * Creates a <code>TableModel</code>Event indicating a change to any or
90      * all columns of a single table row.
91      *
92      * @param source the changed <code>TableModel</code>
93      * @param row the index of the affected row
94      */

95     public TableModelEvent(TableModel source, int row) {
96         this(source, ALL_COLUMNS, row, row, UPDATE);
97     }
98     
99     /**
100      * Creates a <code>TableModel</code>Event indicating a change to any or
101      * all columns of an interval of table rows.
102      *
103      * @param source the changed <code>TableModel</code>
104      * @param firstRow the first table row affected by the update
105      * @param lastRow the last table row affected by the update
106      */

107     public TableModelEvent(TableModel source, int firstRow, int lastRow) {
108         this(source, ALL_COLUMNS, firstRow, lastRow, UPDATE);
109     }
110     
111     /**
112      * Creates a <code>TableModelEvent</code> indicating a change to a
113      * particular column of a single table row or an interval of table rows.
114      *
115      * @param source the changed <code>TableModel</code>
116      * @param column the column that was affected by the update
117      * @param firstRow the first table row affected by the update
118      * @param lastRow the last table row affected by the update
119      */

120     public TableModelEvent(TableModel source, int column, int firstRow, int lastRow) {
121         this(source, column, firstRow, lastRow, UPDATE);
122     }
123     
124     /**
125      * Primary constructor for creating <code>TableModelEvent</code>s.
126      * All other constructors are for convenience and must invoke this
127      * constructor.
128      *
129      * @param source the changed <code>TableModel</code>
130      * @param column the column that was affected by the update,
131      * or <code>ALL_COLUMNS</code> if all columns were affected.
132      * @param firstRow the first table row affected by the update
133      * @param lastRow the last table row affected by the update
134      * @param type The type of change that occurred, one of the following
135      * values:
136      * <ul>
137      * <li>STRUCTURE_CHANGED - indicates the table's structure
138      * changed.</li>
139      * <li>DELETE - indicates one or more rows were deleted.</li>
140      * <li>INSERT - indicates one or more rows were inserted.</li>
141      * <li>UPDATE - indicates one or more rows were updated.</li>
142      * </ul>
143      */

144     public TableModelEvent(TableModel source, int column, int firstRow, int lastRow, int type) {
145         super(source);
146         
147         this.firstRow = firstRow;
148         this.lastRow = lastRow;
149         this.column = column;
150         this.type = type;
151     }
152     
153     /**
154      * Returns the column that was affected by the update.
155      *
156      * @return the column that was affected by the update.
157      */

158     public int getColumn() {
159          return column;
160     }
161     
162     /**
163      * Returns the first row that was affected by the update.
164      *
165      * @return the first row that was affected by the update
166      */

167     public int getFirstRow() {
168         return firstRow;
169     }
170     
171     /**
172      * Returns the last row that was affected by the update.
173      *
174      * @return the last row that was affected by the update
175      */

176     public int getLastRow() {
177         return lastRow;
178     }
179
180     /**
181      * Returns the type of update that occurred.
182      *
183      * @return the type of update that occurred, one of the following values:
184      * <ul>
185      * <li>STRUCTURE_CHANGED - indicates the table's structure
186      * changed.</li>
187      * <li>DELETE - indicates one or more rows were deleted.</li>
188      * <li>INSERT - indicates one or more rows were inserted.</li>
189      * <li>UPDATE - indicates one or more rows were updated.</li>
190      * </ul>
191      */

192     public int getType() {
193         return type;
194     }
195 }
196
Popular Tags