From 9ba172b0db8ba02bfc0e0ac6f26f400eedcdd5e9 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 23 Nov 2018 12:35:59 +0100 Subject: [PATCH] Show BoardName.boardName field in 'Ports' menu ...instead of putting it into the 'label' field during discovery. --- app/src/processing/app/Editor.java | 11 ++++++++--- .../packages/discoverers/serial/SerialDiscovery.java | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 8b0989445..fc9714b16 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1041,18 +1041,23 @@ public class Editor extends JFrame implements RunnerListener { private BoardPort port; public BoardPortJCheckBoxMenuItem(BoardPort port) { - super(port.getLabel()); + super(); + this.port = port; + setText(toString()); addActionListener(e -> { selectSerialPort(port.getAddress()); base.onBoardOrPortChange(); }); - this.port = port; } @Override public String toString() { // This is required for serialPrompt() - return port.getLabel(); + String label = port.getLabel(); + if (port.getBoardName() != null && !port.getBoardName().isEmpty()) { + label += " (" + port.getBoardName() + ")"; + } + return label; } } diff --git a/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialDiscovery.java b/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialDiscovery.java index f589a0195..3d5fb2fd7 100644 --- a/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialDiscovery.java +++ b/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialDiscovery.java @@ -196,9 +196,6 @@ public class SerialDiscovery implements Discovery, Runnable { TargetBoard board = (TargetBoard) boardData.get("board"); if (board != null) { String boardName = board.getName(); - if (boardName != null) { - label += " (" + boardName + ")"; - } boardPort.setBoardName(boardName); } } else {