1 7 8 package org.jdesktop.swing.util; 9 10 import java.util.LinkedList ; 11 import java.util.List ; 12 13 import javax.swing.event.ChangeEvent ; 14 import javax.swing.event.ListSelectionEvent ; 15 import javax.swing.event.TableColumnModelEvent ; 16 import javax.swing.event.TableColumnModelListener ; 17 18 21 public class ColumnModelReport implements TableColumnModelListener { 22 23 26 private List removedEvents = new LinkedList (); 27 private List addedEvents = new LinkedList (); 28 private List movedEvents = new LinkedList (); 29 30 private List selectionEvents = new LinkedList (); 31 private List changeEvents = new LinkedList (); 32 33 public void columnAdded(TableColumnModelEvent e) { 35 addedEvents.add(0, e); 36 37 } 38 public void columnMarginChanged(ChangeEvent e) { 39 changeEvents.add(0, e); 40 41 } 42 public void columnMoved(TableColumnModelEvent e) { 43 movedEvents.add(0, e); 44 45 } 46 public void columnRemoved(TableColumnModelEvent e) { 47 removedEvents.add(0, e); 48 49 } 50 public void columnSelectionChanged(ListSelectionEvent e) { 51 selectionEvents.add(0, e); 52 53 } 54 56 57 public int getEventCount() { 58 return addedEvents.size() + removedEvents.size() + movedEvents.size() + 59 changeEvents.size() + selectionEvents.size(); 60 } 61 62 public boolean hasRemovedEvent() { 63 return !removedEvents.isEmpty(); 64 } 65 66 public TableColumnModelEvent getLastRemoveEvent() { 67 return removedEvents.isEmpty() ? null : (TableColumnModelEvent ) removedEvents.get(0); 68 } 69 70 public boolean hasAddedEvent() { 71 return !addedEvents.isEmpty(); 72 } 73 74 public TableColumnModelEvent getLastAddEvent() { 75 return addedEvents.isEmpty() ? null : (TableColumnModelEvent ) addedEvents.get(0); 76 } 77 78 public boolean hasEvents() { 79 return getEventCount() > 0; 80 } 81 82 83 public void clear() { 84 addedEvents.clear(); 85 removedEvents.clear(); 86 movedEvents.clear(); 87 changeEvents.clear(); 88 selectionEvents.clear(); 89 } 90 } | Popular Tags |