001/* 002 The Broad Institute 003 SOFTWARE COPYRIGHT NOTICE AGREEMENT 004 This software and its documentation are copyright (2003-2008) by the 005 Broad Institute/Massachusetts Institute of Technology. All rights are 006 reserved. 007 008 This software is supplied without any warranty or guaranteed support 009 whatsoever. Neither the Broad Institute nor MIT can be responsible for its 010 use, misuse, or functionality. 011*/ 012 013 014package ca.bc.webarts.widgets.treetable; 015//package org.genomespace.gsui.ui.treetable; 016 017import java.awt.AWTEvent; 018import java.awt.Component; 019import java.awt.event.*; 020import java.io.Serializable; 021import java.util.EventObject; 022import javax.swing.*; 023import javax.swing.event.*; 024 025/** 026 * Description of the Class 027 * 028 * @author Joshua Gould 029 */ 030public class AbstractCellEditor implements CellEditor { 031 032 protected EventListenerList listenerList = new EventListenerList(); 033 034 035 public boolean shouldSelectCell(EventObject anEvent) { 036 return false; 037 } 038 039 040 public boolean stopCellEditing() { 041 return true; 042 } 043 044 045 public void cancelCellEditing() { } 046 047 048 public void addCellEditorListener(CellEditorListener l) { 049 listenerList.add(CellEditorListener.class, l); 050 } 051 052 053 public void removeCellEditorListener(CellEditorListener l) { 054 listenerList.remove(CellEditorListener.class, l); 055 } 056 057 058 /* 059 Notify all listeners that have registered interest for 060 notification on this event type. 061 @see EventListenerList 062 */ 063 protected void fireEditingStopped() { 064 // Guaranteed to return a non-null array 065 Object[] listeners = listenerList.getListenerList(); 066 // Process the listeners last to first, notifying 067 // those that are interested in this event 068 for(int i = listeners.length - 2; i >= 0; i -= 2) { 069 if(listeners[i] == CellEditorListener.class) { 070 ((CellEditorListener) listeners[i + 1]).editingStopped(new ChangeEvent(this)); 071 } 072 } 073 } 074 075 076 /* 077 Notify all listeners that have registered interest for 078 notification on this event type. 079 @see EventListenerList 080 */ 081 protected void fireEditingCanceled() { 082 // Guaranteed to return a non-null array 083 Object[] listeners = listenerList.getListenerList(); 084 // Process the listeners last to first, notifying 085 // those that are interested in this event 086 for(int i = listeners.length - 2; i >= 0; i -= 2) { 087 if(listeners[i] == CellEditorListener.class) { 088 ((CellEditorListener) listeners[i + 1]).editingCanceled(new ChangeEvent(this)); 089 } 090 } 091 } 092 093 094 public Object getCellEditorValue() { 095 return null; 096 } 097 098 099 public boolean isCellEditable(EventObject e) { 100 return true; 101 } 102} 103