/** Default file is ~/.jalview_properties */
static String propertiesFile;
+ private static boolean propsAreReadOnly=false;
+
public static void initLogger()
{
if (log != null)
try
{
InputStream fis;
- try {
+ try
+ {
fis = new java.net.URL(propertiesFile).openStream();
- System.out.println("Loading jalview properties from : "+propertiesFile);
- } catch (Exception ex) {fis=null;}
- if (fis==null) {
+ 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);
}
applicationProperties.load(fis);
*/
public static String setProperty(String key, String obj)
{
+
try
{
- FileOutputStream out = new FileOutputStream(propertiesFile);
applicationProperties.setProperty(key, obj);
- applicationProperties.store(out, "---JalviewX Properties File---");
- out.close();
+ if (!propsAreReadOnly)
+ {
+ FileOutputStream out = new FileOutputStream(propertiesFile);
+ applicationProperties.store(out, "---JalviewX Properties File---");
+ out.close();
+ }
} catch (Exception ex)
{
System.out.println("Error setting property: " + key + " " + obj
*/
public static void saveProperties()
{
- try
- {
- FileOutputStream out = new FileOutputStream(propertiesFile);
- applicationProperties.store(out, "---JalviewX Properties File---");
- out.close();
- } catch (Exception ex)
+ if (!propsAreReadOnly)
{
- System.out.println("Error saving properties: " + ex);
+ try
+ {
+ FileOutputStream out = new FileOutputStream(propertiesFile);
+ applicationProperties.store(out, "---JalviewX Properties File---");
+ out.close();
+ } catch (Exception ex)
+ {
+ System.out.println("Error saving properties: " + ex);
+ }
}
}