/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.contract.info.packet;
import clips.delegate.contract.ContractLocal;
import clips.delegate.contract.ServisePriceData;
import clips.delegate.directory.filtered.DirectoryServiceItem;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.DefaultColors;
import cli_fmw.utils.SelectorEditable;
import cli_fmw.utils.sorted_table.renderer.LabelRenderer;
import javax.swing.JLabel;
import javax.swing.JTable;
/**
*
* @author vip
*/
public class TableCellRendererPacketService extends LabelRenderer{
private ContractLocal contract;
private SelectorEditable<ServisePriceData> contractServiceList;
public TableCellRendererPacketService(ContractLocal contract) throws ClipsException {
this.contract = contract;
contractServiceList = contract.getContractServiceList();
}
@Override
protected void modifyErrorTableCellRendererComponent(JTable table, Object value, int row, int col) throws ClipsException {
JLabel render = render();
TableModelPacketServices model = (TableModelPacketServices) table.getModel();
DirectoryServiceItem service = (DirectoryServiceItem) model.getValueAt(row, TableModelPacketServices.COL_SERVICE);
boolean founded = false;
for (int i = 0; i < contractServiceList.size(); i++) {
ServisePriceData servisePriceData = contractServiceList.get(i);
if (service == servisePriceData.getService()) {
founded = true;
break;
}
}
if (founded) {
return;
} else {
render.setForeground(DefaultColors.TABLE_RED_FOREGROUND);
}
}
}