JAL-3241 simplified enum constructors for classloadability in Java 11
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 30 Apr 2019 10:57:49 +0000 (11:57 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 30 Apr 2019 10:57:49 +0000 (11:57 +0100)
src/jalview/util/ImageMaker.java

index 7840261..7232042 100755 (executable)
@@ -78,22 +78,26 @@ public class ImageMaker
 
   public enum TYPE
   {
-    EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()),
+    EPS("EPS", MessageManager.getString("label.eps_file"), EPS_EXTENSION,
+            EPS_DESCRIPTION),
     PNG("PNG", MessageManager.getString("label.png_image"),
-            getPNGChooser()),
-    SVG("SVG", "SVG", getSVGChooser());
-
-    private JalviewFileChooser chooser;
+            PNG_EXTENSION, PNG_DESCRIPTION),
+    SVG("SVG", "SVG", SVG_EXTENSION, SVG_DESCRIPTION);
 
     private String name;
 
     private String label;
 
-    TYPE(String name, String label, JalviewFileChooser chooser)
+    private String extension;
+
+    private String description;
+
+    TYPE(String name, String label, String ext, String desc)
     {
       this.name = name;
       this.label = label;
-      this.chooser = chooser;
+      this.extension = ext;
+      this.description = desc;
     }
 
     public String getName()
@@ -101,9 +105,9 @@ public class ImageMaker
       return name;
     }
 
-    public JalviewFileChooser getChooser()
+    public JalviewFileChooser getFileChooser()
     {
-      return chooser;
+      return new JalviewFileChooser(extension, description);
     }
 
     public String getLabel()
@@ -126,7 +130,7 @@ public class ImageMaker
       setProgressMessage(MessageManager.formatMessage(
               "status.waiting_for_user_to_select_output_file", type.name));
       JalviewFileChooser chooser;
-      chooser = type.getChooser();
+      chooser = type.getFileChooser();
       chooser.setFileView(new jalview.io.JalviewFileView());
       chooser.setDialogTitle(title);
       chooser.setToolTipText(MessageManager.getString("action.save"));