|
33 | 33 | import com.jcraft.jsch.JSchException;
|
34 | 34 | import jssc.SerialPortException;
|
35 | 35 | import processing.app.debug.RunnerException;
|
| 36 | +import processing.app.debug.TargetBoard; |
| 37 | +import processing.app.debug.TargetPackage; |
| 38 | +import processing.app.debug.TargetPlatform; |
36 | 39 | import processing.app.forms.PasswordAuthorizationDialog;
|
37 | 40 | import processing.app.helpers.DocumentTextChangeListener;
|
38 | 41 | import processing.app.helpers.Keys;
|
@@ -1043,19 +1046,21 @@ private void addInternalTools(JMenu menu) {
|
1043 | 1046 | class SerialMenuListener implements ActionListener {
|
1044 | 1047 |
|
1045 | 1048 | private final String serialPort;
|
| 1049 | + private final String boardId; |
1046 | 1050 |
|
1047 |
| - public SerialMenuListener(String serialPort) { |
| 1051 | + public SerialMenuListener(String serialPort, String boardId) { |
1048 | 1052 | this.serialPort = serialPort;
|
| 1053 | + this.boardId = boardId; |
1049 | 1054 | }
|
1050 | 1055 |
|
1051 | 1056 | public void actionPerformed(ActionEvent e) {
|
1052 |
| - selectSerialPort(serialPort); |
| 1057 | + selectSerialPort(serialPort, boardId); |
1053 | 1058 | base.onBoardOrPortChange();
|
1054 | 1059 | }
|
1055 | 1060 |
|
1056 | 1061 | }
|
1057 | 1062 |
|
1058 |
| - private void selectSerialPort(String name) { |
| 1063 | + private void selectSerialPort(String name, String boardId) { |
1059 | 1064 | if(portMenu == null) {
|
1060 | 1065 | System.out.println(tr("serialMenu is null"));
|
1061 | 1066 | return;
|
@@ -1095,6 +1100,13 @@ private void selectSerialPort(String name) {
|
1095 | 1100 | // ignore
|
1096 | 1101 | }
|
1097 | 1102 | }
|
| 1103 | + |
| 1104 | + if (boardId != null) { |
| 1105 | + TargetBoard targetBoard = BaseNoGui.getPlatform().resolveBoardById(BaseNoGui.packages, boardId); |
| 1106 | + if (targetBoard != null) { |
| 1107 | + base.selectTargetBoard(targetBoard); |
| 1108 | + } |
| 1109 | + } |
1098 | 1110 |
|
1099 | 1111 | onBoardOrPortChange();
|
1100 | 1112 | base.onBoardOrPortChange();
|
@@ -1139,9 +1151,10 @@ public int compare(BoardPort o1, BoardPort o2) {
|
1139 | 1151 | }
|
1140 | 1152 | String address = port.getAddress();
|
1141 | 1153 | String label = port.getLabel();
|
| 1154 | + String boardId = port.getBoardId(); |
1142 | 1155 |
|
1143 | 1156 | JCheckBoxMenuItem item = new JCheckBoxMenuItem(label, address.equals(selectedPort));
|
1144 |
| - item.addActionListener(new SerialMenuListener(address)); |
| 1157 | + item.addActionListener(new SerialMenuListener(address, boardId)); |
1145 | 1158 | portMenu.add(item);
|
1146 | 1159 | }
|
1147 | 1160 |
|
@@ -2175,7 +2188,7 @@ private boolean serialPrompt() {
|
2175 | 2188 | names,
|
2176 | 2189 | 0);
|
2177 | 2190 | if (result == null) return false;
|
2178 |
| - selectSerialPort(result); |
| 2191 | + selectSerialPort(result, null); |
2179 | 2192 | base.onBoardOrPortChange();
|
2180 | 2193 | return true;
|
2181 | 2194 | }
|
|
0 commit comments