mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 23:55:26 +02:00
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
This commit is contained in:
parent
ae02a50dba
commit
b724c1fa17
2 changed files with 7 additions and 18 deletions
|
@ -43,30 +43,18 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
||||||
Label portLabel = new Label(comp, SWT.NONE);
|
Label portLabel = new Label(comp, SWT.NONE);
|
||||||
portLabel.setText(Messages.ArduinoTargetPropertyPage_0);
|
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));
|
portSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
|
||||||
String currentPort = arduinoRemote.getPortName();
|
String currentPort = arduinoRemote.getPortName();
|
||||||
int i = 0, portSel = -1;
|
portSelector.setText(currentPort);
|
||||||
try {
|
try {
|
||||||
for (String port : SerialPort.list()) {
|
for (String port : SerialPort.list()) {
|
||||||
portSelector.add(port);
|
portSelector.add(port);
|
||||||
if (port.equals(currentPort)) {
|
|
||||||
portSel = i;
|
|
||||||
} else {
|
|
||||||
portSel = portSel < 0 ? 0 : portSel;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Activator.log(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);
|
Label boardLabel = new Label(comp, SWT.NONE);
|
||||||
boardLabel.setText(Messages.ArduinoTargetPropertyPage_2);
|
boardLabel.setText(Messages.ArduinoTargetPropertyPage_2);
|
||||||
|
@ -78,7 +66,7 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
||||||
ArduinoBoard currentBoard = arduinoRemote.getBoard();
|
ArduinoBoard currentBoard = arduinoRemote.getBoard();
|
||||||
Collection<ArduinoBoard> boardList = Activator.getService(ArduinoManager.class).getInstalledBoards();
|
Collection<ArduinoBoard> boardList = Activator.getService(ArduinoManager.class).getInstalledBoards();
|
||||||
boards = new ArduinoBoard[boardList.size()];
|
boards = new ArduinoBoard[boardList.size()];
|
||||||
i = 0;
|
int i = 0;
|
||||||
int boardSel = 0;
|
int boardSel = 0;
|
||||||
for (ArduinoBoard board : boardList) {
|
for (ArduinoBoard board : boardList) {
|
||||||
boards[i] = board;
|
boards[i] = board;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class BoardPropertyControl extends Composite {
|
||||||
Label portLabel = new Label(this, SWT.NONE);
|
Label portLabel = new Label(this, SWT.NONE);
|
||||||
portLabel.setText(Messages.NewArduinoTargetWizardPage_4);
|
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));
|
portCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
try {
|
try {
|
||||||
portNames = SerialPort.list();
|
portNames = SerialPort.list();
|
||||||
|
@ -64,12 +64,13 @@ public class BoardPropertyControl extends Composite {
|
||||||
if (portNames.length > 0) {
|
if (portNames.length > 0) {
|
||||||
portCombo.select(0);
|
portCombo.select(0);
|
||||||
portName = portNames[0];
|
portName = portNames[0];
|
||||||
|
} else {
|
||||||
|
portName = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
portCombo.addSelectionListener(new SelectionAdapter() {
|
portCombo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int index = portCombo.getSelectionIndex();
|
portName = portCombo.getText();
|
||||||
portName = index < 0 ? null : portNames[index];
|
|
||||||
fireSelection();
|
fireSelection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue