Coverage Report - de.glossmaker.gui.bibtex.ImageCellRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
ImageCellRenderer
0%
0/15
0%
0/8
3
 
 1  
 package de.glossmaker.gui.bibtex;
 2  
 
 3  
 import java.awt.Color;
 4  
 import java.awt.Component;
 5  
 
 6  
 import javax.swing.ImageIcon;
 7  
 import javax.swing.JLabel;
 8  
 import javax.swing.JTable;
 9  
 import javax.swing.table.TableCellRenderer;
 10  
 
 11  
 import de.glossmaker.bib.datastructure.ABibItem;
 12  
 import de.glossmaker.gui.bibtex.model.BibTeXItemsTableModel;
 13  
 
 14  
 /**
 15  
  * 
 16  
  * @author Markus Flingelli
 17  
  * 
 18  
  */
 19  
 public class ImageCellRenderer extends JLabel implements TableCellRenderer {
 20  
         private static final long serialVersionUID = -2909775801439133536L;
 21  
         private Color mUnselectedForeground;
 22  
         private Color mUnselectedBackground;
 23  
 
 24  
         public ImageCellRenderer() {
 25  0
                 super();
 26  0
                 setOpaque(true);
 27  0
         }
 28  
 
 29  
         public Component getTableCellRendererComponent(JTable table, Object value,
 30  
                         boolean isSelected, boolean hasFocus, int row, int column) {
 31  0
                 if (isSelected) {
 32  0
                         super.setForeground(table.getSelectionForeground());
 33  0
                         super.setBackground(table.getSelectionBackground());
 34  
                 } else {
 35  0
                         super.setForeground((mUnselectedForeground != null) ? mUnselectedForeground
 36  
                                         : table.getForeground());
 37  0
                         super.setBackground((mUnselectedBackground != null) ? mUnselectedBackground
 38  
                                         : table.getBackground());
 39  
                 }
 40  0
                 super.setText((String) value);
 41  0
                 BibTeXItemsTableModel model = (BibTeXItemsTableModel) table.getModel();
 42  0
                 ABibItem item = (ABibItem) model.getValueAt(row);
 43  0
                 if (item.isItemValid()) {
 44  0
                         super.setIcon(new ImageIcon("resources/icons/valid.png"));
 45  
                 } else {
 46  0
                         super.setIcon(new ImageIcon("resources/icons/invalid.png"));
 47  
                 }
 48  
 
 49  0
                 return this;
 50  
         }
 51  
 }