org.symbian.tools.mtw.core/src/org/symbian/tools/tmw/core/internal/projects/ProjectsSupportManager.java
changeset 461 7a8f9fa8d278
child 468 a05c6e5cc7d9
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.tmw.core.internal.projects;
       
    20 
       
    21 import java.util.Collection;
       
    22 import java.util.LinkedList;
       
    23 
       
    24 import org.eclipse.core.resources.IProject;
       
    25 import org.eclipse.core.runtime.CoreException;
       
    26 import org.eclipse.core.runtime.IConfigurationElement;
       
    27 import org.eclipse.core.runtime.Platform;
       
    28 import org.symbian.tools.tmw.core.TMWCore;
       
    29 import org.symbian.tools.tmw.core.projects.IMTWProject;
       
    30 
       
    31 public class ProjectsSupportManager {
       
    32     private Collection<ProjectProvider> providers = null;
       
    33 
       
    34     public IMTWProject create(IProject project) {
       
    35         if (providers == null) {
       
    36             readProviders();
       
    37         }
       
    38         for (ProjectProvider provider : providers) {
       
    39             if (provider.isSupportedProject(project)) {
       
    40                 return provider.create(project);
       
    41             }
       
    42         }
       
    43         return null;
       
    44     }
       
    45 
       
    46     private void readProviders() {
       
    47         providers = new LinkedList<ProjectProvider>();
       
    48         IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(
       
    49                 TMWCore.PLUGIN_ID, "projectProvider");
       
    50         for (IConfigurationElement element : configurationElements) {
       
    51             if (element.getName().equals("projectProvider")) {
       
    52                 try {
       
    53                     providers.add(new ProjectProvider(element));
       
    54                 } catch (CoreException e) {
       
    55                     TMWCore.log(null, e);
       
    56                 }
       
    57             }
       
    58         }
       
    59     }
       
    60 }