Package clips.service

Source Code of clips.service.TableCellRendererSerRenList

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

import beans.contract.entity.Contract;
import clips.delegate.contract.ServisePriceData;
import clips.delegate.doctor.DiseaseLocal;
import cli_fmw.main.ClipsException;
import clips.delegate.service.SerRenLocal;
import cli_fmw.utils.sorted_table.renderer.LabelRenderer;
import java.awt.Color;
import java.awt.Font;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.SwingConstants;

/**
* Отрисовщик таблицы списка услуг
* @author vip
*/
public class TableCellRendererSerRenList extends LabelRenderer {

    private static Font commonFont = new Font(null);
    private static Font boldFont = commonFont.deriveFont(Font.BOLD);
    private List<SerRenLocal> serRenIterator;
    private static ImageIcon ICON_PACKET = new ImageIcon(TableCellRendererSerRenList.class.getResource("/resources/icons/pac.gif"));
    private static ImageIcon STT_ICON = new ImageIcon(TableCellRendererSerRenList.class.getResource("/resources/icons/disease.gif"));
    private static ImageIcon PROFCHECKUP_ICON = new ImageIcon(TableCellRendererSerRenList.class.getResource("/resources/icons/Profcheckup.gif"));

    public TableCellRendererSerRenList(List<SerRenLocal> serRenIterator) {
        this.serRenIterator = serRenIterator;
    }

    @Override
    public void modifyErrorTableCellRendererComponent(JTable table, Object value, int row, int col) throws ClipsException {

        Font font = commonFont;
        render().setVerticalAlignment(SwingConstants.CENTER);
        render().setOpaque(true);

        SerRenLocal serRen = null;
        serRen = serRenIterator.get(row);
        try {
            //Цвет шрифта (может быть запрещена для редактирования)
            if (!serRen.isRendered()) {
                font = boldFont;
            }
        } catch (ClipsException ex) {
            ex.printStackTrace();
        }
        render().setFont(font);
        render().setIcon(null);
        if (col == TableModelSerRenList.COL_PACKET) {
            if ((Integer) value != 0) {
                render().setIcon(ICON_PACKET);
            }
            render().setText("");
            return;
        } else if (col >= TableModelSerRenList.COL_SERVICE && col <=
                TableModelSerRenList.COL_MONEY) {
            return;
        } else if (col == TableModelSerRenList.COL_PAY) {
            ServisePriceData price = serRen.getContractService();
            if (price == null && !serRen.hasReferencedSerRen()
                    && serRen.getPolisData().getContract().getType() != Contract.TYPE_OMI) {
                render().setBackground(Color.RED);
            } else {
                if (!serRen.isSerPayed()) {
                    render().setBackground(Color.RED);
                }
            }
        } else if (col == TableModelSerRenList.COL_DISCOUNT) {
            return;
        } else if (col == TableModelSerRenList.COL_REST) {
            return;
        } else if (col == TableModelSerRenList.COL_STT) {
            DiseaseLocal stt = serRen.getDiseaseLocal();
            render().setText("");
            if (stt != null) {
                if (stt.isProfcheckup()) {
                    render().setIcon(PROFCHECKUP_ICON);
                } else {
                    render().setIcon(stt.getIcon());
                }
            }
            return;
        } else {
            return;
        }
    }
}
TOP

Related Classes of clips.service.TableCellRendererSerRenList

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.