package com.example.preview;

import com.example.filelist.FileListEntry;

import javax.activation.MimetypesFileTypeMap;
import java.util.List;

import static ch.lambdaj.Lambda.*;
import static java.util.Arrays.asList;

/**
 * @author innokenty
 */
public class FilePreviewFactory {

    private FilePreviewFactory() {
    }

    private static final List<? extends FilePreviewBuilder> BUILDERS = asList(
            new TextFilePreviewBuilder(),
            new ImageFilePreviewBuilder()
    );

    public static FilePreview getPreviewDialogFor(FileListEntry file)
            throws Exception {
        String mimetype = new MimetypesFileTypeMap().getContentType(file.getName());
        FilePreviewBuilder builder = selectFirst(
                BUILDERS,
                having(on(FilePreviewBuilder.class)
                        .supportsMimetype(mimetype))
        );
        return builder != null ? builder.getPreviewFor(file) : null;
    }
}

@@ -590,16 +590,70 @@
 ption %7B%0A
+        String nameLC = file.getName().toLowerCase();%0A
         
@@ -712,30 +712,22 @@
 entType(
-file.getName()
+nameLC
 );%0A     
@@ -770,33 +770,16 @@
 ctFirst(
-%0A                
 BUILDERS
@@ -835,33 +835,8 @@
 ass)
-%0A                        
 .sup
@@ -859,25 +859,16 @@
 metype))
-%0A        
 );%0A     

fix - opening files with upper case extension