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