Package clips.analysis.shedule.SheduleEdit

Source Code of clips.analysis.shedule.SheduleEdit.TableModelSheduleEditM1

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

package clips.analysis.shedule.SheduleEdit;

import clips.delegate.doctor.checkup.CheckupLocal;
import clips.delegate.doctor.checkup.shedule.CheckupSheduleLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.ErrorValue;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.SelectorEditable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.AbstractTableModel;

/**
*
* @author vip
*/
public class TableModelSheduleEditM1 extends AbstractTableModel{

    class ExtraCheckup{

        public ExtraCheckup(CheckupLocal checkupLocal, boolean inShedule) {
            this.checkupLocal = checkupLocal;
            this.inShedule = inShedule;
        }
       
        CheckupLocal checkupLocal;
        boolean inShedule;
    }
   
    public static final int COL_COUNT = 5;
    public static final int COL_IN_SEDULE = 0; //в расписании
    public static final int COL_FIO = 1;
    public static final int COL_DATE = 2;               //Дата забора БМ, если был забор
    public static final int COL_PAYED = 3;              //Оплата
    public static final int COL_WORK_LIFE = 4;         //

    private ArrayList<CheckupLocal> checkupList;//Список чекапов
    private ArrayList<CheckupLocal> checkupListDeleted;//Список чекапов
    private Set<CheckupLocal> checkupsInSedule;   
    private CheckupSheduleLocal shedule;
   
    public TableModelSheduleEditM1(ArrayList<CheckupLocal> checkupList, CheckupSheduleLocal shedule) throws ClipsException {
        checkupListDeleted = new ArrayList<CheckupLocal>();
        this.checkupList = checkupList;
        this.shedule = shedule;
        this.checkupsInSedule = shedule.getCheckupSet();
    }
   
    public ArrayList<CheckupLocal> getDeletedCheckup(){
        return checkupListDeleted;
    }

    @Override
    public int getRowCount() {
        return checkupList.size();
    }

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

    @Override
    public Class<?> getColumnClass(int col) {
        if (col == COL_PAYED || col == COL_IN_SEDULE) {
            return Boolean.class;
        } else {
            return super.getColumnClass(col);
        }
    }

    @Override
    public String getColumnName(int col) {
        switch (col) {
            case (COL_IN_SEDULE): return "В расписании";
            case (COL_FIO): return "ФИО";
            case (COL_DATE): return "Взят";
            case (COL_PAYED): return "Оплачен";
            case (COL_WORK_LIFE): return "Годен до";
            default: return "";
        }
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        if (columnIndex == COL_IN_SEDULE){
            return true;
        }
        return false;
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        if (columnIndex == COL_IN_SEDULE){
            try {
                CheckupLocal cl = checkupList.get(rowIndex);
                boolean b = (Boolean) aValue;
                if (b) {
                    checkupsInSedule.add(cl);
                } else {
                    checkupsInSedule.remove(cl);
                }
                shedule.setCheckupList(checkupsInSedule);
            } catch (ClipsException ex) {
                MessageBox.showException(ex);
            }
        }
//        fireTableDataChanged();
    }
   
   
    @Override
    public Object getValueAt(int row, int col) {
        try {
            CheckupLocal checkUpLocal = checkupList.get(row);
            switch (col) {
                case (COL_IN_SEDULE): return checkupsInSedule.contains(checkupList.get(row));
                case (COL_FIO): return checkUpLocal.getSerrenLocal().getPolisData().getClient().getFIO();
                case (COL_DATE): return checkUpLocal.getDate();
                case (COL_PAYED): return checkUpLocal.getSerrenLocal().isSerPayed();
                case (COL_WORK_LIFE): return checkUpLocal.getWorkingLifeDate();
                default: return null;
            }
        } catch (ClipsException ex) {
            return new ErrorValue(ex);
        }
    }

}
TOP

Related Classes of clips.analysis.shedule.SheduleEdit.TableModelSheduleEditM1

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.