Skip to content

Commit 97e9f65

Browse files
author
jan
committed
Ordering is compliant with order in Boards.txt #1450
1 parent b699016 commit 97e9f65

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

io.sloeber.core/src/io/sloeber/core/txt/BoardTxtFile.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public String getMenuItemIDFromMenuItemName(String boardID, String menuID, Strin
5353
* @return The nice names that are the possible selections
5454
*/
5555
public String[] getMenuItemNamesFromMenuID(String menuID, String boardID) {
56-
HashSet<String> ret = new HashSet<>();
56+
List<String> ret = new LinkedList<>();
5757

5858
KeyValueTree boardMenuInfo = myData.getChild(boardID + DOT + MENU + DOT + menuID);
5959
for (KeyValueTree menuData : boardMenuInfo.getChildren().values()) {
@@ -174,7 +174,7 @@ public String[] getAllSectionNames() {
174174
*/
175175
public String[] getAllSectionNames(String[] toaddNames) {
176176

177-
HashSet<String> allNames = new HashSet<>();
177+
LinkedList<String> allNames = new LinkedList<>();
178178
for (String curName : toaddNames) {
179179
allNames.add(curName);
180180
}
@@ -186,10 +186,7 @@ public String[] getAllSectionNames(String[] toaddNames) {
186186
}
187187
}
188188
}
189-
String[] sBoards = new String[allNames.size()];
190-
allNames.toArray(sBoards);
191-
Arrays.sort(sBoards);
192-
return sBoards;
189+
return allNames.toArray( new String[allNames.size()]);
193190
}
194191

195192
public List<String> getAllBoardIDs() {

io.sloeber.core/src/io/sloeber/core/txt/KeyValueTree.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private String dump(KeyValueTree theRoot) {
110110

111111
private Map<String, String> toKeyValues(String prefix, KeyValueTree theRoot) {
112112

113-
Map<String, String> ret = new HashMap<>();
113+
Map<String, String> ret = new LinkedHashMap<>();
114114
Entry<String, String> firstEntry = this.toKeyValue(prefix, theRoot);
115115
if (firstEntry != null) {
116116
ret.put(firstEntry.getKey(), firstEntry.getValue());

io.sloeber.ui/src/io/sloeber/ui/project/properties/BoardSelectionPage.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void handleEvent(Event e) {
8686

8787

8888
genericListenerEnd();
89-
setTheLabelCombos(true,true);
89+
setTheLabelCombos(true);
9090
}
9191

9292
};
@@ -99,7 +99,7 @@ public void handleEvent(Event e) {
9999
}
100100

101101
genericListenerEnd();
102-
setTheLabelCombos(true,true);
102+
setTheLabelCombos(true);
103103
}
104104
};
105105
protected Listener myChangeListener = new Listener() {
@@ -195,6 +195,7 @@ public void handleEvent(Event e) {
195195
myControlUploadProtocol.addListener(myChangeListener);
196196
myControlUploadPort.addListener(myChangeListener);
197197
genericListenerEnd();
198+
setTheLabelCombos(true);
198199

199200
}
200201

@@ -284,7 +285,7 @@ protected void updateScreen(boolean updateData) {
284285
}
285286

286287
myControlUploadPort.setText(myBoardDesc.getUploadPort());
287-
setTheLabelCombos( boardsFileChanged , boardIDChanged);
288+
setTheLabelCombos( boardsFileChanged || boardIDChanged);
288289
disableListeners = false;
289290
}
290291

@@ -300,9 +301,9 @@ private void getBoardFromScreen() {
300301
}
301302
}
302303

303-
private void setTheLabelCombos( boolean boardsFileChanged ,boolean boardIDChanged) {
304+
private void setTheLabelCombos(boolean recreateOptions) {
304305
saveUsedOptionValues();
305-
if (boardsFileChanged || boardIDChanged) {
306+
if (recreateOptions) {
306307
for (LabelCombo labelCombo : myBoardOptionCombos.values()) {
307308
labelCombo.dispose();
308309
}
@@ -328,8 +329,8 @@ private void setTheLabelCombos( boolean boardsFileChanged ,boolean boardIDChang
328329
} else {
329330
// use last used name for this menu ID
330331
optionValue = myUsedOptionValues.get(menuID);
331-
if(optionValue==null) {
332-
optionValue = myBoardDesc.getDefaultValueNameFromMenu( menuID);
332+
if (optionValue == null) {
333+
optionValue = myBoardDesc.getDefaultValueNameFromMenu(menuID);
333334
}
334335
}
335336
if (optionValue != null) {

0 commit comments

Comments
 (0)