From 75a43bd6a9f7a85dfbc04246540f27505622ca97 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sun, 9 Sep 2018 14:04:28 +0100 Subject: [PATCH] JAL-3106 normalise extension before checking if it is '.jar' when constructing fileformat/extension name index --- src/jalview/io/JalviewFileChooser.java | 10 +++++----- src/jalview/io/JalviewFileView.java | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 1294e89..7a21c16 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -68,8 +68,8 @@ public class JalviewFileChooser extends JFileChooser public static JalviewFileChooser forRead(String directory, String selected) { - List extensions = new ArrayList(); - List descs = new ArrayList(); + List extensions = new ArrayList<>(); + List descs = new ArrayList<>(); for (FileFormatI format : FileFormats.getInstance().getFormats()) { if (format.isReadable()) @@ -96,8 +96,8 @@ public class JalviewFileChooser extends JFileChooser { // TODO in Java 8, forRead and forWrite can be a single method // with a lambda expression parameter for isReadable/isWritable - List extensions = new ArrayList(); - List descs = new ArrayList(); + List extensions = new ArrayList<>(); + List descs = new ArrayList<>(); for (FileFormatI format : FileFormats.getInstance().getFormats()) { if (format.isWritable()) @@ -142,7 +142,7 @@ public class JalviewFileChooser extends JFileChooser super(safePath(dir)); if (extensions.length == descs.length) { - List formats = new ArrayList(); + List formats = new ArrayList<>(); for (int i = 0; i < extensions.length; i++) { formats.add(new String[] { extensions[i], descs[i] }); diff --git a/src/jalview/io/JalviewFileView.java b/src/jalview/io/JalviewFileView.java index b2fe587..18114f3 100755 --- a/src/jalview/io/JalviewFileView.java +++ b/src/jalview/io/JalviewFileView.java @@ -37,14 +37,15 @@ public class JalviewFileView extends FileView private void loadExtensions() { - extensions = new HashMap(); + extensions = new HashMap<>(); for (FileFormatI ff : FileFormats.getInstance().getFormats()) { String desc = ff.getName() + " file"; String exts = ff.getExtensions(); for (String ext : exts.split(",")) { - extensions.put(ext.trim().toLowerCase(), + ext = ext.trim().toLowerCase(); + extensions.put(ext, desc + ("jar".equals(ext) ? " (old)" : "")); } } @@ -124,7 +125,7 @@ public class JalviewFileView extends FileView { if (icons == null) { - icons = new HashMap(); + icons = new HashMap<>(); } if (!icons.containsKey(filePath)) { -- 1.7.10.2