00001 /* 00002 * Name: TTreeTableCellEditor.java 00003 * Author: Philip Milne 00004 * Scott Violet 00005 * Maintainer: Rafael Jesus Alcantara Perez 00006 * Summary: Tree-table 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.awt.Component; 00069 import java.awt.event.MouseEvent; 00070 import java.util.EventObject; 00071 import javax.swing.JTable; 00072 import javax.swing.table.TableCellEditor; 00073 import org.mpcl.nui.TTreeTable; 00074 00075 00079 public class TTreeTableCellEditor extends TAbstractCellEditor implements TableCellEditor 00080 { 00081 00083 protected TTreeTable tTreeTable; 00084 00085 00086 // 00087 // C O N S T R U C T O R S 00088 // 00089 00094 public TTreeTableCellEditor (TTreeTable tTREE_TABLE) 00095 { 00096 tTreeTable = tTREE_TABLE; 00097 } 00098 00099 00100 // 00101 // S E L E C T O R S 00102 // 00103 00124 public Component getTableCellEditorComponent ( JTable tTABLE , 00125 Object tVALUE , 00126 boolean gIS_SELECTED , 00127 int iROW , 00128 int iCOLUMN ) 00129 { 00130 return tTreeTable.getTree(); 00131 } 00132 00151 public boolean isCellEditable (EventObject tEVENT_OBJECT) 00152 { 00153 00154 if (tEVENT_OBJECT instanceof MouseEvent) 00155 { 00156 MouseEvent tMouseEvent; 00157 MouseEvent tNewMouseEvent; 00158 TTree tTree = tTreeTable.getTree(); 00159 00160 for (int I = tTreeTable.getColumnCount() - 1; ( I >= 0 ) ;--I) 00161 { 00162 if ( tTreeTable.getColumnClass (I) == ITreeTableModel.class ) 00163 { 00164 tMouseEvent = (MouseEvent) tEVENT_OBJECT; 00165 tNewMouseEvent = 00166 new MouseEvent ( tTree , 00167 tMouseEvent.getID() , 00168 tMouseEvent.getWhen() , 00169 tMouseEvent.getModifiers() , 00170 tMouseEvent.getX() - tTreeTable.getCellRect (0, I, true).x , 00171 tMouseEvent.getY() , 00172 tMouseEvent.getClickCount() , 00173 tMouseEvent.isPopupTrigger() ); 00174 tTree.dispatchEvent (tNewMouseEvent); 00175 break; 00176 } 00177 } 00178 } 00179 return false; 00180 00181 } // isCellEditable() 00182 00183 } // class TTreeTableCellEditor 00184