001/*
002 * Copyright (c) 2005 Jens Schou, Staffan Gustafsson, Bjorn Lanneskog, 
003 * Einar Pehrson and Sebastian Kekkonen
004 *
005 * This file is part of
006 * CleanSheets Extension for Test Cases
007 *
008 * CleanSheets Extension for Test Cases is free software; you can
009 * redistribute it and/or modify it under the terms of the GNU General Public
010 * License as published by the Free Software Foundation; either version 2 of
011 * the License, or (at your option) any later version.
012 *
013 * CleanSheets Extension for Test Cases is distributed in the hope that
014 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
015 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016 * See the GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with CleanSheets Extension for Test Cases; if not, write to the
020 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
021 * Boston, MA  02111-1307  USA
022 */
023package csheets.ext.test.ui;
024
025import javax.swing.DefaultCellEditor;
026import javax.swing.JTextField;
027import javax.swing.table.TableModel;
028
029import csheets.ext.test.TestCaseParam;
030
031/**
032 * The table used to display and provide editing of test case parameters.
033 * @author Bjorn Lanneskog
034 * @author Einar Pehrson
035 */
036@SuppressWarnings("serial")
037public class TestCaseParamTable extends TestTable {
038
039        /**
040         * Creates a new test case parameter table.
041         * @param tableModel the table model
042         */
043        public TestCaseParamTable(TableModel tableModel) {
044                super(tableModel);
045
046                // Configures test case parameter editor and renderer
047                setDefaultRenderer(TestCaseParam.class, new TestCaseParamRenderer());
048                setDefaultEditor(TestCaseParam.class, new DefaultCellEditor(
049                        new JTextField()));
050        }
051
052        /**
053         * Overridden to disable editing of precedent addresses.
054         * @param row the row whose value is to be queried
055         * @param column the column whose value is to be queried                 
056         * @return true if the cell at the given row and column is editable
057         */
058        public boolean isCellEditable(int row, int column) {
059                return column != 0;
060        }
061
062        /**
063         * Returns the class of the column in the table.
064         * @param column the column whose class is to be queried
065         * @return class the class to be returned
066         */
067        public Class<?> getColumnClass(int column) { 
068                if (column == 0)
069                        return Object.class; // Cell.class
070                else
071                        return TestCaseParam.class;
072        }
073}