|
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.runtimes; |
|
20 |
|
21 import java.util.Collections; |
|
22 import java.util.LinkedList; |
|
23 import java.util.List; |
|
24 import java.util.Map; |
|
25 import java.util.TreeMap; |
|
26 |
|
27 import org.eclipse.core.runtime.IConfigurationElement; |
|
28 import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeBridge; |
|
29 import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent; |
|
30 import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentType; |
|
31 import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion; |
|
32 import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager; |
|
33 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime; |
|
34 |
|
35 /** |
|
36 * Integrates mobile web runtime with the faceted project runtime framework. |
|
37 * |
|
38 * @author Eugene Ostroukhov (eugeneo@symbian.org) |
|
39 */ |
|
40 @SuppressWarnings("unchecked") |
|
41 public class MobileRuntimeStub implements IRuntimeBridge.IStub { |
|
42 private final IMobileWebRuntime runtime; |
|
43 private final Map<String, String> properties = new TreeMap<String, String>(); |
|
44 |
|
45 public MobileRuntimeStub(IMobileWebRuntime runtime) { |
|
46 this.runtime = runtime; |
|
47 properties.put("localized-name", runtime.getName()); |
|
48 } |
|
49 |
|
50 private IRuntimeComponent getComponent(String string, String version) { |
|
51 final IRuntimeComponentType componentType = RuntimeManager.getRuntimeComponentType(string); |
|
52 final IRuntimeComponentVersion v = componentType.getVersion(version); |
|
53 return RuntimeManager.createRuntimeComponent(v, Collections.EMPTY_MAP); |
|
54 } |
|
55 |
|
56 public List<IRuntimeComponent> getRuntimeComponents() { |
|
57 final List<IRuntimeComponent> components = new LinkedList<IRuntimeComponent>(); |
|
58 components.add(getComponent(runtime.getId(), runtime.getVersion())); |
|
59 components.add(getComponent("tmw.core", "1.0")); |
|
60 for (IConfigurationElement element : ((MobileWebRuntime) runtime).getComponentElements()) { |
|
61 components.add(getComponent(element.getAttribute("id"), element.getAttribute("version"))); |
|
62 } |
|
63 return components; |
|
64 } |
|
65 |
|
66 public Map<String, String> getProperties() { |
|
67 return properties; |
|
68 } |
|
69 |
|
70 } |