org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 29 Jul 2010 15:59:01 -0700
changeset 460 c0bff5ed874c
parent 458 5ff93668b08c
permissions -rw-r--r--
Local filesystem 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;
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    24
import java.util.HashSet;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    25
import java.util.Map;
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    26
import java.util.Set;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.core.runtime.CoreException;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
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
    30
import org.eclipse.core.runtime.IStatus;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
import org.eclipse.core.runtime.SubProgressMonitor;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
import org.eclipse.jface.operation.IRunnableWithProgress;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
import org.eclipse.jface.util.Policy;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
import org.eclipse.jface.viewers.ArrayContentProvider;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
import org.eclipse.jface.viewers.DoubleClickEvent;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
import org.eclipse.jface.viewers.IDoubleClickListener;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
import org.eclipse.jface.viewers.ISelection;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
import org.eclipse.jface.viewers.ISelectionChangedListener;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
import org.eclipse.jface.viewers.IStructuredSelection;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
import org.eclipse.jface.viewers.SelectionChangedEvent;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
import org.eclipse.jface.viewers.StructuredSelection;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
import org.eclipse.jface.viewers.TableViewer;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
import org.eclipse.jface.viewers.ViewerSorter;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
import org.eclipse.jface.wizard.IWizardContainer;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
import org.eclipse.jface.wizard.WizardDialog;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
import org.eclipse.jface.wizard.WizardPage;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
import org.eclipse.swt.SWT;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
import org.eclipse.swt.events.SelectionAdapter;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
import org.eclipse.swt.events.SelectionEvent;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
import org.eclipse.swt.layout.FormAttachment;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
import org.eclipse.swt.layout.FormData;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
import org.eclipse.swt.layout.FormLayout;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
import org.eclipse.swt.widgets.Button;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
import org.eclipse.swt.widgets.Composite;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    55
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
    56
import org.eclipse.ui.model.WorkbenchLabelProvider;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    57
import org.eclipse.ui.part.PageBook;
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    58
import org.symbian.tools.mtw.core.MTWCore;
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    59
import org.symbian.tools.mtw.core.runtimes.IPackager;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    60
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
    61
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
    62
