org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeployWizardContext.java
changeset 461 7a8f9fa8d278
parent 460 c0bff5ed874c
child 462 cdc4995b1677
equal deleted inserted replaced
460:c0bff5ed874c 461:7a8f9fa8d278
     1 /**
       
     2  * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Symbian Foundation - initial contribution.
       
    11  * Contributors:
       
    12  * Description:
       
    13  * Overview:
       
    14  * Details:
       
    15  * Platforms/Drives/Compatibility:
       
    16  * Assumptions/Requirement/Pre-requisites:
       
    17  * Failures and causes:
       
    18  */
       
    19 package org.symbian.tools.mtw.internal.deployment;
       
    20 
       
    21 import java.util.Arrays;
       
    22 import java.util.Collection;
       
    23 import java.util.HashSet;
       
    24 
       
    25 import org.eclipse.core.runtime.CoreException;
       
    26 import org.eclipse.core.runtime.IProgressMonitor;
       
    27 import org.eclipse.core.runtime.SubProgressMonitor;
       
    28 import org.symbian.tools.mtw.core.projects.IMTWProject;
       
    29 import org.symbian.tools.mtw.ui.MTWCoreUI;
       
    30 
       
    31 public class DeployWizardContext {
       
    32     private DeploymentTargetWrapper target;
       
    33     private final IMTWProject project;
       
    34     private boolean logging;
       
    35 
       
    36     public DeployWizardContext(IMTWProject project) {
       
    37         this.project = project;
       
    38     }
       
    39 
       
    40     public void setTarget(DeploymentTargetWrapper target) {
       
    41         this.target = target;
       
    42     }
       
    43 
       
    44     public DeploymentTargetWrapper getTarget() {
       
    45         return target;
       
    46     }
       
    47 
       
    48     public IMTWProject getProject() {
       
    49         return project;
       
    50     }
       
    51 
       
    52     public DeploymentTargetWrapper[] getDeploymentTargets() {
       
    53         final DeploymentTargetTypeDescriptor[] providers = MTWCoreUI.getDefault().getDeploymentTypesRegistry()
       
    54                 .getProviders();
       
    55         Collection<DeploymentTargetWrapper> targets = new HashSet<DeploymentTargetWrapper>();
       
    56 
       
    57         for (DeploymentTargetTypeDescriptor provider : providers) {
       
    58             if (provider.supports(project)) {
       
    59                 targets.addAll(Arrays.asList(provider.getTargets(project)));
       
    60             }
       
    61         }
       
    62         return targets.toArray(new DeploymentTargetWrapper[targets.size()]);
       
    63     }
       
    64 
       
    65     public void doSearch(IProgressMonitor monitor) throws CoreException {
       
    66         final DeploymentTargetTypeDescriptor[] providers = MTWCoreUI.getDefault().getDeploymentTypesRegistry()
       
    67                 .getProviders();
       
    68         monitor.beginTask("Discovering deployment targets", providers.length * 10);
       
    69         for (DeploymentTargetTypeDescriptor descriptor : providers) {
       
    70             descriptor.discoverTargets(new SubProgressMonitor(monitor, 10));
       
    71         }
       
    72         monitor.done();
       
    73     }
       
    74 
       
    75     public boolean areTargetsReady() {
       
    76         final DeploymentTargetTypeDescriptor[] providers = MTWCoreUI.getDefault().getDeploymentTypesRegistry()
       
    77                 .getProviders();
       
    78         for (DeploymentTargetTypeDescriptor descriptor : providers) {
       
    79             if (!descriptor.targetsDiscovered()) {
       
    80                 return false;
       
    81             }
       
    82         }
       
    83         return true;
       
    84     }
       
    85 
       
    86     public void setLogging(boolean logging) {
       
    87         this.logging = logging;
       
    88     }
       
    89 
       
    90     public boolean isLogging() {
       
    91         return logging;
       
    92     }
       
    93 }