Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / swing / treeTable / AbstractCellEditor.java @ 40561

History | View | Annotate | Download (4.42 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.swing.treeTable;
25

    
26
import java.util.EventObject;
27

    
28
import javax.swing.CellEditor;
29
import javax.swing.event.CellEditorListener;
30
import javax.swing.event.ChangeEvent;
31
import javax.swing.event.EventListenerList;
32

    
33

    
34
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
35
 *
36
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
37
 *
38
 * This program is free software; you can redistribute it and/or
39
 * modify it under the terms of the GNU General Public License
40
 * as published by the Free Software Foundation; either version 2
41
 * of the License, or (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
51
 *
52
 * For more information, contact:
53
 *
54
 *  Generalitat Valenciana
55
 *   Conselleria d'Infraestructures i Transport
56
 *   Av. Blasco Ib??ez, 50
57
 *   46010 VALENCIA
58
 *   SPAIN
59
 *
60
 *      +34 963862235
61
 *   gvsig@gva.es
62
 *      www.gvsig.gva.es
63
 *
64
 *    or
65
 *
66
 *   IVER T.I. S.A
67
 *   Salamanca 50
68
 *   46005 Valencia
69
 *   Spain
70
 *
71
 *   +34 963163400
72
 *   dac@iver.es
73
 */
74
/* CVS MESSAGES:
75
 *
76
 * $Id: AbstractCellEditor.java 13136 2007-08-20 08:38:34Z evercher $
77
 * $Log$
78
 * Revision 1.1  2007-08-20 08:34:46  evercher
79
 * He fusionado LibUI con LibUIComponents
80
 *
81
 * Revision 1.1  2006/10/23 08:18:39  jorpiell
82
 * A?adida la clase treetable
83
 *
84
 *
85
 */
86
/**
87
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
88
 */
89
public class AbstractCellEditor implements CellEditor {
90
        
91
        protected EventListenerList listenerList = new EventListenerList();
92
        
93
        public Object getCellEditorValue() { return null; }
94
        public boolean isCellEditable(EventObject e) { return true; }
95
        public boolean shouldSelectCell(EventObject anEvent) { return false; }
96
        public boolean stopCellEditing() { return true; }
97
        public void cancelCellEditing() {}
98
        
99
        public void addCellEditorListener(CellEditorListener l) {
100
                listenerList.add(CellEditorListener.class, l);
101
        }
102
        
103
        public void removeCellEditorListener(CellEditorListener l) {
104
                listenerList.remove(CellEditorListener.class, l);
105
        }
106
        
107
        /**
108
         * Notify all listeners that have registered interest for
109
         * notification on this event type.  
110
         * @see EventListenerList
111
         */
112
        protected void fireEditingStopped() {
113
                // Guaranteed to return a non-null array
114
                Object[] listeners = listenerList.getListenerList();
115
                // Process the listeners last to first, notifying
116
                // those that are interested in this event
117
                for (int i = listeners.length-2; i>=0; i-=2) {
118
                        if (listeners[i]==CellEditorListener.class) {
119
                                ((CellEditorListener)listeners[i+1]).editingStopped(new ChangeEvent(this));
120
                        }               
121
                }
122
        }
123
        
124
        /**
125
         * Notify all listeners that have registered interest for
126
         * notification on this event type.  
127
         * @see EventListenerList
128
         */
129
        protected void fireEditingCanceled() {
130
                // Guaranteed to return a non-null array
131
                Object[] listeners = listenerList.getListenerList();
132
                // Process the listeners last to first, notifying
133
                // those that are interested in this event
134
                for (int i = listeners.length-2; i>=0; i-=2) {
135
                        if (listeners[i]==CellEditorListener.class) {
136
                                ((CellEditorListener)listeners[i+1]).editingCanceled(new ChangeEvent(this));
137
                        }               
138
                }
139
        }
140
}
141