org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeployWizardContext.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Wed, 28 Jul 2010 14:07:39 -0700
changeset 456 12b549765c34
parent 455 5da55957c779
child 457 f1087591ff71
permissions -rw-r--r--
Refactoring and adding better bluetooth target decoration
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
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    21
import java.util.Arrays;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    22
import java.util.Collection;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    23
import java.util.HashSet;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    24
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.core.runtime.CoreException;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    26
import org.eclipse.core.runtime.IProgressMonitor;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.core.runtime.SubProgressMonitor;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    28
import org.symbian.tools.mtw.core.projects.IMTWProject;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
public class DeployWizardContext {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    31
    private DeploymentTargetWrapper target;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    32
    private final IMTWProject project;
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
    33
    private boolean logging;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    35
    public DeployWizardContext(IMTWProject project) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
        this.project = project;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    39
    public void setTarget(DeploymentTargetWrapper target) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
        this.target = target;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    43
    public DeploymentTargetWrapper getTarget() {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
        return target;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    47
    public IMTWProject getProject() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    48
        return project;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    49
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    50
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    51
    public DeploymentTargetWrapper[] getDeploymentTargets() {
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    52
        final DeploymentTargetTypeDescriptor[] providers = DeploymentTargetTypesRegistry.getInstance()
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    53
                .getProviders();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    54
        Collection<DeploymentTargetWrapper> targets = new HashSet<DeploymentTargetWrapper>();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    55
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    56
        for (DeploymentTargetTypeDescriptor provider : providers) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    57
            if (provider.supports(project)) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    58
                targets.addAll(Arrays.asList(provider.getTargets(project)));
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    59
            }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    60
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    61
        return targets.toArray(new DeploymentTargetWrapper[targets.size()]);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    62
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    64
    public void doSearch(IProgressMonitor monitor) throws CoreException {
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    65
        final DeploymentTargetTypeDescriptor[] providers = DeploymentTargetTypesRegistry.getInstance()
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    66
                .getProviders();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    67
        monitor.beginTask("Discovering deployment targets", providers.length * 10);
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    68
        for (DeploymentTargetTypeDescriptor descriptor : providers) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    69
            descriptor.discoverTargets(new SubProgressMonitor(monitor, 10));
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    70
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    71
        monitor.done();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    74
    public boolean areTargetsReady() {
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    75
        final DeploymentTargetTypeDescriptor[] providers = DeploymentTargetTypesRegistry.getInstance()
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    76
                .getProviders();
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    77
        for (DeploymentTargetTypeDescriptor descriptor : providers) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    78
            if (!descriptor.targetsDiscovered()) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    79
                return false;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    80
            }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    81
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    82
        return true;
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
    83
    }
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
    84
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
    85
    public void setLogging(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
    86
        this.logging = 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
    87
    }
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
    88
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
    89
    public boolean isLogging() {
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
    90
        return 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
    91
    }
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    92
}