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