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