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