public Icon getIcon(File obj) { String extension = FilenameUtils.getExtension(obj.getName()); if (extension != null) { return IconManager.instance().getIconForExtension(extension); } return null; }
@Override public Component getListCellRendererComponent( JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); String extension = FilenameUtils.getExtension(value.toString()); if (extension != null) { setIcon(IconManager.instance().getIconForExtension(extension)); } return this; }
/** Returns the icon. */ Icon getIcon() { // gubs: seems like this didn't fly // maybe the icon isn't refreshed. // see MetadataModel.addProperties() if (isDownloading()) { return GUIMediator.getThemeImage("downloading"); } String ext = getExtension(); // let's try to extract the extension from inside the torrent name if (ext.equals("torrent")) { String filename = getFilename().replace(".torrent", ""); Matcher fileExtensionMatcher = Pattern.compile(".*\\.(\\S*)$").matcher(filename); if (fileExtensionMatcher.matches()) { ext = fileExtensionMatcher.group(1); } } return IconManager.instance().getIconForExtension(ext); }