JAL-3247 Code changes to getdown. Double click open of .jvp files in Windows and...
[jalview.git] / getdown / src / getdown / launcher / src / main / java / com / threerings / getdown / launcher / Getdown.java
index ae679e2..e0f7c35 100644 (file)
@@ -16,11 +16,13 @@ import java.awt.image.BufferedImage;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
 
@@ -1051,16 +1053,39 @@ public abstract class Getdown extends Thread
           if (j > -1) {
             ext = filename.substring(j+1);
           }
-          // jvp files
-          if (ext.equals("jvp")) {
+          // jvp files etc
+          boolean addedStartupFile = false; // only add one startup file
+          if (_app.startupFileExtensions.contains(ext.toLowerCase()) && ! addedStartupFile) {
             File f = new File(filename);
             if (f.exists()) {
               _app.addStartupFile(f);
+              addedStartupFile = true;
             }
           }
           // jvl files
-          if (ext.equals("jvl")) {
-            // Do stuff with the appbase here!
+          if (_app.locatorFileExtension.equals(ext.toLowerCase())) {
+            // Do something special with this here
+            File f = new File(filename);
+            if (f.exists()) {
+              String line = null;
+              try {
+                FileReader fr = new FileReader(f);
+                BufferedReader br = new BufferedReader(fr);
+                line = br.readLine();
+                br.close();
+              } catch(Exception e) {
+                log.warning("Something went wrong reading Jalview Version Locator file '"+filename+"'", e);
+              }
+              if (line != null) {
+                String urlString = line.trim();
+                try {
+                  URL newAppbase = new URL(urlString);
+                  _app.newAppbase(newAppbase);
+                } catch(MalformedURLException e) {
+                  log.warning("Java Version Locator url '"+urlString+"' found in file '"+filename+"' is malformed", e);
+                }
+              }
+            }
           }
         }
       }
@@ -1099,4 +1124,5 @@ public abstract class Getdown extends Thread
 
     protected static final int MAX_LOOPS = 5;
     protected static final long FALLBACK_CHECK_TIME = 1000L;
+    
 }