From 12b38c5fcdfc1f19b09530c5e8c89a576e35dfb0 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 9 Nov 2018 18:36:47 +0100 Subject: [PATCH] Nicer serial port selection dialog box --- app/src/processing/app/Editor.java | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index fef31f2c0..b96b349b8 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1961,26 +1961,24 @@ public class Editor extends JFrame implements RunnerListener { names[i] = portMenu.getItem(i).getText(); } - // FIXME: This is horribly unreadable - String result = (String) - JOptionPane.showInputDialog(this, - I18n.format( - tr("Serial port {0} not found.\n" + - "Retry the upload with another serial port?"), - PreferencesData.get("serial.port") - ), - "Serial port not found", - JOptionPane.PLAIN_MESSAGE, - null, - names, - 0); - if (result == null) return false; + String port = PreferencesData.get("serial.port"); + String title; + if (port == null || port.isEmpty()) { + title = tr("Serial port not selected."); + } else { + title = I18n.format(tr("Serial port {0} not found."), port); + } + String question = tr("Retry the upload with another serial port?"); + String result = (String) JOptionPane + .showInputDialog(this, title + "\n" + question, title, + JOptionPane.PLAIN_MESSAGE, null, names, 0); + if (result == null) + return false; selectSerialPort(result); base.onBoardOrPortChange(); return true; } - /** * Called by Sketch → Export. * Handles calling the export() function on sketch, and