1 20 package com.puppycrawl.tools.checkstyle.gui; 21 22 import java.util.EventObject ; 23 import javax.swing.CellEditor ; 24 import javax.swing.event.CellEditorListener ; 25 import javax.swing.event.ChangeEvent ; 26 import javax.swing.event.EventListenerList ; 27 28 33 public class AbstractCellEditor implements CellEditor 34 { 35 private final EventListenerList mListenerList = new EventListenerList (); 36 37 38 public Object getCellEditorValue() 39 { 40 return null; 41 } 42 43 44 public boolean isCellEditable(EventObject e) 45 { 46 return true; 47 } 48 49 50 public boolean shouldSelectCell(EventObject anEvent) 51 { 52 return false; 53 } 54 55 56 public boolean stopCellEditing() 57 { 58 return true; 59 } 60 61 62 public void cancelCellEditing() 63 { 64 } 65 66 67 public void addCellEditorListener(CellEditorListener l) 68 { 69 mListenerList.add(CellEditorListener .class, l); 70 } 71 72 73 public void removeCellEditorListener(CellEditorListener l) 74 { 75 mListenerList.remove(CellEditorListener .class, l); 76 } 77 78 83 protected void fireEditingStopped() 84 { 85 final Object [] listeners = mListenerList.getListenerList(); 87 for (int i = listeners.length - 2; i >= 0; i -= 2) { 90 if (listeners[i] == CellEditorListener .class) { 91 ((CellEditorListener ) listeners[i + 1]).editingStopped(new ChangeEvent (this)); 92 } 93 } 94 } 95 96 101 protected void fireEditingCanceled() 102 { 103 final Object [] listeners = mListenerList.getListenerList(); 105 for (int i = listeners.length - 2; i >= 0; i -= 2) { 108 if (listeners[i] == CellEditorListener .class) { 109 ((CellEditorListener ) listeners[i + 1]).editingCanceled(new ChangeEvent (this)); 110 } 111 } 112 } 113 } 114 | Popular Tags |