KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > util > DataEventReport


1 /*
2  * $Id: DataEventReport.java,v 1.1 2005/02/24 16:09:20 kleopatra Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.util;
9
10 import java.util.*;
11
12 import org.jdesktop.dataset.event.DataTableListener;
13 import org.jdesktop.dataset.event.RowChangeEvent;
14 import org.jdesktop.dataset.event.TableChangeEvent;
15 import org.jdesktop.swing.data.ValueChangeEvent;
16 import org.jdesktop.swing.data.ValueChangeListener;
17
18 /**
19  * A DataTableListener that stores the received events .
20  */

21 public class DataEventReport implements DataTableListener {
22
23     /**
24      * Holds a list of all received ValueChangeEvents.
25      */

26     private List events = new LinkedList();
27     private List rowEvents = new LinkedList();
28     private List tableEvents = new LinkedList();
29     
30     public void rowChanged(RowChangeEvent evt) {
31         events.add(0, evt);
32         rowEvents.add(0, evt);
33
34     }
35     public void tableChanged(TableChangeEvent evt) {
36         events.add(0, evt);
37         tableEvents.add(0, evt);
38
39     }
40
41     public int getEventCount() {
42         return events.size();
43     }
44     
45     public boolean hasEvents() {
46         return !events.isEmpty();
47     }
48
49     public EventObject getLastEvent() {
50         return events.isEmpty() ? null : (EventObject) events.get(0);
51     }
52
53     public int getRowEventCount() {
54         return rowEvents.size();
55     }
56     
57     public boolean hasRowEvents() {
58         return !rowEvents.isEmpty();
59     }
60     
61     public RowChangeEvent getLastRowEvent() {
62         return rowEvents.isEmpty() ? null : (RowChangeEvent) rowEvents.get(0);
63     }
64
65     public int getTableEventCount() {
66         return tableEvents.size();
67     }
68     
69     public boolean hasTableEvents() {
70         return !tableEvents.isEmpty();
71     }
72     
73     public TableChangeEvent getLastTableEvent() {
74         return tableEvents.isEmpty() ? null : (TableChangeEvent) tableEvents.get(0);
75     }
76     
77     public void clear() {
78         events.clear();
79         rowEvents.clear();
80         tableEvents.clear();
81     }
82 }
Popular Tags