From b724c1fa17bd302e112d6821489dd941389ebeef Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Mon, 7 Dec 2015 20:28:21 -0500 Subject: [PATCH] Bug 480580 - [Arduino] Be more flexible about serial port names. Allow empty for testing or setting up and allow freeform in case the desired serial port doesn't match our filter. Change-Id: Iff94b6b7fcb0acf4d2109e818c3b5de9a013086e --- .../remote/ArduinoTargetPropertyPage.java | 18 +++--------------- .../internal/remote/BoardPropertyControl.java | 7 ++++--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoTargetPropertyPage.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoTargetPropertyPage.java index c614af52350..650a7739f19 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoTargetPropertyPage.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoTargetPropertyPage.java @@ -43,30 +43,18 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc Label portLabel = new Label(comp, SWT.NONE); portLabel.setText(Messages.ArduinoTargetPropertyPage_0); - portSelector = new Combo(comp, SWT.READ_ONLY); + portSelector = new Combo(comp, SWT.NONE); portSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); String currentPort = arduinoRemote.getPortName(); - int i = 0, portSel = -1; + portSelector.setText(currentPort); try { for (String port : SerialPort.list()) { portSelector.add(port); - if (port.equals(currentPort)) { - portSel = i; - } else { - portSel = portSel < 0 ? 0 : portSel; - } - i++; } } catch (IOException e) { Activator.log(e); } - if (portSel >= 0) { - portSelector.select(portSel); - } else { - setMessage(Messages.ArduinoTargetPropertyPage_1, ERROR); - setValid(false); - } Label boardLabel = new Label(comp, SWT.NONE); boardLabel.setText(Messages.ArduinoTargetPropertyPage_2); @@ -78,7 +66,7 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc ArduinoBoard currentBoard = arduinoRemote.getBoard(); Collection boardList = Activator.getService(ArduinoManager.class).getInstalledBoards(); boards = new ArduinoBoard[boardList.size()]; - i = 0; + int i = 0; int boardSel = 0; for (ArduinoBoard board : boardList) { boards[i] = board; diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/BoardPropertyControl.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/BoardPropertyControl.java index 506e01287eb..9ed9ccddbb4 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/BoardPropertyControl.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/BoardPropertyControl.java @@ -50,7 +50,7 @@ public class BoardPropertyControl extends Composite { Label portLabel = new Label(this, SWT.NONE); portLabel.setText(Messages.NewArduinoTargetWizardPage_4); - portCombo = new Combo(this, SWT.READ_ONLY); + portCombo = new Combo(this, SWT.NONE); portCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); try { portNames = SerialPort.list(); @@ -64,12 +64,13 @@ public class BoardPropertyControl extends Composite { if (portNames.length > 0) { portCombo.select(0); portName = portNames[0]; + } else { + portName = ""; //$NON-NLS-1$ } portCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - int index = portCombo.getSelectionIndex(); - portName = index < 0 ? null : portNames[index]; + portName = portCombo.getText(); fireSelection(); } });