Package clips.doctor.profcheckup.checkup

Source Code of clips.doctor.profcheckup.checkup.TableModelClients

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

import clips.delegate.doctor.profchekup.ProfcheckupItemLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.ErrorValue;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
*
* @author petr
*/
public class TableModelClients extends AbstractTableModel {

    /**Фамилия клиента*/
    public static final int CL_SURNAME = 0;
    /**имя клиента*/
    public static final int CL_NAME = 1;
    /**отчество клиента*/
    public static final int CL_PATHRON = 2;
    /**пакет услуг*/
    public static final int CL_DANGER = 3;
   
    public static final int COLUMN_COUNT = 4;
    private ArrayList<ProfcheckupItemLocal> profcheckupItemList;//кеш профчекап итемов
//    private DirectoryDanger danger;

    public TableModelClients(ArrayList<ProfcheckupItemLocal> profcheckupList) throws ClipsException {
        this.profcheckupItemList = profcheckupList;
//        danger = (DirectoryDanger) DirectoryLocator.getDirectory(DirectoryDanger.class, false);
    }

    @Override
    public String getColumnName(int col) {
        switch (col) {
            case CL_SURNAME:
                return "Фамилия";
            case CL_NAME:
                return "Имя";
            case CL_PATHRON:
                return "Отчество";
            case CL_DANGER:
                return "Вредный фактор";
            default:
                System.err.print("не сработал switch-case: TableModelClients, getColumnName(), column: " + col);
                return "";
        }
    }

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

    @Override
    public int getRowCount() {
        int count = 0;
        if (profcheckupItemList != null) {//не факт что он инициализирован
            count = profcheckupItemList.size();
        }
        return count;
    }

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

    @Override
    public Object getValueAt(int row, int col) {
        try {
            ProfcheckupItemLocal pil = profcheckupItemList.get(row);
            switch (col) {
                case CL_SURNAME:
                    return pil.getPolisData().getClient().getSurname();
                case CL_NAME:
                    return pil.getPolisData().getClient().getName();
                case CL_PATHRON:
                    return pil.getPolisData().getClient().getPathron();
                case CL_DANGER:
                    return pil.getDanger();
                default:
                    System.err.print("не сработал switch-case: TableModelClients, getValueAt(), int row: " + row + " int col: " + col);
                    return "";
            }
        } catch (ClipsException ex) {
            return new ErrorValue(ex);
        }
    }
}
TOP

Related Classes of clips.doctor.profcheckup.checkup.TableModelClients

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.