JAL-3141. This adds quite a lot of code to allow an 'Include backup files' checkbox...
[jalview.git] / src / jalview / io / JalviewFileView.java
index 18114f3..857d043 100755 (executable)
  */
 package jalview.io;
 
+import jalview.util.MessageManager;
+
 import java.io.File;
 import java.net.URL;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 import javax.swing.Icon;
@@ -55,7 +58,9 @@ public class JalviewFileView extends FileView
   public String getTypeDescription(File f)
   {
     String extension = getExtension(f);
+    
     String type = getDescriptionForExtension(extension);
+    
     if (extension != null)
     {
       if (extensions.containsKey(extension))
@@ -84,8 +89,27 @@ public class JalviewFileView extends FileView
   {
     String extension = getExtension(f);
     Icon icon = null;
+    String type = getDescriptionForExtension(extension);
+
+    if (type == null)
+    {
+      Iterator<String> it = extensions.keySet().iterator();
+      while (it.hasNext())
+      {
+        String ext = it.next();
+        BackupFilenameParts bfp = BackupFilenameParts
+                .currentBackupFilenameParts(f.getName(), ext, true);
+        if (bfp.isBackupFile())
+        {
+          extension = ext;
+          type = getDescriptionForExtension(extension)
+                  + MessageManager.getString("label.backup");
+          break;
+        }
+      }
+    }
 
-    if (getDescriptionForExtension(extension) != null)
+    if (type != null)
     {
       icon = getImageIcon("/images/file.png");
     }