X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fjalview%2Futil%2FLaunchUtils.java;fp=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fjalview%2Futil%2FLaunchUtils.java;h=3302dbad9962adb5924df016565c931a91eed645;hb=d043ce47fc710d3eb2629ba926a8a7417bd67d8c;hp=0000000000000000000000000000000000000000;hpb=49db0dff1da16c3355b43a41498c1fc93ef47e91;p=jalview.git diff --git a/getdown/src/getdown/core/src/main/java/jalview/util/LaunchUtils.java b/getdown/src/getdown/core/src/main/java/jalview/util/LaunchUtils.java new file mode 100644 index 0000000..3302dba --- /dev/null +++ b/getdown/src/getdown/core/src/main/java/jalview/util/LaunchUtils.java @@ -0,0 +1,56 @@ +package jalview.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +public class LaunchUtils +{ + + public static void loadChannelProps(File dir) + { + ChannelProperties.loadProps(dir); + } + + private static Properties userPreferences = null; + + public static String getUserPreference(String key) + { + if (userPreferences == null) + { + String channelPrefsFilename = ChannelProperties + .getProperty("preferences.filename"); + if (channelPrefsFilename == null) + { + return null; + } + File propertiesFile = new File(System.getProperty("user.home"), + channelPrefsFilename); + if (!propertiesFile.exists()) + { + return null; + } + try + { + userPreferences = new Properties(); + userPreferences.load(new FileInputStream(propertiesFile)); + } catch (FileNotFoundException e) + { + // didn't find user preferences file + return null; + } catch (IOException e) + { + System.err.println(e.getMessage()); + return null; + } + } + return userPreferences.getProperty(key); + } + + public static boolean getBooleanUserPreference(String key) + { + return Boolean.parseBoolean(getUserPreference(key)); + } +}