@@ -959,7 +959,7 @@ public void rebuildImportMenu(JMenu importMenu) {
959
959
//Choose which library to add by chip platform
960
960
961
961
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.
963
963
String platformname = this .getBoardPreferences ().get ("platform" );
964
964
String targetname = this .getPlatformPreferences (platformname ).get ("name" );
965
965
String libraryPath = this .getPlatformPreferences (platformname ).get ("library.core.path" );
@@ -1553,11 +1553,20 @@ static public String getAvrBasePath() {
1553
1553
1554
1554
1555
1555
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 ;
1557
1565
}
1558
1566
1559
1567
1560
1568
static public Map <String , String > getPlatformPreferences () {
1569
+ System .out .println ("getPlatformPreferences() no arguments: start" );
1561
1570
Target target = getTarget ();
1562
1571
//if (target == null) return new LinkedHashMap();
1563
1572
Map map = target .getPlatforms ();
@@ -1576,22 +1585,73 @@ static public Map<String, String> getPlatformPreferences() {
1576
1585
1577
1586
//Get a specific platform
1578
1587
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 );
1579
1593
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 ;
1583
1609
}
1584
1610
1585
- static public Map <String , String > getBoardPreferences () {
1611
+ static public Map <String , String > bogusgetBoardPreferences () {
1612
+ System .out .println ("getBoardPrefences method: start" );
1586
1613
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
+ }
1588
1618
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
+ }
1590
1623
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
+
1592
1643
return map ;
1593
1644
}
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
+ }
1595
1655
1596
1656
static public File getSketchbookFolder () {
1597
1657
return new File (Preferences .get ("sketchbook.path" ));
0 commit comments