20 |
20 |
21 import java.util.Map; |
21 import java.util.Map; |
22 import java.util.TreeMap; |
22 import java.util.TreeMap; |
23 |
23 |
24 import org.eclipse.core.runtime.IConfigurationElement; |
24 import org.eclipse.core.runtime.IConfigurationElement; |
|
25 import org.eclipse.core.runtime.Platform; |
|
26 import org.symbian.tools.tmw.core.TMWCore; |
|
27 import org.symbian.tools.tmw.core.internal.runtimes.RuntimesManagerImpl.LazyProvider; |
|
28 import org.symbian.tools.tmw.core.runtimes.IApplicationLayoutProvider; |
25 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime; |
29 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime; |
26 import org.symbian.tools.tmw.core.utilities.CoreUtil; |
30 import org.symbian.tools.tmw.core.utilities.CoreUtil; |
27 |
31 |
28 public final class MobileWebRuntime implements IMobileWebRuntime { |
32 public final class MobileWebRuntime implements IMobileWebRuntime { |
29 private final IConfigurationElement element; |
33 private final IConfigurationElement element; |
|
34 private IApplicationLayoutProvider layout; |
30 |
35 |
31 public MobileWebRuntime(IConfigurationElement element) { |
36 public MobileWebRuntime(IConfigurationElement element) { |
32 this.element = element; |
37 this.element = element; |
|
38 checkRegistry(); |
33 } |
39 } |
34 |
40 |
35 public String getId() { |
41 private synchronized void checkRegistry() { |
36 return element.getAttribute("component-id"); |
42 if (layout == null) { |
37 } |
43 final IConfigurationElement[] configuration = Platform.getExtensionRegistry().getConfigurationElementsFor( |
38 |
44 TMWCore.PLUGIN_ID, "runtimeAppLayout"); |
39 public String getVersion() { |
45 for (IConfigurationElement element : configuration) { |
40 return element.getAttribute("component-version"); |
46 final String runtimeId = element.getAttribute("runtime-id"); |
41 } |
47 final String version = element.getAttribute("runtime-version"); |
42 |
48 if (getId().endsWith(runtimeId) && getVersion().endsWith(version)) { |
43 public String getName() { |
49 layout = new LazyProvider(element); |
44 return element.getAttribute("name"); |
50 break; |
|
51 } |
|
52 } |
|
53 if (layout == null) { |
|
54 TMWCore.log("No layout provider for runtime %s:%s (from plugin %s)", getId(), getVersion(), element |
|
55 .getContributor().getName()); |
|
56 } |
|
57 } |
45 } |
58 } |
46 |
59 |
47 public IConfigurationElement[] getComponentElements() { |
60 public IConfigurationElement[] getComponentElements() { |
48 return element.getChildren("runtime-component"); |
61 return element.getChildren("runtime-component"); |
49 } |
|
50 |
|
51 @Override |
|
52 public String toString() { |
|
53 return getId() + ":" + getVersion(); |
|
54 } |
62 } |
55 |
63 |
56 public Map<String, String> getFixedFacets() { |
64 public Map<String, String> getFixedFacets() { |
57 final Map<String, String> facets = new TreeMap<String, String>(); |
65 final Map<String, String> facets = new TreeMap<String, String>(); |
58 final IConfigurationElement[] children = element.getChildren("fixed-facet"); |
66 final IConfigurationElement[] children = element.getChildren("fixed-facet"); |
60 facets.put(CoreUtil.notNull(element.getAttribute("id")), element.getAttribute("version")); |
68 facets.put(CoreUtil.notNull(element.getAttribute("id")), element.getAttribute("version")); |
61 } |
69 } |
62 return facets; |
70 return facets; |
63 } |
71 } |
64 |
72 |
|
73 public String getId() { |
|
74 return element.getAttribute("component-id"); |
|
75 } |
|
76 |
|
77 public IApplicationLayoutProvider getLayoutProvider() { |
|
78 return layout; |
|
79 } |
|
80 |
|
81 public String getName() { |
|
82 return element.getAttribute("name"); |
|
83 } |
|
84 |
|
85 public String getVersion() { |
|
86 return element.getAttribute("component-version"); |
|
87 } |
|
88 |
|
89 @Override |
|
90 public String toString() { |
|
91 return getId() + ":" + getVersion(); |
|
92 } |
|
93 |
65 } |
94 } |