@@ -128,19 +128,9 @@ public String[] getMenuItemNamesFromMenuID(String menuID, String boardID) {
128
128
return new String [0 ];
129
129
}
130
130
131
- String SearchKey = menuID + DOT + boardID + DOT ;
132
- SearchKey = SearchKey .toUpperCase ();
133
- for (Entry <String , String > e2 : menuInfo .entrySet ()) {
134
- int numsubkeys = e2 .getKey ().split ("\\ ." ).length ; //$NON-NLS-1$
135
- boolean startOk = e2 .getKey ().toUpperCase ().startsWith (SearchKey );
136
- if ((numsubkeys == 3 ) && (startOk ))
137
- ret .add (e2 .getValue ());
138
- }
139
- // from Arduino IDE 1.5.4 menu is subset of the board. The previous code
140
- // will not return a result
141
131
Map <String , String > boardInfo = this .fileContent .get (boardID );
142
132
if (boardInfo != null ) {
143
- SearchKey = MENU + DOT + menuID + DOT ;
133
+ String SearchKey = MENU + DOT + menuID + DOT ;
144
134
SearchKey = SearchKey .toUpperCase ();
145
135
for (Entry <String , String > e2 : boardInfo .entrySet ()) {
146
136
int numsubkeys = e2 .getKey ().split ("\\ ." ).length ; //$NON-NLS-1$
@@ -152,6 +142,38 @@ public String[] getMenuItemNamesFromMenuID(String menuID, String boardID) {
152
142
return ret .toArray (new String [ret .size ()]);
153
143
}
154
144
145
+ /**
146
+ * Get all the acceptable values for a option for a board The outcome of
147
+ * this method can be used to fill a
148
+ *
149
+ * @param menu
150
+ * the id of a menu not the name
151
+ * @param boardID
152
+ * the id of a board not the name
153
+ * @return The IDs that are the possible selections
154
+ */
155
+ public String [] getMenuItemIDsFromMenuID (String menuID , String boardID ) {
156
+ HashSet <String > ret = new HashSet <>();
157
+ Map <String , String > menuInfo = this .fileContent .get (MENU );
158
+ if (menuInfo == null ) {
159
+ return new String [0 ];
160
+ }
161
+
162
+ Map <String , String > boardInfo = this .fileContent .get (boardID );
163
+ if (boardInfo != null ) {
164
+ String SearchKey = MENU + DOT + menuID + DOT ;
165
+ SearchKey = SearchKey .toUpperCase ();
166
+ for (Entry <String , String > e2 : boardInfo .entrySet ()) {
167
+ String [] subKeys = e2 .getKey ().split ("\\ ." );//$NON-NLS-1$
168
+ int numsubkeys = subKeys .length ;
169
+ boolean startOk = e2 .getKey ().toUpperCase ().startsWith (SearchKey );
170
+ if ((numsubkeys == 3 ) && (startOk ))
171
+ ret .add (subKeys [2 ]);
172
+ }
173
+ }
174
+ return ret .toArray (new String [ret .size ()]);
175
+ }
176
+
155
177
/**
156
178
* this is public String[] getAllNames(String[] toaddNames) with a empty
157
179
* toaddnames
@@ -177,7 +199,7 @@ public String[] getAllNames() {
177
199
*
178
200
*/
179
201
public String [] getAllNames (String [] toaddNames ) {
180
- if (this .mLastLoadedTxtFile .equals (Const . EMPTY_STRING )) {
202
+ if (this .mLastLoadedTxtFile .equals (new String () )) {
181
203
return toaddNames ;
182
204
}
183
205
HashSet <String > allNames = new HashSet <>();
@@ -347,9 +369,11 @@ public File getTxtFile() {
347
369
348
370
public String getMenuNameFromID (String menuID ) {
349
371
Map <String , String > menuSectionMap = getSection (MENU );
350
- for (Entry <String , String > curOption : menuSectionMap .entrySet ()) {
351
- if (curOption .getKey ().equalsIgnoreCase (menuID )) {
352
- return curOption .getValue ();
372
+ if (menuSectionMap != null ) {
373
+ for (Entry <String , String > curOption : menuSectionMap .entrySet ()) {
374
+ if (curOption .getKey ().equalsIgnoreCase (menuID )) {
375
+ return curOption .getValue ();
376
+ }
353
377
}
354
378
}
355
379
return MENU + " ID " + menuID + Messages .Boards_not_found ; //$NON-NLS-1$
@@ -378,7 +402,7 @@ public String getMenuItemNameFromMenuItemID(String boardID, String menuID, Strin
378
402
public String getNameFromID (String myBoardID ) {
379
403
Map <String , String > boardSection = getSection (myBoardID );
380
404
if (boardSection == null ) {
381
- return Const . EMPTY_STRING ;
405
+ return new String () ;
382
406
}
383
407
return boardSection .get ("name" ); //$NON-NLS-1$
384
408
}
0 commit comments