blob: 43ba1d88e08d75c00d3741c5f33152010b7cd3d7 (
plain) (
blame)
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
90
91
92
93
94
95
96
97
98
99
100
|
/*******************************************************************************
* 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 java.util.Set;
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
import org.eclipse.cdt.arduino.ui.internal.Activator;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
public class NewArduinoTargetWizard extends Wizard implements IRemoteUIConnectionWizard, INewWizard {
private NewArduinoTargetWizardPage page;
private IRemoteConnectionWorkingCopy workingCopy;
private boolean isNewWizard;
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
isNewWizard = true;
}
@Override
public void addPages() {
page = new NewArduinoTargetWizardPage();
addPage(page);
}
@Override
public boolean performFinish() {
if (getConnection() == null) {
return false;
}
page.performFinish(workingCopy);
if (isNewWizard) {
// if called as a new wizard, we need to do the save
try {
workingCopy.save();
} catch (RemoteConnectionException e) {
Activator.log(e);
return false;
}
}
return true;
}
@Override
public IRemoteConnectionWorkingCopy open() {
return getConnection();
}
@Override
public IRemoteConnectionWorkingCopy getConnection() {
if (workingCopy == null) {
IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
IRemoteConnectionType connectionType = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
try {
workingCopy = connectionType.newConnection(page.name);
} catch (RemoteConnectionException e) {
Activator.getDefault().getLog().log(e.getStatus());
return null;
}
}
return workingCopy;
}
@Override
public void setConnection(IRemoteConnectionWorkingCopy connection) {
workingCopy = connection;
}
@Override
public void setConnectionName(String name) {
// TODO Auto-generated method stub
}
@Override
public void setInvalidConnectionNames(Set<String> names) {
// TODO Auto-generated method stub
}
}
|