Bug 480580 - [Arduino] Be more flexible about serial port names.
authorDoug Schaefer <dschaefer@qnx.com>
Tue, 8 Dec 2015 01:28:21 +0000 (20:28 -0500)
committerDoug Schaefer <dschaefer@qnx.com>
Tue, 8 Dec 2015 01:28:21 +0000 (20:28 -0500)
Allow empty for testing or setting up and allow freeform in case the
desired serial port doesn't match our filter.

Change-Id: Iff94b6b7fcb0acf4d2109e818c3b5de9a013086e

toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/ArduinoTargetPropertyPage.java
toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/remote/BoardPropertyControl.java

index c614af5..650a773 100644 (file)
@@ -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<ArduinoBoard> 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;
index 506e012..9ed9ccd 100644 (file)
@@ -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();
                        }
                });