Package clips.doctor.certificate

Source Code of clips.doctor.certificate.TableModelCertificateList

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package clips.doctor.certificate;

import clips.delegate.doctor.certificate.CertificateLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.ErrorValue;
import java.util.Date;
import javax.swing.table.DefaultTableModel;

/**
*
* @author vip
*/
public class TableModelCertificateList extends DefaultTableModel{
    public static final int COL_DATE = 0;
    public static final int COL_COLLABORATOR = 1;
    public static final int COL_TYPE = 2;
    public static final int COLUMN_COUNT = 3;
   
    private CertificateLocal[] list;

    public TableModelCertificateList(CertificateLocal[] list) {
        this.list = list;
    }

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

    @Override
    public String getColumnName(int col) {
        switch(col) {
            case COL_DATE:
                return "Дата выписки";
            case COL_COLLABORATOR:
                return "Врач";
            case COL_TYPE:
                return "Тип исходящего документа";
        }
        return "";
    }

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

    @Override
    public Object getValueAt(int row, int col) {
        try {
            CertificateLocal certificateLocal = list[row];
            switch (col) {
                case COL_DATE: {
                    return  certificateLocal.getDate();
                }
                case COL_COLLABORATOR: {
                    return certificateLocal.getCollaborator();
                }
                case COL_TYPE: {
                    return certificateLocal.getType().getTitle();
                }
            }
        } 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.certificate.TableModelCertificateList

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.