JAL-1740 migrated BioJSMSAViewer git repo to https://github.com/jalview/exporter...
[jalview.git] / src / jalview / io / BioJsHTMLOutput.java
index 74fb147..6c8d2df 100644 (file)
@@ -1,9 +1,10 @@
 package jalview.io;
 
 import jalview.api.AlignmentViewPanel;
+import jalview.datamodel.AlignmentExportData;
 import jalview.exceptions.NoFileSelectedException;
-import jalview.json.binding.v1.BioJSReleasePojo;
-import jalview.json.binding.v1.BioJSRepositoryPojo;
+import jalview.json.binding.biojs.BioJSReleasePojo;
+import jalview.json.binding.biojs.BioJSRepositoryPojo;
 import jalview.util.MessageManager;
 
 import java.io.BufferedInputStream;
@@ -36,7 +37,7 @@ public class BioJsHTMLOutput
   public static final String BJS_TEMPLATE_GIT_REPO = jalview.bin.Cache
           .getDefault(
                   "biojs_template_git_repo",
-                  "https://raw.githubusercontent.com/tcofoegbu/bjs-template/master/package.json");
+                  "https://raw.githubusercontent.com/jalview/exporter-templates/master/biojs/package.json");
 
   public BioJsHTMLOutput(AlignmentViewPanel ap)
   {
@@ -51,7 +52,20 @@ public class BioJsHTMLOutput
     try
     {
       String outputFile = getOutputFile();
-      String jalviewAlignmentJson = JSONFile.getJSONData(ap);
+      // String jalviewAlignmentJson = JSONFile.getJSONData(ap);
+      AlignmentExportData exportData = jalview.gui.AlignFrame
+              .getAlignmentForExport(
+              JSONFile.FILE_DESC, ap.getAlignViewport());
+      if (exportData.getSettings().isCancelled())
+      {
+        return;
+      }
+      String jalviewAlignmentJson = new FormatAdapter(ap,
+              exportData.getSettings()).formatSequences(JSONFile.FILE_DESC,
+              exportData.getAlignment(), exportData.getOmitHidden(),
+              exportData.getStartEndPostions(), ap.getAlignViewport()
+                      .getColumnSelection());
+
       String bioJSTemplateString = getBioJsTemplateAsString();
       String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
               .replaceAll(
@@ -82,10 +96,8 @@ public class BioJsHTMLOutput
             { "HTML files" }, "HTML files");
     jvFileChooser.setFileView(new JalviewFileView());
 
-    // TODO uncomment when supported by MassageManager
     jvFileChooser.setDialogTitle(MessageManager
             .getString("label.save_as_biojs_html"));
-    jvFileChooser.setDialogTitle("save as BioJs HTML");
     jvFileChooser.setToolTipText(MessageManager.getString("action.save"));
 
     int fileChooserOpt = jvFileChooser.showSaveDialog(null);
@@ -187,10 +199,13 @@ public class BioJsHTMLOutput
         try
         {
           String gitRepoPkgJson = getURLContentAsString(BJS_TEMPLATE_GIT_REPO);
-          BioJSRepositoryPojo release = new BioJSRepositoryPojo(
-                  gitRepoPkgJson);
-          syncUpdates(BJS_TEMPLATES_LOCAL_DIRECTORY, release);
-          refreshBioJSVersionsInfo(BJS_TEMPLATES_LOCAL_DIRECTORY);
+          if (gitRepoPkgJson != null)
+          {
+            BioJSRepositoryPojo release = new BioJSRepositoryPojo(
+                    gitRepoPkgJson);
+            syncUpdates(BJS_TEMPLATES_LOCAL_DIRECTORY, release);
+            refreshBioJSVersionsInfo(BJS_TEMPLATES_LOCAL_DIRECTORY);
+          }
         } catch (URISyntaxException e)
         {
           e.printStackTrace();