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);
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;
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();
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();
}
});