package com.intellij.openapi.fileTypes.impl;

import com.intellij.ide.FileIconProvider;
import com.intellij.openapi.fileTypes.NativeFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.DeferredIconImpl;
import com.intellij.util.Function;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @author yole
 */
public class NativeFileIconProvider implements FileIconProvider {
  private FileSystemView myFileSystemView = FileSystemView.getFileSystemView();
  private final Map<String, Icon> myIconCache = new HashMap<String, Icon>();

  public Icon getIcon(VirtualFile file, int flags, @Nullable Project project) {
    if (!(file.getFileType() instanceof NativeFileType)) {
      return null;
    }
    final String ext = file.getExtension();
    Icon icon;
    synchronized (myIconCache) {
      icon = ext != null ? myIconCache.get(ext) : null;
    }
    if (icon != null) {
      return icon;
    }
    return new DeferredIconImpl<VirtualFile>(file.getFileType().getIcon(), file, false, new Function<VirtualFile, Icon>() {
      public Icon fun(VirtualFile virtualFile) {
        Icon icon = myFileSystemView.getSystemIcon(new File(virtualFile.getPath()));
        if (ext != null) {
          synchronized (myIconCache) {
            myIconCache.put(ext, icon);
          }
        }
        return icon;
      }
    });
  }
}

@@ -371,55 +371,8 @@
 .*;%0A
-import javax.swing.filechooser.FileSystemView;%0A
 impo
@@ -541,74 +541,53 @@
 ate 
+J
 File
-SystemView myFileSystemView = FileSystemView.getFileSystemView
+Chooser myFileChooser = new JFileChooser
 ();%0A
@@ -1234,28 +1234,19 @@
 File
-SystemView.getSystem
+Chooser.get
 Icon

use JFileChooser.getIcon() instead of FileSystemView.getIcon()