26
26
import java .awt .event .*;
27
27
import java .io .*;
28
28
import java .util .*;
29
+ import java .util .List ;
29
30
30
31
import javax .swing .*;
31
32
@@ -48,7 +49,7 @@ public class Base {
48
49
/** Set true if this a proper release rather than a numbered revision. */
49
50
static public boolean RELEASE = false ;
50
51
51
- static HashMap <Integer , String > platformNames = new HashMap <Integer , String >();
52
+ static Map <Integer , String > platformNames = new HashMap <Integer , String >();
52
53
static {
53
54
platformNames .put (PConstants .WINDOWS , "windows" );
54
55
platformNames .put (PConstants .MACOSX , "macosx" );
@@ -78,19 +79,18 @@ public class Base {
78
79
static private File examplesFolder ;
79
80
static private File librariesFolder ;
80
81
static private File toolsFolder ;
81
- static private File hardwareFolder ;
82
82
83
- static HashSet <File > libraries ;
83
+ static Set <File > libraries ;
84
84
85
85
// maps imported packages to their library folder
86
- static HashMap <String , File > importToLibraryTable ;
86
+ static Map <String , File > importToLibraryTable ;
87
87
88
88
// classpath for all known libraries for p5
89
89
// (both those in the p5/libs folder and those with lib subfolders
90
90
// found in the sketchbook)
91
91
static public String librariesClassPath ;
92
92
93
- static public HashMap <String , Target > targetsTable ;
93
+ static public Map <String , Target > targetsTable ;
94
94
95
95
// Location for untitled items
96
96
static File untitledFolder ;
@@ -99,10 +99,7 @@ public class Base {
99
99
// static Image icon;
100
100
101
101
// int editorCount;
102
- // Editor[] editors;
103
- java .util .List <Editor > editors =
104
- Collections .synchronizedList (new ArrayList <Editor >());
105
- // ArrayList editors = Collections.synchronizedList(new ArrayList<Editor>());
102
+ List <Editor > editors = Collections .synchronizedList (new ArrayList <Editor >());
106
103
Editor activeEditor ;
107
104
108
105
@@ -956,17 +953,19 @@ public void rebuildImportMenu(JMenu importMenu) {
956
953
//Choose which library to add by chip platform
957
954
958
955
try {
959
- //Find the current target. Get the platform, and then select the correct name and core path.
960
- String platformname = this .getBoardPreferences ().get ("platform" );
961
- String targetname = this .getPlatformPreferences (platformname ).get ("name" );
962
- String libraryPath = this .getPlatformPreferences (platformname ).get ("library.core.path" );
956
+ // Find the current target. Get the platform, and then select the
957
+ // correct name and core path.
958
+ String platformname = getBoardPreferences ().get ("platform" );
959
+ String targetname = getPlatformPreferences (platformname )
960
+ .get ("name" );
961
+ String libraryPath = getPlatformPreferences (platformname ).get (
962
+ "library.core.path" );
963
963
964
964
JMenuItem platformItem = new JMenuItem (targetname );
965
965
platformItem .setEnabled (false );
966
966
importMenu .add (platformItem );
967
967
importMenu .addSeparator ();
968
968
addLibraries (importMenu , getCoreLibraries (libraryPath ));
969
-
970
969
} catch (IOException e ) {
971
970
e .printStackTrace ();
972
971
}
@@ -1574,91 +1573,28 @@ static public Target getTarget() {
1574
1573
}
1575
1574
1576
1575
1577
- static public Map <String , String > getPlatformPreferences () {
1578
- System .out .println ("getPlatformPreferences() no arguments: start" );
1576
+ static public PreferencesMap getPlatformPreferences () {
1579
1577
Target target = getTarget ();
1580
- //if (target == null) return new LinkedHashMap();
1581
- Map map = target .getPlatforms ();
1582
- /*
1583
- if (map == null)
1584
- {
1585
- System.err.println("Error loading platforms preference from Target");
1586
- System.exit(0);
1587
- }
1588
- */
1589
- //if (map == null) return new LinkedHashMap();
1590
- map = (Map ) map .get (Preferences .get ("platform" ));
1591
- //if (map == null) return new LinkedHashMap();
1592
- return map ;
1578
+ Map <String , PreferencesMap > platforms = target .getPlatforms ();
1579
+ return platforms .get (Preferences .get ("platform" ));
1593
1580
}
1594
1581
1595
1582
//Get a specific platform
1596
- static public Map <String , String > getPlatformPreferences (String platformname ) {
1597
- if (platformname == null ) {
1598
- platformname = Preferences .get ("platform" );
1599
-
1600
- }
1601
- System .out .println ("getlatformPreferences(String platformname)): start: platformname = " + platformname );
1583
+ static public PreferencesMap getPlatformPreferences (String platformName ) {
1584
+ if (platformName == null )
1585
+ platformName = Preferences .get ("platform" );
1602
1586
Target target = getTarget ();
1603
- if (target == null ) {
1604
- System .out .println ("get target is null. trouble! " );
1605
- }
1606
- Map map = target .getPlatforms ();
1607
- map = (Map ) map .get (platformname );
1608
-
1609
- //What if null or defaults to nonexisent platform
1610
- System .out .println ("PlatformName: " + platformname );
1611
- if (map == null )
1612
- {
1613
- System .err .println ("Error loading platforms preference from Target" );
1614
- System .exit (0 );
1615
- }
1616
-
1617
- return map ;
1618
- }
1619
-
1620
- static public Map <String , String > bogusgetBoardPreferences () {
1621
- System .out .println ("getBoardPrefences method: start" );
1622
- Target target = getTarget ();
1623
- if (target == null ) {
1624
- System .out .println ("getBoardPrefereces method: target == null" );
1625
- return new LinkedHashMap ();
1626
- }
1627
- Map map = target .getBoards ();
1628
- if (map == null ) {
1629
- System .out .println ("getBoardPrefereces method: target.getBoards() == null" );
1630
- return new LinkedHashMap ();
1631
- }
1632
- map = (Map ) map .get (Preferences .get ("board" ));
1633
- if (map == null ) {
1634
- System .out .println ("getBoardPrefereces method: Preferences.get(board) == null" );
1635
- return new LinkedHashMap ();
1636
- }
1637
- //Debug iterate the map
1638
- Iterator iterator = map .entrySet ().iterator ();
1639
- while (iterator .hasNext ())
1640
- {
1641
- Map .Entry pair = (Map .Entry )iterator .next ();
1642
- if (pair .getValue () == null )
1643
- {
1644
- System .out .println ("KeyName: " + pair .getKey () + " val: null" );
1645
- }
1646
- else
1647
- {
1648
- System .out .println ("KeyName: " + pair .getKey () + " val" + pair .getValue ());
1649
- }
1650
- }
1651
-
1652
- return map ;
1587
+ Map <String , PreferencesMap > platforms = target .getPlatforms ();
1588
+ return platforms .get (platformName );
1653
1589
}
1654
1590
1655
- static public Map < String , String > getBoardPreferences () {
1591
+ static public PreferencesMap getBoardPreferences () {
1656
1592
Target target = getTarget ();
1657
1593
if (target != null ) {
1658
1594
String board = Preferences .get ("board" );
1659
1595
return target .getBoards ().get (board );
1660
1596
}
1661
- return new HashMap < String , String > ();
1597
+ return new PreferencesMap ();
1662
1598
}
1663
1599
1664
1600
static public File getSketchbookFolder () {
0 commit comments