public static void loadProperties(String propsFile)
{
propertiesFile = propsFile;
+ String releasePropertiesFile = null;
+ boolean defaultProperties = false;
if (propsFile == null && !propsAreReadOnly)
{
+ String channelPrefsFilename = ChannelProperties
+ .getProperty("preferences.filename");
+ String releasePrefsFilename = ".jalview_properties";
propertiesFile = System.getProperty("user.home") + File.separatorChar
- + ".jalview_properties";
+ + channelPrefsFilename;
+ releasePropertiesFile = System.getProperty("user.home")
+ + File.separatorChar + releasePrefsFilename;
+ defaultProperties = true;
}
else
{
InputStream fis;
try
{
+ // props file provided as URL
fis = new URL(propertiesFile).openStream();
System.out.println(
"Loading jalview properties from : " + propertiesFile);
System.out.println(
"Disabling Jalview writing to user's local properties file.");
propsAreReadOnly = true;
-
} catch (Exception ex)
{
fis = null;
}
if (fis == null)
{
- fis = new FileInputStream(propertiesFile);
+ String readPropertiesFile = propertiesFile;
+ // if we're using the usual properties file and the channel properties
+ // file doesn't exist, read .jalview_properties
+ // (but we'll still save to the channel properties file).
+ if (defaultProperties && (!new File(propertiesFile).exists())
+ && (new File(releasePropertiesFile).exists()))
+ {
+ readPropertiesFile = releasePropertiesFile;
+ }
+ fis = new FileInputStream(readPropertiesFile);
}
applicationProperties.clear();
applicationProperties.load(fis);
@Override
public void run()
{
- String buildPropertiesUrl = Cache.getAppbaseBuildProperties();
+ String remoteBuildPropertiesUrl = Cache
+ .getAppbaseBuildProperties();
String orgtimeout = System
.getProperty("sun.net.client.defaultConnectTimeout");
{
System.setProperty("sun.net.client.defaultConnectTimeout",
"5000");
- java.net.URL url = new java.net.URL(buildPropertiesUrl);
+ java.net.URL url = new java.net.URL(remoteBuildPropertiesUrl);
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
{
System.out
.println("Non-fatal exception when checking version at "
- + buildPropertiesUrl + ":");
+ + remoteBuildPropertiesUrl + ":");
System.out.println(ex);
remoteVersion = getProperty("VERSION");
}
InputStream in = localJarFileURL.openStream();
buildProperties.load(in);
in.close();
- applicationProperties.put("BUILD_DATE",
- buildProperties.get("BUILD_DATE"));
- applicationProperties.put("INSTALLATION",
- buildProperties.get("INSTALLATION"));
- applicationProperties.put("VERSION", buildProperties.get("VERSION"));
+ if (buildProperties.getProperty("BUILD_DATE", null) != null)
+ {
+ applicationProperties.put("BUILD_DATE",
+ buildProperties.getProperty("BUILD_DATE"));
+ }
+ if (buildProperties.getProperty("INSTALLATION", null) != null)
+ {
+ applicationProperties.put("INSTALLATION",
+ buildProperties.getProperty("INSTALLATION"));
+ }
+ if (buildProperties.getProperty("VERSION", null) != null)
+ {
+ applicationProperties.put("VERSION",
+ buildProperties.getProperty("VERSION"));
+ }
} catch (Exception ex)
{
System.out.println("Error reading build details: " + ex);
static
{
- Float specversion = Float
- .parseFloat(System.getProperty("java.specification.version"));
- releaseAppbase = (specversion < 9)
- ? "https://www.jalview.org/getdown/release/1.8"
- : "https://www.jalview.org/getdown/release/11";
+ if (!Platform.isJS())
+ {
+ Float specversion = Float
+ .parseFloat(System.getProperty("java.specification.version"));
+ releaseAppbase = (specversion < 9)
+ ? "https://www.jalview.org/getdown/release/1.8"
+ : "https://www.jalview.org/getdown/release/11";
+ }
+ else
+ {
+ // this value currenly made up, can be changed to URL that will be
+ // "https://www.jalview.org/jalview-js/swingjs/j2s/build_properties"
+ releaseAppbase = "https://www.jalview.org/jalview-js";
+ getdownAppbase = releaseAppbase;
+ getdownDistDir = "/swingjs/j2s";
+ }
}
// look for properties (passed in by getdown) otherwise default to release