@@ -959,7 +959,7 @@ public void rebuildImportMenu(JMenu importMenu) {
959959 //Choose which library to add by chip platform
960960
961961 try {
962- //Find the current target. Get the platform, and then select the correct name and core path.
962+ //Find the current target. Get the platform, and then select the correct name and core path.
963963 String platformname = this .getBoardPreferences ().get ("platform" );
964964 String targetname = this .getPlatformPreferences (platformname ).get ("name" );
965965 String libraryPath = this .getPlatformPreferences (platformname ).get ("library.core.path" );
@@ -1553,11 +1553,20 @@ static public String getAvrBasePath() {
15531553
15541554
15551555 static public Target getTarget () {
1556- return Base .targetsTable .get (Preferences .get ("target" ));
1556+ System .out .println ("Base.targetsTable.get(Preferences.get(\" target\" ))" + Base .targetsTable .get (Preferences .get ("target" )));
1557+ System .out .println ("Preferences.get(\" target\" )" + Preferences .get ("target" ));
1558+ Target target = Base .targetsTable .get (Preferences .get ("target" ));
1559+ if (target == null ) {
1560+ System .out .println ("default target is not in list. Replace with default." );
1561+ Preferences .set ("target" , "arduino" );
1562+ target = Base .targetsTable .get (Preferences .get ("target" ));
1563+ }
1564+ return target ;
15571565 }
15581566
15591567
15601568static public Map <String , String > getPlatformPreferences () {
1569+ System .out .println ("getPlatformPreferences() no arguments: start" );
15611570 Target target = getTarget ();
15621571 //if (target == null) return new LinkedHashMap();
15631572 Map map = target .getPlatforms ();
@@ -1576,22 +1585,73 @@ static public Map<String, String> getPlatformPreferences() {
15761585
15771586 //Get a specific platform
15781587 static public Map <String , String > getPlatformPreferences (String platformname ) {
1588+ if (platformname == null ) {
1589+ platformname = Preferences .get ("platform" );
1590+
1591+ }
1592+ System .out .println ("getlatformPreferences(String platformname)): start: platformname = " + platformname );
15791593 Target target = getTarget ();
1580- Map map = target .getPlatforms ();
1581- map = (Map ) map .get (platformname );
1582- return map ;
1594+ if (target == null ) {
1595+ System .out .println ("get target is null. trouble! " );
1596+ }
1597+ Map map = target .getPlatforms ();
1598+ map = (Map ) map .get (platformname );
1599+
1600+ //What if null or defaults to nonexisent platform
1601+ System .out .println ("PlatformName: " + platformname );
1602+ if (map == null )
1603+ {
1604+ System .err .println ("Error loading platforms preference from Target" );
1605+ System .exit (0 );
1606+ }
1607+
1608+ return map ;
15831609 }
15841610
1585- static public Map <String , String > getBoardPreferences () {
1611+ static public Map <String , String > bogusgetBoardPreferences () {
1612+ System .out .println ("getBoardPrefences method: start" );
15861613 Target target = getTarget ();
1587- if (target == null ) return new LinkedHashMap ();
1614+ if (target == null ) {
1615+ System .out .println ("getBoardPrefereces method: target == null" );
1616+ return new LinkedHashMap ();
1617+ }
15881618 Map map = target .getBoards ();
1589- if (map == null ) return new LinkedHashMap ();
1619+ if (map == null ) {
1620+ System .out .println ("getBoardPrefereces method: target.getBoards() == null" );
1621+ return new LinkedHashMap ();
1622+ }
15901623 map = (Map ) map .get (Preferences .get ("board" ));
1591- if (map == null ) return new LinkedHashMap ();
1624+ if (map == null ) {
1625+ System .out .println ("getBoardPrefereces method: Preferences.get(board) == null" );
1626+ return new LinkedHashMap ();
1627+ }
1628+ //Debug iterate the map
1629+ Iterator iterator = map .entrySet ().iterator ();
1630+ while (iterator .hasNext ())
1631+ {
1632+ Map .Entry pair = (Map .Entry )iterator .next ();
1633+ if (pair .getValue () == null )
1634+ {
1635+ System .out .println ("KeyName: " + pair .getKey () + " val: null" );
1636+ }
1637+ else
1638+ {
1639+ System .out .println ("KeyName: " + pair .getKey () + " val" + pair .getValue ());
1640+ }
1641+ }
1642+
15921643 return map ;
15931644 }
1594-
1645+
1646+ static public Map <String , String > getBoardPreferences () {
1647+ Target target = getTarget ();
1648+ Map map = new LinkedHashMap ();
1649+ if (target != null ) {
1650+ map = target .getBoards ();
1651+ map = (Map ) map .get (Preferences .get ("board" ));
1652+ }
1653+ return map ;
1654+ }
15951655
15961656 static public File getSketchbookFolder () {
15971657 return new File (Preferences .get ("sketchbook.path" ));
0 commit comments