1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Some runtime infos now resides in preferences under runtime.* keys

This commit is contained in:
Cristian Maglie 2012-02-01 14:27:41 +01:00
parent ab00a1360f
commit b295ab911e
2 changed files with 20 additions and 15 deletions

View File

@ -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<String> 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);
}
}

View File

@ -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<String, String> {
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