Skip to content

Commit a105e2e

Browse files
author
jantje
committed
#1343 #1333 #1321 still problems with multiple configs
The environment variables are causing problems due to racing conditions
1 parent f952747 commit a105e2e

File tree

10 files changed

+383
-358
lines changed

10 files changed

+383
-358
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.util.List;
1111
import java.util.Map;
1212
import java.util.Map.Entry;
13-
import java.util.Set;
1413
import java.util.TreeMap;
1514

1615
import org.eclipse.cdt.core.parser.util.StringUtil;
@@ -530,9 +529,6 @@ public String[] getMenuItemNamesFromMenuID(String menuID) {
530529
return this.myTxtFile.getMenuItemNamesFromMenuID(menuID, this.myBoardID);
531530
}
532531

533-
public Set<String> getAllMenuNames() {
534-
return this.myTxtFile.getMenuNames();
535-
}
536532

537533
public TreeMap<String, IPath> getAllExamples() {
538534
updateWhenDirty();
@@ -1134,4 +1130,8 @@ public void reloadTxtFile() {
11341130

11351131
}
11361132

1133+
public Map<String, String> getAllMenus() {
1134+
return myTxtFile.getMenus();
1135+
}
1136+
11371137
}

io.sloeber.core/src/io/sloeber/core/api/CompileDescription.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,25 @@ public enum WarningLevels {
2424
* @param customCommand
2525
* the command that needs to be used
2626
*/
27-
public void setCustomWarningLevel(String customCommand) {
27+
public void setCustomWarningLevel(String customWarningLevel) {
2828
if (this == CUSTOM) {
29-
myCustomWarningLevel = customCommand;
29+
myCustomWarningLevel = customWarningLevel;
3030
}
3131
}
3232

33+
public void setCustomWarningLevel(String customWarningLevel, boolean force) {
34+
if (force) {
35+
myCustomWarningLevel = customWarningLevel;
36+
} else {
37+
setCustomWarningLevel(customWarningLevel);
38+
}
39+
40+
}
41+
42+
public String getCustomWarningLevel() {
43+
return myCustomWarningLevel;
44+
}
45+
3346
/**
3447
* Get the string that should be put in the environment variable that places the
3548
* warning part in the command string This is a non expanded string for Arduino
@@ -52,6 +65,7 @@ public String getEnvValue() {
5265
return "${compiler.warning_flags.none}"; //$NON-NLS-1$
5366
}
5467

68+
5569
}
5670

5771
private WarningLevels myWarningLevel = WarningLevels.NONE;

io.sloeber.ui/src/io/sloeber/ui/LabelCombo.java

+18-41
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@
1111
* a class containing a label and a combobox in one. This makes it easier to make both visible together
1212
*/
1313
public class LabelCombo {
14-
private GridData myComboGriddata;
15-
private GridData myLabelGriddata;
16-
private String myID = new String();
1714
private Label myLabel;
1815
private Combo myCombo;
19-
private String myValue = ""; //$NON-NLS-1$
2016
private String myMenuName;
21-
private Listener myListener = null;
2217

2318
/**
2419
* Create a combo box with a label in front of it.
@@ -28,11 +23,10 @@ public class LabelCombo {
2823
* @param horSpan
2924
* @param fixedList if true only items of the list can be selected. If false you can type any text you want
3025
*/
31-
public LabelCombo(Composite composite, String menuName, String ID, int horSpan, boolean fixedList) {
32-
myID = ID;
26+
public LabelCombo(Composite composite, String menuName, int horSpan, boolean fixedList) {
3327
myLabel = new Label(composite, SWT.NONE);
3428
myLabel.setText(menuName + " :"); //$NON-NLS-1$
35-
myLabelGriddata = new GridData();
29+
GridData myLabelGriddata = new GridData();
3630
myLabelGriddata.horizontalSpan = 1;
3731
myLabelGriddata.horizontalAlignment = SWT.FILL;
3832
myLabel.setLayoutData(myLabelGriddata);
@@ -41,41 +35,26 @@ public LabelCombo(Composite composite, String menuName, String ID, int horSpan,
4135
} else {
4236
myCombo = new Combo(composite, SWT.BORDER);
4337
}
44-
myComboGriddata = new GridData();
38+
GridData myComboGriddata = new GridData();
4539
myComboGriddata.horizontalSpan = horSpan;
4640
myComboGriddata.horizontalAlignment = SWT.FILL;
4741
myCombo.setLayoutData(myComboGriddata);
4842
myMenuName = menuName;
43+
myCombo.layout();
4944

5045
}
5146

5247
public void addListener(Listener listener) {
5348
myCombo.addListener(SWT.Modify, listener);
54-
myListener = listener;
55-
}
56-
57-
58-
59-
public String getValue() {
60-
myValue = myCombo.getText().trim();
61-
return myValue;
6249
}
6350

6451
public String getMenuName() {
6552
return myMenuName.trim();
6653
}
6754

68-
public void setValue(String value) {
69-
myValue = value;
70-
myCombo.setText(value);
71-
}
72-
73-
public void setVisible(boolean visible) {
74-
boolean newvisible = visible && (myCombo.getItemCount() > 0);
75-
myLabel.setVisible(newvisible);
76-
myCombo.setVisible(newvisible);
77-
myComboGriddata.exclude = !newvisible;
78-
myLabelGriddata.exclude = !newvisible;
55+
public void dispose() {
56+
myLabel.dispose();
57+
myCombo.dispose();
7958
}
8059

8160
public boolean isValid() {
@@ -87,26 +66,23 @@ public void setEnabled(boolean enabled) {
8766
}
8867

8968
public void setItems(String[] items) {
90-
if (myListener != null)
91-
myCombo.removeListener(SWT.Modify, myListener);
69+
Listener[] listeners = myCombo.getListeners(SWT.Modify);
70+
for (Listener curListener : listeners) {
71+
myCombo.removeListener(SWT.Modify, curListener);
72+
}
73+
String curValue = getText();
9274
myCombo.setItems(items);
93-
myCombo.setText(myValue);
94-
if (myListener != null)
95-
myCombo.addListener(SWT.Modify, myListener);
75+
myCombo.setText(curValue);
76+
for (Listener curListener : listeners) {
77+
myCombo.addListener(SWT.Modify, curListener);
78+
}
9679

9780
}
9881

9982
public void add(String item) {
10083
myCombo.add(item);
10184
}
10285

103-
public String getID() {
104-
return myID;
105-
}
106-
107-
public boolean isVisible() {
108-
return (myCombo.getItemCount() > 0);
109-
}
11086

11187
public void setLabel(String newLabel) {
11288
myLabel.setText(newLabel);
@@ -122,7 +98,7 @@ public void select(int ordinal) {
12298
}
12399

124100
public String getText() {
125-
return myCombo.getText();
101+
return myCombo.getText().trim();
126102
}
127103

128104
public void setText(String text) {
@@ -134,4 +110,5 @@ public void addListener(int event, Listener comboListener) {
134110
myCombo.addListener( event, comboListener);
135111

136112
}
113+
137114
}

io.sloeber.ui/src/io/sloeber/ui/monitor/views/OpenSerialDialogBox.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ protected Control createDialogArea(Composite parent) {
4242
GridLayout layout = new GridLayout();
4343
layout.numColumns = 2;
4444
parent.setLayout(layout);
45-
mySerialPorts = new LabelCombo(parent, Messages.openSerialDialogBoxSerialPortToConnectTo, null, 1, false);
45+
mySerialPorts = new LabelCombo(parent, Messages.openSerialDialogBoxSerialPortToConnectTo, 1, false);
4646
mySerialPorts.setItems(SerialManager.listComPorts());
4747
mySerialPorts.setText(MyPreferences.getLastUsedPort());
4848

49-
myBaudRates = new LabelCombo(parent, Messages.openSerialDialogBoxSelectTheBautRate, null, 1, false);
49+
myBaudRates = new LabelCombo(parent, Messages.openSerialDialogBoxSelectTheBautRate, 1, false);
5050
myBaudRates.setItems(SerialManager.listBaudRates());
5151
myBaudRates.setText(MyPreferences.getLastUsedRate());
5252

0 commit comments

Comments
 (0)