mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
fixed board and custom menus order
removed readBoardsOrder
This commit is contained in:
parent
9b7f473fae
commit
c851f47d6b
@ -1146,7 +1146,7 @@ public class Base {
|
||||
String platformName = targetPlatform.getName();
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1161,7 +1161,7 @@ public class Base {
|
||||
boardsMenu.add(separator);
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -24,20 +24,16 @@
|
||||
package processing.app.debug;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.tools.MapWithSubkeys;
|
||||
import processing.core.PApplet;
|
||||
|
||||
public class TargetPlatform {
|
||||
private String name;
|
||||
private File folder;
|
||||
private Map<String, PreferencesMap> boards;
|
||||
private List<String> boardsOrder;
|
||||
private Map<String, PreferencesMap> programmers;
|
||||
private PreferencesMap preferences;
|
||||
private MapWithSubkeys customMenus;
|
||||
@ -47,7 +43,6 @@ public class TargetPlatform {
|
||||
name = _name;
|
||||
folder = _folder;
|
||||
boards = new HashMap<String, PreferencesMap>();
|
||||
boardsOrder = new ArrayList<String>();
|
||||
programmers = new HashMap<String, PreferencesMap>();
|
||||
preferences = new PreferencesMap();
|
||||
|
||||
@ -59,7 +54,6 @@ public class TargetPlatform {
|
||||
boards = boardPreferences.createFirstLevelMap();
|
||||
customMenus = MapWithSubkeys.createFrom(boards.get("menu"));
|
||||
boards.remove("menu");
|
||||
boardsOrder = readBoardsOrder(boardsFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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() {
|
||||
return name;
|
||||
}
|
||||
@ -129,10 +97,6 @@ public class TargetPlatform {
|
||||
return customMenus;
|
||||
}
|
||||
|
||||
public List<String> getOrderedBoards() {
|
||||
return boardsOrder;
|
||||
}
|
||||
|
||||
public Map<String, PreferencesMap> getProgrammers() {
|
||||
return programmers;
|
||||
}
|
||||
|
@ -28,25 +28,17 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import processing.app.Base;
|
||||
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);
|
||||
}
|
||||
|
||||
public PreferencesMap(PreferencesMap prefs) {
|
||||
super(prefs);
|
||||
}
|
||||
|
||||
public PreferencesMap() {
|
||||
super();
|
||||
}
|
||||
@ -86,18 +78,18 @@ public class PreferencesMap extends HashMap<String, String> {
|
||||
Set<String> keys = new HashSet<String>(keySet());
|
||||
|
||||
// Override keys that have OS specific versions
|
||||
for (String k : keys) {
|
||||
for (String key : keys) {
|
||||
boolean replace = false;
|
||||
if (Base.isLinux() && k.endsWith(".linux"))
|
||||
if (Base.isLinux() && key.endsWith(".linux"))
|
||||
replace = true;
|
||||
if (Base.isWindows() && k.endsWith(".windows"))
|
||||
if (Base.isWindows() && key.endsWith(".windows"))
|
||||
replace = true;
|
||||
if (Base.isMacOS() && k.endsWith(".macos"))
|
||||
if (Base.isMacOS() && key.endsWith(".macos"))
|
||||
replace = true;
|
||||
if (replace) {
|
||||
int dot = k.lastIndexOf('.');
|
||||
String overridenKey = k.substring(0, dot);
|
||||
put(overridenKey, get(k));
|
||||
int dot = key.lastIndexOf('.');
|
||||
String overridenKey = key.substring(0, dot);
|
||||
put(overridenKey, get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,7 +121,7 @@ public class PreferencesMap extends HashMap<String, String> {
|
||||
* @return
|
||||
*/
|
||||
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()) {
|
||||
int dot = key.indexOf('.');
|
||||
if (dot == -1)
|
||||
|
@ -1,8 +1,6 @@
|
||||
package processing.app.tools;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class MapWithSubkeys {
|
||||
@ -35,8 +33,8 @@ public class MapWithSubkeys {
|
||||
private final Map<String, MapWithSubkeys> maps;
|
||||
|
||||
public MapWithSubkeys() {
|
||||
this.values = new HashMap<String, String>();
|
||||
this.maps = new HashMap<String, MapWithSubkeys>();
|
||||
this.values = new LinkedHashMap<String, String>();
|
||||
this.maps = new LinkedHashMap<String, MapWithSubkeys>();
|
||||
}
|
||||
|
||||
public Collection<String> getKeys() {
|
||||
@ -53,9 +51,11 @@ public class MapWithSubkeys {
|
||||
|
||||
public MapWithSubkeys get(String key) {
|
||||
if (!maps.containsKey(key)) {
|
||||
put(key, null);
|
||||
maps.put(key, new MapWithSubkeys());
|
||||
}
|
||||
if (!values.containsKey(key)) {
|
||||
put(key, null);
|
||||
}
|
||||
return maps.get(key);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user