Package clips.kek.resolution

Source Code of clips.kek.resolution.TableModelComResolutionList

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

package clips.kek.resolution;

import clips.delegate.kek.CommitteeDirectionData;
import clips.delegate.kek.CommitteeLocal;
import clips.delegate.kek.CommitteeResolutionData;
import cli_fmw.utils.ErrorValue;
import cli_fmw.utils.SelectorEditable;
import cli_fmw.main.ClipsException;
import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

/**
*
* @author lacoste
*/
public class TableModelComResolutionList extends DefaultTableModel{
    public static final int COL_RES_ID = 0;
    public static final int COL_TYPE = 1;
    public static final int COL_MKB = 2;
    public static final int COL_DESC = 3;
    public static final int COL_COLLAB = 4;
    public static final int COL_COMDIR_ID = 5;
    public static final int COLUMN_COUNT = 6;
   
    private ArrayList<CommitteeResolutionData> comResList;
    private CommitteeLocal committee;

    public TableModelComResolutionList(ArrayList<CommitteeResolutionData> comResList, CommitteeLocal committee) {
        this.committee = committee;
        this.comResList = comResList;
    }
   
    @Override
    public int getColumnCount() {
        return COLUMN_COUNT;
    }

    @Override
    public String getColumnName(int col) {
        switch(col) {
            case COL_RES_ID: return "№";
            case COL_TYPE: return "Тип решения";           
            case COL_MKB: return "Заболевание";           
            case COL_DESC: return "Примечание";
            case COL_COLLAB: return "Выписал";
            case COL_COMDIR_ID: return "№ направления";
        }
        return "";
    }

    @Override
    public int getRowCount() {       
        if (comResList == null) {
            return 0;
        }
        return comResList.size();
    }
   
    @Override
    public Object getValueAt(int row, int col) {
        try {
            CommitteeResolutionData resData = comResList.get(row);
            switch (col) {
                case COL_RES_ID: {
                    return resData.getId();
                }
                case COL_TYPE: {
                    return resData.getType();
                }
                case COL_MKB: {
                    return resData.getMkb();
                }
                case COL_DESC: {
                    return resData.getDescription();
                }
                case COL_COLLAB: {
                    return resData.getCollaborator() != null ? resData.getCollaborator() : "";
                }
                case COL_COMDIR_ID: {
                    CommitteeDirectionData data = null;
                    SelectorEditable<CommitteeDirectionData> list = committee.getDirectionList();
                    for (int i = 0; i < list.size(); i++) {
                        data = list.get(i);
                        if (committee.getResolutionByDirection(data) != null
                                && data.getId() == resData.getKey()) {
                            break;
                        }
                    }
                    return data != null ? data.getId() : "";
                }
            }
        } catch (ClipsException ex) {
            return new ErrorValue(ex);
        }
        return null;
    }

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

Related Classes of clips.kek.resolution.TableModelComResolutionList

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.