JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / io / FileLoader.java
index f8283c3..95f85e6 100755 (executable)
@@ -37,6 +37,7 @@ import jalview.gui.JvOptionPane;
 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
 import jalview.project.Jalview2XML;
 import jalview.schemes.ColourSchemeI;
+import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.ws.utils.UrlDownloadClient;
@@ -277,9 +278,9 @@ public class FileLoader implements Runnable
     Runtime rt = Runtime.getRuntime();
     try
     {
-      if (Desktop.getInstance() != null)
+      if (Desktop.instance != null)
       {
-        Desktop.getInstance().startLoading(file);
+        Desktop.instance.startLoading(file);
       }
       if (format == null)
       {
@@ -301,12 +302,12 @@ public class FileLoader implements Runnable
 
       if (format == null)
       {
-        Desktop.getInstance().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(),
@@ -317,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
@@ -360,15 +361,15 @@ 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);
               
               // BH - switching to File object here so as to hold
-              // .秘bytes array directly
+              // ._bytes array directly
               File tempFile = new File(tempStructureFileStr);
               UrlDownloadClient.download(file, tempFile);
               
@@ -409,7 +410,8 @@ public class FileLoader implements Runnable
               {
                 // register PDB entries with desktop's structure selection
                 // manager
-                Desktop.getInstance().getStructureSelectionManager()
+                StructureSelectionManager
+                        .getStructureSelectionManager(Desktop.instance)
                         .registerPDBEntry(pdbe);
               }
             }
@@ -498,23 +500,23 @@ public class FileLoader implements Runnable
         }
         else
         {
-          if (Desktop.getInstance() != null)
+          if (Desktop.instance != null)
           {
-            Desktop.getInstance().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"),
@@ -542,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 }),
@@ -564,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 }),
@@ -586,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)
       {
@@ -608,9 +610,9 @@ public class FileLoader implements Runnable
       }
     }
     // remove the visual delay indicator
-    if (Desktop.getInstance() != null)
+    if (Desktop.instance != null)
     {
-      Desktop.getInstance().stopLoading();
+      Desktop.instance.stopLoading();
     }
 
   }