mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
fixed board and custom menus order
removed readBoardsOrder
This commit is contained in:
@ -1146,7 +1146,7 @@ public class Base {
|
|||||||
String platformName = targetPlatform.getName();
|
String platformName = targetPlatform.getName();
|
||||||
Map<String, PreferencesMap> boards = targetPlatform.getBoards();
|
Map<String, PreferencesMap> boards = targetPlatform.getBoards();
|
||||||
|
|
||||||
if (targetPlatform.getPreferences().get("name") == null || targetPlatform.getOrderedBoards().isEmpty()) {
|
if (targetPlatform.getPreferences().get("name") == null || targetPlatform.getBoards().isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1161,7 +1161,7 @@ public class Base {
|
|||||||
boardsMenu.add(separator);
|
boardsMenu.add(separator);
|
||||||
|
|
||||||
// For every platform cycle through all boards
|
// For every platform cycle through all boards
|
||||||
for (final String boardID : targetPlatform.getOrderedBoards()) {
|
for (final String boardID : targetPlatform.getBoards().keySet()) {
|
||||||
|
|
||||||
PreferencesMap boardAttributes = boards.get(boardID);
|
PreferencesMap boardAttributes = boards.get(boardID);
|
||||||
|
|
||||||
|
@ -24,20 +24,16 @@
|
|||||||
package processing.app.debug;
|
package processing.app.debug;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.tools.MapWithSubkeys;
|
import processing.app.tools.MapWithSubkeys;
|
||||||
import processing.core.PApplet;
|
|
||||||
|
|
||||||
public class TargetPlatform {
|
public class TargetPlatform {
|
||||||
private String name;
|
private String name;
|
||||||
private File folder;
|
private File folder;
|
||||||
private Map<String, PreferencesMap> boards;
|
private Map<String, PreferencesMap> boards;
|
||||||
private List<String> boardsOrder;
|
|
||||||
private Map<String, PreferencesMap> programmers;
|
private Map<String, PreferencesMap> programmers;
|
||||||
private PreferencesMap preferences;
|
private PreferencesMap preferences;
|
||||||
private MapWithSubkeys customMenus;
|
private MapWithSubkeys customMenus;
|
||||||
@ -47,7 +43,6 @@ public class TargetPlatform {
|
|||||||
name = _name;
|
name = _name;
|
||||||
folder = _folder;
|
folder = _folder;
|
||||||
boards = new HashMap<String, PreferencesMap>();
|
boards = new HashMap<String, PreferencesMap>();
|
||||||
boardsOrder = new ArrayList<String>();
|
|
||||||
programmers = new HashMap<String, PreferencesMap>();
|
programmers = new HashMap<String, PreferencesMap>();
|
||||||
preferences = new PreferencesMap();
|
preferences = new PreferencesMap();
|
||||||
|
|
||||||
@ -59,7 +54,6 @@ public class TargetPlatform {
|
|||||||
boards = boardPreferences.createFirstLevelMap();
|
boards = boardPreferences.createFirstLevelMap();
|
||||||
customMenus = MapWithSubkeys.createFrom(boards.get("menu"));
|
customMenus = MapWithSubkeys.createFrom(boards.get("menu"));
|
||||||
boards.remove("menu");
|
boards.remove("menu");
|
||||||
boardsOrder = readBoardsOrder(boardsFile);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -87,32 +81,6 @@ public class TargetPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the ordered list of boards as they appears on the boards.txt file
|
|
||||||
*
|
|
||||||
* @param boardsFile
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<String> readBoardsOrder(File boardsFile) {
|
|
||||||
String[] strings = PApplet.loadStrings(boardsFile);
|
|
||||||
|
|
||||||
List<String> res = new ArrayList<String>();
|
|
||||||
String latestBoard = "-";
|
|
||||||
for (String s : strings) {
|
|
||||||
int dot = s.indexOf('.');
|
|
||||||
if (dot == -1)
|
|
||||||
continue;
|
|
||||||
String board = s.substring(0, dot);
|
|
||||||
if (board.equals(latestBoard))
|
|
||||||
continue;
|
|
||||||
if (!boards.containsKey(board))
|
|
||||||
continue;
|
|
||||||
latestBoard = board;
|
|
||||||
res.add(board);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -129,10 +97,6 @@ public class TargetPlatform {
|
|||||||
return customMenus;
|
return customMenus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getOrderedBoards() {
|
|
||||||
return boardsOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, PreferencesMap> getProgrammers() {
|
public Map<String, PreferencesMap> getProgrammers() {
|
||||||
return programmers;
|
return programmers;
|
||||||
}
|
}
|
||||||
|
@ -28,25 +28,17 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import processing.app.Base;
|
import processing.app.Base;
|
||||||
import processing.core.PApplet;
|
import processing.core.PApplet;
|
||||||
|
|
||||||
public class PreferencesMap extends HashMap<String, String> {
|
public class PreferencesMap extends LinkedHashMap<String, String> {
|
||||||
|
|
||||||
public PreferencesMap(Hashtable<String, String> table) {
|
public PreferencesMap(Map<String, String> table) {
|
||||||
super(table);
|
super(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreferencesMap(PreferencesMap prefs) {
|
|
||||||
super(prefs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PreferencesMap() {
|
public PreferencesMap() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -86,18 +78,18 @@ public class PreferencesMap extends HashMap<String, String> {
|
|||||||
Set<String> keys = new HashSet<String>(keySet());
|
Set<String> keys = new HashSet<String>(keySet());
|
||||||
|
|
||||||
// Override keys that have OS specific versions
|
// Override keys that have OS specific versions
|
||||||
for (String k : keys) {
|
for (String key : keys) {
|
||||||
boolean replace = false;
|
boolean replace = false;
|
||||||
if (Base.isLinux() && k.endsWith(".linux"))
|
if (Base.isLinux() && key.endsWith(".linux"))
|
||||||
replace = true;
|
replace = true;
|
||||||
if (Base.isWindows() && k.endsWith(".windows"))
|
if (Base.isWindows() && key.endsWith(".windows"))
|
||||||
replace = true;
|
replace = true;
|
||||||
if (Base.isMacOS() && k.endsWith(".macos"))
|
if (Base.isMacOS() && key.endsWith(".macos"))
|
||||||
replace = true;
|
replace = true;
|
||||||
if (replace) {
|
if (replace) {
|
||||||
int dot = k.lastIndexOf('.');
|
int dot = key.lastIndexOf('.');
|
||||||
String overridenKey = k.substring(0, dot);
|
String overridenKey = key.substring(0, dot);
|
||||||
put(overridenKey, get(k));
|
put(overridenKey, get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,7 +121,7 @@ public class PreferencesMap extends HashMap<String, String> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<String, PreferencesMap> createFirstLevelMap() {
|
public Map<String, PreferencesMap> createFirstLevelMap() {
|
||||||
Map<String, PreferencesMap> res = new HashMap<String, PreferencesMap>();
|
Map<String, PreferencesMap> res = new LinkedHashMap<String, PreferencesMap>();
|
||||||
for (String key : keySet()) {
|
for (String key : keySet()) {
|
||||||
int dot = key.indexOf('.');
|
int dot = key.indexOf('.');
|
||||||
if (dot == -1)
|
if (dot == -1)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package processing.app.tools;
|
package processing.app.tools;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class MapWithSubkeys {
|
public class MapWithSubkeys {
|
||||||
@ -35,8 +33,8 @@ public class MapWithSubkeys {
|
|||||||
private final Map<String, MapWithSubkeys> maps;
|
private final Map<String, MapWithSubkeys> maps;
|
||||||
|
|
||||||
public MapWithSubkeys() {
|
public MapWithSubkeys() {
|
||||||
this.values = new HashMap<String, String>();
|
this.values = new LinkedHashMap<String, String>();
|
||||||
this.maps = new HashMap<String, MapWithSubkeys>();
|
this.maps = new LinkedHashMap<String, MapWithSubkeys>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getKeys() {
|
public Collection<String> getKeys() {
|
||||||
@ -53,9 +51,11 @@ public class MapWithSubkeys {
|
|||||||
|
|
||||||
public MapWithSubkeys get(String key) {
|
public MapWithSubkeys get(String key) {
|
||||||
if (!maps.containsKey(key)) {
|
if (!maps.containsKey(key)) {
|
||||||
put(key, null);
|
|
||||||
maps.put(key, new MapWithSubkeys());
|
maps.put(key, new MapWithSubkeys());
|
||||||
}
|
}
|
||||||
|
if (!values.containsKey(key)) {
|
||||||
|
put(key, null);
|
||||||
|
}
|
||||||
return maps.get(key);
|
return maps.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user