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