Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / javax / swing / AbstractCellEditor.java
blob4ed15809a83336286a20eec3b5cfc5b44228fe12
1 /* AbstractCellEditor.java --
2 Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing;
41 import java.io.Serializable;
42 import java.util.EventObject;
44 import javax.swing.event.CellEditorListener;
45 import javax.swing.event.ChangeEvent;
46 import javax.swing.event.EventListenerList;
48 /**
49 * An abstract superclass for table and tree cell editors. This provides some
50 * common shared functionality.
52 * @author Andrew Selkirk
54 public abstract class AbstractCellEditor
55 implements CellEditor, Serializable
57 private static final long serialVersionUID = -1048006551406220959L;
59 /**
60 * Our Swing event listeners.
62 protected EventListenerList listenerList;
64 /**
65 * The cached ChangeEvent.
67 protected transient ChangeEvent changeEvent;
69 /**
70 * Creates a new instance of AbstractCellEditor.
72 public AbstractCellEditor() {
73 listenerList = new EventListenerList();
74 changeEvent = new ChangeEvent(this);
75 } // AbstractCellEditor()
77 /**
78 * Returns <code>true</code> if the cell is editable using
79 * <code>event</code>, <code>false</code>
80 * if it's not. The default behaviour is to return <code>true</code>.
82 * @param event an event
84 * @return <code>true</code> if the cell is editable using
85 * <code>event</code>, <code>false</code> if it's not
87 public boolean isCellEditable(EventObject event) {
88 return true;
89 } // isCellEditable()
91 /**
92 * Returns <code>true</code> if the editing cell should be selected,
93 * <code>false</code> otherwise. This is usually returning <code>true</code>,
94 * but in some special cases it might be useful not to switch cell selection
95 * when editing one cell.
97 * @param event an event
99 * @return <code>true</code> if the editing cell should be selected,
100 * <code>false</code> otherwise
102 public boolean shouldSelectCell(EventObject event) {
103 return true;
104 } // shouldSelectCell()
107 * Stop editing the cell and accept any partial value that has been entered
108 * into the cell.
110 * @returns <code>true</code> if editing has been stopped successfully,
111 * <code>false</code>otherwise
113 public boolean stopCellEditing() {
114 fireEditingStopped();
115 return true;
116 } // stopCellEditing()
119 * Stop editing the cell and do not accept any partial value that has
120 * been entered into the cell.
122 public void cancelCellEditing() {
123 fireEditingCanceled();
124 } // cancelCellEditing()
127 * Adds a CellEditorListener to the list of CellEditorListeners of this
128 * CellEditor.
130 * @param listener the CellEditorListener to add
132 public void addCellEditorListener (CellEditorListener listener)
134 listenerList.add (CellEditorListener.class, listener);
138 * Removes the specified CellEditorListener from the list of the
139 * CellEditorListeners of this CellEditor.
141 * @param listener the CellEditorListener to remove
143 public void removeCellEditorListener (CellEditorListener listener)
145 listenerList.remove (CellEditorListener.class, listener);
149 * Returns the list of CellEditorListeners that have been registered
150 * in this CellEditor.
152 * @return the list of CellEditorListeners that have been registered
153 * in this CellEditor
155 * @since 1.4
157 public CellEditorListener[] getCellEditorListeners()
159 return (CellEditorListener[]) listenerList.getListeners
160 (CellEditorListener.class);
164 * Notifies all registered listeners that the editing of the cell has has been
165 * stopped.
167 protected void fireEditingStopped()
169 CellEditorListener[] listeners = getCellEditorListeners();
171 for (int index = 0; index < listeners.length; index++)
173 listeners[index].editingStopped(changeEvent);
178 * Notifies all registered listeners that the editing of the cell has
179 * has been canceled.
181 protected void fireEditingCanceled()
183 CellEditorListener[] listeners = getCellEditorListeners();
185 for (int index = 0; index < listeners.length; index++)
187 listeners[index].editingCanceled(changeEvent);