1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Slighty changed custom menu format: simplifies parsing

This commit is contained in:
Cristian Maglie
2013-03-03 11:31:31 +01:00
parent eed4a43b54
commit 51c36c7325
3 changed files with 141 additions and 142 deletions

View File

@ -20,6 +20,10 @@ public class TargetBoard {
public TargetBoard(String _id, PreferencesMap _prefs) {
id = _id;
prefs = new PreferencesMap(_prefs);
PreferencesMap menus = prefs.firstLevelMap().get("menu");
if (menus != null)
menuOptions = menus.firstLevelMap();
}
/**

View File

@ -77,35 +77,14 @@ public class TargetPlatform {
// Create custom menus for this platform
PreferencesMap menus = boardsPreferences.get("menu");
boardsPreferences.remove("menu");
if (menus != null)
customMenus = menus.topLevelMap();
// Create maps for every menu option:
// - a Map that pairs a specific menu option (e.g. "cpu") to
// - a Map that pairs a specific board (e.g. "duemilanove") to
// - a PrefenceMap with all the options that overrides default
// configuration values
Map<String, Map<String, PreferencesMap>> subMenus = new LinkedHashMap<String, Map<String, PreferencesMap>>();
for (String id : customMenus.keySet()) {
subMenus.put(id, menus.subTree(id).firstLevelMap());
}
boardsPreferences.remove("menu");
// Create boards
for (String id : boardsPreferences.keySet()) {
PreferencesMap preferences = boardsPreferences.get(id);
TargetBoard board = new TargetBoard(id, preferences);
if (menus != null) {
// Build custom menu for the specified board
PreferencesMap boardCustomMenu = new PreferencesMap();
for (String menuId : customMenus.keySet()) {
// Check if the board has option for this custom menu
if (subMenus.get(menuId).containsKey(id))
// Add specific custom menu to the board
board.setMenuOptions(menuId, subMenus.get(menuId).get(id));
}
}
boards.put(id, board);
}
} catch (IOException e) {