1 package net.logAnalyzer.utils.gui.treetable;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 import java.awt.Component;
43 import java.awt.event.*;
44 import java.awt.AWTEvent;
45 import javax.swing.*;
46 import javax.swing.event.*;
47 import java.util.EventObject;
48 import java.io.Serializable;
49
50 /***
51 * @version %I% %G%
52 *
53 * A base class for CellEditors, providing default implementations for all
54 * methods in the CellEditor interface and support for managing a series
55 * of listeners.
56 *
57 * @author Philip Milne
58 */
59
60 public class AbstractCellEditor implements CellEditor {
61
62 protected EventListenerList listenerList = new EventListenerList();
63
64 public Object getCellEditorValue() { return null; }
65 public boolean isCellEditable(EventObject e) { return true; }
66 public boolean shouldSelectCell(EventObject anEvent) { return false; }
67 public boolean stopCellEditing() { return true; }
68 public void cancelCellEditing() {}
69
70 public void addCellEditorListener(CellEditorListener l) {
71 listenerList.add(CellEditorListener.class, l);
72 }
73
74 public void removeCellEditorListener(CellEditorListener l) {
75 listenerList.remove(CellEditorListener.class, l);
76 }
77
78 /***
79 * Notify all listeners that have registered interest for
80 * notification on this event type.
81 * @see EventListenerList
82 */
83 protected void fireEditingStopped() {
84
85 Object[] listeners = listenerList.getListenerList();
86
87
88 for (int i = listeners.length-2; i>=0; i-=2) {
89 if (listeners[i]==CellEditorListener.class) {
90 ((CellEditorListener)listeners[i+1]).editingStopped(new ChangeEvent(this));
91 }
92 }
93 }
94
95 /***
96 * Notify all listeners that have registered interest for
97 * notification on this event type.
98 * @see EventListenerList
99 */
100 protected void fireEditingCanceled() {
101
102 Object[] listeners = listenerList.getListenerList();
103
104
105 for (int i = listeners.length-2; i>=0; i-=2) {
106 if (listeners[i]==CellEditorListener.class) {
107 ((CellEditorListener)listeners[i+1]).editingCanceled(new ChangeEvent(this));
108 }
109 }
110 }
111 }
112