diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 865433cde..8d61ec7ea 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -149,6 +149,14 @@ public class Preferences { "You'll need to reinstall Arduino."), e); } + // set some runtime constants (not saved on preferences file) + table.put("runtime.os", PConstants.platformNames[PApplet.platform]); + String idePath = System.getProperty("user.dir"); + if (Base.isMacOS()) + idePath += "/Arduino.app/Contents/Resources/Java"; + table.put("runtime.ide.path", idePath); + table.put("runtime.ide.version", "" + Base.REVISION); + // check for platform-specific properties in the defaults String platformExt = "." + PConstants.platformNames[PApplet.platform]; int platformExtLength = platformExt.length(); @@ -607,6 +615,8 @@ public class Preferences { Enumeration e = table.keys(); //properties.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); + if (key.startsWith("runtime.")) + continue; writer.println(key + "=" + ((String) table.get(key))); } @@ -782,20 +792,10 @@ public class Preferences { return new SyntaxStyle(color, italic, bold, underlined); } - //get a Map of the Preferences + // get a copy of the Preferences static public PreferencesMap getMap() { - PreferencesMap globalpreferences = new PreferencesMap(); - Enumeration e = table.keys(); - - while (e.hasMoreElements()) - { - String key = (String) e.nextElement(); - String value = (String) table.get(key); - globalpreferences.put(key, value); - } - - return globalpreferences; + return new PreferencesMap(table); } } diff --git a/app/src/processing/app/helpers/PreferencesMap.java b/app/src/processing/app/helpers/PreferencesMap.java index 0935791d3..13b4bd049 100644 --- a/app/src/processing/app/helpers/PreferencesMap.java +++ b/app/src/processing/app/helpers/PreferencesMap.java @@ -29,21 +29,26 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; +import java.util.Hashtable; import java.util.Map; import processing.core.PApplet; public class PreferencesMap extends HashMap { - public PreferencesMap(PreferencesMap prefs) { - super(prefs); + public PreferencesMap(Hashtable table) { + super(table); } + public PreferencesMap(PreferencesMap prefs) { + super(prefs); + } + public PreferencesMap() { super(); } - /** + /** * Parse a property list file and put kev/value pairs into the Map * * @param file