mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Majority of non Compiler.java changes made.
This commit is contained in:
parent
41600a22eb
commit
fa268259a0
@ -956,8 +956,20 @@ public class Base {
|
||||
importToLibraryTable = new HashMap<String, File>();
|
||||
|
||||
// Add from the "libraries" subfolder in the Processing directory
|
||||
//Choose which library to add by chip platform
|
||||
|
||||
try {
|
||||
addLibraries(importMenu, librariesFolder);
|
||||
//Find the current target. Get the platform, and then select the correct name and core path.
|
||||
String platformname = this.getBoardPreferences().get("platform");
|
||||
String targetname = this.getPlatformPreferences(platformname).get("name");
|
||||
String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path");
|
||||
|
||||
JMenuItem platformItem = new JMenuItem(targetname);
|
||||
platformItem.setEnabled(false);
|
||||
importMenu.add(platformItem);
|
||||
importMenu.addSeparator();
|
||||
addLibraries(importMenu, getCoreLibraries(libraryPath));
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1005,6 +1017,8 @@ public class Base {
|
||||
//System.out.println("Switching to " + target + ":" + board);
|
||||
Preferences.set("target", (String) getValue("target"));
|
||||
Preferences.set("board", (String) getValue("board"));
|
||||
//Debug: created new imports menu based on board
|
||||
rebuildImportMenu(activeEditor.importMenu);
|
||||
}
|
||||
};
|
||||
action.putValue("target", target.getName());
|
||||
@ -1518,6 +1532,10 @@ public class Base {
|
||||
return getContentFile("hardware");
|
||||
}
|
||||
|
||||
//Get the core libraries
|
||||
static public File getCoreLibraries(String path) {
|
||||
return getContentFile(path);
|
||||
}
|
||||
|
||||
static public String getHardwarePath() {
|
||||
return getHardwareFolder().getAbsolutePath();
|
||||
@ -1538,7 +1556,32 @@ public class Base {
|
||||
return Base.targetsTable.get(Preferences.get("target"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static public Map<String, String> getPlatformPreferences() {
|
||||
Target target = getTarget();
|
||||
//if (target == null) return new LinkedHashMap();
|
||||
Map map = target.getPlatforms();
|
||||
/*
|
||||
if (map == null)
|
||||
{
|
||||
System.err.println("Error loading platforms preference from Target");
|
||||
System.exit(0);
|
||||
}
|
||||
*/
|
||||
//if (map == null) return new LinkedHashMap();
|
||||
map = (Map) map.get(Preferences.get("platform"));
|
||||
//if (map == null) return new LinkedHashMap();
|
||||
return map;
|
||||
}
|
||||
|
||||
//Get a specific platform
|
||||
static public Map<String, String> getPlatformPreferences(String platformname) {
|
||||
Target target = getTarget();
|
||||
Map map = target.getPlatforms();
|
||||
map = (Map) map.get(platformname);
|
||||
return map;
|
||||
}
|
||||
|
||||
static public Map<String, String> getBoardPreferences() {
|
||||
Target target = getTarget();
|
||||
if (target == null) return new LinkedHashMap();
|
||||
|
@ -684,6 +684,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
if (boardsMenu == null) {
|
||||
boardsMenu = new JMenu("Board");
|
||||
base.rebuildBoardsMenu(boardsMenu);
|
||||
//Debug: rebuild imports
|
||||
importMenu.removeAll();
|
||||
base.rebuildImportMenu(importMenu);
|
||||
}
|
||||
menu.add(boardsMenu);
|
||||
|
||||
|
@ -776,4 +776,22 @@ public class Preferences {
|
||||
|
||||
return new SyntaxStyle(color, italic, bold);
|
||||
}
|
||||
|
||||
//get a Map of the Preferences
|
||||
static public Map<String, String> getMap()
|
||||
{
|
||||
Map globalpreferences = new LinkedHashMap();
|
||||
Enumeration e = table.keys();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
String key = (String) e.nextElement();
|
||||
//System.out.println("Key: " + key + "Val: " + table.get(key));
|
||||
String value = (String) table.get(key);
|
||||
globalpreferences.put(key, value );
|
||||
}
|
||||
|
||||
return globalpreferences;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1328,10 +1328,14 @@ public class Sketch {
|
||||
// grab the imports from the code just preproc'd
|
||||
|
||||
importedLibraries = new ArrayList<File>();
|
||||
|
||||
//Remember to clear library path before building it.
|
||||
libraryPath = "";
|
||||
for (String item : preprocessor.getExtraImports()) {
|
||||
File libFolder = (File) Base.importToLibraryTable.get(item);
|
||||
|
||||
File libFolder = (File) Base.importToLibraryTable.get(item);
|
||||
//Debug libraryPath
|
||||
|
||||
if (libFolder != null && !importedLibraries.contains(libFolder)) {
|
||||
importedLibraries.add(libFolder);
|
||||
//classPath += Compiler.contentsToClassPath(libFolder);
|
||||
|
@ -29,18 +29,21 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import processing.app.Preferences;
|
||||
//import processing.app.Base;
|
||||
|
||||
public class Target {
|
||||
private String name;
|
||||
private File folder;
|
||||
private Map boards;
|
||||
private Map programmers;
|
||||
|
||||
private Map platforms;
|
||||
|
||||
public Target(String name, File folder) {
|
||||
this.name = name;
|
||||
this.folder = folder;
|
||||
this.boards = new LinkedHashMap();
|
||||
this.programmers = new LinkedHashMap();
|
||||
this.platforms = new LinkedHashMap();
|
||||
|
||||
File boardsFile = new File(folder, "boards.txt");
|
||||
try {
|
||||
@ -60,6 +63,28 @@ public class Target {
|
||||
System.err.println("Error loading boards from " + boardsFile + ": " + e);
|
||||
}
|
||||
|
||||
File platformsFile = new File(folder,"platforms.txt");
|
||||
try
|
||||
{
|
||||
if(platformsFile.exists()){
|
||||
Map platformPreferences = new LinkedHashMap();
|
||||
Preferences.load(new FileInputStream(platformsFile), platformPreferences);
|
||||
for(Object k : platformPreferences.keySet())
|
||||
{
|
||||
String key=(String) k;
|
||||
String platform=key.substring(0,key.indexOf('.'));
|
||||
if (!platforms.containsKey(platform)) platforms.put(platform, new HashMap());
|
||||
((Map) platforms.get(platform)).put(key.substring(key.indexOf('.') + 1),platformPreferences.get(key));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error loading platforms from " +
|
||||
platformsFile + ": " + e);
|
||||
// System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
File programmersFile = new File(folder, "programmers.txt");
|
||||
try {
|
||||
if (programmersFile.exists()) {
|
||||
@ -88,4 +113,8 @@ public class Target {
|
||||
public Map<String, Map<String, String>> getProgrammers() {
|
||||
return programmers;
|
||||
}
|
||||
}
|
||||
public Map<String, Map<String, String>> getPlatforms() {
|
||||
return platforms;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user