01: package com.xoetrope.swing.treetable;
02:
03: import java.util.EventObject;
04: import javax.swing.CellEditor;
05: import javax.swing.event.CellEditorListener;
06: import javax.swing.event.ChangeEvent;
07: import javax.swing.event.EventListenerList;
08:
09: /**
10: * A tree node wrapper for an XModel node
11: *
12: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
13: * the GNU Public License (GPL), please see license.txt for more details. If
14: * you make commercial use of this software you must purchase a commercial
15: * license from Xoetrope.</p>
16: * <p> $Revision: 1.5 $</p>
17: */
18: public class AbstractCellEditor implements CellEditor {
19: protected EventListenerList listenerList = new EventListenerList();
20:
21: public Object getCellEditorValue() {
22: return null;
23: }
24:
25: public boolean isCellEditable(EventObject e) {
26: return true;
27: }
28:
29: public boolean shouldSelectCell(EventObject anEvent) {
30: return false;
31: }
32:
33: public boolean stopCellEditing() {
34: return true;
35: }
36:
37: public void cancelCellEditing() {
38: }
39:
40: public void addCellEditorListener(CellEditorListener l) {
41: listenerList.add(CellEditorListener.class, l);
42: }
43:
44: public void removeCellEditorListener(CellEditorListener l) {
45: listenerList.remove(CellEditorListener.class, l);
46: }
47:
48: /*
49: * Notify all listeners that have registered interest for
50: * notification on this event type.
51: * @see EventListenerList
52: */
53: protected void fireEditingStopped() {
54: // Guaranteed to return a non-null array
55: Object[] listeners = listenerList.getListenerList();
56: // Process the listeners last to first, notifying
57: // those that are interested in this event
58: for (int i = listeners.length - 2; i >= 0; i -= 2) {
59: if (listeners[i] == CellEditorListener.class)
60: ((CellEditorListener) listeners[i + 1])
61: .editingStopped(new ChangeEvent(this ));
62: }
63: }
64:
65: /*
66: * Notify all listeners that have registered interest for
67: * notification on this event type.
68: * @see EventListenerList
69: */
70: protected void fireEditingCanceled() {
71: // Guaranteed to return a non-null array
72: Object[] listeners = listenerList.getListenerList();
73: // Process the listeners last to first, notifying
74: // those that are interested in this event
75: for (int i = listeners.length - 2; i >= 0; i -= 2) {
76: if (listeners[i] == CellEditorListener.class)
77: ((CellEditorListener) listeners[i + 1])
78: .editingCanceled(new ChangeEvent(this));
79: }
80: }
81: }
|