import jalview.bin.HiDPISetting;
import jalview.bin.MemorySetting;
-import jalview.bin.LaunchUtils;
-import jalview.util.ChannelProperties;
+import jalview.util.LaunchUtils;
import com.threerings.getdown.util.*;
// avoid ambiguity with java.util.Base64 which we can't use as it's 1.8+
}
// use saved preferences if no cmdline args
- File channelProps = getLocalPath(ChannelProperties.CHANNEL_PROPERTIES_FILENAME);
- if (channelProps.exists()) {
- try {
- InputStream is = new FileInputStream(channelProps);
- ChannelProperties.loadProps(is);
- } catch (IOException e) {
- log.error(e.getMessage());
- }
- }
- boolean useCustomisedSettings = Boolean.parseBoolean(LaunchUtils.getUserPreference(MemorySetting.CUSTOMISED_SETTINGS));
- if (useCustomisedSettings) {
+ LaunchUtils.loadChannelProps(getAppDir());
+ if (LaunchUtils.getBooleanUserPreference(MemorySetting.CUSTOMISED_SETTINGS)) {
if (jvmmempc == null) {
jvmmempc = LaunchUtils.getUserPreference(MemorySetting.MEMORY_JVMMEMPC);
}
package jalview.util;
import java.awt.Image;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
}
}
- public static void loadProps(InputStream is)
+ protected static void loadProps(File dir)
{
- try
+ File channelPropsFile = new File(dir, CHANNEL_PROPERTIES_FILENAME);
+ if (channelPropsFile.exists())
{
- channelProps.load(is);
- } catch (IOException e)
- {
- System.err.println(e.getMessage());
+ try
+ {
+ InputStream is = new FileInputStream(channelPropsFile);
+ channelProps.load(is);
+ } catch (FileNotFoundException e)
+ {
+ System.err.println(e.getMessage());
+ } catch (IOException e)
+ {
+ System.err.println(e.getMessage());
+ }
}
}
-package jalview.bin;
+package jalview.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
-import jalview.util.ChannelProperties;
-
public class LaunchUtils
{
+ public static void loadChannelProps(File dir)
+ {
+ ChannelProperties.loadProps(dir);
+ }
+
private static Properties userPreferences = null;
public static String getUserPreference(String key)
{
String channelPrefsFilename = ChannelProperties
.getProperty("preferences.filename");
- String propertiesFile = System.getProperty("user.home")
- + File.separatorChar + channelPrefsFilename;
+ if (channelPrefsFilename == null)
+ {
+ return null;
+ }
+ File propertiesFile = new File(System.getProperty("user.home"),
+ channelPrefsFilename);
+ if (!propertiesFile.exists())
+ {
+ return null;
+ }
try
{
userPreferences = new Properties();
return userPreferences.getProperty(key);
}
+ public static boolean getBooleanUserPreference(String key)
+ {
+ return Boolean.parseBoolean(getUserPreference(key));
+ }
}
import java.util.Iterator;
import java.util.ServiceLoader;
-import jalview.bin.LaunchUtils;
-import jalview.util.ChannelProperties;
+import jalview.util.LaunchUtils;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RegistryValue;
String port = null;
boolean proxyAuth = false;
String username = null;
- File channelProps = app.getLocalPath(ChannelProperties.CHANNEL_PROPERTIES_FILENAME);
- if (channelProps.exists()) {
- try {
- InputStream is = new FileInputStream(channelProps);
- ChannelProperties.loadProps(is);
- } catch (IOException e) {
- log.error(e.getMessage());
+ LaunchUtils.loadChannelProps(app.getAppDir());
+ if (LaunchUtils.getBooleanUserPreference("USE_PROXY")) {
+ host = LaunchUtils.getUserPreference("PROXY_SERVER_HTTPS");
+ port = LaunchUtils.getUserPreference("PROXY_PORT_HTTPS");
+ if (StringUtil.isBlank(host)) {
+ host = LaunchUtils.getUserPreference("PROXY_SERVER");
+ port = LaunchUtils.getUserPreference("PROXY_PORT");
}
- if (Boolean.parseBoolean(LaunchUtils.getUserPreference("USE_PROXY"))) {
- host = LaunchUtils.getUserPreference("PROXY_SERVER_HTTPS");
- port = LaunchUtils.getUserPreference("PROXY_PORT_HTTPS");
- if (StringUtil.isBlank(host)) {
- host = LaunchUtils.getUserPreference("PROXY_SERVER");
- port = LaunchUtils.getUserPreference("PROXY_PORT");
- }
- proxyAuth = Boolean.parseBoolean(LaunchUtils.getUserPreference("PROXY_AUTH"));
- if (proxyAuth) {
- username = LaunchUtils.getUserPreference("PROXY_AUTH_USERNAME");
- }
+ proxyAuth = LaunchUtils.getBooleanUserPreference("PROXY_AUTH");
+ if (proxyAuth) {
+ username = LaunchUtils.getUserPreference("PROXY_AUTH_USERNAME");
}
}
return new String[]{ host, port, String.valueOf(proxyAuth), username };
import java.util.List;
import jalview.util.ChannelProperties;
+import jalview.util.LaunchUtils;
/**
* A Launcher class for Jalview. This class is used to launch Jalview from the
}
// use saved preferences if no cmdline args
- boolean useCustomisedSettings = Boolean.parseBoolean(LaunchUtils
- .getUserPreference(MemorySetting.CUSTOMISED_SETTINGS));
+ boolean useCustomisedSettings = LaunchUtils
+ .getBooleanUserPreference(MemorySetting.CUSTOMISED_SETTINGS);
if (useCustomisedSettings)
{
if (jvmmempc == null)
package jalview.util;
import java.awt.Image;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
}
}
- public static void loadProps(InputStream is)
+ protected static void loadProps(File dir)
{
- try
+ File channelPropsFile = new File(dir, CHANNEL_PROPERTIES_FILENAME);
+ if (channelPropsFile.exists())
{
- channelProps.load(is);
- } catch (IOException e)
- {
- System.err.println(e.getMessage());
+ try
+ {
+ InputStream is = new FileInputStream(channelPropsFile);
+ channelProps.load(is);
+ } catch (FileNotFoundException e)
+ {
+ System.err.println(e.getMessage());
+ } catch (IOException e)
+ {
+ System.err.println(e.getMessage());
+ }
}
}
-package jalview.bin;
+package jalview.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
-import jalview.util.ChannelProperties;
-
public class LaunchUtils
{
+ public static void loadChannelProps(File dir)
+ {
+ ChannelProperties.loadProps(dir);
+ }
+
private static Properties userPreferences = null;
public static String getUserPreference(String key)
{
String channelPrefsFilename = ChannelProperties
.getProperty("preferences.filename");
- String propertiesFile = System.getProperty("user.home")
- + File.separatorChar + channelPrefsFilename;
+ if (channelPrefsFilename == null)
+ {
+ return null;
+ }
+ File propertiesFile = new File(System.getProperty("user.home"),
+ channelPrefsFilename);
+ if (!propertiesFile.exists())
+ {
+ return null;
+ }
try
{
userPreferences = new Properties();
return userPreferences.getProperty(key);
}
+ public static boolean getBooleanUserPreference(String key)
+ {
+ return Boolean.parseBoolean(getUserPreference(key));
+ }
}