- JalviewFileChooser jvFileChooser = getJalviewFileChooserOption();
- int fileChooserOpt = jvFileChooser.showSaveDialog(null);
- if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION)
- {
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", jvFileChooser
- .getSelectedFile().getParent());
- String selectedFile = jvFileChooser.getSelectedFile().getPath();
- String generartedBioJs = generateBioJsAlignmentData(av
- .getAlignment());
- PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
- selectedFile));
- out.print(generartedBioJs);
- out.close();
- jalview.util.BrowserLauncher.openURL("file:///" + selectedFile);
- }
- } catch (Exception ex)
+ String outputFile = getOutputFile();
+ String jalviewAlignmentJson = JSONFile.getJSONData(av);
+ String bioJSTemplateString = getBioJsTemplateAsString(this);
+ String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
+ .replaceAll(
+"#sequenceData#", jalviewAlignmentJson)
+ .toString();
+
+ PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
+ outputFile));
+ out.print(generatedBioJsWithJalviewAlignmentAsJson);
+ out.flush();
+ out.close();
+ jalview.util.BrowserLauncher.openURL("file:///" + outputFile);
+ } catch (NoFileSelectedException ex)
+ {
+ // do noting if no file was selected
+ } catch (Exception e)