this.tableModel = tableModel;
this.tableSorter = tableSorter;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row, int column) {
JComponent renderer = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
renderer.setOpaque(true);//!!!!
//We don't want border in the cells
renderer.setBorder(DEFAULT_BORDER);
//Get the selected file
File f = tableModel.getFileAt(tableSorter.modelIndex(row));
//Null file ?? should not happen
assert f != null;
//A selected item
if(isSelected) {
if (table.hasFocus()) {
renderer.setBackground(SELECTED);
// If the current row is the lead selection of the table, add a border
if (table.getSelectedRows().length > 1 &&
row == table.getSelectionModel().getLeadSelectionIndex()) {
renderer.setBorder(LEAD_SEL_BORDER);
}
}
else
renderer.setBackground(SELECTED_NOFOCUS);
}
//A directory
else if( f.isDirectory() ) {
//We have an unselected Directory
//Default color for directories
renderer.setBackground(DIRECTORIES);
renderer.setForeground(Color.BLACK);
}
//A File
else {
if(f instanceof AudioFile) {
//We have an audiofile
Tag tag = ((AudioFile) f).getTag();
if(PreferencesManager.getBoolean("tageditor.table.indexfiles"))
{
if (SqlProvider.FichierExist(f.getAbsolutePath()))
renderer.setForeground(Color.GREEN);
else
renderer.setForeground(Color.RED);
}
if(!tag.isEmpty())
renderer.setBackground(TAGGED);
else
renderer.setBackground(NO_TAG);
} else {
//A File that could not be read
renderer.setBackground(READ_ERROR);
}
}
return renderer;
}