org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 29 Jul 2010 10:00:34 -0700
changeset 458 5ff93668b08c
parent 457 f1087591ff71
child 460 c0bff5ed874c
permissions -rw-r--r--
Emulator deployment was added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 */
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    19
package org.symbian.tools.mtw.internal.deployment;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import java.lang.reflect.InvocationTargetException;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import java.text.MessageFormat;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    23
import java.util.HashMap;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    24
import java.util.Map;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.core.runtime.CoreException;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.core.runtime.IProgressMonitor;
278
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
    28
import org.eclipse.core.runtime.IStatus;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.eclipse.core.runtime.SubProgressMonitor;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
import org.eclipse.jface.operation.IRunnableWithProgress;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
import org.eclipse.jface.util.Policy;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
import org.eclipse.jface.viewers.ArrayContentProvider;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
import org.eclipse.jface.viewers.DoubleClickEvent;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
import org.eclipse.jface.viewers.IDoubleClickListener;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
import org.eclipse.jface.viewers.ISelection;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
import org.eclipse.jface.viewers.ISelectionChangedListener;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
import org.eclipse.jface.viewers.IStructuredSelection;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
import org.eclipse.jface.viewers.SelectionChangedEvent;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
import org.eclipse.jface.viewers.StructuredSelection;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
import org.eclipse.jface.viewers.TableViewer;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
import org.eclipse.jface.viewers.ViewerSorter;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
import org.eclipse.jface.wizard.IWizardContainer;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
import org.eclipse.jface.wizard.WizardDialog;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
import org.eclipse.jface.wizard.WizardPage;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
import org.eclipse.swt.SWT;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
import org.eclipse.swt.events.SelectionAdapter;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
import org.eclipse.swt.events.SelectionEvent;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
import org.eclipse.swt.layout.FormAttachment;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
import org.eclipse.swt.layout.FormData;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
import org.eclipse.swt.layout.FormLayout;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
import org.eclipse.swt.widgets.Button;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
import org.eclipse.swt.widgets.Composite;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    53
import org.eclipse.swt.widgets.Control;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    54
import org.eclipse.ui.model.WorkbenchLabelProvider;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    55
import org.eclipse.ui.part.PageBook;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    56
import org.symbian.tools.mtw.ui.MTWCoreUI;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    57
import org.symbian.tools.mtw.ui.ProjectMemo;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    58
import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    59
import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    60
import org.symbian.tools.mtw.ui.deployment.ITargetDetailsPane;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    61
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    62
public class DeploymentTargetWizardPage extends WizardPage {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
    private final DeployWizardContext context;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
    private TableViewer list;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    65
    private final IDeploymentTarget prev;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    66
    private PageBook descriptions;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    67
    private final Map<IDeploymentTargetType, ITargetDetailsPane> panes = new HashMap<IDeploymentTargetType, ITargetDetailsPane>();
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    68
    private Control emptyness;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    69
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    70
    public DeploymentTargetWizardPage(DeployWizardContext context, ProjectMemo memo) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
        super("TargetPage", "Select Deployment Target", null);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
        this.context = context;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    73
        prev = memo.getPreviousDeploymentTarget();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
        setDescription(MessageFormat.format("Select emulator or device to deploy WRT application ''{0}''", context
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    75
                .getProject().getProject().getName()));
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    78
    public void createControl(Composite parent) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
        Composite root = new Composite(parent, SWT.NONE);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    80
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
        root.setLayout(new FormLayout());
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    82
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    83
        list = new TableViewer(root, SWT.BORDER);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
        list.setContentProvider(new ArrayContentProvider());
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    85
        list.setLabelProvider(new WorkbenchLabelProvider());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    86
        list.setSorter(new ViewerSorter() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    87
            @Override
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    88
            public int category(Object element) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    89
                return ((DeploymentTargetWrapper) element).getCategory();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    90
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    91
        });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    92
        list.addSelectionChangedListener(new ISelectionChangedListener() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    93
            public void selectionChanged(SelectionChangedEvent event) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    94
                IStructuredSelection selection = ((IStructuredSelection) event.getSelection());
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    95
                DeploymentTargetWrapper target = (DeploymentTargetWrapper) selection.getFirstElement();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    96
                selectDeploymentTarget(target);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    97
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    98
        });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    99
        list.addDoubleClickListener(new IDoubleClickListener() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   100
            public void doubleClick(DoubleClickEvent event) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   101
                if (getWizard().performFinish()) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   102
                    IWizardContainer container = getWizard().getContainer();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   103
                    if (container instanceof WizardDialog) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   104
                        ((WizardDialog) container).close();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   105
                    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   106
                }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   107
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   108
        });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   109
        final Button search = new Button(root, SWT.NONE);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   110
        search.addSelectionListener(new SelectionAdapter() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   111
            @Override
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   112
            public void widgetSelected(SelectionEvent e) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   113
                doBluetoothSearch(search);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   114
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   115
        });
