001: /*
002: * The contents of this file are subject to the Mozilla Public License
003: * Version 1.1 (the "License"); you may not use this file except in
004: * compliance with the License. You may obtain a copy of the License at
005: * http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009: * License for the specific language governing rights and limitations
010: * under the License.
011: *
012: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013: *
014: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016: *
017: * Contributor(s):
018: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019: *
020: * If you didn't download this code from the following link, you should check
021: * if you aren't using an obsolete version: http://www.isqlviewer.com
022: */
023: package org.isqlviewer.swing.outline;
024:
025: import java.util.EventObject;
026:
027: import javax.swing.CellEditor;
028: import javax.swing.event.CellEditorListener;
029: import javax.swing.event.ChangeEvent;
030: import javax.swing.event.EventListenerList;
031:
032: /**
033: * TODO Add AbstractCellEditor Object overview JavaDoc information.
034: * <p>
035: *
036: * @author Mark A. Kobold
037: * @version 1.0
038: */
039: public class AbstractCellEditor implements CellEditor {
040:
041: protected EventListenerList listenerList = new EventListenerList();
042:
043: public Object getCellEditorValue() {
044:
045: return null;
046: }
047:
048: public boolean isCellEditable(EventObject e) {
049:
050: return true;
051: }
052:
053: public boolean shouldSelectCell(EventObject anEvent) {
054:
055: return false;
056: }
057:
058: public boolean stopCellEditing() {
059:
060: return true;
061: }
062:
063: public void cancelCellEditing() {
064:
065: }
066:
067: public void addCellEditorListener(CellEditorListener l) {
068:
069: listenerList.add(CellEditorListener.class, l);
070: }
071:
072: public void removeCellEditorListener(CellEditorListener l) {
073:
074: listenerList.remove(CellEditorListener.class, l);
075: }
076:
077: /*
078: * Notify all listeners that have registered interest for notification on this event type.
079: *
080: * @see EventListenerList
081: */
082: protected void fireEditingStopped() {
083:
084: // Guaranteed to return a non-null array
085: Object[] listeners = listenerList.getListenerList();
086: // Process the listeners last to first, notifying
087: // those that are interested in this event
088: for (int i = listeners.length - 2; i >= 0; i -= 2) {
089: if (listeners[i] == CellEditorListener.class) {
090: ((CellEditorListener) listeners[i + 1])
091: .editingStopped(new ChangeEvent(this ));
092: }
093: }
094: }
095:
096: /*
097: * Notify all listeners that have registered interest for notification on this event type.
098: *
099: * @see EventListenerList
100: */
101: protected void fireEditingCanceled() {
102:
103: // Guaranteed to return a non-null array
104: Object[] listeners = listenerList.getListenerList();
105: // Process the listeners last to first, notifying
106: // those that are interested in this event
107: for (int i = listeners.length - 2; i >= 0; i -= 2) {
108: if (listeners[i] == CellEditorListener.class) {
109: ((CellEditorListener) listeners[i + 1])
110: .editingCanceled(new ChangeEvent(this));
111: }
112: }
113: }
114: }
|