+ 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
+ .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 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();
+
+ }
+
+
+
+ public static void refreshVersionInfo(String dirName)
+ throws URISyntaxException
+ {
+ File directory = new File(BJS_TEMPLATES_LOCAL_DIRECTORY);
+ Objects.requireNonNull(dirName, "dirName MUST not be null!");
+ Objects.requireNonNull(directory, "directory MUST not be null!");
+ TreeMap<String, File> versionFileMap = new TreeMap<String, File>();
+
+ for (File file : directory.listFiles())
+ {
+ if (file.isFile())
+ {
+ String fileName = file.getName().substring(0,
+ file.getName().lastIndexOf("."));
+ String fileMeta[] = fileName.split("_");
+ if (fileMeta.length > 2)
+ {
+ setCurrentBJSTemplateFile(file);
+ versionFileMap.put(fileMeta[2], file);
+ }
+ else if (fileMeta.length > 1)
+ {
+ versionFileMap.put(fileMeta[1], file);
+ }
+ }
+ }
+ if (getCurrentBJSTemplateFile() == null && versionFileMap.size() > 0)
+ {
+ setCurrentBJSTemplateFile(versionFileMap.lastEntry().getValue());
+ }
+ setBioJsMSAVersions(versionFileMap);
+ }
+
+ public static void updateBioJS()