Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

TAbstractCellEditor.java

00001 /*
00002 *  Name:        TAbstractCellEditor.java
00003 *  Author:      Philip Milne
00004 *               Scott Violet
00005 *  Maintainer:  Rafael Jesus Alcantara Perez
00006 *  Summary:     Abstract cell editor.
00007 *  Date:        $Date: 2003/09/28 23:22:05 $
00008 *  Revision:    $Revision: 1.2 $
00009 *
00010 *  Copyright (C) 2003  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00011 *
00012 *  This program is free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  This program is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  You should have received a copy of the GNU General Public License
00023 *  along with this program; if not, write to the Free Software
00024 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00025 *  MA 02111-1307, USA.
00026 *
00027 *
00028 *  Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
00029 *
00030 *  Redistribution and use in source and binary forms, with or
00031 *  without modification, are permitted provided that the following
00032 *  conditions are met:
00033 *
00034 *  - Redistributions of source code must retain the above copyright
00035 *    notice, this list of conditions and the following disclaimer.
00036 *
00037 *  - Redistribution in binary form must reproduce the above
00038 *    copyright notice, this list of conditions and the following
00039 *    disclaimer in the documentation and/or other materials
00040 *    provided with the distribution.
00041 *
00042 *  Neither the name of Sun Microsystems, Inc. or the names of
00043 *  contributors may be used to endorse or promote products derived
00044 *  from this software without specific prior written permission.
00045 *
00046 *  This software is provided "AS IS," without a warranty of any
00047 *  kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
00048 *  WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
00049 *  FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
00050 *  EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
00051 *  DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
00052 *  RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
00053 *  ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
00054 *  FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
00055 *  SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
00056 *  CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
00057 *  THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
00058 *  BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00059 *
00060 *  You acknowledge that this software is not designed, licensed or
00061 *  intended for use in the design, construction, operation or
00062 *  maintenance of any nuclear facility.
00063 */
00064 
00066 package org.mpcl.nui.treetable;
00067 
00068 import java.util.EventObject;
00069 import javax.swing.CellEditor;
00070 import javax.swing.event.CellEditorListener;
00071 import javax.swing.event.ChangeEvent;
00072 import javax.swing.event.EventListenerList;
00073 
00074 
00076 public class TAbstractCellEditor implements CellEditor
00077 {
00078 
00080   protected EventListenerList   tEventListenerList = new EventListenerList();
00081 
00082 
00083   //
00084   //  C O N S T R U C T O R S
00085   //
00086 
00087   public void addCellEditorListener (CellEditorListener tCELL_EDITOR_LISTENER)
00088   {
00089     tEventListenerList.add (CellEditorListener.class, tCELL_EDITOR_LISTENER);
00090   }
00091 
00092   public void cancelCellEditing() {}
00093 
00094   public void removeCellEditorListener (CellEditorListener tCELL_EDITOR_LISTENER)
00095   {
00096     tEventListenerList.remove (CellEditorListener.class, tCELL_EDITOR_LISTENER);
00097   }
00098 
00099 
00100   //
00101   //  S E L E C T O R S
00102   //
00103 
00109   protected void fireEditingStopped()
00110   {
00111 
00112     Object[]      aListenerTypeListenerPair;
00113     ChangeEvent   tChangeEvent = null;
00114 
00115     //
00116     //  The getListenerList()  method is guaranteed to return a non-null array.
00117     //  Processes  the  listeners  last  to first,  notifying  those  that  are
00118     //  interested in this event.  The \a ChangeEvent object is created lazily.
00119     //
00120     aListenerTypeListenerPair = tEventListenerList.getListenerList();
00121     for (int I = aListenerTypeListenerPair.length-2; ( I >= 0 ) ;I-=2)
00122     {
00123       if ( aListenerTypeListenerPair [I] == CellEditorListener.class )
00124       {
00125         if ( tChangeEvent == null )
00126         {
00127           tChangeEvent = new ChangeEvent (this);
00128         }
00129         ((CellEditorListener) aListenerTypeListenerPair [I + 1]).editingStopped (tChangeEvent);
00130       }
00131     }
00132 
00133   }  // fireEditingStopped()
00134 
00140   protected void fireEditingCanceled()
00141   {
00142 
00143     Object[]      aListenerTypeListenerPair;
00144     ChangeEvent   tChangeEvent = null;
00145 
00146     //
00147     //  The getListenerList()  method is guaranteed to return a non-null array.
00148     //  Processes  the  listeners  last  to first,  notifying  those  that  are
00149     //  interested in this event.  The \a ChangeEvent object is created lazily.
00150     //
00151     aListenerTypeListenerPair = tEventListenerList.getListenerList();
00152     for (int I = aListenerTypeListenerPair.length-2; ( I >= 0 ) ;I-=2)
00153     {
00154       if ( aListenerTypeListenerPair [I] == CellEditorListener.class )
00155       {
00156         if ( tChangeEvent == null )
00157         {
00158           tChangeEvent = new ChangeEvent (this);
00159         }
00160         ((CellEditorListener) aListenerTypeListenerPair [I + 1]).editingCanceled (tChangeEvent);
00161       }        
00162     }
00163 
00164   }  // fireEditingCanceled()
00165 
00166 
00167   //
00168   //  S E L E C T O R S
00169   //
00170 
00171   public Object getCellEditorValue()
00172   {
00173     return null;
00174   }
00175 
00176   public boolean isCellEditable (EventObject tEVENT_OBJECT)
00177   {
00178     return true;
00179   }
00180 
00181   public boolean shouldSelectCell (EventObject tEVENT_OBJECT)
00182   {
00183     return false;
00184   }
00185 
00186   public boolean stopCellEditing()
00187   {
00188     return true;
00189   }
00190 
00191 }  // class TAbstractCellEditor

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18