1 | class ContentParserRegistryReader extends RegistryReader↵ | | 1 | class DynamicPackageRegistryReader extends RegistryReader↵
|
2 | {↵ | | 2 | {↵
|
3 | static final String TAG_PARSER = "parser";↵ | | 3 | static final String TAG_RESOURCE = "resource";↵
|
4 | static final String ATT_CONTENT_TYPE_IDENTIFIER = "contentTypeIdentifier";↵ | | 4 | static final String ATT_URI = "uri";↵
|
5 | static final String ATT_CLASS = "class";↵ | | 5 | static final String ATT_↵
|
|
6 | public ContentParser↵ | | 6 | LOCATION = "location";↵
|
|
7 | RegistryReader()↵ | | 7 | public DynamicPackageRegistryReader()↵
|
8 | {↵ | | 8 | {↵
|
9 | super↵ | | 9 | super↵
|
10 | (Platform.getExtensionRegistry(),↵ | | 10 | (Platform.getExtensionRegistry(),↵
|
11 | EcorePlugin.getPlugin().getBundle().getSymbolicName(), ↵ | | 11 | EcorePlugin.getPlugin().getBundle().getSymbolicName(), ↵
|
12 | EcorePlugin.CONTENT_PARSER_PPID);↵ | | 12 | EcorePlugin.DYNAMIC_PACKAGE_PPID);↵
|
13 | }↵ | | 13 | }↵
|
|
14 | @Override↵ | | 14 | @Override↵
|
15 | protected boolean readElement(IConfigurationElement element, boolean add)↵ | | 15 | protected boolean readElement(IConfigurationElement element, boolean add)↵
|
16 | {↵ | | 16 | {↵
|
17 | if (element.getName().equals(TAG_PARSER))↵ | | 17 | if (element.getName().equals(TAG_RESOURCE))↵
|
18 | {↵ | | 18 | {↵
|
19 | String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);↵ | | 19 | String packageURI = element.getAttribute(ATT_↵
|
20 | if (contentTypeIdentifier↵ | | 20 | URI);↵
|
21 | == null)↵ | | 21 | if (packageURI == null)↵
|
22 | {↵ | | 22 | {↵
|
23 | logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);↵ | | 23 | logMissingAttribute(element, ATT_URI);↵
|
24 | }↵ | | 24 | }↵
|
25 | else if (element.getAttribute(ATT_CLASS) == null)↵ | | 25 | else if (element.getAttribute(ATT_LOCATION) == null)↵
|
26 | {↵ | | 26 | {↵
|
27 | logMissingAttribute(element, ATT_CLASS);↵ | | 27 | logMissingAttribute(element, ATT_LOCATION);↵
|
28 | }↵ | | 28 | }↵
|
29 | else if (add)↵ | | 29 | else if (add)↵
|
30 | {↵ | | 30 | {↵
|
31 | Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));↵ | | 31 | Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));↵
|
32 | if (previous instanceof ResourceFactoryDescriptor)↵ | | 32 | if (previous instanceof PluginClassDescriptor)↵
|
33 | {↵ | | 33 | {↵
|
34 | ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;↵ | | 34 | PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;↵
|
35 | EcorePlugin.INSTANCE.log↵ | | 35 | EcorePlugin.INSTANCE.log↵
|
36 | ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'");↵ | | 36 | ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");↵
|
37 | }↵ | | 37 | }↵
|
| | | 38 | ↵
|
38 | return true;↵ | | 39 | return true;↵
|
39 | }↵ | | 40 | }↵
|
40 | else↵ | | 41 | else↵
|
41 | {↵ | | 42 | {↵
|
42 | Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);↵ | | 43 | EPackage.Registry.INSTANCE.remove(packageURI);↵
|
43 | return true;↵ | | 44 | return true;↵
|
44 | }↵ | | 45 | }↵
|
45 | }↵ | | 46 | }↵
|
|
46 | return false;↵ | | 47 | return false;↵
|
47 | | | 48 |
|