278
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   116
        search.setText("Discover");
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   117
        search.setImage(MTWCoreUI.getImages().getDiscoverButtonIcon());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   118
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   119
        descriptions = new PageBook(root, SWT.BORDER);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   120
        emptyness = new Composite(descriptions, SWT.NONE);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   121
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   122
        FormData data = new FormData();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   123
        data.left = new FormAttachment(0, 5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   124
        data.right = new FormAttachment(100, -5);
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   125
        data.bottom = new FormAttachment(100, -5);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   126
        data.height = 50;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   127
        descriptions.setLayoutData(data);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   129
        data = new FormData();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   130
        data.top = new FormAttachment(0, 5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   131
        data.right = new FormAttachment(100, -5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   132
        search.setLayoutData(data);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   133
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   134
        data = new FormData();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   135
        data.left = new FormAttachment(0, 5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
        data.top = new FormAttachment(0, 5);
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   137
        data.bottom = new FormAttachment(descriptions, -10);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
        data.right = new FormAttachment(search, -10);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
        list.getControl().setLayoutData(data);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   142
        list.setInput(context.getDeploymentTargets());
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   144
        setPageComplete(false);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   145
        if (prev != null) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   146
            list.setSelection(new StructuredSelection(prev));
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   147
        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   148
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   149
        if (!context.areTargetsReady()) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   150
            setMessage("Press \"Discover\" to find more deployment targets", IStatus.WARNING);
278
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   151
        }
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   152
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   153
        setControl(root);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   154
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   155
278
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   156
    protected void toggleLogging(boolean logging) {
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   157
        context.setLogging(logging);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   158
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   159
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   160
    protected void doBluetoothSearch(final Button search) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   161
        try {
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   162
            final ISelection sel = list.getSelection();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   163
            getContainer().run(true, true, new IRunnableWithProgress() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   164
                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   165
                    monitor.beginTask("Searching for Bluetooth devices", IProgressMonitor.UNKNOWN);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   166
                    try {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   167
                        context.doSearch(new SubProgressMonitor(monitor, 100));
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
                    } catch (CoreException e) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   169
                        Policy.getStatusHandler().show(e.getStatus(), "WRT Application Deployment");
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   170
                    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   171
                    monitor.done();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   172
                    search.getDisplay().asyncExec(new Runnable() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   173
                        public void run() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   174
                            list.setInput(context.getDeploymentTargets());
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   175
                            if (!sel.isEmpty()) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   176
                                list.setSelection(sel);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   177
                                selectDeploymentTarget((DeploymentTargetWrapper) ((IStructuredSelection)sel).getFirstElement());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   178
                            } else {
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   179
                                DeploymentTargetWrapper[] deploymentTargets = context.getDeploymentTargets();
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   180
                                if (deploymentTargets.length == 0) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   181
                                    selectDeploymentTarget(null);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   182
                                } else {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   183
                                    list.setSelection(new StructuredSelection(deploymentTargets[0]));
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   184
                                    selectDeploymentTarget(deploymentTargets[0]);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   185
                                }
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   186
                            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   187
                        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   188
                    });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   189
                }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   190
            });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   191
        } catch (InvocationTargetException e) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   192
            MTWCoreUI.log(e);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   193
        } catch (InterruptedException e) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   194
            MTWCoreUI.log(e);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   195
        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   196
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   197
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   198
    protected void selectDeploymentTarget(DeploymentTargetWrapper target) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   199
        if (target != null) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   200
            context.setTarget(target);
278
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   201
            setMessage(null);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   202
            setErrorMessage(null);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   203
            setPageComplete(true);
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   204
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   205
            IDeploymentTargetType type = target.getType();
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   206
            ITargetDetailsPane pane = panes.get(type);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   207
            if (pane == null) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   208
                pane = MTWCoreUI.getDefault().getPresentations().createDetailsPane(type);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   209
                pane.createControl(descriptions);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   210
                pane.init(this);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   211
                panes.put(type, pane);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   212
            }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   213
            pane.setTarget(target.getActualTarget());
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   214
            descriptions.showPage(pane.getControl());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   215
        } else {
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   216
            descriptions.showPage(emptyness);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   217
            context.setTarget(null);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   218
            setPageComplete(false);
278
890be734ebec Bug 2304 - Hint the user that he should do search to deploy the application to bluetooth
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 263
diff changeset
   219
            setMessage(null);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   220
            setErrorMessage("Select device or emulator to deploy the application");
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   221
        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   222
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   223
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   224
}