X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FBioJsHTMLOutput.java;h=13bfb8c0f93fd145aa231a7ba7d1d0c4b6b76cd5;hb=ccc53e88e3260886f5d3bdacc619c0f374be9b8f;hp=52ce845cb4a373c23a7e70221e5b5efcaf8b14f9;hpb=3d0101179759ef157b088ea135423cd909512d9f;p=jalview.git diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 52ce845..13bfb8c 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -20,13 +20,6 @@ */ package jalview.io; -import jalview.exceptions.NoFileSelectedException; -import jalview.gui.AlignmentPanel; -import jalview.gui.OOMWarning; -import jalview.json.binding.biojs.BioJSReleasePojo; -import jalview.json.binding.biojs.BioJSRepositoryPojo; -import jalview.util.MessageManager; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; @@ -39,9 +32,15 @@ import java.net.URL; import java.util.Objects; import java.util.TreeMap; +import jalview.bin.Cache; +import jalview.gui.AlignmentPanel; +import jalview.gui.OOMWarning; +import jalview.json.binding.biojs.BioJSReleasePojo; +import jalview.json.binding.biojs.BioJSRepositoryPojo; +import jalview.util.MessageManager; + public class BioJsHTMLOutput extends HTMLOutput { - private static File currentBJSTemplateFile; private static TreeMap bioJsMSAVersions; @@ -49,43 +48,16 @@ public class BioJsHTMLOutput extends HTMLOutput public static final String DEFAULT_DIR = System.getProperty("user.home") + File.separatorChar + ".biojs_templates" + File.separatorChar; - public static final String BJS_TEMPLATES_LOCAL_DIRECTORY = jalview.bin.Cache + public static final String BJS_TEMPLATES_LOCAL_DIRECTORY = Cache .getDefault("biojs_template_directory", DEFAULT_DIR); - public static final String BJS_TEMPLATE_GIT_REPO = jalview.bin.Cache - .getDefault("biojs_template_git_repo", - "https://raw.githubusercontent.com/jalview/exporter-templates/master/biojs/package.json"); + public static final String BJS_TEMPLATE_GIT_REPO = Cache.getDefault( + "biojs_template_git_repo", + "https://raw.githubusercontent.com/jalview/exporter-templates/master/biojs/package.json"); public BioJsHTMLOutput(AlignmentPanel ap) { - super(ap); - } - - @Override - public void exportHTML(String outputFile) - { - exportStarted(); - try - { - if (outputFile == null) - { - outputFile = getOutputFile(); - } - generatedFile = new File(outputFile); - } catch (NoFileSelectedException e) - { - setProgressMessage(MessageManager.formatMessage( - "status.cancelled_image_export_operation", "BioJS MSA")); - return; - } catch (Exception e) - { - setProgressMessage(MessageManager - .formatMessage("info.error_creating_file", "BioJS MSA")); - e.printStackTrace(); - return; - } - new Thread(this).start(); - + super(ap, "BioJS MSA"); } public static void refreshVersionInfo(String dirName) @@ -166,8 +138,9 @@ public class BioJsHTMLOutput extends HTMLOutput { if (!biojsDirectory.mkdirs()) { - System.out.println("Couldn't create local directory : " - + BJS_TEMPLATES_LOCAL_DIRECTORY); + jalview.bin.Console + .outPrintln("Couldn't create local directory : " + + BJS_TEMPLATES_LOCAL_DIRECTORY); return; } } @@ -271,12 +244,6 @@ public class BioJsHTMLOutput extends HTMLOutput } @Override - public File getExportedFile() - { - return generatedFile; - } - - @Override public void run() { try @@ -293,21 +260,28 @@ public class BioJsHTMLOutput extends HTMLOutput out.flush(); out.close(); setProgressMessage(MessageManager - .formatMessage("status.export_complete", "BioJS")); + .formatMessage("status.export_complete", getDescription())); exportCompleted(); } catch (OutOfMemoryError err) { - System.out.println("########################\n" + "OUT OF MEMORY " - + generatedFile + "\n" + "########################"); + jalview.bin.Console + .outPrintln("########################\n" + "OUT OF MEMORY " + + generatedFile + "\n" + "########################"); new OOMWarning("Creating Image for " + generatedFile, err); } catch (Exception e) { setProgressMessage(MessageManager - .formatMessage("info.error_creating_file", "HTML")); + .formatMessage("info.error_creating_file", getDescription())); e.printStackTrace(); } } + @Override + public void run(String s) + { + run(); + } + }