Package com.ledruide.druidecave.model

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

/**
* 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.business.lists.ColorProxy;
import com.ledruide.druidecave.business.lists.RegionProxy;
import com.ledruide.druidecave.dao.Bottle;
import com.ledruide.druidecave.helpers.I18nScreens;

import java.util.Vector;

public class TableBouteilles extends ResultatsTableModel {
    private static final String[] LES_TITRES = {I18nScreens.getInstance().get("screen.bottle.search.table.name"),
                                                I18nScreens.getInstance().get("screen.bottle.search.table.region"),
                                                I18nScreens.getInstance().get("screen.bottle.search.table.color"),
                                                I18nScreens.getInstance().get("screen.bottle.search.table.year"),
                                                I18nScreens.getInstance().get("screen.bottle.search.table.quantity")};

    public static final int INDEX_NAME     = 0;
    public static final int INDEX_REGION   = 1;
    public static final int INDEX_COLOR    = 2;
    public static final int INDEX_YEAR     = 3;
    public static final int INDEX_QUANTITY = 4;

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

    public Object getValueAt(int row, int col) {
        Bottle objet = (Bottle)dataVector.get(row);
        if (objet != null) {
            try {
                switch (col) {
                    case INDEX_NAME:
                        return objet.getName();
                    case INDEX_REGION:
                        return RegionProxy.get(objet.getCountry_id(), objet.getRegion_id());
                    case INDEX_COLOR:
                        return ColorProxy.get(objet.getColor_id());
                    case INDEX_YEAR:
                        return objet.getYear();
                    case INDEX_QUANTITY:
                        return objet.getQuantity();
                }
            }
            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.TableBouteilles

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.