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