JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / io / FileFormats.java
index aadcdb9..e83b87c 100644 (file)
@@ -20,6 +20,9 @@
  */
 package jalview.io;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -36,23 +39,11 @@ import java.util.Set;
  * @author gmcarstairs
  *
  */
-public class FileFormats
+public class FileFormats implements ApplicationSingletonI
 {
-  private static FileFormats instance = new FileFormats();
-
-  /*
-   * A lookup map of file formats by upper-cased name
-   */
-  private static Map<String, FileFormatI> formats;
-
-  /*
-   * Formats in this set are capable of being identified by IdentifyFile 
-   */
-  private static Set<FileFormatI> identifiable;
-
   public static FileFormats getInstance()
   {
-    return instance;
+    return (FileFormats) ApplicationSingletonProvider.getInstance(FileFormats.class);
   }
 
   /**
@@ -63,6 +54,16 @@ public class FileFormats
     reset();
   }
 
+  /*
+   * A lookup map of file formats by upper-cased name
+   */
+  private Map<String, FileFormatI> formats;
+
+  /*
+   * Formats in this set are capable of being identified by IdentifyFile 
+   */
+  private Set<FileFormatI> identifiable;
+
   /**
    * Reset to just the built-in file formats packaged with Jalview. These are
    * added (and will be shown in menus) in the order of their declaration in the
@@ -70,8 +71,8 @@ public class FileFormats
    */
   public synchronized void reset()
   {
-    formats = new LinkedHashMap<String, FileFormatI>();
-    identifiable = new HashSet<FileFormatI>();
+    formats = new LinkedHashMap<>();
+    identifiable = new HashSet<>();
     for (FileFormat format : FileFormat.values())
     {
       registerFileFormat(format, format.isIdentifiable());
@@ -135,7 +136,7 @@ public class FileFormats
    */
   public List<String> getWritableFormats(boolean textOnly)
   {
-    List<String> l = new ArrayList<String>();
+    List<String> l = new ArrayList<>();
     for (FileFormatI ff : formats.values())
     {
       if (ff.isWritable() && (!textOnly || ff.isTextFormat()))
@@ -154,7 +155,7 @@ public class FileFormats
    */
   public List<String> getReadableFormats()
   {
-    List<String> l = new ArrayList<String>();
+    List<String> l = new ArrayList<>();
     for (FileFormatI ff : formats.values())
     {
       if (ff.isReadable())