org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeployWizardContext.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 29 Jul 2010 10:51:59 -0700
changeset 459 c278f0c8917f
parent 457 f1087591ff71
permissions -rw-r--r--
Refactored packager and deployer interfaces
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;
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
    29
import org.symbian.tools.mtw.ui.MTWCoreUI;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
public class DeployWizardContext {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    32
    private DeploymentTargetWrapper target;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    33
    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
    34
    private boolean logging;
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    36
    public DeployWizardContext(IMTWProject project) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
        this.project = project;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    40
    public void setTarget(DeploymentTargetWrapper target) {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
        this.target = target;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    44
    public DeploymentTargetWrapper getTarget() {
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
        return target;
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    48
    public IMTWProject getProject() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    49
        return project;
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
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    52
    public DeploymentTargetWrapper[] getDeploymentTargets() {
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
    53
        final DeploymentTargetTypeDescriptor[] providers = MTWCoreUI.getDefault().getDeploymentTypesRegistry()
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    54
                .getProviders();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    55
        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
    56
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    57
        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
    58
            if (provider.supports(project)) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    59
                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
    60
            }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    61
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    62
        return targets.toArray(new DeploymentTargetWrapper[targets.size()]);
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
    }
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    65
    public void doSearch(IProgressMonitor monitor) throws CoreException {
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
    66
        final DeploymentTargetTypeDescriptor[] providers = MTWCoreUI.getDefault().getDeploymentTypesRegistry()
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    67
                .getProviders();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    68
        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
    69
        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
    70
            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
    71
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    72
        monitor.done();
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
    }
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 boolean areTargetsReady() {
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
    76
        final DeploymentTargetTypeDescriptor[] providers = MTWCoreUI.getDefault().getDeploymentTypesRegistry()
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    77
                .getProviders();
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    78
        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
    79
            if (!descriptor.targetsDiscovered()) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    80
                return false;
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
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 278
diff changeset
    83
        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
    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
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
    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
    87
        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
    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
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
    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
    91
        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
    92
    }
263
0c4249e0396d Bug 2068 - Improve packaging and deployment usability
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    93
}