(String name)
| 1002 | |
| 1003 | |
| 1004 | private void selectSerialPort(String name) { |
| 1005 | if(portMenu == null) { |
| 1006 | System.out.println(tr("serialMenu is null")); |
| 1007 | return; |
| 1008 | } |
| 1009 | if (name == null) { |
| 1010 | System.out.println(tr("name is null")); |
| 1011 | return; |
| 1012 | } |
| 1013 | JCheckBoxMenuItem selection = null; |
| 1014 | for (int i = 0; i < portMenu.getItemCount(); i++) { |
| 1015 | JMenuItem menuItem = portMenu.getItem(i); |
| 1016 | if (!(menuItem instanceof JCheckBoxMenuItem)) { |
| 1017 | continue; |
| 1018 | } |
| 1019 | JCheckBoxMenuItem checkBoxMenuItem = ((JCheckBoxMenuItem) menuItem); |
| 1020 | checkBoxMenuItem.setState(false); |
| 1021 | if (name.equals(checkBoxMenuItem.getText())) selection = checkBoxMenuItem; |
| 1022 | } |
| 1023 | if (selection != null) selection.setState(true); |
| 1024 | //System.out.println(item.getLabel()); |
| 1025 | |
| 1026 | BaseNoGui.selectSerialPort(name); |
| 1027 | try { |
| 1028 | boolean reopenMonitor = ((serialMonitor != null && serialMonitor.isVisible()) || |
| 1029 | serialPlotter != null && serialPlotter.isVisible()); |
| 1030 | if (serialMonitor != null) { |
| 1031 | serialMonitor.close(); |
| 1032 | } |
| 1033 | if (serialPlotter != null) { |
| 1034 | serialPlotter.close(); |
| 1035 | } |
| 1036 | if (reopenMonitor) { |
| 1037 | handleSerial(); |
| 1038 | } |
| 1039 | } catch (Exception e) { |
| 1040 | // ignore |
| 1041 | } |
| 1042 | |
| 1043 | onBoardOrPortChange(); |
| 1044 | base.onBoardOrPortChange(); |
| 1045 | |
| 1046 | //System.out.println("set to " + get("serial.port")); |
| 1047 | } |
| 1048 | |
| 1049 | class BoardPortJCheckBoxMenuItem extends JCheckBoxMenuItem { |
| 1050 | private BoardPort port; |
no test coverage detected