    001    /* ========================================================================
    002     * JCommon : a free general purpose class library for the Java(tm) platform
    003     * ========================================================================
    004     *
    005     * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
    006     *
    007     * Project Info:  http://www.jfree.org/jcommon/index.html
    008     *
    009     * This library is free software; you can redistribute it and/or modify it
    010     * under the terms of the GNU Lesser General Public License as published by
    011     * the Free Software Foundation; either version 2.1 of the License, or
    012     * (at your option) any later version.
    013     *
    014     * This library is distributed in the hope that it will be useful, but
    015     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    016     * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
    017     * License for more details.
    018     *
    019     * You should have received a copy of the GNU Lesser General Public
    020     * License along with this library; if not, write to the Free Software
    021     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
    022     * USA.
    023     *
    024     * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
    025     * in the United States and other countries.]
    026     *
    027     * ---------------------------
    028     * ContributorsTableModel.java
    029     * ---------------------------
    030     * (C) Copyright 2001-2008, by Object Refinery Limited.
    031     *
    032     * Original Author:  David Gilbert (for Object Refinery Limited);
    033     * Contributor(s):   -;
    034     *
    035     * $Id: ContributorsTableModel.java,v 1.6 2008/12/18 09:57:32 mungady Exp $
    036     *
    037     * Changes
    038     * -------
    039     * 10-Dec-2001 : Version 1 (DG);
    040     * 28-Feb-2002 : Moved into package com.jrefinery.ui.about.  Changed import
    041     *               statements and updated Javadoc comments (DG);
    042     * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
    043     * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by
    044     *               Jess Thrysoee (DG);
    045     *
    046     */
    047
    048    package org.jfree.ui.about;
    049
    050    import java.util.List;
    051    import java.util.ResourceBundle;
    052
    053    import javax.swing.table.AbstractTableModel;
    054
    055    import org.jfree.util.ResourceBundleWrapper;
    056
    057    /**
    058     * A table model containing a list of contributors to a project.
    059     * <P>
    060     * Used in the ContributorsPanel class.
    061     *
    062     * @author David Gilbert
    063     */
    064    public class ContributorsTableModel extends AbstractTableModel {
    065
    066        /** Storage for the contributors. */
    067        private List contributors;
    068
    069        /** Localised version of the name column label. */
    070        private String nameColumnLabel;
    071
    072        /** Localised version of the contact column label. */
    073        private String contactColumnLabel;
    074
    075        /**
    076         * Constructs a ContributorsTableModel.
    077         *
    078         * @param contributors  the contributors.
    079         */
    080        public ContributorsTableModel(final List contributors) {
    081
    082            this.contributors = contributors;
    083
    084            final String baseName = "org.jfree.ui.about.resources.AboutResources";
    085            final ResourceBundle resources = ResourceBundleWrapper.getBundle(
    086                    baseName);
    087            this.nameColumnLabel = resources.getString(
    088                    "contributors-table.column.name");
    089            this.contactColumnLabel = resources.getString(
    090                    "contributors-table.column.contact");
    091
    092        }
    093
    094        /**
    095         * Returns the number of rows in the table model.
    096         *
    097         * @return The number of rows.
    098         */
    099        public int getRowCount() {
    100            return this.contributors.size();
    101        }
    102
    103        /**
    104         * Returns the number of columns in the table model.  In this case, there
    105         * are always two columns (name and e-mail address).
    106         *
    107         * @return The number of columns in the table model.
    108         */
    109        public int getColumnCount() {
    110            return 2;
    111        }
    112
    113        /**
    114         * Returns the name of a column in the table model.
    115         *
    116         * @param column  the column index (zero-based).
    117         *
    118         * @return  the name of the specified column.
    119         */
    120        public String getColumnName(final int column) {
    121
    122            String result = null;
    123
    124            switch (column) {
    125
    126                case 0:  result = this.nameColumnLabel;
    127                         break;
    128
    129                case 1:  result = this.contactColumnLabel;
    130                         break;
    131
    132            }
    133
    134            return result;
    135
    136        }
    137
    138        /**
    139         * Returns the value for a cell in the table model.
    140         *
    141         * @param row  the row index (zero-based).
    142         * @param column  the column index (zero-based).
    143         *
    144         * @return the value.
    145         */
    146        public Object getValueAt(final int row, final int column) {
    147
    148            Object result = null;
    149            final Contributor contributor
    150                    = (Contributor) this.contributors.get(row);
    151
    152            if (column == 0) {
    153                result = contributor.getName();
    154            }
    155            else if (column == 1) {
    156                result = contributor.getEmail();
    157            }
    158            return result;
    159
    160        }
    161
    162    }