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.HashMap; |
|
22 import java.util.Map; |
|
23 |
|
24 import org.eclipse.core.runtime.CoreException; |
|
25 import org.eclipse.core.runtime.IConfigurationElement; |
|
26 import org.eclipse.core.runtime.Platform; |
|
27 import org.symbian.tools.mtw.ui.MTWCoreUI; |
|
28 import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType; |
|
29 import org.symbian.tools.mtw.ui.deployment.ITargetDetailsPane; |
|
30 |
|
31 public class DeploymentTargetPresentationsManager { |
|
32 private Map<IDeploymentTargetType, IConfigurationElement> presentations; |
|
33 |
|
34 public ITargetDetailsPane createDetailsPane(IDeploymentTargetType targetType) { |
|
35 readRegistry(); |
|
36 final IConfigurationElement element = presentations.get(targetType); |
|
37 if (element != null && element.getAttribute("detailsPane") != null) { |
|
38 try { |
|
39 return (ITargetDetailsPane) element.createExecutableExtension("detailsPane"); |
|
40 } catch (CoreException e) { |
|
41 MTWCoreUI.log(e); |
|
42 } |
|
43 } |
|
44 return new DefaultDeploymentTypePresentation(); |
|
45 } |
|
46 |
|
47 private synchronized void readRegistry() { |
|
48 if (presentations == null) { |
|
49 presentations = new HashMap<IDeploymentTargetType, IConfigurationElement>(); |
|
50 final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor( |
|
51 MTWCoreUI.PLUGIN_ID, "targetPresentation"); |
|
52 for (IConfigurationElement element : elements) { |
|
53 final String runtimeId = element.getAttribute("targetTypeId"); |
|
54 final IDeploymentTargetType targetType = MTWCoreUI.getDefault().getDeploymentTypesRegistry() |
|
55 .getType(runtimeId); |
|
56 if (targetType == null) { |
|
57 MTWCoreUI.log("Runtime %s was not found. It is referenced from plugin %s", runtimeId, element |
|
58 .getContributor().getName()); |
|
59 continue; |
|
60 } else { |
|
61 presentations.put(targetType, element); |
|
62 } |
|
63 } |
|
64 } |
|
65 } |
|
66 } |
|