Package com.ledruide.druidecave.model

Source Code of com.ledruide.druidecave.model.TableDegustations

/**
* Copyright (C) 2007 Julien Revault d'Allonnes
*
* This file is part of DruideDB.
*
* DruideDB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DruideDB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DruideDB; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
package com.ledruide.druidecave.model;

import com.ledruide.druidecave.dao.Tasting;
import com.ledruide.druidecave.helpers.I18nScreens;

import java.util.Vector;

public class TableDegustations extends ResultatsTableModel {
    private static final String[] LES_TITRES = {I18nScreens.getInstance().get("screen.bottle.tasting.list.table.date"),
                                                I18nScreens.getInstance().get("screen.bottle.tasting.list.table.note"),
                                                I18nScreens.getInstance().get("screen.bottle.tasting.list.table.type"),
                                                I18nScreens.getInstance().get("screen.bottle.tasting.list.table.comment")};

    public static final int INDEX_DATE  = 0;
    public static final int INDEX_NOTE  = 1;
    public static final int INDEX_TYPE  = 2;
    public static final int INDEX_DEBUT = 3;

    public TableDegustations() {
        columnNames = TableDegustations.LES_TITRES;
        dataVector = new Vector();
    }

    public Object getValueAt(int row, int col) {
        Tasting objet = (Tasting) dataVector.get(row);
        if (objet != null) {
            try {
                switch (col) {
                    case TableDegustations.INDEX_DATE:
                        return objet.getDate();
                    case TableDegustations.INDEX_NOTE:
                        return objet.getNote();
                    case TableDegustations.INDEX_TYPE:
                        if (objet.getType() != null) {
                            return objet.getType();
                        }
                        return "";
                    case TableDegustations.INDEX_DEBUT:
                        return objet.getComment().substring(0, 20);
                }
            }
            catch (Exception e) {
                System.out.println("Une erreur est survenue durant l'affichage : " + e.getMessage());
            }
        }
        return new Object();
    }

}
TOP

Related Classes of com.ledruide.druidecave.model.TableDegustations

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.