JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / io / FileLoader.java
index d3bf4e0..95f85e6 100755 (executable)
@@ -25,7 +25,6 @@ import jalview.api.FeatureSettingsModelI;
 import jalview.api.FeaturesDisplayedI;
 import jalview.api.FeaturesSourceI;
 import jalview.bin.Cache;
-import jalview.bin.Instance;
 import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
@@ -279,9 +278,9 @@ public class FileLoader implements Runnable
     Runtime rt = Runtime.getRuntime();
     try
     {
-      if (Instance.getDesktop() != null)
+      if (Desktop.instance != null)
       {
-        Instance.getDesktop().startLoading(file);
+        Desktop.instance.startLoading(file);
       }
       if (format == null)
       {
@@ -303,12 +302,12 @@ public class FileLoader implements Runnable
 
       if (format == null)
       {
-        Instance.getDesktop().stopLoading();
+        Desktop.instance.stopLoading();
         System.err.println("The input file \"" + file
                 + "\" has null or unidentifiable data content!");
         if (!Jalview.isHeadlessMode())
         {
-          JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+          JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                   MessageManager.getString("label.couldnt_read_data")
                           + " in " + file + "\n"
                           + AppletFormatAdapter.getSupportedFormats(),
@@ -319,7 +318,7 @@ public class FileLoader implements Runnable
       }
       // TODO: cache any stream datasources as a temporary file (eg. PDBs
       // retrieved via URL)
-      if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage())
+      if (Desktop.desktop != null && Desktop.desktop.isShowMemoryUsage())
       {
         System.gc();
         memused = (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); // free
@@ -362,9 +361,9 @@ public class FileLoader implements Runnable
             if (downloadStructureFile)
             {
               String structExt = format.getExtensions().split(",")[0];
-              int pt = file.lastIndexOf(file.indexOf('/') >= 0 ? "/"
-                      : System.getProperty("file.separator"));
-              String urlLeafName = file.substring(pt,
+              String urlLeafName = file.substring(
+                      file.lastIndexOf(
+                              System.getProperty("file.separator")),
                       file.lastIndexOf("."));
               String tempStructureFileStr = createNamedJvTempFile(
                       urlLeafName, structExt);
@@ -412,7 +411,7 @@ public class FileLoader implements Runnable
                 // register PDB entries with desktop's structure selection
                 // manager
                 StructureSelectionManager
-                        .getStructureSelectionManager(Instance.getDesktop())
+                        .getStructureSelectionManager(Desktop.instance)
                         .registerPDBEntry(pdbe);
               }
             }
@@ -501,23 +500,23 @@ public class FileLoader implements Runnable
         }
         else
         {
-          if (Instance.getDesktop() != null)
+          if (Desktop.instance != null)
           {
-            Instance.getDesktop().stopLoading();
+            Desktop.instance.stopLoading();
           }
 
           final String errorMessage = MessageManager.getString(
                   "label.couldnt_load_file") + " " + title + "\n" + error;
           // TODO: refactor FileLoader to be independent of Desktop / Applet GUI
           // bits ?
-          if (raiseGUI && Desktop.getDesktopPane() != null)
+          if (raiseGUI && Desktop.desktop != null)
           {
             javax.swing.SwingUtilities.invokeLater(new Runnable()
             {
               @Override
               public void run()
               {
-                JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+                JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                         errorMessage,
                         MessageManager
                                 .getString("label.error_loading_file"),
@@ -545,7 +544,7 @@ public class FileLoader implements Runnable
           @Override
           public void run()
           {
-            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                     MessageManager.formatMessage(
                             "label.problems_opening_file", new String[]
                             { file }),
@@ -567,7 +566,7 @@ public class FileLoader implements Runnable
           @Override
           public void run()
           {
-            JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
+            JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                     MessageManager.formatMessage(
                             "warn.out_of_memory_loading_file", new String[]
                             { file }),
@@ -589,7 +588,7 @@ public class FileLoader implements Runnable
     // memory
     // after
     // load
-    if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage())
+    if (Desktop.desktop != null && Desktop.desktop.isShowMemoryUsage())
     {
       if (alignFrame != null)
       {
@@ -611,9 +610,9 @@ public class FileLoader implements Runnable
       }
     }
     // remove the visual delay indicator
-    if (Instance.getDesktop() != null)
+    if (Desktop.instance != null)
     {
-      Instance.getDesktop().stopLoading();
+      Desktop.instance.stopLoading();
     }
 
   }