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", "/biojs_templates/");
+ .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/tcofoegbu/bjs-template/master/package.json");
- public BioJsHTMLOutput(AlignmentPanel ap,
- FeatureRenderer fr1)
+ public BioJsHTMLOutput(AlignmentPanel ap, FeatureRenderer fr1)
{
if (ap != null)
{
public void refreshBioJSVersionsInfo(String dirName)
throws URISyntaxException
{
- URL url = getClass().getResource(dirName);
- File directory = new File(url.toURI());
+ 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>();
public void updateBioJS()
{
- try
- {
- String gitRepoPkgJson = getURLContentAsString(BJS_TEMPLATE_GIT_REPO);
- BioJSRepositoryPojo release = new BioJSRepositoryPojo(gitRepoPkgJson);
- syncUpdates(BJS_TEMPLATES_LOCAL_DIRECTORY, release);
- refreshBioJSVersionsInfo(BJS_TEMPLATES_LOCAL_DIRECTORY);
- } catch (URISyntaxException e)
+ Thread updateThread = new Thread()
{
- e.printStackTrace();
- }
+ public void run()
+ {
+ try
+ {
+ String gitRepoPkgJson = getURLContentAsString(BJS_TEMPLATE_GIT_REPO);
+ BioJSRepositoryPojo release = new BioJSRepositoryPojo(
+ gitRepoPkgJson);
+ syncUpdates(BJS_TEMPLATES_LOCAL_DIRECTORY, release);
+ refreshBioJSVersionsInfo(BJS_TEMPLATES_LOCAL_DIRECTORY);
+ } catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+ updateThread.start();
+
}
public void syncUpdates(String localDir, BioJSRepositoryPojo repo)
- throws URISyntaxException
{
for (BioJSReleasePojo bjsRelease : repo.getReleases())
{
{
releaseFile = "Latest_BioJsMSA_" + releaseVersion + ".txt";
}
- File file = null;
- URL url = getClass().getResource(
- BJS_TEMPLATES_LOCAL_DIRECTORY + releaseFile);
- if (url == null)
- {
- String path = getClass().getResource(BJS_TEMPLATES_LOCAL_DIRECTORY)
- .getPath();
- System.out.println("------> " + path);
- file = new File(path + releaseFile);
- }
- else
+
+ File biojsDirectory = new File(BJS_TEMPLATES_LOCAL_DIRECTORY);
+ if (!biojsDirectory.exists())
{
- file = new File(url.toURI());
+ if (!biojsDirectory.mkdirs())
+ {
+ System.out.println("Couldn't create local directory : "
+ + BJS_TEMPLATES_LOCAL_DIRECTORY);
+ return;
+ }
}
+ File file = new File(BJS_TEMPLATES_LOCAL_DIRECTORY + releaseFile);
if (!file.exists())
{
+
PrintWriter out = null;
try
{