connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java
author Ed Swartz <ed.swartz@nokia.com>
Wed, 30 Dec 2009 11:43:43 -0600
changeset 730 8ecd45ef360e
parent 728 a39d0ba41f81
child 731 68bc07acac96
permissions -rw-r--r--
Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     1
/*
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     8
*
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    11
*
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    12
* Contributors:
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    13
*
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    14
* Description: 
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    15
*
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    16
*/
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    17
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    18
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    19
package com.nokia.carbide.remoteconnections.internal.ui;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    20
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    21
import com.nokia.carbide.remoteconnections.Messages;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    22
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    23
import com.nokia.carbide.remoteconnections.interfaces.*;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    24
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    25
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    26
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    27
import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    28
import com.nokia.cpp.internal.api.utils.core.Check;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    29
import com.nokia.cpp.internal.api.utils.core.ListenerList;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    30
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
    31
import org.eclipse.core.runtime.IStatus;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
    32
import org.eclipse.core.runtime.Status;
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    33
import org.eclipse.jface.dialogs.Dialog;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    34
import org.eclipse.jface.dialogs.IDialogConstants;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    35
import org.eclipse.jface.resource.JFaceResources;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    36
import org.eclipse.jface.viewers.*;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    37
import org.eclipse.swt.SWT;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    38
import org.eclipse.swt.events.DisposeEvent;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    39
import org.eclipse.swt.events.DisposeListener;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    40
import org.eclipse.swt.events.SelectionAdapter;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    41
import org.eclipse.swt.events.SelectionEvent;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    42
import org.eclipse.swt.graphics.*;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    43
import org.eclipse.swt.layout.GridData;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    44
import org.eclipse.swt.layout.GridLayout;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    45
import org.eclipse.swt.widgets.*;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    46
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    47
import java.text.MessageFormat;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    48
import java.util.*;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    49
import java.util.List;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    50
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    51
/**
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    52
 * Implementation of IClientServiceSiteUI2
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    53
 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    54
@SuppressWarnings("deprecation")
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    55
public class ClientServiceSiteUI2 implements IClientServiceSiteUI2, IConnectionListener, IConnectionsManagerListener {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    56
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    57
	private IService service;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    58
	private ComboViewer viewer;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    59
	private FontMetrics fm;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    60
	private Set<IConnectionType> compatibleConnectionTypes;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    61
	private Button editButton;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    62
	private Button newButton;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    63
	private String connection;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    64
	private ListenerList<IListener> listenerList;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    65
	private static final String UID = ".uid"; //$NON-NLS-1$
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    66
	private Map<String, String> connectionNames;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    67
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    68
	public ClientServiceSiteUI2(IService service) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    69
		Check.checkArg(service);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    70
		this.service = service;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    71
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    72
	
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    73
	public void createComposite(Composite parent) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    74
		initializeDialogUnits(parent);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    75
		Group group = new Group(parent, SWT.NONE);
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
    76
		group.setText(Messages.getString("ClientServiceSiteUI2.UseConnectionGroupLabel")); //$NON-NLS-1$
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    77
		group.setLayout(new GridLayout());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    78
		group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    79
		group.setData(UID, "useConnectionGroup"); //$NON-NLS-1$
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    80
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    81
		viewer = new ComboViewer(group, SWT.READ_ONLY);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    82
		viewer.setLabelProvider(new LabelProvider() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    83
			@Override
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    84
			public String getText(Object element) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    85
				Check.checkContract(element instanceof String);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    86
				String id = (String) element;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    87
				return connectionNames.get(id);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    88
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    89
		});
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    90
		viewer.setContentProvider(new ArrayContentProvider());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    91
		GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    92
		viewer.getCombo().setLayoutData(gd);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    93
		viewer.getControl().setData(UID, "viewer"); //$NON-NLS-1$
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    94
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    95
			public void selectionChanged(SelectionChangedEvent event) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    96
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    97
				String connection = (String) selection.getFirstElement();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    98
				if (!connection.equals(ClientServiceSiteUI2.this.connection)) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    99
					ClientServiceSiteUI2.this.connection = connection;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   100
					fireConnectionSelected();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   101
				}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   102
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   103
		});
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   104
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   105
		final Composite composite = new Composite(group, SWT.NONE);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   106
		GridLayout layout = new GridLayout();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   107
		layout.numColumns = 2;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   108
		layout.makeColumnsEqualWidth = true;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   109
		layout.marginWidth = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_MARGIN);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   110
		layout.marginHeight = Dialog.convertVerticalDLUsToPixels(fm, IDialogConstants.VERTICAL_MARGIN);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   111
		layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_SPACING);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   112
		layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fm, IDialogConstants.VERTICAL_SPACING);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   113
		composite.setLayout(layout);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   114
		gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   115
		composite.setLayoutData(gd);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   116
		composite.setFont(parent.getFont());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   117
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   118
		newButton = new Button(composite, SWT.PUSH);
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   119
		newButton.setText(Messages.getString("ClientServiceSiteUI2.NewButtonLabel")); //$NON-NLS-1$
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   120
		newButton.setFont(JFaceResources.getDialogFont());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   121
		gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   122
		int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   123
		Point minSize = newButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   124
		gd.widthHint = Math.max(widthHint, minSize.x);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   125
		newButton.setLayoutData(gd);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   126
		newButton.setData(UID, "newButton"); //$NON-NLS-1$
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   127
		newButton.addSelectionListener(new SelectionAdapter() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   128
			@Override
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   129
			public void widgetSelected(SelectionEvent e) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   130
				SettingsWizard wizard = new SettingsWizard(null, service);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   131
				wizard.open(composite.getShell());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   132
				IConnection connection = wizard.getConnectionToEdit();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   133
				// note: refresh ASAP so the selection will be valid; but endure a listener event
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   134
				// which will redo this
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   135
				refreshUI();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   136
				setViewerInput(connection);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   137
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   138
		});
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   139
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   140
		editButton = new Button(composite, SWT.PUSH);
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   141
		editButton.setText(Messages.getString("ClientServiceSiteUI2.EditButtonLabel")); //$NON-NLS-1$
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   142
		editButton.setFont(JFaceResources.getDialogFont());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   143
		gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   144
		widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   145
		minSize = editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   146
		gd.widthHint = Math.max(widthHint, minSize.x);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   147
		editButton.setLayoutData(gd);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   148
		editButton.setData(UID, "editButton"); //$NON-NLS-1$
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   149
		editButton.addSelectionListener(new SelectionAdapter() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   150
			@Override
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   151
			public void widgetSelected(SelectionEvent e) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   152
				IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   153
				Object value = selection.getFirstElement();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   154
				if (value instanceof String) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   155
					IConnection editConnection = getActualConnection((String) value);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   156
					SettingsWizard wizard = new SettingsWizard(editConnection, service);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   157
					wizard.open(composite.getShell());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   158
					
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   159
					// leave the viewer the same, callback will refresh anything needed
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   160
				}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   161
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   162
		});
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   163
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   164
		// attach listeners
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   165
		RemoteConnectionsActivator.getConnectionsManager().addConnectionListener(this);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   166
		RemoteConnectionsActivator.getConnectionsManager().addConnectionStoreChangedListener(this);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   167
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   168
		// remove listeners on dispose
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   169
		group.addDisposeListener(new DisposeListener() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   170
			
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   171
			public void widgetDisposed(DisposeEvent e) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   172
				RemoteConnectionsActivator.getConnectionsManager().addConnectionListener(ClientServiceSiteUI2.this);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   173
				RemoteConnectionsActivator.getConnectionsManager().addConnectionStoreChangedListener(ClientServiceSiteUI2.this);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   174
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   175
		});
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   176
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   177
		setViewerInput(null);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   178
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   179
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   180
	/**
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   181
	 * Get the actual connection for an identifier.
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   182
	 * This is not {@link IConnectionsManager#ensureConnection(String, IService)} because we don't
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   183
	 * want to actually validate the connection now.
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   184
	 * @param id
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   185
	 * @return {@link IConnection} or <code>null</code>
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   186
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   187
	protected IConnection getActualConnection(String id) {
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   188
		if (id == null) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   189
			return null;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   190
		}
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   191
		if (id.equals(Registry.DEFAULT_CONNECTION_ID)) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   192
			return RemoteConnectionsActivator.getConnectionsManager().getDefaultConnection();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   193
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   194
		for (IConnection connection : RemoteConnectionsActivator.getConnectionsManager().getConnections()) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   195
			if (connection.getIdentifier().equals(id)) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   196
				return connection;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   197
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   198
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   199
		return null;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   200
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   201
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   202
	/**
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   203
	 * Set the selected input.  
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   204
	 * @param connection existing connection or <code>null</code> for the default   
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   205
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   206
	private void setViewerInput(IConnection connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   207
		List<IConnection> compatible = getCompatibleConnections();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   208
		connectionNames = new LinkedHashMap<String, String>();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   209
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   210
		// update the default
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   211
		IConnection defaultConnection = RemoteConnectionsActivator.getConnectionsManager().getDefaultConnection();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   212
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   213
		connectionNames.put(Registry.DEFAULT_CONNECTION_ID, createDefaultConnectionName(defaultConnection));
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   214
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   215
		for (IConnection conn : compatible) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   216
			connectionNames.put(conn.getIdentifier(), conn.getDisplayName());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   217
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   218
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   219
		viewer.setInput(connectionNames.keySet());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   220
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   221
		if (connectionNames.isEmpty())
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   222
			viewer.getCombo().setEnabled(false);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   223
		else {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   224
			viewer.getCombo().setEnabled(true);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   225
			if (connection == null) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   226
				viewer.getCombo().select(0);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   227
				viewer.setSelection(viewer.getSelection());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   228
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   229
			else
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   230
				selectConnection(connection.getIdentifier());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   231
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   232
		editButton.setEnabled(!viewer.getSelection().isEmpty());
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   233
		
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   234
		// fire listener in case we selected anew or the default connection changed
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   235
		fireConnectionSelected();
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   236
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   237
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   238
	private void refreshUI() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   239
		Display.getDefault().syncExec(new Runnable() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   240
			public void run() {
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   241
				if (viewer != null && viewer.getContentProvider() != null) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   242
					
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   243
					// try to preserve the currently selected item, if it's a concrete
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   244
					// connection; if it's default, allow for the new default to be chosen.
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   245
					IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   246
					Object value = selection.getFirstElement();
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   247
					String current = null;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   248
					if (value instanceof String) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   249
						current = (String) value;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   250
					}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   251
					if (Registry.DEFAULT_CONNECTION_ID.equals(current)) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   252
						current = null;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   253
					}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   254
					setViewerInput(getActualConnection(current));
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   255
				}
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   256
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   257
		});
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   258
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   259
	
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   260
	/**
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   261
	 * @param defaultConnection
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   262
	 * @return
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   263
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   264
	private String createDefaultConnectionName(IConnection defaultConnection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   265
		return MessageFormat.format("Default connection ({0})",
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   266
				defaultConnection != null ? defaultConnection.getDisplayName() : 
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   267
					"when defined");
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   268
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   269
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   270
	private void initializeDialogUnits(Composite parent) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   271
		GC gc = new GC(parent);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   272
		gc.setFont(JFaceResources.getDialogFont());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   273
		fm = gc.getFontMetrics();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   274
		gc.dispose();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   275
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   276
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   277
	private List<IConnection> getCompatibleConnections() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   278
		getCompatibleConnectionTypes();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   279
		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   280
		List<IConnection> compatibleConnections = new ArrayList<IConnection>();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   281
		for (IConnection connection : Registry.instance().getConnections()) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   282
			if (isCompatibleConnection(connection))
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   283
				compatibleConnections.add(connection);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   284
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   285
		return compatibleConnections;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   286
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   287
	
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   288
	private boolean isCompatibleConnection(IConnection connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   289
		return compatibleConnectionTypes.contains(connection.getConnectionType());
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   290
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   291
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   292
	private void getCompatibleConnectionTypes() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   293
		compatibleConnectionTypes = new HashSet<IConnectionType>();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   294
		Collection<String> compatibleTypeIds =
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   295
			Registry.instance().getCompatibleConnectionTypeIds(service);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   296
		for (String typeId : compatibleTypeIds) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   297
			compatibleConnectionTypes.add(
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   298
					Registry.instance().getConnectionType(typeId));
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   299
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   300
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   301
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   302
	public void selectConnection(String connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   303
		viewer.setSelection(new StructuredSelection(connection));
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   304
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   305
	
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   306
	public String getSelectedConnection() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   307
		return connection;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   308
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   309
	
730
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   310
	public IStatus getSelectionStatus() {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   311
		// no selection yet...?
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   312
		if (connection == null) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   313
			return new Status(IStatus.ERROR, RemoteConnectionsActivator.PLUGIN_ID,
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   314
					Messages.getString("ClientServiceSiteUI2.NoConnectionError"));
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   315
		}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   316
		
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   317
		// check whether the default is compatible with the service and connection type
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   318
		if (Registry.DEFAULT_CONNECTION_ID.equals(connection)) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   319
			IConnection actual = getActualConnection(connection);
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   320
			if (actual != null) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   321
				// is the service supported?
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   322
				boolean found = false;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   323
				for (IConnectedService aService : Registry.instance().getConnectedServices(actual)) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   324
					if (service.getIdentifier().equals(aService.getService().getIdentifier())) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   325
						found = true;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   326
						break;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   327
					}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   328
				}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   329
				if (!found) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   330
					return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID,
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   331
							MessageFormat.format(
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   332
									Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionService"),
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   333
									actual.getDisplayName(),
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   334
									service.getDisplayName()));
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   335
				}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   336
				
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   337
				// is the hardware type supported by the service?
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   338
				if (!isCompatibleConnection(actual)) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   339
					String requiredConnectionTypes  = "";
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   340
					for (IConnectionType type : compatibleConnectionTypes) {
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   341
						if (requiredConnectionTypes.length() > 0)
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   342
							requiredConnectionTypes += ", ";
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   343
						requiredConnectionTypes += type.getDisplayName();
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   344
					}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   345
					return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID,
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   346
							MessageFormat.format(
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   347
									Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionType"),
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   348
									actual.getDisplayName(),
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   349
									requiredConnectionTypes));
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   350
			
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   351
				}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   352
				
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   353
			}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   354
		}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   355
		
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   356
		// otherwise, it's okay!
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   357
		return Status.OK_STATUS;
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   358
	}
8ecd45ef360e Fix up some issues found when using the random connected service provider. Also, move validation checks of IClientServiceSiteUI2 into a method of that interface, since we need to handle the case where the default connection is currently incompatible.
Ed Swartz <ed.swartz@nokia.com>
parents: 728
diff changeset
   359
	
728
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   360
	/* (non-Javadoc)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   361
	 * @see com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2#getConnectionDisplayName(java.lang.String)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   362
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   363
	public String getConnectionDisplayName(String connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   364
		String display = connectionNames.get(connection);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   365
		if (display == null)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   366
			display = MessageFormat.format("<<nonexistent connection {0}>>", connection);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   367
		return display;
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   368
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   369
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   370
	public void addListener(IListener listener) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   371
		if (listenerList == null)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   372
			listenerList = new ListenerList<IListener>();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   373
		listenerList.add(listener);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   374
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   375
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   376
	public void removeListener(IListener listener) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   377
		if (listenerList != null)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   378
			listenerList.remove(listener);
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   379
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   380
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   381
	private void fireConnectionSelected() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   382
		if (listenerList != null) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   383
			for (IListener listener : listenerList) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   384
				listener.connectionSelected();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   385
			}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   386
		}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   387
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   388
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   389
	/* (non-Javadoc)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   390
	 * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener#connectionAdded(com.nokia.carbide.remoteconnections.interfaces.IConnection)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   391
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   392
	public void connectionAdded(IConnection connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   393
		refreshUI();
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   394
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   395
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   396
	/* (non-Javadoc)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   397
	 * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener#connectionRemoved(com.nokia.carbide.remoteconnections.interfaces.IConnection)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   398
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   399
	public void connectionRemoved(IConnection connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   400
		refreshUI();		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   401
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   402
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   403
	/* (non-Javadoc)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   404
	 * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener#defaultConnectionSet(com.nokia.carbide.remoteconnections.interfaces.IConnection)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   405
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   406
	public void defaultConnectionSet(IConnection connection) {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   407
		refreshUI();		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   408
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   409
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   410
	/* (non-Javadoc)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   411
	 * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener#connectionStoreChanged()
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   412
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   413
	public void connectionStoreChanged() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   414
		refreshUI();		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   415
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   416
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   417
	/* (non-Javadoc)
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   418
	 * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener#displayChanged()
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   419
	 */
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   420
	public void displayChanged() {
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   421
		refreshUI();		
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   422
	}
a39d0ba41f81 Initial work for bug #10418
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   423
}