JAL-3026 fix bug loading Jalview Project (in Java)
[jalview.git] / src / jalview / project / Jalview2XML.java
index 09f1675..4d772a1 100644 (file)
@@ -214,21 +214,9 @@ public class Jalview2XML
   // BH 2018 we add the .jvp binary extension to J2S so that
   // it will declare that binary when we do the file save from the browser
 
-  private static void addJ2SBinaryType(String ext)
-  {
-    ext = "." + ext + "?";
-
-    /**
-     * @j2sNative
-     * 
-     *            J2S._binaryTypes.push(ext);
-     * 
-     */
-  }
-
   static
   {
-    addJ2SBinaryType(".jvp?");
+    Platform.addJ2SBinaryType(".jvp?");
   }
 
   private static final String VIEWER_PREFIX = "viewer_";
@@ -474,7 +462,7 @@ public class Jalview2XML
       public boolean isResolvable()
       {
         return super.isResolvable() && mp.getTo() != null;
-      };
+      }
 
       @Override
       boolean resolve()
@@ -706,7 +694,6 @@ public class Jalview2XML
       } catch (Exception foo)
       {
       }
-      ;
       jout.close();
     } catch (Exception ex)
     {
@@ -768,9 +755,10 @@ public class Jalview2XML
     try
     {
       // create backupfiles object and get new temp filename destination
-      BackupFiles backupfiles = new BackupFiles(jarFile);
-      FileOutputStream fos = new FileOutputStream(
-              backupfiles.getTempFilePath());
+      boolean doBackup = BackupFiles.getEnabled();
+      BackupFiles backupfiles = doBackup ? new BackupFiles(jarFile) : null;
+      FileOutputStream fos = new FileOutputStream(doBackup ? 
+              backupfiles.getTempFilePath() : jarFile);
 
       JarOutputStream jout = new JarOutputStream(fos);
       List<AlignFrame> frames = new ArrayList<>();
@@ -791,12 +779,14 @@ public class Jalview2XML
       } catch (Exception foo)
       {
       }
-      ;
       jout.close();
       boolean success = true;
 
-      backupfiles.setWriteSuccess(success);
-      success = backupfiles.rollBackupsAndRenameTempFile();
+      if (doBackup)
+      {
+        backupfiles.setWriteSuccess(success);
+        success = backupfiles.rollBackupsAndRenameTempFile();
+      }
 
       return success;
     } catch (Exception ex)
@@ -2771,7 +2761,7 @@ public class Jalview2XML
           public void run()
           {
             setLoadingFinishedForNewStructureViewers();
-          };
+          }
         });
       } catch (Exception x)
       {
@@ -2787,8 +2777,8 @@ public class Jalview2XML
                // BH 2018 allow for bytes already attached to File object
                try {
                        String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString());
-                       byte[] bytes = /** @j2sNative ofile._bytes || */
-                                       null;
+      byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile)
+              : null;
                        URL url = null;
                        errorMessage = null;
                        uniqueSetSuffix = null;
@@ -4213,10 +4203,8 @@ public class Jalview2XML
           // TODO: verify 'associate with all views' works still
           tp.getTreeCanvas().setViewport(av); // af.viewport;
           tp.getTreeCanvas().setAssociatedPanel(ap); // af.alignPanel;
-          // FIXME: should we use safeBoolean here ?
-          tp.getTreeCanvas().setApplyToAllViews(tree.isLinkToAllViews());
-
         }
+        tp.getTreeCanvas().setApplyToAllViews(tree.isLinkToAllViews());
         if (tp == null)
         {
           warn("There was a problem recovering stored Newick tree: \n"