Package clips.job

Source Code of clips.job.TableModelJobList

/*
* TableModelFoundClients.java
*
* Created on 23 Декабрь 2007 г., 17:56
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package clips.job;

import cli_fmw.main.ClipsException;
import clips.delegate.job.JobLocal;
import cli_fmw.utils.ErrorValue;
import clips.delegate.directory.complex.DirectoryEnterpriseItem;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
* Модель таблицы, отображающая список мест работы клиента
* Необходимо передать jobList
* @author ViP
*/
public class TableModelJobList extends AbstractTableModel {

    private List<JobLocal> jobList;
    public static final int COLCOUNT = 4;
    public static final int COL_JOB = 0;
    public static final int COL_PROFESSION = 1;
    public static final int COL_BEGIN = 2;
    public static final int COL_END = 3;

    public TableModelJobList(List<JobLocal> jobList) {
        this.jobList = jobList;
    }

    @Override
    public boolean isCellEditable(int r, int c) {
        return false;
    }

    @Override
    public Object getValueAt(int r, int c) {
        JobLocal jobLocal = jobList.get(r);       
        try {
            switch (c) {
                case COL_JOB: {   //предприятие, на котором работал
                    DirectoryEnterpriseItem enterprise = jobLocal.getEnterprise();
                    return enterprise.getFullTitle(false);
                }
                case COL_PROFESSION: {
                    return jobLocal.getProfession();
                }
                case COL_BEGIN: {
                    return jobLocal.getBegin();
                }
                case COL_END: {
                    return jobLocal.getEnd();
                }
                default: {
                    throw new RuntimeException("Column out of range");
                }
            }
        } catch (ClipsException ex) {
            return new ErrorValue(ex);
        }
    }

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

    @Override
    public int getRowCount() {
        if (jobList != null) {
            return jobList.size();
        } else {
            return 0;
        }
    }

    @Override
    public String getColumnName(int c) {
        switch (c) {
            case COL_JOB:
                return "Место работы";
            case COL_PROFESSION:
                return "Профессия";
            case COL_BEGIN:
                return "Принят";
            case COL_END:
                return "Уволен";
            default:
                throw new RuntimeException("Column out of range");
        }
    }
   
    public JobLocal getJob(int row){
        return jobList.get(row);
    }
   
}

TOP

Related Classes of clips.job.TableModelJobList

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.