Package clips.doctor.prescription

Source Code of clips.doctor.prescription.TableModelPrescriptionList

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.doctor.prescription;

import clips.delegate.doctor.prescription.PrescriptionLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.ErrorValue;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.table.DefaultTableModel;

/**
* Модель таблицы списка Рецептов
* @author vip
*/
public class TableModelPrescriptionList extends DefaultTableModel {

    public static final int COL_DATE = 0;
    public static final int COL_COLL = 1;
    public static final int COLUMN_COUNT = 2;
    private ArrayList<PrescriptionLocal> ii;

    public TableModelPrescriptionList(ArrayList<PrescriptionLocal> ii) {
        this.ii = ii;
    }

    @Override
    public int getColumnCount() {
        return COLUMN_COUNT;
    }

    @Override
    public String getColumnName(int col) {
        switch (col) {
            case COL_DATE:
                return "Дата";
            case COL_COLL:
                return "Врач";
        }
        return "";
    }

    @Override
    public int getRowCount() {
        if (ii == null) {
            return 0;
        }
        return ii.size();
    }

    @Override
    public Object getValueAt(int row, int col) {
        try {
            PrescriptionLocal prescription = ii.get(row);
            switch (col) {
                case COL_DATE: {
                    return prescription.getDate();
                }
                case COL_COLL: {
                    return prescription.getSerrenLocal().getSerRenDirector();
                }
            }
        } catch (ClipsException ex) {
            return new ErrorValue(ex);
        }
        return null;
    }

    @Override
    public boolean isCellEditable(int row, int col) {
        return false;
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex == COL_DATE){
            return Date.class;
        }else{
            return super.getColumnClass(columnIndex);
        }
    }
}
TOP

Related Classes of clips.doctor.prescription.TableModelPrescriptionList

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.