Package clips.accountant

Source Code of clips.accountant.TableModelFunctions

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

package clips.accountant;

import cli_fmw.main.ClipsException;
import cli_fmw.utils.ErrorValue;
import cli_fmw.utils.SelectorEditable;
import clips.delegate.client.CollaboratorFunctionsChunk;
import clips.delegate.directory.complex.DirectoryCollaboratorFunctionsItem;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

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

    public static final int CL_RECEPTIONTYPE = 0;
    public static final int CL_DVR = 1;
    public static final int CL_FMA = 2;
    public static final int CL_SPECIALITY = 3;
    public static final int CL_COUNT = 4;

    private List<CollaboratorFunctionsChunk> chunks;
    private ArrayList<DirectoryCollaboratorFunctionsItem> directoryItems;

    public TableModelFunctions(SelectorEditable<CollaboratorFunctionsChunk> functions) {
        chunks = new ArrayList<CollaboratorFunctionsChunk>();
        for(int i = 0; i<functions.size(); i++){
            chunks.add(functions.get(i));
        }
    }

    public TableModelFunctions(ArrayList<DirectoryCollaboratorFunctionsItem> list) {
        directoryItems = list;
    }


    public TableModelFunctions() {
        chunks = new ArrayList<CollaboratorFunctionsChunk>();
    }
   
    @Override
    public int getRowCount() {
        return chunks != null ? chunks.size() : directoryItems.size();
    }

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

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        try {
            if (chunks != null) {
                CollaboratorFunctionsChunk chunk = chunks.get(rowIndex);
                switch (columnIndex) {
                    case CL_RECEPTIONTYPE:
                        return chunk.getReceptionType();
                    case CL_DVR:
                        return chunk.getDvr();
                    case CL_FMA:
                        return chunk.getFirstMedicalAid();
                    case CL_SPECIALITY:
                        return chunk.getSpeciality();
                }
            } else {
                DirectoryCollaboratorFunctionsItem item = directoryItems.get(rowIndex);
                switch (columnIndex) {
                    case CL_RECEPTIONTYPE:
                        return item.getReceptionType();
                    case CL_DVR:
                        return item.getDvr();
                    case CL_FMA:
                        return item.getFirstMedicalAid();
                    case CL_SPECIALITY:
                        return item.getSpeciality();
                }
            }
        } catch (ClipsException ex) {
            return new ErrorValue(ex);
        }
        return null;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case CL_RECEPTIONTYPE:
                return "Тип приема";
            case CL_DVR:
                return "Должность";
            case CL_FMA:
                return "Тип первичной мед. помощи";
            case CL_SPECIALITY:
                return "Специальность";

            default: return "Неизвестная колонка";
        }
    }

}
TOP

Related Classes of clips.accountant.TableModelFunctions

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.