import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    63
import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    64
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
    65
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    66
public class DeploymentTargetWizardPage extends WizardPage implements ITargetDetailsPane.Context {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    67
    private final DeployWizardContext context;
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    68
    private PageBook descriptions;
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    69
    private Control emptyness;
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    70
    private final Set<IDeploymentTarget> inited = new HashSet<IDeploymentTarget>();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
    private TableViewer list;
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
    72
    private final Map<IDeploymentTargetType, ITargetDetailsPane> panes = new HashMap<IDeploymentTargetType, ITargetDetailsPane>();
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    73
    private final IDeploymentTarget prev;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    75
    public DeploymentTargetWizardPage(DeployWizardContext context, ProjectMemo memo) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
        super("TargetPage", "Select Deployment Target", null);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
        this.context = context;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    78
        prev = memo.getPreviousDeploymentTarget();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
        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
    80
                .getProject().getProject().getName()));
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
    }
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
    public void createControl(Composite parent) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
        Composite root = new Composite(parent, SWT.NONE);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    85
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    86
        root.setLayout(new FormLayout());
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    87
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    88
        list = new TableViewer(root, SWT.BORDER);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    89
        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
    90
        list.setLabelProvider(new WorkbenchLabelProvider());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    91
        list.setSorter(new ViewerSorter() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    92
            @Override
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    93
            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
    94
                return ((DeploymentTargetWrapper) element).getCategory();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    95
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    96
        });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    97
        list.addSelectionChangedListener(new ISelectionChangedListener() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    98
            public void selectionChanged(SelectionChangedEvent event) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    99
                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
   100
                DeploymentTargetWrapper target = (DeploymentTargetWrapper) selection.getFirstElement();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   101
                selectDeploymentTarget(target);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   102
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   103
        });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   104
        list.addDoubleClickListener(new IDoubleClickListener() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   105
            public void doubleClick(DoubleClickEvent event) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   106
                if (getWizard().performFinish()) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   107
                    IWizardContainer container = getWizard().getContainer();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   108
                    if (container instanceof WizardDialog) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   109
                        ((WizardDialog) container).close();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   110
                    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   111
                }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   112
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   113
        });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   114
        final Button search = new Button(root, SWT.NONE);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   115
        search.addSelectionListener(new SelectionAdapter() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   116
            @Override
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   117
            public void widgetSelected(SelectionEvent e) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   118
                doBluetoothSearch(search);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   119
            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   120
        });
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
   121
        search.setText("Discover");
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   122
        search.setImage(MTWCoreUI.getImages().getDiscoverButtonIcon());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   123
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   124
        descriptions = new PageBook(root, SWT.BORDER);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   125
        emptyness = new Composite(descriptions, SWT.NONE);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   126
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   127
        FormData data = new FormData();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
        data.left = new FormAttachment(0, 5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   129
        data.right = new FormAttachment(100, -5);
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   130
        data.bottom = new FormAttachment(100, -5);
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   131
        data.height = 80;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   132
        descriptions.setLayoutData(data);
263
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.top = new FormAttachment(0, 5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
        data.right = new FormAttachment(100, -5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   137
        search.setLayoutData(data);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
        data = new FormData();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
        data.left = new FormAttachment(0, 5);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
        data.top = new FormAttachment(0, 5);
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   142
        data.bottom = new FormAttachment(descriptions, -10);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
        data.right = new FormAttachment(search, -10);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   144
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   145
        list.getControl().setLayoutData(data);
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   146
        list.setInput(context.getDeploymentTargets());
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   147
        setPageComplete(false);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   148
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   149
        if (prev != null) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   150
            list.setSelection(new StructuredSelection(prev));
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   151
        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   152
        setControl(root);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   153
    }
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
    protected void doBluetoothSearch(final Button search) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   156
        try {
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   157
            final ISelection sel = list.getSelection();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   158
            getContainer().run(true, true, new IRunnableWithProgress() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   159
                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   160
                    monitor.beginTask("Searching for Bluetooth devices", IProgressMonitor.UNKNOWN);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   161
                    try {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   162
                        context.doSearch(new SubProgressMonitor(monitor, 100));
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   163
                    } catch (CoreException e) {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   164
                        Policy.getStatusHandler().show(e.getStatus(), "WRT Application Deployment");
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   165
                    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   166
                    monitor.done();
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   167
                    search.getDisplay().asyncExec(new Runnable() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
                        public void run() {
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   169
                            list.setInput(context.getDeploymentTargets());
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   170
                            if (!sel.isEmpty()) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   171
                                list.setSelection(sel);
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   172
                                selectDeploymentTarget((DeploymentTargetWrapper) ((IStructuredSelection) sel)
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   173
                                        .getFirstElement());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   174
                            } else {
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   175
                                DeploymentTargetWrapper[] deploymentTargets = context.getDeploymentTargets();
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   176
                                if (deploymentTargets.length == 0) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   177
                                    selectDeploymentTarget(null);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   178
                                } else {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   179
                                    list.setSelection(new StructuredSelection(deploymentTargets[0]));
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   180
                                    selectDeploymentTarget(deploymentTargets[0]);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   181
                                }
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   182
                            }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   183
                        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   184
                    });
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   185
                }
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
        } catch (InvocationTargetException e) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   188
            MTWCoreUI.log(e);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   189
        } catch (InterruptedException e) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
   190
            MTWCoreUI.log(e);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   191
        }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   192
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   193
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   194
    private IPackager getPackager() {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   195
        return MTWCore.getDefault().getRuntimesManager().getPackager(context.getProject());
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   196
    }
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
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) {
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   200
            if (!inited.contains(target)) {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   201
                target.init(context.getProject(), getPackager(),
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   202
                        MTWCoreUI.getMemo(context.getProject()).getMemo(target.getType().getId(), target));
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   203
                inited.add(target);
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   204
            }
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   205
            context.setTarget(target);
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   206
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   207
            IDeploymentTargetType type = target.getType();
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   208
            ITargetDetailsPane pane = panes.get(type);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   209
            if (pane == null) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   210
                pane = MTWCoreUI.getDefault().getPresentations().createDetailsPane(type);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   211
                pane.createControl(descriptions);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   212
                pane.init(this);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   213
                panes.put(type, pane);
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   214
            }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   215
            pane.setTarget(target.getActualTarget());
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   216
            descriptions.showPage(pane.getControl());
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   217
        } else {
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   218
            descriptions.showPage(emptyness);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   219
            context.setTarget(null);
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   220
            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
   221
            setMessage(null);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   222
        }
460
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   223
        revalidate();
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   224
    }
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   225
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   226
    protected void toggleLogging(boolean logging) {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   227
        context.setLogging(logging);
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   228
    }
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   229
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   230
    public void revalidate() {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   231
        String error = null;
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   232
        String warning = !context.areTargetsReady() ? "Press \"Discover\" to find more deployment targets" : null;
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   233
        if (context.getTarget() == null) {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   234
            error = "Select device or emulator to deploy the application";
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   235
        } else {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   236
            final IStatus validate = panes.get(context.getTarget().getType()).validate();
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   237
            if (validate.getSeverity() == IStatus.ERROR) {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   238
                error = validate.getMessage();
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   239
            } else if (validate.getSeverity() == IStatus.WARNING) {
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   240
                warning = validate.getMessage();
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   241
            }
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   242
        }
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   243
        setErrorMessage(error);
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   244
        setMessage(warning, IStatus.WARNING);
c0bff5ed874c Local filesystem deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   245
        setPageComplete(error == null);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   246
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   247
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   248
}