package com.example.filelist;

import javax.swing.*;
import java.awt.*;

/**
 * @author innokenty
 */
class FileListEntryRenderer implements ListCellRenderer<FileListEntry> {

    @Override
    public Component getListCellRendererComponent(
            JList<? extends FileListEntry> list,
            FileListEntry value,
            int index,
            boolean isSelected,
            boolean cellHasFocus
    ) {
        JLabel label = new JLabel(value.getName());
        if (isSelected) {
            label.setOpaque(true);
            label.setBackground(list.getSelectionBackground());
            label.setForeground(list.getSelectionForeground());
        }

        return label;
    }
}

@@ -64,16 +64,200 @@
 a.awt.*;
+%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.UUID;%0A%0Aimport static javax.swing.SwingConstants.LEFT;%0Aimport static org.apache.commons.io.FilenameUtils.getExtension;
 %0A%0A/**%0A *
@@ -493,20 +493,19 @@
 stEntry 
-valu
+fil
 e,%0A     
@@ -633,12 +633,11 @@
 bel(
-valu
+fil
 e.ge
@@ -643,16 +643,37 @@
 etName()
+, getIcon(file), LEFT
 );%0A     
@@ -867,16 +867,16 @@
      %7D%0A%0A
-
         
@@ -894,11 +894,685 @@
 l;%0A    %7D
+%0A%0A    private static Icon getIcon(FileListEntry file) %7B%0A        Icon icon;%0A        if (file.isDirectory()) %7B%0A            icon = UIManager.getDefaults().getIcon(%22FileView.directoryIcon%22);%0A        %7D else %7B%0A            try %7B%0A                File tempFile = File.createTempFile(%0A                        UUID.randomUUID().toString(),%0A                        %22.%22 + getExtension(file.getName())%0A                );%0A                tempFile.deleteOnExit();%0A                icon = new JFileChooser().getIcon(tempFile);%0A            %7D catch (IOException e) %7B%0A                icon = UIManager.getDefaults().getIcon(%22FileView.fileIcon%22);%0A            %7D%0A        %7D%0A        return icon;%0A    %7D
 %0A%7D%0A

add - add fancy file icons