author | dadubrow |
Mon, 06 Apr 2009 14:33:24 -0500 | |
branch | RCL_2_0 |
changeset 55 | 8254273d11c0 |
parent 48 | cfd7fcf6bf2d |
child 163 | b25acbfc406a |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
package com.nokia.carbide.remoteconnections.settings.ui; |
|
20 |
||
21 |
import com.nokia.carbide.remoteconnections.Messages; |
|
22 |
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
|
23 |
import com.nokia.carbide.remoteconnections.interfaces.*; |
|
24 |
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus; |
|
25 |
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener; |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
26 |
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus; |
2 | 27 |
import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory.IValidationErrorReporter; |
28 |
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller; |
|
29 |
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller.IPackageContents; |
|
30 |
import com.nokia.cpp.internal.api.utils.core.*; |
|
31 |
||
32 |
import org.eclipse.core.runtime.IPath; |
|
33 |
import org.eclipse.core.runtime.Path; |
|
34 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
35 |
import org.eclipse.jface.viewers.*; |
|
36 |
import org.eclipse.jface.wizard.IWizardContainer2; |
|
37 |
import org.eclipse.jface.wizard.WizardPage; |
|
38 |
import org.eclipse.swt.SWT; |
|
39 |
import org.eclipse.swt.custom.CLabel; |
|
40 |
import org.eclipse.swt.custom.SashForm; |
|
41 |
import org.eclipse.swt.events.*; |
|
42 |
import org.eclipse.swt.graphics.Image; |
|
43 |
import org.eclipse.swt.graphics.Point; |
|
44 |
import org.eclipse.swt.layout.GridData; |
|
45 |
import org.eclipse.swt.layout.GridLayout; |
|
46 |
import org.eclipse.swt.program.Program; |
|
47 |
import org.eclipse.swt.widgets.*; |
|
48 |
import org.eclipse.ui.ISharedImages; |
|
49 |
import org.eclipse.ui.PlatformUI; |
|
50 |
import org.osgi.framework.Version; |
|
51 |
||
52 |
import java.io.File; |
|
53 |
import java.io.InputStream; |
|
54 |
import java.text.MessageFormat; |
|
55 |
import java.util.*; |
|
56 |
import java.util.List; |
|
57 |
||
58 |
public class ConnectionSettingsPage extends WizardPage { |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
59 |
|
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
60 |
public final class Tester extends Thread { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
61 |
@Override |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
62 |
public void run() { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
63 |
((AbstractConnectedService) connectedService).setManualTesting(); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
64 |
for (int i = 0; i < 3 && connectedService != null; i++) { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
65 |
connectedService.testStatus(); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
66 |
try { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
67 |
if (i < 2) |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
68 |
sleep(AbstractConnectedService.TIMEOUT); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
69 |
} catch (InterruptedException e) { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
70 |
break; |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
71 |
} |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
72 |
} |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
73 |
resetServiceTesting(false); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
74 |
} |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
75 |
} |
2 | 76 |
|
77 |
private final static TreeNode LOADING_CONTENT_TREENODE = |
|
78 |
new TreeNode(Messages.getString("ConnectionSettingsPage.GettingDataMessage")); //$NON-NLS-1$ |
|
79 |
private static final String STATUS_NOT_TESTED = |
|
80 |
Messages.getString("ConnectionSettingsPage.NotTestedStatusString"); //$NON-NLS-1$ |
|
81 |
private final static Image FOLDER_ICON_IMG = |
|
82 |
PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( |
|
83 |
ISharedImages.IMG_OBJ_FOLDER).createImage(); |
|
84 |
private static final String UID = ".uid"; //$NON-NLS-1$ |
|
85 |
private final SettingsWizard settingsWizard; |
|
86 |
private IConnectionType connectionType; |
|
87 |
private ComboViewer deviceOSComboViewer; |
|
88 |
private Group settingsGroup; |
|
89 |
private Composite agentTestTabComposite; |
|
90 |
private ListViewer servicesListViewer; |
|
91 |
private Text serviceTestInfo; |
|
92 |
private Button serviceTestButton; |
|
93 |
private boolean isTesting; |
|
94 |
private Label statusLabel; |
|
95 |
private Text statusText; |
|
96 |
private IConnectionFactory connectionFactory; |
|
97 |
private IConnection connection; |
|
98 |
private IService service; |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
99 |
private volatile IConnectedService connectedService; |
2 | 100 |
private IStatusChangedListener statusListener; |
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
101 |
private Tester tester; |
2 | 102 |
private SashForm installerSashForm; |
103 |
private TreeViewer installerTreeViewer; |
|
104 |
private Text installerInfoText; |
|
105 |
private Button installerSaveButton; |
|
106 |
private Button installButton; |
|
107 |
private String saveAsParent; |
|
108 |
private List<IRemoteAgentInstallerProvider> installerProviders; |
|
109 |
||
110 |
protected ConnectionSettingsPage(SettingsWizard settingsWizard) { |
|
111 |
super("settingspage"); //$NON-NLS-1$ |
|
112 |
this.settingsWizard = settingsWizard; |
|
113 |
} |
|
114 |
||
115 |
/* (non-Javadoc) |
|
116 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
117 |
*/ |
|
118 |
public void createControl(Composite parent) { |
|
119 |
final TabFolder tabFolder = new TabFolder(parent, SWT.NONE); |
|
120 |
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
121 |
tabFolder.setData(UID, "ConnectionSettingsPage"); //$NON-NLS-1$ |
|
122 |
||
123 |
createAgentTestTabComposite(tabFolder); |
|
124 |
createInstallTabComposite(tabFolder); |
|
125 |
||
126 |
RemoteConnectionsActivator.setHelp(tabFolder, ".connection_settings_page"); //$NON-NLS-1$ |
|
127 |
||
128 |
setControl(tabFolder); |
|
129 |
} |
|
130 |
||
131 |
private void createAgentTestTabComposite(TabFolder tabFolder) { |
|
132 |
TabItem tabItem = new TabItem(tabFolder, SWT.NONE); |
|
133 |
tabItem.setText(Messages.getString("ConnectionSettingsPage.AgentTestTabLabel")); //$NON-NLS-1$ |
|
134 |
tabItem.setData(UID, "testTab"); //$NON-NLS-1$ |
|
135 |
agentTestTabComposite = new Composite(tabFolder, SWT.NONE); |
|
136 |
GridLayout gridLayout = new GridLayout(); |
|
137 |
gridLayout.numColumns = 2; |
|
138 |
agentTestTabComposite.setLayout(gridLayout); |
|
139 |
tabItem.setControl(agentTestTabComposite); |
|
140 |
||
141 |
createSettingsGroup(agentTestTabComposite); |
|
142 |
||
143 |
createDeviceOSCombo(agentTestTabComposite); |
|
144 |
||
145 |
createServiceTestComposite(agentTestTabComposite); |
|
146 |
} |
|
147 |
||
148 |
private void createDeviceOSCombo(Composite parent) { |
|
149 |
Composite comboComposite = new Composite(parent, SWT.NONE); |
|
150 |
GridData gd_composite = new GridData(SWT.FILL, SWT.CENTER, true, false); |
|
151 |
gd_composite.horizontalSpan = 2; |
|
152 |
comboComposite.setLayoutData(gd_composite); |
|
153 |
GridLayout gridLayout = new GridLayout(); |
|
154 |
gridLayout.numColumns = 2; |
|
155 |
comboComposite.setLayout(gridLayout); |
|
156 |
||
157 |
Label deviceOSLabel = new Label(comboComposite, SWT.NONE); |
|
158 |
GridData gd_sdkLabel = new GridData(); |
|
159 |
deviceOSLabel.setLayoutData(gd_sdkLabel); |
|
160 |
deviceOSLabel.setText(Messages.getString("ConnectionSettingsPage.DeviceOSLabel")); //$NON-NLS-1$ |
|
161 |
||
162 |
deviceOSComboViewer = new ComboViewer(comboComposite, SWT.READ_ONLY); |
|
163 |
GridData gd_sdkcombo = new GridData(SWT.LEFT, SWT.CENTER, true, false); |
|
164 |
gd_sdkcombo.widthHint = 150; |
|
165 |
deviceOSComboViewer.getCombo().setLayoutData(gd_sdkcombo); |
|
166 |
deviceOSComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
167 |
public void selectionChanged(SelectionChangedEvent event) { |
|
168 |
IStructuredSelection selection = (IStructuredSelection) deviceOSComboViewer.getSelection(); |
|
169 |
Pair<String, Version> pair = (Pair<String, Version>) selection.getFirstElement(); |
|
170 |
setSelectionToInstallComposite(pair); |
|
171 |
if (connectedService != null) |
|
172 |
connectedService.setDeviceOS(pair.first, pair.second); |
|
173 |
} |
|
174 |
}); |
|
175 |
deviceOSComboViewer.setContentProvider(new ArrayContentProvider()); |
|
176 |
deviceOSComboViewer.setLabelProvider(new LabelProvider() { |
|
177 |
@Override |
|
178 |
public String getText(Object element) { |
|
179 |
Check.checkState(element instanceof Pair); |
|
180 |
Pair pair = (Pair) element; |
|
181 |
return MessageFormat.format("{0} {1}", pair.first, pair.second); //$NON-NLS-1$ |
|
182 |
} |
|
183 |
}); |
|
184 |
deviceOSComboViewer.getControl().setToolTipText(Messages.getString("ConnectionSettingsPage.DeviceOSComboToolTip")); //$NON-NLS-1$ |
|
185 |
deviceOSComboViewer.getControl().setData(UID, "deviceOSComboViewer"); //$NON-NLS-1$ |
|
186 |
} |
|
187 |
||
188 |
private void createSettingsGroup(Composite parent) { |
|
189 |
settingsGroup = new Group(parent, SWT.NONE); |
|
190 |
GridLayout settingsLayout = new GridLayout(); |
|
191 |
settingsGroup.setLayout(settingsLayout); |
|
192 |
GridData gd_settings = new GridData(GridData.FILL_HORIZONTAL); |
|
193 |
gd_settings.horizontalSpan = 2; |
|
194 |
settingsGroup.setLayoutData(gd_settings); |
|
195 |
settingsGroup.setText(Messages.getString("ConnectionSettingsPage.ConnectionSettingsGroupLabel")); //$NON-NLS-1$ |
|
196 |
} |
|
197 |
||
198 |
private void createServiceTestComposite(Composite parent) { |
|
199 |
Composite serviceSelectionComposite = new Composite(parent, SWT.NONE); |
|
200 |
serviceSelectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
|
201 |
serviceSelectionComposite.setLayout(new GridLayout()); |
|
202 |
Label label = new Label(serviceSelectionComposite, SWT.NONE); |
|
203 |
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
204 |
label.setText(Messages.getString("ConnectionSettingsPage.ServicesListLabel")); //$NON-NLS-1$ |
|
205 |
servicesListViewer = new ListViewer(serviceSelectionComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); |
|
206 |
GridData gd_viewer = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); |
|
207 |
servicesListViewer.getControl().setLayoutData(gd_viewer); |
|
208 |
servicesListViewer.setContentProvider(new ArrayContentProvider()); |
|
209 |
servicesListViewer.setLabelProvider(new LabelProvider() { |
|
210 |
@Override |
|
211 |
public String getText(Object element) { |
|
212 |
if (element instanceof IService) |
|
213 |
return ((IService) element).getDisplayName(); |
|
214 |
return null; |
|
215 |
} |
|
216 |
}); |
|
217 |
servicesListViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
218 |
public void selectionChanged(SelectionChangedEvent event) { |
|
219 |
IStructuredSelection selection = (IStructuredSelection) servicesListViewer.getSelection(); |
|
220 |
IService curService = (IService) selection.getFirstElement(); |
|
221 |
if (!curService.equals(service)) { |
|
222 |
service = curService; |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
223 |
resetServiceTesting(true); |
2 | 224 |
} |
225 |
} |
|
226 |
}); |
|
227 |
servicesListViewer.getControl().setToolTipText(Messages.getString("ConnectionSettingsPage.ServicesListToolTip")); //$NON-NLS-1$ |
|
228 |
servicesListViewer.getControl().setData(UID, "servicesListViewer"); //$NON-NLS-1$ |
|
229 |
||
230 |
Composite testButtonComposite = new Composite(parent, SWT.NONE); |
|
231 |
testButtonComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
232 |
testButtonComposite.setLayout(new GridLayout()); |
|
233 |
serviceTestInfo = new Text(testButtonComposite, SWT.READ_ONLY | SWT.WRAP); |
|
234 |
serviceTestButton = new Button(testButtonComposite, SWT.PUSH); |
|
235 |
GridData gd_button = new GridData(SWT.CENTER, SWT.CENTER, false, false); |
|
236 |
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
|
237 |
serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel")); //$NON-NLS-1$ |
|
238 |
Point minSize = serviceTestButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
|
239 |
gd_button.widthHint = Math.max(widthHint, minSize.x); |
|
240 |
GridData gd_text = new GridData(SWT.CENTER, SWT.FILL, true, true); |
|
241 |
gd_text.widthHint = gd_button.widthHint; |
|
242 |
serviceTestInfo.setLayoutData(gd_text); |
|
243 |
serviceTestInfo.setData(UID, "serviceTestInfo"); //$NON-NLS-1$ |
|
244 |
serviceTestButton.setLayoutData(gd_button); |
|
245 |
serviceTestButton.setToolTipText(Messages.getString("ConnectionSettingsPage.ServiceTestButtonToolTip")); //$NON-NLS-1$ |
|
246 |
serviceTestButton.setData(UID, "serviceTestButton"); //$NON-NLS-1$ |
|
247 |
serviceTestButton.addSelectionListener(new SelectionAdapter() { |
|
248 |
@Override |
|
249 |
public void widgetSelected(SelectionEvent e) { |
|
250 |
if (isTesting) { |
|
251 |
serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel")); //$NON-NLS-1$ |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
252 |
resetServiceTesting(true); |
2 | 253 |
} |
254 |
else { |
|
255 |
serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StopServiceTestButtonLabel")); //$NON-NLS-1$ |
|
256 |
testService(); |
|
257 |
} |
|
258 |
} |
|
259 |
}); |
|
260 |
||
261 |
Composite statusComposite = new Composite(parent, SWT.NONE); |
|
262 |
statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); |
|
263 |
statusComposite.setLayout(new GridLayout()); |
|
264 |
statusLabel = new Label(statusComposite, SWT.NONE); |
|
265 |
statusLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); |
|
266 |
statusLabel.setText(Messages.getString("ConnectionSettingsPage.StatusLabel")); //$NON-NLS-1$ |
|
267 |
statusText = new Text(statusComposite, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.WRAP); |
|
268 |
statusText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
269 |
statusText.setText(STATUS_NOT_TESTED); |
|
270 |
statusText.setData(UID, "statusText"); //$NON-NLS-1$ |
|
271 |
} |
|
272 |
||
273 |
private void createInstallTabComposite(TabFolder tabFolder) { |
|
274 |
TabItem tabItem = new TabItem(tabFolder, SWT.NONE); |
|
275 |
tabItem.setText(Messages.getString("ConnectionSettingsPage.InstallTabLabel")); //$NON-NLS-1$ |
|
276 |
tabItem.setData(UID, "installTab"); //$NON-NLS-1$ |
|
277 |
Composite composite = new Composite(tabFolder, SWT.NONE); |
|
278 |
GridLayout gridLayout = new GridLayout(); |
|
279 |
composite.setLayout(gridLayout); |
|
280 |
tabItem.setControl(composite); |
|
281 |
||
282 |
Composite installDebugAgentComposite = new Composite(tabFolder, SWT.NONE); |
|
283 |
installDebugAgentComposite.setLayout(new GridLayout(1, false)); |
|
284 |
tabItem.setControl(installDebugAgentComposite); |
|
285 |
||
286 |
installerSashForm = new SashForm(installDebugAgentComposite, SWT.HORIZONTAL); |
|
287 |
GridData gd_sash = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
288 |
gd_sash.widthHint = 420; |
|
289 |
gd_sash.heightHint = 280; |
|
290 |
installerSashForm.setLayoutData(gd_sash); |
|
291 |
||
292 |
installerTreeViewer = new TreeViewer(installerSashForm, SWT.BORDER); |
|
293 |
GridData gd_tree = new GridData(SWT.CENTER, SWT.CENTER, false, false); |
|
294 |
installerTreeViewer.getTree().setLayoutData(gd_tree); |
|
295 |
installerTreeViewer.getControl().setData(UID, "installerTreeViewer"); //$NON-NLS-1$ |
|
296 |
installerTreeViewer.setContentProvider(new TreeNodeContentProvider()); |
|
297 |
installerTreeViewer.setLabelProvider(new LabelProvider() { |
|
298 |
@Override |
|
299 |
public String getText(Object element) { |
|
300 |
TreeNode node = (TreeNode) element; |
|
301 |
Object value = node.getValue(); |
|
302 |
if (value instanceof IRemoteAgentInstaller) { |
|
303 |
String label = ((IRemoteAgentInstaller) value).getLabel(); |
|
304 |
return label == null ? Messages.getString("ConnectionSettingsPage.UnlabeledPackageLabel") : label; //$NON-NLS-1$ |
|
305 |
} |
|
306 |
||
307 |
return value.toString(); |
|
308 |
} |
|
309 |
||
310 |
@Override |
|
311 |
public Image getImage(Object element) { |
|
312 |
if (element.equals(LOADING_CONTENT_TREENODE)) |
|
313 |
return null; |
|
314 |
||
315 |
TreeNode node = (TreeNode) element; |
|
316 |
Object value = node.getValue(); |
|
317 |
if (value instanceof IRemoteAgentInstaller) |
|
318 |
return ((IRemoteAgentInstaller) value).getImage(); |
|
319 |
||
320 |
return FOLDER_ICON_IMG; |
|
321 |
} |
|
322 |
}); |
|
323 |
installerTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
324 |
public void selectionChanged(SelectionChangedEvent event) { |
|
325 |
TreeNode node = (TreeNode) ((StructuredSelection) event.getSelection()).getFirstElement(); |
|
326 |
if (node == null) |
|
327 |
return; |
|
328 |
Object value = node.getValue(); |
|
329 |
boolean isPackage = value instanceof IRemoteAgentInstaller; |
|
330 |
boolean installable = false; |
|
331 |
String information = null; |
|
332 |
if (isPackage) { |
|
333 |
IRemoteAgentInstaller installer = (IRemoteAgentInstaller) value; |
|
334 |
installable = installer.fileSupportsInstall(); |
|
335 |
information = installer.getInformation(); |
|
336 |
} |
|
337 |
if (information != null) |
|
338 |
installerInfoText.setText(information); |
|
339 |
else |
|
340 |
installerInfoText.setText(""); //$NON-NLS-1$ |
|
341 |
installButton.setEnabled(isPackage && installable); |
|
342 |
installerSaveButton.setEnabled(isPackage); |
|
343 |
} |
|
344 |
}); |
|
345 |
||
346 |
installerInfoText = new Text(installerSashForm, SWT.READ_ONLY | SWT.BORDER | SWT.WRAP); |
|
347 |
String errorText = Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString"); //$NON-NLS-1$ |
|
348 |
errorText += "\n" + Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString2"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
349 |
installerInfoText.setText(errorText); |
|
350 |
installerInfoText.setData(UID, "installerInfoText"); //$NON-NLS-1$ |
|
351 |
installerSashForm.setWeights(new int[] {160, 100 }); |
|
352 |
||
353 |
Composite buttonsArea = new Composite(installDebugAgentComposite, SWT.NONE); |
|
354 |
buttonsArea.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); |
|
355 |
gridLayout = new GridLayout(); |
|
356 |
gridLayout.numColumns = 2; |
|
357 |
buttonsArea.setLayout(gridLayout); |
|
358 |
||
359 |
installerSaveButton = new Button(buttonsArea, SWT.NONE); |
|
360 |
final GridData gd_saveButton = new GridData(SWT.RIGHT, SWT.CENTER, false, false); |
|
361 |
gd_saveButton.widthHint = 125; |
|
362 |
installerSaveButton.setLayoutData(gd_saveButton); |
|
363 |
installerSaveButton.setText(Messages.getString("ConnectionSettingsPage.SaveButtonLabel")); //$NON-NLS-1$ |
|
364 |
installerSaveButton.setEnabled(false); |
|
365 |
installerSaveButton.setToolTipText(Messages.getString("ConnectionSettingsPage.SaveButtonToolTip")); //$NON-NLS-1$ |
|
366 |
installerSaveButton.setData(UID, "installerSaveButton"); //$NON-NLS-1$ |
|
367 |
installerSaveButton.addSelectionListener(new SelectionAdapter() { |
|
368 |
public void widgetSelected(SelectionEvent event) { |
|
369 |
Display.getDefault().syncExec(new Runnable() { |
|
370 |
public void run() { |
|
371 |
try { |
|
372 |
IRemoteAgentInstaller installer = getCurrentInstaller(); |
|
373 |
saveAs(installer.getPackageContents(getContainer())); |
|
374 |
} |
|
375 |
catch (Exception e) { |
|
376 |
RemoteConnectionsActivator.logError(e); |
|
377 |
} |
|
378 |
} |
|
379 |
}); |
|
380 |
} |
|
381 |
}); |
|
382 |
||
383 |
installButton = new Button(buttonsArea, SWT.NONE); |
|
384 |
final GridData gd_installButton = new GridData(SWT.RIGHT, SWT.CENTER, false, false); |
|
385 |
gd_installButton.widthHint = 125; |
|
386 |
installButton.setLayoutData(gd_installButton); |
|
387 |
installButton.setText(Messages.getString("ConnectionSettingsPage.InstallButtonLabel")); //$NON-NLS-1$ |
|
388 |
installButton.setEnabled(false); |
|
389 |
installButton.setToolTipText(Messages.getString("ConnectionSettingsPage.InstallButtonToolTip")); //$NON-NLS-1$ |
|
390 |
installButton.setData(UID, "installButton"); //$NON-NLS-1$ |
|
391 |
installButton.addSelectionListener(new SelectionAdapter() { |
|
392 |
public void widgetSelected(SelectionEvent event) { |
|
393 |
Display.getDefault().syncExec(new Runnable() { |
|
394 |
public void run() { |
|
395 |
try { |
|
396 |
IRemoteAgentInstaller installer = getCurrentInstaller(); |
|
397 |
attemptInstall(installer.getPackageContents(getContainer())); |
|
398 |
} |
|
399 |
catch (Exception e) { |
|
400 |
RemoteConnectionsActivator.logError(e); |
|
401 |
} |
|
402 |
} |
|
403 |
}); |
|
404 |
} |
|
405 |
}); |
|
406 |
} |
|
407 |
||
408 |
||
409 |
public void setVisible(boolean visible) { |
|
410 |
super.setVisible(visible); |
|
411 |
if (visible) |
|
412 |
updateDynamicUI(); |
|
413 |
} |
|
414 |
||
415 |
public void updateDynamicUI() { |
|
416 |
IConnectionType currentConnectionType = settingsWizard.getConnectionType(); |
|
417 |
if (currentConnectionType != null && !currentConnectionType.equals(connectionType)) { |
|
418 |
setErrorMessage(null); |
|
419 |
setPageComplete(true); |
|
420 |
String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$ |
|
421 |
serviceTestButton.setText(buttonLabel); |
|
422 |
connectionType = currentConnectionType; |
|
423 |
setTitle(MessageFormat.format(Messages.getString("ConnectionSettingsPage.PageTitleFmt"), connectionType.getDisplayName())); //$NON-NLS-1$ |
|
424 |
setDescription(connectionType.getDescription()); |
|
425 |
||
426 |
// update settings editing UI |
|
427 |
Control[] settingsUI = settingsGroup.getChildren(); |
|
428 |
if (settingsUI.length > 0) { |
|
429 |
for (Control control : settingsUI) { |
|
430 |
control.dispose(); |
|
431 |
} |
|
432 |
} |
|
433 |
connectionFactory = connectionType.getConnectionFactory(); |
|
434 |
Map<String, String> initialSettings = null; |
|
435 |
IConnection connectionToEdit = settingsWizard.getConnectionToEdit(); |
|
436 |
if (connectionToEdit != null && connectionToEdit.getConnectionType().equals(connectionType)) // show existing settings |
|
437 |
initialSettings = connectionToEdit.getSettings(); |
|
438 |
connectionFactory.createEditingUI(settingsGroup, new IValidationErrorReporter() { |
|
439 |
public void setErrorMessage(String newMessage) { |
|
440 |
ConnectionSettingsPage.this.setErrorMessage(newMessage); |
|
441 |
boolean noError = newMessage == null; |
|
442 |
setPageComplete(noError); |
|
443 |
String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$ |
|
444 |
serviceTestButton.setText(buttonLabel); |
|
445 |
} |
|
446 |
}, initialSettings); |
|
447 |
settingsUI = settingsGroup.getChildren(); |
|
448 |
if (settingsUI.length == 0) { |
|
449 |
CLabel label = new CLabel(settingsGroup, SWT.NONE); |
|
450 |
label.setText(MessageFormat.format(Messages.getString("ConnectionSettingsPage.NoSettingsString"), connectionType.getDisplayName())); //$NON-NLS-1$ |
|
451 |
GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, true); |
|
452 |
label.setLayoutData(gd); |
|
453 |
} |
|
454 |
||
455 |
// update services list |
|
456 |
Collection<IService> compatibleServices = |
|
457 |
RemoteConnectionsActivator.getConnectionTypeProvider().getCompatibleServices(connectionType); |
|
458 |
servicesListViewer.setInput(compatibleServices); |
|
459 |
if (!compatibleServices.isEmpty()) { |
|
460 |
servicesListViewer.getList().select(0); |
|
461 |
servicesListViewer.setSelection(servicesListViewer.getSelection()); |
|
462 |
} |
|
463 |
servicesListViewer.getList().addFocusListener(new FocusAdapter() { |
|
464 |
public void focusGained(FocusEvent e) { |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
465 |
resetServiceTesting(true); |
2 | 466 |
} |
467 |
}); |
|
468 |
||
469 |
Thread t = new Thread() { |
|
470 |
@Override |
|
471 |
public void run() { |
|
472 |
initializeInstallerData(); |
|
473 |
} |
|
474 |
}; |
|
475 |
t.start(); |
|
476 |
} |
|
477 |
||
478 |
if (getControl().isVisible()) |
|
479 |
agentTestTabComposite.layout(true, true); |
|
480 |
||
481 |
if (getControl().isVisible()) |
|
482 |
((IWizardContainer2) getWizard().getContainer()).updateSize(); |
|
483 |
} |
|
484 |
||
485 |
private synchronized void initializeInstallerData() { |
|
486 |
Display.getDefault().asyncExec(new Runnable() { |
|
487 |
public void run() { |
|
488 |
installerTreeViewer.setInput(new TreeNode[] { LOADING_CONTENT_TREENODE }); |
|
489 |
installerInfoText.setText(""); //$NON-NLS-1$ |
|
490 |
deviceOSComboViewer.setInput(Collections.EMPTY_LIST); |
|
491 |
} |
|
492 |
}); |
|
493 |
||
494 |
IConnectionTypeProvider connectionTypeProvider = RemoteConnectionsActivator.getConnectionTypeProvider(); |
|
495 |
Collection<IService> services = connectionTypeProvider.getCompatibleServices(connectionType); |
|
496 |
getInstallerProviders(services); |
|
497 |
final TreeNode[] treeNodes = createTreeNodes(); // gets actual data from server |
|
498 |
||
499 |
Display.getDefault().asyncExec(new Runnable() { |
|
500 |
public void run() { |
|
501 |
// update installer tree |
|
502 |
installerTreeViewer.setInput(treeNodes); |
|
503 |
installerTreeViewer.refresh(true); |
|
504 |
installerTreeViewer.expandAll(); |
|
505 |
||
506 |
if (treeNodes.length == 0) { |
|
507 |
String errorText = Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString"); //$NON-NLS-1$ |
|
508 |
errorText += "\n" + Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString2"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
509 |
installerInfoText.setText(errorText); |
|
510 |
} |
|
511 |
||
512 |
// update sdk combo |
|
513 |
List<Pair<String, Version>> deviceOSPairs = createDeviceOSPairs(); |
|
514 |
deviceOSComboViewer.setInput(deviceOSPairs); |
|
515 |
if (!deviceOSPairs.isEmpty()) { |
|
516 |
deviceOSComboViewer.getCombo().select(0); |
|
517 |
deviceOSComboViewer.setSelection(deviceOSComboViewer.getSelection()); |
|
518 |
} |
|
519 |
else { |
|
520 |
String errorLabel = Messages.getString("ConnectionSettingsPage.NoInstallerDataInfoString"); //$NON-NLS-1$ |
|
521 |
deviceOSComboViewer.getCombo().setItems(new String[] {errorLabel}); |
|
522 |
deviceOSComboViewer.getCombo().select(0); |
|
523 |
deviceOSComboViewer.getCombo().setEnabled(false); |
|
524 |
} |
|
525 |
deviceOSComboViewer.getCombo().addFocusListener(new FocusAdapter() { |
|
526 |
public void focusGained(FocusEvent e) { |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
527 |
resetServiceTesting(true); |
2 | 528 |
} |
529 |
}); |
|
530 |
} |
|
531 |
}); |
|
532 |
||
533 |
} |
|
534 |
||
535 |
protected void setSelectionToInstallComposite(Pair<String, Version> pair) { |
|
536 |
Object input = installerTreeViewer.getInput(); |
|
537 |
if (input instanceof TreeNode[]) { |
|
538 |
TreeNode node = findTreeNodeForPair((TreeNode[]) input, pair); |
|
539 |
if (node != null) { |
|
540 |
installerTreeViewer.setSelection(new StructuredSelection(node)); |
|
541 |
} |
|
542 |
} |
|
543 |
} |
|
544 |
||
545 |
private TreeNode findTreeNodeForPair(TreeNode[] treeNodes, Pair<String, Version> pair) { |
|
546 |
for (TreeNode treeNode : treeNodes) { |
|
547 |
Object value = treeNode.getValue(); |
|
548 |
if (value instanceof IRemoteAgentInstaller) { |
|
549 |
TreeNode versionNode = treeNode.getParent(); |
|
550 |
TreeNode familyNode = versionNode.getParent(); |
|
551 |
if (pair.equals(new Pair(familyNode.getValue(), versionNode.getValue()))) |
|
552 |
return treeNode; |
|
553 |
} |
|
554 |
TreeNode[] children = treeNode.getChildren(); |
|
555 |
if (children != null) { |
|
556 |
TreeNode treeNodeFromChildren = findTreeNodeForPair(children, pair); |
|
557 |
if (treeNodeFromChildren != null) |
|
558 |
return treeNodeFromChildren; |
|
559 |
} |
|
560 |
} |
|
561 |
return null; |
|
562 |
} |
|
563 |
||
564 |
protected void testService() { |
|
565 |
Map<String, String> settings = connectionFactory.getSettingsFromUI(); |
|
566 |
boolean newConnection = connection == null || !connectionType.equals(connection.getConnectionType()); |
|
567 |
if (newConnection) { |
|
568 |
if (connection != null) |
|
569 |
connection.dispose(); |
|
570 |
connection = connectionFactory.createConnection(settings); |
|
571 |
connection.setDisplayName("TestConnection:"+connectionType.getDisplayName()); //$NON-NLS-1$ |
|
572 |
} |
|
573 |
else { |
|
574 |
connection.updateSettings(settings); |
|
575 |
} |
|
576 |
if (newConnection || connectedService == null || !connectedService.getService().equals(service)) { |
|
577 |
disposeConnectedService(); |
|
578 |
connectedService = |
|
579 |
RemoteConnectionsActivator.getConnectionsManager().createConnectedService(service, connection); |
|
580 |
IStructuredSelection selection = (IStructuredSelection) deviceOSComboViewer.getSelection(); |
|
581 |
Pair<String, Version> pair = (Pair<String, Version>) selection.getFirstElement(); |
|
582 |
if (pair != null) |
|
583 |
connectedService.setDeviceOS(pair.first, pair.second); |
|
584 |
connectedService.addStatusChangedListener(statusListener = new IStatusChangedListener() { |
|
585 |
public void statusChanged(final IStatus status) { |
|
586 |
Display.getDefault().asyncExec(new Runnable() { |
|
587 |
public void run() { |
|
588 |
if (!statusText.isDisposed()) |
|
589 |
statusText.setText(status.getLongDescription()); |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
590 |
if (status.getEStatus().equals(EStatus.UP)) |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
591 |
resetServiceTesting(false); |
2 | 592 |
} |
593 |
}); |
|
594 |
} |
|
595 |
}); |
|
596 |
if (connectedService instanceof AbstractConnectedService) |
|
597 |
((AbstractConnectedService) connectedService).setRunnableContext(getContainer()); |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
598 |
tester = new Tester(); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
599 |
tester.start(); |
2 | 600 |
isTesting = true; |
601 |
} |
|
602 |
} |
|
603 |
||
604 |
@Override |
|
605 |
public void dispose() { |
|
606 |
disposeInstallerProviders(); |
|
607 |
disposeConnectedService(); |
|
608 |
if (connection != null) |
|
609 |
connection.dispose(); |
|
610 |
super.dispose(); |
|
611 |
} |
|
612 |
||
613 |
private void disposeConnectedService() { |
|
614 |
if (connectedService != null) { |
|
615 |
connectedService.removeStatusChangedListener(statusListener); |
|
616 |
connectedService.dispose(); |
|
617 |
connectedService = null; |
|
618 |
} |
|
619 |
} |
|
620 |
||
621 |
public Map<String, String> getSettings() { |
|
622 |
if (connectionFactory == null) { |
|
623 |
IConnection connectionToEdit = settingsWizard.getConnectionToEdit(); |
|
624 |
if (connectionToEdit == null || !connectionToEdit.getConnectionType().equals(settingsWizard.getConnectionType())) { |
|
625 |
return null; |
|
626 |
} |
|
627 |
return connectionToEdit.getSettings(); |
|
628 |
} |
|
629 |
return connectionFactory.getSettingsFromUI(); |
|
630 |
} |
|
631 |
||
632 |
private void saveAs(IPackageContents packageContents) throws Exception { |
|
633 |
InputStream is = packageContents.getInputStream(); |
|
634 |
if (is != null) { |
|
635 |
Shell shell = getShell(); |
|
636 |
FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
|
637 |
dialog.setText(Messages.getString("ConnectionSettingsPage.SaveAsDialogTitle")); //$NON-NLS-1$ |
|
638 |
if (saveAsParent == null) |
|
639 |
saveAsParent = System.getProperty("user.home"); //$NON-NLS-1$ |
|
640 |
dialog.setFilterPath(saveAsParent); |
|
641 |
dialog.setFileName(packageContents.getDefaultNameFileName()); |
|
642 |
dialog.setOverwrite(true); // prompt for overwrite |
|
643 |
String path = dialog.open(); |
|
644 |
if (path != null) { |
|
645 |
IPath saveAsPath = new Path(path); |
|
646 |
saveAsParent = saveAsPath.removeLastSegments(1).toString(); |
|
647 |
File file = saveAsPath.toFile(); |
|
648 |
FileUtils.copyFile(is, file); |
|
649 |
} |
|
650 |
} |
|
651 |
} |
|
652 |
||
653 |
private void attemptInstall(IPackageContents packageContents) throws Exception { |
|
654 |
File tempDir = FileUtils.getTemporaryDirectory(); |
|
655 |
IPath path = new Path(tempDir.getAbsolutePath()); |
|
656 |
IPath tempFilePath = path.append(packageContents.getDefaultNameFileName()); |
|
657 |
File tempFile = tempFilePath.toFile(); |
|
658 |
if (tempFile.exists()) |
|
659 |
tempFile.delete(); |
|
660 |
InputStream is = packageContents.getInputStream(); |
|
661 |
if (is != null) { |
|
662 |
FileUtils.copyFile(is, tempFile); |
|
663 |
Program.launch(tempFile.getAbsolutePath()); |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
||
668 |
private IRemoteAgentInstaller getCurrentInstaller() { |
|
669 |
TreeNode node = (TreeNode) ((StructuredSelection) installerTreeViewer.getSelection()).getFirstElement(); |
|
670 |
if (node != null) { |
|
671 |
Object value = node.getValue(); |
|
672 |
if (value instanceof IRemoteAgentInstaller) |
|
673 |
return (IRemoteAgentInstaller) value; |
|
674 |
} |
|
675 |
return null; |
|
676 |
} |
|
677 |
||
678 |
private TreeNode[] createTreeNodes() { |
|
679 |
Map<String, TreeNode> sdkFamilyToNodes = new HashMap<String, TreeNode>(); |
|
680 |
for (IRemoteAgentInstallerProvider installerProvider : installerProviders) { |
|
681 |
List<String> familyNames = installerProvider.getSDKFamilyNames(null); |
|
682 |
for (String familyName : familyNames) { |
|
683 |
if (!sdkFamilyToNodes.containsKey(familyName)) |
|
684 |
sdkFamilyToNodes.put(familyName, new TreeNode(familyName)); |
|
685 |
TreeNode familyNode = sdkFamilyToNodes.get(familyName); |
|
686 |
createFamilySubNodes(familyNode, installerProvider); |
|
687 |
} |
|
688 |
} |
|
689 |
return (TreeNode[]) sdkFamilyToNodes.values().toArray(new TreeNode[sdkFamilyToNodes.values().size()]); |
|
690 |
} |
|
691 |
||
692 |
private void createFamilySubNodes(TreeNode familyNode, IRemoteAgentInstallerProvider installerProvider) { |
|
693 |
String familyName = familyNode.getValue().toString(); |
|
694 |
List<Version> versions = installerProvider.getVersions(familyName); |
|
695 |
List<TreeNode> childList = new ArrayList<TreeNode>(); |
|
696 |
TreeNode[] children = familyNode.getChildren(); |
|
697 |
if (children != null) |
|
698 |
childList.addAll(Arrays.asList(children)); |
|
699 |
for (Version version : versions) { |
|
700 |
TreeNode versionNode = getVersionNode(familyNode, version); |
|
701 |
if (versionNode == null) { |
|
702 |
versionNode = new TreeNode(version); |
|
703 |
versionNode.setParent(familyNode); |
|
704 |
childList.add(versionNode); |
|
705 |
} |
|
706 |
createInstallerNodes(versionNode, installerProvider); |
|
707 |
} |
|
708 |
familyNode.setChildren((TreeNode[]) childList.toArray(new TreeNode[childList.size()])); |
|
709 |
} |
|
710 |
||
711 |
private TreeNode getVersionNode(TreeNode familyNode, Version version) { |
|
712 |
TreeNode[] children = familyNode.getChildren(); |
|
713 |
if (children != null) { |
|
714 |
for (TreeNode node : children) { |
|
715 |
if (node.getValue().equals(version)) |
|
716 |
return node; |
|
717 |
} |
|
718 |
} |
|
719 |
return null; |
|
720 |
} |
|
721 |
||
722 |
private void createInstallerNodes(TreeNode versionNode, IRemoteAgentInstallerProvider installerProvider) { |
|
723 |
String familyName = versionNode.getParent().getValue().toString(); |
|
724 |
Version version = (Version) versionNode.getValue(); |
|
725 |
List<IRemoteAgentInstaller> installers = |
|
726 |
installerProvider.getRemoteAgentInstallers(familyName, version); |
|
727 |
List<TreeNode> childList = new ArrayList<TreeNode>(); |
|
728 |
TreeNode[] children = versionNode.getChildren(); |
|
729 |
if (children != null) |
|
730 |
childList.addAll(Arrays.asList(children)); |
|
731 |
for (IRemoteAgentInstaller installer : installers) { |
|
732 |
TreeNode installerNode = new TreeNode(installer); |
|
733 |
installerNode.setParent(versionNode); |
|
734 |
childList.add(installerNode); |
|
735 |
} |
|
736 |
versionNode.setChildren((TreeNode[]) childList.toArray(new TreeNode[childList.size()])); |
|
737 |
} |
|
738 |
||
739 |
private List<Pair<String, Version>> createDeviceOSPairs() { |
|
740 |
List<Pair<String, Version>> deviceOSPairs = new ArrayList<Pair<String, Version>>(); |
|
741 |
for (IRemoteAgentInstallerProvider installerProvider : installerProviders) { |
|
742 |
List<String> familyNames = installerProvider.getSDKFamilyNames(null); |
|
743 |
for (String familyName : familyNames) { |
|
744 |
List<Version> versions = installerProvider.getVersions(familyName); |
|
745 |
for (Version version : versions) { |
|
746 |
Pair<String, Version> pair = new Pair(familyName, version); |
|
747 |
if (!deviceOSPairs.contains(pair)) |
|
748 |
deviceOSPairs.add(pair); |
|
749 |
} |
|
750 |
} |
|
751 |
} |
|
752 |
return deviceOSPairs; |
|
753 |
} |
|
754 |
||
755 |
private void getInstallerProviders(Collection<IService> services) { |
|
756 |
if (installerProviders != null) { |
|
757 |
// check to see if we already have this set of installer providers |
|
758 |
Set<String> serviceIds = new TreeSet<String>(); |
|
759 |
for (IService service : services) { |
|
760 |
if (service.getInstallerProvider() != null) |
|
761 |
serviceIds.add(service.getIdentifier()); |
|
762 |
} |
|
763 |
Set<String> existingServiceIds = new TreeSet<String>(); |
|
764 |
for (IRemoteAgentInstallerProvider installerProvider : installerProviders) { |
|
765 |
existingServiceIds.add(installerProvider.getService().getIdentifier()); |
|
766 |
} |
|
767 |
if (serviceIds.equals(existingServiceIds)) |
|
768 |
return; |
|
769 |
} |
|
770 |
disposeInstallerProviders(); |
|
771 |
installerProviders = new ArrayList<IRemoteAgentInstallerProvider>(); |
|
772 |
for (IService service : services) { |
|
773 |
IRemoteAgentInstallerProvider installerProvider = service.getInstallerProvider(); |
|
774 |
if (installerProvider != null) |
|
775 |
installerProviders.add(installerProvider); |
|
776 |
} |
|
777 |
} |
|
778 |
||
779 |
private void disposeInstallerProviders() { |
|
780 |
if (installerProviders != null) { |
|
781 |
for (IRemoteAgentInstallerProvider installerProvider : installerProviders) { |
|
782 |
installerProvider.dispose(); |
|
783 |
} |
|
784 |
installerProviders.clear(); |
|
785 |
installerProviders = null; |
|
786 |
} |
|
787 |
} |
|
788 |
||
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
789 |
private void resetServiceTesting(final boolean resetAll) { |
2 | 790 |
isTesting = false; |
791 |
if (service == null) |
|
792 |
return; |
|
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
793 |
// may be called from a test thread |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
794 |
Display.getDefault().syncExec(new Runnable() { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
795 |
public void run() { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
796 |
if (resetAll) { |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
797 |
statusText.setText(STATUS_NOT_TESTED); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
798 |
serviceTestInfo.setText(service.getAdditionalServiceInfo()); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
799 |
agentTestTabComposite.layout(true, true); |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
800 |
} |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
801 |
disposeConnectedService(); |
55
8254273d11c0
[Bug 8297] add description column to remote connections view with long description of status and move in-use UI to connection rather than displaying on each service - use blue color for in-use status text rather than yellow
dadubrow
parents:
48
diff
changeset
|
802 |
if (!serviceTestButton.isDisposed()) { |
8254273d11c0
[Bug 8297] add description column to remote connections view with long description of status and move in-use UI to connection rather than displaying on each service - use blue color for in-use status text rather than yellow
dadubrow
parents:
48
diff
changeset
|
803 |
String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$ |
8254273d11c0
[Bug 8297] add description column to remote connections view with long description of status and move in-use UI to connection rather than displaying on each service - use blue color for in-use status text rather than yellow
dadubrow
parents:
48
diff
changeset
|
804 |
serviceTestButton.setText(buttonLabel); |
8254273d11c0
[Bug 8297] add description column to remote connections view with long description of status and move in-use UI to connection rather than displaying on each service - use blue color for in-use status text rather than yellow
dadubrow
parents:
48
diff
changeset
|
805 |
} |
48
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
806 |
} |
cfd7fcf6bf2d
Modifying autotest behavior from connection settings page such that for each time the user request testing, test at most 3 times with success ending autotesting
dadubrow
parents:
2
diff
changeset
|
807 |
}); |
2 | 808 |
} |
809 |
||
810 |
} |