1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*******************************************************************************
* Copyright (c) 2015 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.arduino.ui.internal.remote;
import org.eclipse.cdt.arduino.ui.internal.Messages;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class NewArduinoTargetWizardPage extends WizardPage {
String name;
private Text nameText;
BoardPropertyControl boardControl;
public NewArduinoTargetWizardPage() {
super("NewArduinoTargetPage"); //$NON-NLS-1$
setDescription(Messages.NewArduinoTargetWizardPage_0);
setTitle(Messages.NewArduinoTargetWizardPage_1);
}
@Override
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout());
Composite nameComp = new Composite(comp, SWT.NONE);
nameComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
nameComp.setLayout(new GridLayout(2, false));
Label nameLabel = new Label(nameComp, SWT.NONE);
nameLabel.setText(Messages.NewArduinoTargetWizardPage_2);
nameText = new Text(nameComp, SWT.BORDER | SWT.SINGLE);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
nameText.setText(Messages.NewArduinoTargetWizardPage_3);
nameText.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
name = nameText.getText();
updateStatus();
}
@Override
public void keyPressed(KeyEvent e) {
}
});
boardControl = new BoardPropertyControl(comp, SWT.NONE);
boardControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
boardControl.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateStatus();
}
});
setControl(comp);
setPageComplete(false);
}
private void updateStatus() {
setPageComplete(name != null && !name.isEmpty() && boardControl.getPortName() != null
&& boardControl.getSelectedBoard() != null);
}
public void performFinish(IRemoteConnectionWorkingCopy workingCopy) {
boardControl.apply(workingCopy);
}
}
|