*/
package jalview.io;
-import jalview.exceptions.NoFileSelectedException;
+import jalview.bin.Cache;
import jalview.gui.AlignmentPanel;
import jalview.gui.OOMWarning;
import jalview.json.binding.biojs.BioJSReleasePojo;
public class BioJsHTMLOutput extends HTMLOutput
{
-
private static File currentBJSTemplateFile;
private static TreeMap<String, File> bioJsMSAVersions;
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);
+ super(ap, "BioJS MSA");
}
- @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();
-
- }
-
-
-
public static void refreshVersionInfo(String dirName)
throws URISyntaxException
{
{
try
{
- String gitRepoPkgJson = getURLContentAsString(BJS_TEMPLATE_GIT_REPO);
+ String gitRepoPkgJson = getURLContentAsString(
+ BJS_TEMPLATE_GIT_REPO);
if (gitRepoPkgJson != null)
{
BioJSRepositoryPojo release = new BioJSRepositoryPojo(
}
}
}
- return responseStrBuilder == null ? null : responseStrBuilder
- .toString();
+ return responseStrBuilder == null ? null
+ : responseStrBuilder.toString();
}
public static File getCurrentBJSTemplateFile()
}
@Override
- public File getExportedFile()
- {
- return generatedFile;
- }
-
- @Override
public void run()
{
try
String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
.replaceAll("#sequenceData#", bioJSON).toString();
- PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
- generatedFile));
+ PrintWriter out = new java.io.PrintWriter(
+ new java.io.FileWriter(generatedFile));
out.print(generatedBioJsWithJalviewAlignmentAsJson);
out.flush();
out.close();
- setProgressMessage(MessageManager.formatMessage(
- "status.export_complete", "BioJS"));
+ setProgressMessage(MessageManager
+ .formatMessage("status.export_complete", getDescription()));
exportCompleted();
} catch (OutOfMemoryError err)
new OOMWarning("Creating Image for " + generatedFile, err);
} catch (Exception e)
{
- setProgressMessage(MessageManager.formatMessage(
- "info.error_creating_file", "HTML"));
+ setProgressMessage(MessageManager
+ .formatMessage("info.error_creating_file", getDescription()));
e.printStackTrace();
}