mirror of https://github.com/noisymime/Arduino.git
Moved getBoardPreferences() and related methods from Base to BaseNoGui (work in progress).
This commit is contained in:
parent
4c1b187313
commit
4443911746
|
@ -2091,20 +2091,7 @@ public class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public PreferencesMap getBoardPreferences() {
|
static public PreferencesMap getBoardPreferences() {
|
||||||
TargetBoard board = getTargetBoard();
|
return BaseNoGui.getBoardPreferences();
|
||||||
|
|
||||||
PreferencesMap prefs = new PreferencesMap(board.getPreferences());
|
|
||||||
for (String menuId : board.getMenuIds()) {
|
|
||||||
String entry = Preferences.get("custom_" + menuId);
|
|
||||||
if (board.hasMenu(menuId) && entry != null &&
|
|
||||||
entry.startsWith(board.getId())) {
|
|
||||||
String selectionId = entry.substring(entry.indexOf("_") + 1);
|
|
||||||
prefs.putAll(board.getMenuPreferences(menuId, selectionId));
|
|
||||||
prefs.put("name", prefs.get("name") + ", " +
|
|
||||||
board.getMenuLabel(menuId, selectionId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return prefs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TargetBoard getTargetBoard() {
|
public static TargetBoard getTargetBoard() {
|
||||||
|
|
|
@ -7,10 +7,12 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import processing.app.debug.TargetBoard;
|
||||||
import processing.app.debug.TargetPackage;
|
import processing.app.debug.TargetPackage;
|
||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
import processing.app.debug.TargetPlatformException;
|
import processing.app.debug.TargetPlatformException;
|
||||||
import processing.app.helpers.OSUtils;
|
import processing.app.helpers.OSUtils;
|
||||||
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.helpers.filefilters.OnlyDirs;
|
import processing.app.helpers.filefilters.OnlyDirs;
|
||||||
|
|
||||||
public class BaseNoGui {
|
public class BaseNoGui {
|
||||||
|
@ -54,6 +56,23 @@ public class BaseNoGui {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public PreferencesMap getBoardPreferences() {
|
||||||
|
TargetBoard board = getTargetBoard();
|
||||||
|
|
||||||
|
PreferencesMap prefs = new PreferencesMap(board.getPreferences());
|
||||||
|
for (String menuId : board.getMenuIds()) {
|
||||||
|
String entry = Preferences.get("custom_" + menuId);
|
||||||
|
if (board.hasMenu(menuId) && entry != null &&
|
||||||
|
entry.startsWith(board.getId())) {
|
||||||
|
String selectionId = entry.substring(entry.indexOf("_") + 1);
|
||||||
|
prefs.putAll(board.getMenuPreferences(menuId, selectionId));
|
||||||
|
prefs.put("name", prefs.get("name") + ", " +
|
||||||
|
board.getMenuLabel(menuId, selectionId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
|
||||||
static public File getContentFile(String name) {
|
static public File getContentFile(String name) {
|
||||||
String path = System.getProperty("user.dir");
|
String path = System.getProperty("user.dir");
|
||||||
|
|
||||||
|
@ -99,6 +118,11 @@ public class BaseNoGui {
|
||||||
return new File(getSketchbookFolder(), "hardware");
|
return new File(getSketchbookFolder(), "hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TargetBoard getTargetBoard() {
|
||||||
|
String boardId = Preferences.get("board");
|
||||||
|
return getTargetPlatform().getBoard(boardId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently selected TargetPlatform.
|
* Returns the currently selected TargetPlatform.
|
||||||
*
|
*
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class Compiler implements MessageConsumer {
|
||||||
String _primaryClassName)
|
String _primaryClassName)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
|
|
||||||
if (Base.getBoardPreferences() == null) {
|
if (BaseNoGui.getBoardPreferences() == null) {
|
||||||
RunnerException re = new RunnerException(
|
RunnerException re = new RunnerException(
|
||||||
_("No board selected; please choose a board from the Tools > Board menu."));
|
_("No board selected; please choose a board from the Tools > Board menu."));
|
||||||
re.hideStackTrace();
|
re.hideStackTrace();
|
||||||
|
@ -188,12 +188,12 @@ public class Compiler implements MessageConsumer {
|
||||||
// Check if the board needs a platform from another package
|
// Check if the board needs a platform from another package
|
||||||
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
|
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
|
||||||
TargetPlatform corePlatform = null;
|
TargetPlatform corePlatform = null;
|
||||||
PreferencesMap boardPreferences = Base.getBoardPreferences();
|
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
|
||||||
String core = boardPreferences.get("build.core");
|
String core = boardPreferences.get("build.core");
|
||||||
if (core.contains(":")) {
|
if (core.contains(":")) {
|
||||||
String[] split = core.split(":");
|
String[] split = core.split(":");
|
||||||
core = split[1];
|
core = split[1];
|
||||||
corePlatform = Base.getTargetPlatform(split[0], targetPlatform.getId());
|
corePlatform = BaseNoGui.getTargetPlatform(split[0], targetPlatform.getId());
|
||||||
if (corePlatform == null) {
|
if (corePlatform == null) {
|
||||||
RunnerException re = new RunnerException(I18n
|
RunnerException re = new RunnerException(I18n
|
||||||
.format(_("Selected board depends on '{0}' core (not installed)."),
|
.format(_("Selected board depends on '{0}' core (not installed)."),
|
||||||
|
@ -209,7 +209,7 @@ public class Compiler implements MessageConsumer {
|
||||||
if (corePlatform != null)
|
if (corePlatform != null)
|
||||||
p.putAll(corePlatform.getPreferences());
|
p.putAll(corePlatform.getPreferences());
|
||||||
p.putAll(targetPlatform.getPreferences());
|
p.putAll(targetPlatform.getPreferences());
|
||||||
p.putAll(Base.getBoardPreferences());
|
p.putAll(BaseNoGui.getBoardPreferences());
|
||||||
for (String k : p.keySet()) {
|
for (String k : p.keySet()) {
|
||||||
if (p.get(k) == null)
|
if (p.get(k) == null)
|
||||||
p.put(k, "");
|
p.put(k, "");
|
||||||
|
@ -250,7 +250,7 @@ public class Compiler implements MessageConsumer {
|
||||||
t = targetPlatform;
|
t = targetPlatform;
|
||||||
} else {
|
} else {
|
||||||
String[] split = variant.split(":", 2);
|
String[] split = variant.split(":", 2);
|
||||||
t = Base.getTargetPlatform(split[0], targetPlatform.getId());
|
t = BaseNoGui.getTargetPlatform(split[0], targetPlatform.getId());
|
||||||
variant = split[1];
|
variant = split[1];
|
||||||
}
|
}
|
||||||
File variantFolder = new File(t.getFolder(), "variants");
|
File variantFolder = new File(t.getFolder(), "variants");
|
||||||
|
|
Loading…
Reference in New Issue