1 | class DynamicPackageRegistryReader extends RegistryReader↵ | | 1 | class ProtocolParserRegistryReader extends RegistryReader↵
|
2 | {↵ | | 2 | {↵
|
3 | static final String TAG_RESOURCE = "resource";↵ | | 3 | static final String TAG_PARSER = "parser";↵
|
4 | static final String ATT_URI = "uri";↵ | | 4 | static final String ATT_PROTOCOLNAME = "protocolName";↵
|
5 | static final String ATT_LOCATION = "location";↵ | | 5 | static final String ATT_↵
|
|
6 | public DynamicPackage↵ | | 6 | CLASS = "class";↵
|
|
7 | RegistryReader()↵ | | 7 | public ProtocolParserRegistryReader()↵
|
8 | {↵ | | 8 | {↵
|
9 | super↵ | | 9 | super↵
|
10 | (Platform.getExtensionRegistry(),↵ | | 10 | (Platform.getExtensionRegistry(),↵
|
11 | EcorePlugin.getPlugin().getBundle().getSymbolicName(), ↵ | | 11 | EcorePlugin.getPlugin().getBundle().getSymbolicName(), ↵
|
12 | EcorePlugin.DYNAMIC_PACKAGE_PPID);↵ | | 12 | EcorePlugin.PROTOCOL_PARSER_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_RESOURCE))↵ | | 17 | if (element.getName().equals(TAG_PARSER))↵
|
18 | {↵ | | 18 | {↵
|
19 | String packageURI = element.getAttribute(ATT_URI);↵ | | 19 | String protocolName = element.getAttribute(ATT_PROTOCOLNAME);↵
|
20 | if (packageURI == null)↵ | | 20 | if (protocolName == null)↵
|
21 | {↵ | | 21 | {↵
|
22 | logMissingAttribute(element, ATT_URI);↵ | | 22 | logMissingAttribute(element, ATT_PROTOCOLNAME);↵
|
23 | }↵ | | 23 | }↵
|
24 | else if (element.getAttribute(ATT_LOCATION) == null)↵ | | 24 | else if (element.getAttribute(ATT_CLASS) == null)↵
|
25 | {↵ | | 25 | {↵
|
26 | logMissingAttribute(element, ATT_LOCATION);↵ | | 26 | logMissingAttribute(element, ATT_CLASS);↵
|
27 | }↵ | | 27 | }↵
|
28 | else if (add)↵ | | 28 | else if (add)↵
|
29 | {↵ | | 29 | {↵
|
30 | Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));↵ | | 30 | Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));↵
|
31 | if (previous instanceof PluginClassDescriptor)↵ | | 31 | if (previous instanceof ResourceFactoryDescriptor)↵
|
32 | {↵ | | 32 | {↵
|
33 | PluginClassDescriptor descriptor = (PluginClassDescriptor)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 package for '" + packageURI + "'");↵ | | 35 | ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");↵
|
36 | }↵ | | 36 | }↵
|
37 | ↵ | | |
|
38 | return true;↵ | | 37 | return true;↵
|
39 | }↵ | | 38 | }↵
|
40 | else↵ | | 39 | else↵
|
41 | {↵ | | 40 | {↵
|
42 | EPackage.Registry.INSTANCE.remove(packageURI);↵ | | 41 | Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);↵
|
43 | return true;↵ | | 42 | return true;↵
|
44 | }↵ | | 43 | }↵
|
45 | }↵ | | 44 | }↵
|
|
46 | return false;↵ | | 45 | return false;↵
|
47 | | | 46 |
|