1 /***
2 * ReportChangeEvent.java
3 *
4 * This file is part of the creme library.
5 * The creme library intends to ease the development effort of large
6 * applications by providing easy to use support classes.
7 *
8 * Copyright (C) 2002 Denis Bregeon
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * contact information: dbregeon@sourceforge.net
25 */
26 package org.jcreme.reporting;
27
28 import java.util.EventObject;
29
30 /***
31 * Instances of this class signal changes in a Report object. They are typically
32 * used to enable a GUI refresh.
33 *
34 * @author $Author: dbregeon $
35 * @version $Revision: 1.1 $
36 */
37 public class ReportChangeEvent extends EventObject {
38 /***
39 * This type signals that new lines have been added.
40 */
41 public static final int INSERT = 0;
42
43 /***
44 * This type signals that some lines have changed.
45 */
46 public static final int UPDATE = 1;
47
48 /***
49 * This type signals that some lines have been removed.
50 */
51 public static final int DELETE = 2;
52
53 /***
54 * This type signals that the column list has changed.
55 */
56 public static final int COLUMN_LIST = 3;
57
58 /***
59 * The first row that changed.
60 */
61 private int firstRow = -1;
62
63 /***
64 * The last row that changed.
65 */
66 private int lastRow = Integer.MAX_VALUE;
67
68 /***
69 * The first column that changed.
70 */
71 private int firstColumn = -1;
72
73 /***
74 * The last column that changed.
75 */
76 private int lastColumn = Integer.MAX_VALUE;
77
78 /***
79 * The type of the change (either INSERT, UPDATE, DELETE or COLUMN_LIST).
80 */
81 private int type = UPDATE;
82
83 /***
84 * Creates new ReportChangeEvent
85 *
86 * @param source
87 * the report that changed.
88 */
89 public ReportChangeEvent(Report source) {
90 super(source);
91 }
92
93 /***
94 * Creates new ReportChangeEvent
95 *
96 * @param source
97 * the report that changed.
98 * @param row
99 * the row that changed in the report.
100 */
101 public ReportChangeEvent(Report source, int row) {
102 this(source);
103 this.firstRow = row;
104 this.lastRow = row;
105 }
106
107 /***
108 * Creates new ReportChangeEvent
109 *
110 * @param source
111 * the report that changed.
112 * @param firstRow
113 * the first row that changed in the report.
114 * @param lastRow
115 * the last row that changed in the report.
116 */
117 public ReportChangeEvent(Report source, int firstRow, int lastRow) {
118 this(source);
119 this.firstRow = firstRow;
120 this.lastRow = lastRow;
121 }
122
123 /***
124 * Creates new ReportChangeEvent
125 *
126 * @param source
127 * the report that changed.
128 * @param firstRow
129 * the first row that changed in the report.
130 * @param lastRow
131 * the last row that changed in the report.
132 * @param column
133 * the column that changed in the lines.
134 */
135 public ReportChangeEvent(Report source, int firstRow, int lastRow,
136 int column) {
137 this(source, firstRow, lastRow);
138 this.firstColumn = column;
139 this.lastColumn = column;
140 }
141
142 /***
143 * Creates new ReportChangeEvent
144 *
145 * @param source
146 * the report that changed.
147 * @param firstRow
148 * the first row that changed in the report.
149 * @param lastRow
150 * the last row that changed in the report.
151 * @param firstColumn
152 * the first column that changed in the lines.
153 * @param lastColumn
154 * the last column that changed in the lines.
155 */
156 public ReportChangeEvent(Report source, int firstRow, int lastRow,
157 int firstColumn, int lastColumn) {
158 this(source, firstRow, lastRow);
159 this.firstColumn = firstColumn;
160 this.lastColumn = lastColumn;
161 }
162
163 /***
164 * Creates new ReportChangeEvent
165 *
166 * @param source
167 * the report that changed.
168 * @param firstRow
169 * the first row that changed in the report.
170 * @param lastRow
171 * the last row that changed in the report.
172 * @param firstColumn
173 * the first column that changed in the lines.
174 * @param lastColumn
175 * the last column that changed in the lines.
176 * @param type
177 * the type of change that occured.
178 */
179 public ReportChangeEvent(Report source, int firstRow, int lastRow,
180 int firstColumn, int lastColumn, int type) {
181 this(source, firstRow, lastRow);
182 this.firstColumn = firstColumn;
183 this.lastColumn = lastColumn;
184 this.type = type;
185 }
186
187 /***
188 * This method gives access to the number of the first line that has
189 * changed.
190 *
191 * @return the number of the first line that changed.
192 */
193 public int getFirstRow() {
194 return this.firstRow;
195 }
196
197 /***
198 * This method gives access to the number of the last line that has changed.
199 *
200 * @return the number of the last line that changed.
201 */
202 public int getLastRow() {
203 return this.lastRow;
204 }
205
206 /***
207 * This method gives access to the number of the first column that has
208 * changed.
209 *
210 * @return the number of the first column that changed.
211 */
212 public int getFirstColumn() {
213 return this.firstColumn;
214 }
215
216 /***
217 * This method gives access to the number of the last column that has
218 * changed.
219 *
220 * @return the number of the last column that changed.
221 */
222 public int getLastColumn() {
223 return this.lastColumn;
224 }
225
226 /***
227 * Gives access to the type of change that occured in the source.
228 *
229 * @return the type of the change (INSERT, UPDATE, DELETE or COLUMN_LIST).
230 */
231 public int getType() {
232 return this.type;
233 }
234 }