mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Reordered boards menu
This commit is contained in:
parent
b2f1bce2ac
commit
2f8e766588
@ -1113,7 +1113,10 @@ public class Base {
|
||||
String selBoard = Preferences.get("board");
|
||||
|
||||
menu.removeAll();
|
||||
boolean first = true;
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
|
||||
// Cycle through all packages
|
||||
for (TargetPackage targetPackage : packages.values()) {
|
||||
String packageName = targetPackage.getName();
|
||||
@ -1123,8 +1126,16 @@ public class Base {
|
||||
String platformName = targetPlatform.getName();
|
||||
Map<String, PreferencesMap> boards = targetPlatform.getBoards();
|
||||
|
||||
// For every platform cycle throug all boards
|
||||
for (String board : boards.keySet()) {
|
||||
// Add a title for each group of boards
|
||||
if (!first)
|
||||
menu.add(new JSeparator());
|
||||
first = false;
|
||||
JMenuItem separator = new JMenuItem(targetPlatform.getPreferences().get("name"));
|
||||
separator.setEnabled(false);
|
||||
menu.add(separator);
|
||||
|
||||
// For every platform cycle through all boards
|
||||
for (String board : targetPlatform.getOrderedBoards()) {
|
||||
|
||||
// Setup a menu item for the current board
|
||||
String boardName = boards.get(board).get("name");
|
||||
|
@ -24,15 +24,19 @@
|
||||
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.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;
|
||||
|
||||
@ -50,6 +54,7 @@ public class TargetPlatform {
|
||||
PreferencesMap boardPreferences = new PreferencesMap();
|
||||
boardPreferences.load(boardsFile);
|
||||
boards = boardPreferences.createFirstLevelMap();
|
||||
boardsOrder = readBoardsOrder(boardsFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error loading boards from boards.txt: " + e);
|
||||
@ -76,6 +81,32 @@ 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;
|
||||
}
|
||||
@ -87,6 +118,10 @@ public class TargetPlatform {
|
||||
public Map<String, PreferencesMap> getBoards() {
|
||||
return boards;
|
||||
}
|
||||
|
||||
public List<String> getOrderedBoards() {
|
||||
return boardsOrder;
|
||||
}
|
||||
|
||||
public Map<String, PreferencesMap> getProgrammers() {
|
||||
return programmers;
|
||||
|
@ -2,7 +2,7 @@
|
||||
# AVR compile variables
|
||||
# ---------------------
|
||||
|
||||
name=Arduino
|
||||
name=Arduino AVR Boards
|
||||
# Default "compiler.path" is correct, change only if you want to overidde the initial value
|
||||
#compiler.path={ide.path}/tools/avr/bin/..
|
||||
compiler.c.cmd=avr-gcc
|
||||
|
@ -2,7 +2,7 @@
|
||||
# SAM3 compile variables
|
||||
# ---------------------
|
||||
|
||||
name=Atmel SAM3
|
||||
name=Arduino ARM (32-bits) Boards
|
||||
compiler.path={runtime.ide.path}/hardware/tools/g++_arm_none_eabi/bin/
|
||||
#compiler.path=C:/arm-none-eabi-gcc-4_6/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
|
Loading…
x
Reference in New Issue
Block a user