1 7 8 package org.jdesktop.swing.util; 9 10 import java.util.*; 11 12 import org.jdesktop.swing.data.TabularValueChangeEvent; 13 import org.jdesktop.swing.data.TabularValueChangeListener; 14 import org.jdesktop.swing.data.ValueChangeEvent; 15 import org.jdesktop.swing.data.ValueChangeListener; 16 17 20 public class TabularValueChangeReport implements TabularValueChangeListener { 21 22 25 private List events = new LinkedList(); 26 27 29 public void tabularValueChanged(TabularValueChangeEvent e) { 30 events.add(0, e); 31 32 } 33 34 public int getEventCount() { 35 return events.size(); 36 } 37 38 public boolean hasEvents() { 39 return !events.isEmpty(); 40 } 41 42 public TabularValueChangeEvent getLastEvent() { 43 return events.isEmpty() ? null : (TabularValueChangeEvent) events.get(0); 44 } 45 46 public String getLastFieldName() { 47 return getLastEvent().getFieldName(); 48 } 49 50 public boolean gotEvent(Object fieldName) { 51 for (Iterator iter = events.iterator(); iter.hasNext();) { 52 TabularValueChangeEvent event = (TabularValueChangeEvent) iter.next(); 53 if (fieldName.equals(event.getFieldName())) 54 return true; 55 } 56 return false; 57 } 58 59 public void clear() { 60 events.clear(); 61 } 62 63 } | Popular Tags |