|
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;
|
@@ -1050,19 +1053,21 @@ private void addInternalTools(JMenu menu) {
|
1050 | 1053 | class SerialMenuListener implements ActionListener {
|
1051 | 1054 |
|
1052 | 1055 | private final String serialPort;
|
| 1056 | + private final String boardId; |
1053 | 1057 |
|
1054 |
| - public SerialMenuListener(String serialPort) { |
| 1058 | + public SerialMenuListener(String serialPort, String boardId) { |
1055 | 1059 | this.serialPort = serialPort;
|
| 1060 | + this.boardId = boardId; |
1056 | 1061 | }
|
1057 | 1062 |
|
1058 | 1063 | public void actionPerformed(ActionEvent e) {
|
1059 |
| - selectSerialPort(serialPort); |
| 1064 | + selectSerialPort(serialPort, boardId); |
1060 | 1065 | base.onBoardOrPortChange();
|
1061 | 1066 | }
|
1062 | 1067 |
|
1063 | 1068 | }
|
1064 | 1069 |
|
1065 |
| - private void selectSerialPort(String name) { |
| 1070 | + private void selectSerialPort(String name, String boardId) { |
1066 | 1071 | if(portMenu == null) {
|
1067 | 1072 | System.out.println(tr("serialMenu is null"));
|
1068 | 1073 | return;
|
@@ -1102,6 +1107,13 @@ private void selectSerialPort(String name) {
|
1102 | 1107 | // ignore
|
1103 | 1108 | }
|
1104 | 1109 | }
|
| 1110 | + |
| 1111 | + if (boardId != null) { |
| 1112 | + TargetBoard targetBoard = BaseNoGui.getPlatform().resolveBoardById(BaseNoGui.packages, boardId); |
| 1113 | + if (targetBoard != null) { |
| 1114 | + base.selectTargetBoard(targetBoard); |
| 1115 | + } |
| 1116 | + } |
1105 | 1117 |
|
1106 | 1118 | onBoardOrPortChange();
|
1107 | 1119 | base.onBoardOrPortChange();
|
@@ -1146,9 +1158,10 @@ public int compare(BoardPort o1, BoardPort o2) {
|
1146 | 1158 | }
|
1147 | 1159 | String address = port.getAddress();
|
1148 | 1160 | String label = port.getLabel();
|
| 1161 | + String boardId = port.getBoardId(); |
1149 | 1162 |
|
1150 | 1163 | JCheckBoxMenuItem item = new JCheckBoxMenuItem(label, address.equals(selectedPort));
|
1151 |
| - item.addActionListener(new SerialMenuListener(address)); |
| 1164 | + item.addActionListener(new SerialMenuListener(address, boardId)); |
1152 | 1165 | portMenu.add(item);
|
1153 | 1166 | }
|
1154 | 1167 |
|
@@ -2182,7 +2195,7 @@ private boolean serialPrompt() {
|
2182 | 2195 | names,
|
2183 | 2196 | 0);
|
2184 | 2197 | if (result == null) return false;
|
2185 |
| - selectSerialPort(result); |
| 2198 | + selectSerialPort(result, null); |
2186 | 2199 | base.onBoardOrPortChange();
|
2187 | 2200 | return true;
|
2188 | 2201 | }
|
|
0 commit comments