org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetProviderRegistry.java
changeset 455 5da55957c779
equal deleted inserted replaced
454:38d6944cff88 455:5da55957c779
       
     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 org.eclipse.core.runtime.IConfigurationElement;
       
    22 import org.eclipse.core.runtime.Platform;
       
    23 import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetProvider;
       
    24 
       
    25 public class DeploymentTargetProviderRegistry {
       
    26     private static DeploymentTargetProviderRegistry INSTANCE;
       
    27 
       
    28     private DeploymentTargetProviderDescriptor[] descriptors;
       
    29 
       
    30     private DeploymentTargetProviderRegistry() {
       
    31         readExtensions();
       
    32     }
       
    33 
       
    34     private void readExtensions() {
       
    35         final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
       
    36                 "org.symbian.tools.mtw.ui.deploymentTargetsProvider");
       
    37         descriptors = new DeploymentTargetProviderDescriptor[elements.length];
       
    38         for (int i = 0; i < elements.length; i++) {
       
    39             descriptors[i] = new DeploymentTargetProviderDescriptor(elements[i]);
       
    40         }
       
    41     }
       
    42 
       
    43     public static synchronized DeploymentTargetProviderRegistry getInstance() {
       
    44         if (INSTANCE == null) {
       
    45             INSTANCE = new DeploymentTargetProviderRegistry();
       
    46         }
       
    47         return INSTANCE;
       
    48     }
       
    49 
       
    50     public DeploymentTargetProviderDescriptor[] getProviders() {
       
    51         return descriptors;
       
    52     }
       
    53 
       
    54     public IDeploymentTargetProvider getProvider(String id) {
       
    55         DeploymentTargetProviderDescriptor[] providers = getProviders();
       
    56         for (DeploymentTargetProviderDescriptor descriptor : providers) {
       
    57             if (descriptor.getId().equals(id)) {
       
    58                 return descriptor;
       
    59             }
       
    60         }
       
    61         return null;
       
    62     }
       
    63 }