01: package gruntspud.ui.treetable;
02:
03: import java.awt.Component;
04: import java.awt.event.*;
05: import java.awt.AWTEvent;
06: import javax.swing.*;
07: import javax.swing.event.*;
08: import java.util.EventObject;
09: import java.io.Serializable;
10:
11: public class AbstractCellEditor implements CellEditor {
12:
13: protected EventListenerList listenerList = new EventListenerList();
14:
15: public Object getCellEditorValue() {
16: return null;
17: }
18:
19: public boolean isCellEditable(EventObject e) {
20: return true;
21: }
22:
23: public boolean shouldSelectCell(EventObject anEvent) {
24: return false;
25: }
26:
27: public boolean stopCellEditing() {
28: return true;
29: }
30:
31: public void cancelCellEditing() {
32: }
33:
34: public void addCellEditorListener(CellEditorListener l) {
35: listenerList.add(CellEditorListener.class, l);
36: }
37:
38: public void removeCellEditorListener(CellEditorListener l) {
39: listenerList.remove(CellEditorListener.class, l);
40: }
41:
42: /*
43: * Notify all listeners that have registered interest for
44: * notification on this event type.
45: * @see EventListenerList
46: */
47: protected void fireEditingStopped() {
48: // Guaranteed to return a non-null array
49: Object[] listeners = listenerList.getListenerList();
50: // Process the listeners last to first, notifying
51: // those that are interested in this event
52: for (int i = listeners.length - 2; i >= 0; i -= 2) {
53: if (listeners[i] == CellEditorListener.class) {
54: ((CellEditorListener) listeners[i + 1])
55: .editingStopped(new ChangeEvent(this ));
56: }
57: }
58: }
59:
60: /*
61: * Notify all listeners that have registered interest for
62: * notification on this event type.
63: * @see EventListenerList
64: */
65: protected void fireEditingCanceled() {
66: // Guaranteed to return a non-null array
67: Object[] listeners = listenerList.getListenerList();
68: // Process the listeners last to first, notifying
69: // those that are interested in this event
70: for (int i = listeners.length - 2; i >= 0; i -= 2) {
71: if (listeners[i] == CellEditorListener.class) {
72: ((CellEditorListener) listeners[i + 1])
73: .editingCanceled(new ChangeEvent(this));
74: }
75: }
76: }
77: }
|