ALMA Computing Group

MyCellEditor.java

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * ALMA - Atacama Large Millimeter Array
00003  * Copyright (c) ESO - European Southern Observatory, 2011
00004  * (in the framework of the ALMA collaboration).
00005  * All rights reserved.
00006  * 
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  * 
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020  *******************************************************************************/
00021 package alma.demo.dyncomp;
00022 
00023 import javax.swing.table.TableCellEditor;
00024 import javax.swing.AbstractCellEditor;
00025 import javax.swing.JButton;
00026 import javax.swing.JTable;
00027 import java.awt.Component;
00028 import javax.swing.event.CellEditorListener;
00029 import java.util.EventObject;
00030 
00031 import alma.demo.dyncomp.JDynAct;
00032 
00037 class MyCellEditor extends AbstractCellEditor implements TableCellEditor {
00038 
00039         JDynAct m_dynActDlg;
00040         JButton releaseBtn;
00041 
00042         public MyCellEditor(JDynAct dynActDlg) {
00043                 releaseBtn = new JButton(" ");
00044                 m_dynActDlg=dynActDlg;
00045         }
00046 
00057         public Component getTableCellEditorComponent(
00058                         JTable table, 
00059                         Object value, 
00060                         boolean isSelected, 
00061                         int row, 
00062                         int column) {
00063                 if (table.getValueAt(row,column)!=null) {
00064                         releaseBtn.setText("Release "+(String)table.getValueAt(row,0));
00065                         releaseBtn.addActionListener(m_dynActDlg);
00066                         releaseBtn.setVisible(true);
00067                         return releaseBtn;
00068                 } else return null;
00069         }
00070 
00073         public void stopEditing() {
00074                 releaseBtn.setVisible(false);
00075                 fireEditingStopped();
00076         }
00077 
00082         public Object getCellEditorValue() { return null; }
00083 }
00084 
00085