|
60 | 60 | @SuppressWarnings("serial")
|
61 | 61 | public class Editor extends JFrame implements RunnerListener {
|
62 | 62 |
|
| 63 | + private final static List<String> BOARD_PROTOCOLS_ORDER = Arrays.asList(new String[]{"serial", "network"}); |
| 64 | + private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(new String[]{_("Serial ports"), _("Network ports")}); |
| 65 | + |
63 | 66 | Base base;
|
64 | 67 |
|
65 | 68 | // otherwise, if the window is resized with the message label
|
@@ -441,7 +444,7 @@ protected void applyPreferences() {
|
441 | 444 | textarea.setEditable(!external);
|
442 | 445 | saveMenuItem.setEnabled(!external);
|
443 | 446 | saveAsMenuItem.setEnabled(!external);
|
444 |
| - |
| 447 | + |
445 | 448 | textarea.setDisplayLineNumbers(Preferences.getBoolean("editor.linenumbers"));
|
446 | 449 |
|
447 | 450 | TextAreaPainter painter = textarea.getPainter();
|
@@ -996,7 +999,30 @@ protected void populatePortMenu() {
|
996 | 999 | String selectedPort = Preferences.get("serial.port");
|
997 | 1000 |
|
998 | 1001 | List<BoardPort> ports = Base.getDiscoveryManager().discovery();
|
| 1002 | + |
| 1003 | + Collections.sort(ports, new Comparator<BoardPort>() { |
| 1004 | + @Override |
| 1005 | + public int compare(BoardPort o1, BoardPort o2) { |
| 1006 | + return BOARD_PROTOCOLS_ORDER.indexOf(o1.getProtocol()) - BOARD_PROTOCOLS_ORDER.indexOf(o2.getProtocol()); |
| 1007 | + } |
| 1008 | + }); |
| 1009 | + |
| 1010 | + String lastProtocol = null; |
| 1011 | + String lastProtocolTranslated; |
999 | 1012 | for (BoardPort port : ports) {
|
| 1013 | + if (lastProtocol == null || !port.getProtocol().equals(lastProtocol)) { |
| 1014 | + if (lastProtocol != null) { |
| 1015 | + serialMenu.addSeparator(); |
| 1016 | + } |
| 1017 | + lastProtocol = port.getProtocol(); |
| 1018 | + |
| 1019 | + if (BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol()) != -1) { |
| 1020 | + lastProtocolTranslated = BOARD_PROTOCOLS_ORDER_TRANSLATIONS.get(BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol())); |
| 1021 | + } else { |
| 1022 | + lastProtocolTranslated = port.getProtocol(); |
| 1023 | + } |
| 1024 | + serialMenu.add(new JMenuItem(_(lastProtocolTranslated))); |
| 1025 | + } |
1000 | 1026 | String address = port.getAddress();
|
1001 | 1027 | String label = port.getLabel();
|
1002 | 1028 |
|
@@ -1646,7 +1672,7 @@ protected void setCode(SketchCodeDocument codeDoc) {
|
1646 | 1672 | if (document == null) { // this document not yet inited
|
1647 | 1673 | document = new SyntaxDocument();
|
1648 | 1674 | codeDoc.setDocument(document);
|
1649 |
| - |
| 1675 | + |
1650 | 1676 | // turn on syntax highlighting
|
1651 | 1677 | document.setTokenMarker(new PdeKeywords());
|
1652 | 1678 |
|
@@ -1870,7 +1896,7 @@ protected String getCurrentKeyword() {
|
1870 | 1896 |
|
1871 | 1897 | } catch (BadLocationException bl) {
|
1872 | 1898 | bl.printStackTrace();
|
1873 |
| - } |
| 1899 | + } |
1874 | 1900 | return text;
|
1875 | 1901 | }
|
1876 | 1902 |
|
|
0 commit comments