|
Lines 55-61
Link Here
|
| 55 |
* A collection of platform-neutral static utilities |
55 |
* A collection of platform-neutral static utilities |
| 56 |
* as well as Eclipse support utilities. |
56 |
* as well as Eclipse support utilities. |
| 57 |
*/ |
57 |
*/ |
| 58 |
public class EcorePlugin extends EMFPlugin |
58 |
public class EcorePlugin extends EMFPlugin |
| 59 |
{ |
59 |
{ |
| 60 |
/** |
60 |
/** |
| 61 |
* The singleton instance of the plugin. |
61 |
* The singleton instance of the plugin. |
|
Lines 67-73
Link Here
|
| 67 |
*/ |
67 |
*/ |
| 68 |
private EcorePlugin() |
68 |
private EcorePlugin() |
| 69 |
{ |
69 |
{ |
| 70 |
super(new ResourceLocator[] {}); |
70 |
super(new ResourceLocator []{}); |
| 71 |
} |
71 |
} |
| 72 |
|
72 |
|
| 73 |
@Override |
73 |
@Override |
|
Lines 162-168
Link Here
|
| 162 |
* @param arguments an array of "command line" options. |
162 |
* @param arguments an array of "command line" options. |
| 163 |
* @return the arguments stripped of those recognized as platform resource options. |
163 |
* @return the arguments stripped of those recognized as platform resource options. |
| 164 |
*/ |
164 |
*/ |
| 165 |
public static String [] handlePlatformResourceOptions(String [] arguments) |
165 |
public static String[] handlePlatformResourceOptions(String[] arguments) |
| 166 |
{ |
166 |
{ |
| 167 |
getPlatformResourceMap(); |
167 |
getPlatformResourceMap(); |
| 168 |
|
168 |
|
|
Lines 204-210
Link Here
|
| 204 |
} |
204 |
} |
| 205 |
} |
205 |
} |
| 206 |
|
206 |
|
| 207 |
String [] remainingArguments = new String [arguments.length - (i - start)]; |
207 |
String[] remainingArguments = new String [arguments.length - (i - start)]; |
| 208 |
System.arraycopy(arguments, 0, remainingArguments, 0, start); |
208 |
System.arraycopy(arguments, 0, remainingArguments, 0, start); |
| 209 |
System.arraycopy(arguments, i, remainingArguments, start, arguments.length - i); |
209 |
System.arraycopy(arguments, i, remainingArguments, start, arguments.length - i); |
| 210 |
return remainingArguments; |
210 |
return remainingArguments; |
|
Lines 213-219
Link Here
|
| 213 |
|
213 |
|
| 214 |
return arguments; |
214 |
return arguments; |
| 215 |
} |
215 |
} |
| 216 |
|
216 |
|
| 217 |
/** |
217 |
/** |
| 218 |
* Returns a map from {@link EPackage#getNsURI() package namespace URI} (represented as a String) |
218 |
* Returns a map from {@link EPackage#getNsURI() package namespace URI} (represented as a String) |
| 219 |
* to the location of the GenModel containing a GenPackage for the package (represented as a {@link URI URI}). |
219 |
* to the location of the GenModel containing a GenPackage for the package (represented as a {@link URI URI}). |
|
Lines 258-267
Link Here
|
| 258 |
} |
258 |
} |
| 259 |
return result; |
259 |
return result; |
| 260 |
} |
260 |
} |
| 261 |
|
261 |
|
| 262 |
private static Pattern bundleSymbolNamePattern; |
262 |
private static Pattern bundleSymbolNamePattern; |
| 263 |
private static byte [] NO_BYTES = new byte [0]; |
263 |
private static byte[] NO_BYTES = new byte [0]; |
| 264 |
|
264 |
|
| 265 |
/** |
265 |
/** |
| 266 |
* Computes a map from <code>platform:/plugin/<plugin-id>/</code> {@link URI} to |
266 |
* Computes a map from <code>platform:/plugin/<plugin-id>/</code> {@link URI} to |
| 267 |
* <code>platform:/resource/<plugin-location>/</code> URI |
267 |
* <code>platform:/resource/<plugin-location>/</code> URI |
|
Lines 277-288
Link Here
|
| 277 |
Map<URI, URI> result = new HashMap<URI, URI>(); |
277 |
Map<URI, URI> result = new HashMap<URI, URI>(); |
| 278 |
IWorkspaceRoot root = getWorkspaceRoot(); |
278 |
IWorkspaceRoot root = getWorkspaceRoot(); |
| 279 |
if (root != null) |
279 |
if (root != null) |
| 280 |
{ |
280 |
{ |
| 281 |
IProject [] projects = root.getProjects(); |
281 |
IProject[] projects = root.getProjects(); |
| 282 |
if (projects != null) |
282 |
if (projects != null) |
| 283 |
{ |
283 |
{ |
| 284 |
String pluginID = null; |
284 |
String pluginID = null; |
| 285 |
|
285 |
|
| 286 |
class Handler extends DefaultHandler |
286 |
class Handler extends DefaultHandler |
| 287 |
{ |
287 |
{ |
| 288 |
public String pluginID; |
288 |
public String pluginID; |
|
Lines 298-308
Link Here
|
| 298 |
} |
298 |
} |
| 299 |
} |
299 |
} |
| 300 |
Handler handler = new Handler(); |
300 |
Handler handler = new Handler(); |
| 301 |
|
301 |
|
| 302 |
SAXParserFactory parserFactory= SAXParserFactory.newInstance(); |
302 |
SAXParserFactory parserFactory = SAXParserFactory.newInstance(); |
| 303 |
parserFactory.setNamespaceAware(true); |
303 |
parserFactory.setNamespaceAware(true); |
| 304 |
SAXParser parser = null; |
304 |
SAXParser parser = null; |
| 305 |
|
305 |
|
| 306 |
try |
306 |
try |
| 307 |
{ |
307 |
{ |
| 308 |
parser = parserFactory.newSAXParser(); |
308 |
parser = parserFactory.newSAXParser(); |
|
Lines 311-324
Link Here
|
| 311 |
{ |
311 |
{ |
| 312 |
INSTANCE.log(exception); |
312 |
INSTANCE.log(exception); |
| 313 |
} |
313 |
} |
| 314 |
|
314 |
|
| 315 |
if (bundleSymbolNamePattern == null) |
315 |
if (bundleSymbolNamePattern == null) |
| 316 |
{ |
316 |
{ |
| 317 |
bundleSymbolNamePattern = Pattern.compile("^\\s*Bundle-SymbolicName\\s*:\\s*([^\\s;]*)\\s*(;.*)?$", Pattern.MULTILINE); |
317 |
bundleSymbolNamePattern = Pattern.compile("^\\s*Bundle-SymbolicName\\s*:\\s*([^\\s;]*)\\s*(;.*)?$", Pattern.MULTILINE); |
| 318 |
} |
318 |
} |
| 319 |
|
319 |
|
| 320 |
byte [] bytes = NO_BYTES; |
320 |
byte[] bytes = NO_BYTES; |
| 321 |
|
321 |
|
| 322 |
for (int i = 0, size = projects.length; i < size; ++i) |
322 |
for (int i = 0, size = projects.length; i < size; ++i) |
| 323 |
{ |
323 |
{ |
| 324 |
IProject project = projects[i]; |
324 |
IProject project = projects[i]; |
|
Lines 331-337
Link Here
|
| 331 |
InputStream inputStream = null; |
331 |
InputStream inputStream = null; |
| 332 |
try |
332 |
try |
| 333 |
{ |
333 |
{ |
| 334 |
inputStream = manifest.getContents(); |
334 |
inputStream = manifest.getContents(); |
| 335 |
int available = inputStream.available(); |
335 |
int available = inputStream.available(); |
| 336 |
if (bytes.length < available) |
336 |
if (bytes.length < available) |
| 337 |
{ |
337 |
{ |
|
Lines 386-406
Link Here
|
| 386 |
} |
386 |
} |
| 387 |
} |
387 |
} |
| 388 |
} |
388 |
} |
| 389 |
|
389 |
|
| 390 |
if (pluginID != null) |
390 |
if (pluginID != null) |
| 391 |
{ |
391 |
{ |
| 392 |
URI platformPluginURI = URI.createPlatformPluginURI(pluginID + "/", false); |
392 |
URI platformPluginURI = URI.createPlatformPluginURI(pluginID + "/", false); |
| 393 |
URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true); |
393 |
URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true); |
| 394 |
result.put(platformPluginURI, platformResourceURI); |
394 |
result.put(platformPluginURI, platformResourceURI); |
| 395 |
} |
395 |
} |
| 396 |
} |
396 |
} |
| 397 |
} |
397 |
} |
| 398 |
} |
398 |
} |
| 399 |
} |
399 |
} |
| 400 |
|
400 |
|
| 401 |
return result; |
401 |
return result; |
| 402 |
} |
402 |
} |
| 403 |
|
403 |
|
| 404 |
/** |
404 |
/** |
| 405 |
* Computes a map so that plugins in the workspace will override those in the environment |
405 |
* Computes a map so that plugins in the workspace will override those in the environment |
| 406 |
* and so that plugins with Ecore and GenModels will look like projects in the workspace. |
406 |
* and so that plugins with Ecore and GenModels will look like projects in the workspace. |
|
Lines 425-437
Link Here
|
| 425 |
result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet<URI>(EcorePlugin.getEPackageNsURIToGenModelLocationMap().values()))); |
425 |
result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet<URI>(EcorePlugin.getEPackageNsURIToGenModelLocationMap().values()))); |
| 426 |
return result; |
426 |
return result; |
| 427 |
} |
427 |
} |
| 428 |
|
428 |
|
| 429 |
/** |
429 |
/** |
| 430 |
* The platform resource map. |
430 |
* The platform resource map. |
| 431 |
* @see #getPlatformResourceMap |
431 |
* @see #getPlatformResourceMap |
| 432 |
*/ |
432 |
*/ |
| 433 |
private static Map<String, URI> platformResourceMap; |
433 |
private static Map<String, URI> platformResourceMap; |
| 434 |
|
434 |
|
| 435 |
/** |
435 |
/** |
| 436 |
* The map from package namespace URIs to the location of the GenModel for that package. |
436 |
* The map from package namespace URIs to the location of the GenModel for that package. |
| 437 |
* @see #getPlatformResourceMap |
437 |
* @see #getPlatformResourceMap |
|
Lines 452-458
Link Here
|
| 452 |
super(); |
452 |
super(); |
| 453 |
plugin = this; |
453 |
plugin = this; |
| 454 |
} |
454 |
} |
| 455 |
|
455 |
|
| 456 |
/** |
456 |
/** |
| 457 |
* Starts up this plugin by reading some extensions and populating the relevant registries. |
457 |
* Starts up this plugin by reading some extensions and populating the relevant registries. |
| 458 |
* <p> |
458 |
* <p> |
|
Lines 520-571
Link Here
|
| 520 |
workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
520 |
workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); |
| 521 |
} |
521 |
} |
| 522 |
|
522 |
|
| 523 |
new RegistryReader |
523 |
new RegistryReader( |
| 524 |
(Platform.getExtensionRegistry(), |
524 |
Platform.getExtensionRegistry(), |
| 525 |
EcorePlugin.getPlugin().getBundle().getSymbolicName(), |
525 |
EcorePlugin.getPlugin().getBundle().getSymbolicName(), |
| 526 |
PACKAGE_REGISTRY_IMPLEMENTATION_PPID) |
526 |
PACKAGE_REGISTRY_IMPLEMENTATION_PPID) |
| 527 |
{ |
|
|
| 528 |
IConfigurationElement previous; |
| 529 |
|
| 530 |
@Override |
| 531 |
protected boolean readElement(IConfigurationElement element) |
| 532 |
{ |
527 |
{ |
| 533 |
if (element.getName().equals("registry")) |
528 |
IConfigurationElement previous; |
|
|
529 |
|
| 530 |
@Override |
| 531 |
protected boolean readElement(IConfigurationElement element) |
| 534 |
{ |
532 |
{ |
| 535 |
String implementationClass = element.getAttribute("class"); |
533 |
if (element.getName().equals("registry")) |
| 536 |
if (implementationClass == null) |
|
|
| 537 |
{ |
534 |
{ |
| 538 |
logMissingAttribute(element, "class"); |
535 |
String implementationClass = element.getAttribute("class"); |
| 539 |
} |
536 |
if (implementationClass == null) |
| 540 |
else |
537 |
{ |
| 541 |
{ |
538 |
logMissingAttribute(element, "class"); |
| 542 |
if (defaultRegistryImplementation != null) |
539 |
} |
|
|
540 |
else |
| 543 |
{ |
541 |
{ |
| 544 |
if (previous != null) |
542 |
if (defaultRegistryImplementation != null) |
| 545 |
{ |
543 |
{ |
| 546 |
log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package registry implementation"); |
544 |
if (previous != null) |
|
|
545 |
{ |
| 546 |
log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() |
| 547 |
+ "' register a package registry implementation"); |
| 548 |
} |
| 549 |
if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator) |
| 550 |
{ |
| 551 |
return false; |
| 552 |
} |
| 547 |
} |
553 |
} |
| 548 |
if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator) |
554 |
try |
| 549 |
{ |
555 |
{ |
| 550 |
return false; |
556 |
defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class"); |
|
|
557 |
previous = element; |
| 551 |
} |
558 |
} |
|
|
559 |
catch (CoreException exception) |
| 560 |
{ |
| 561 |
log(exception); |
| 562 |
} |
| 563 |
return true; |
| 552 |
} |
564 |
} |
| 553 |
try |
|
|
| 554 |
{ |
| 555 |
defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class"); |
| 556 |
previous = element; |
| 557 |
} |
| 558 |
catch (CoreException exception) |
| 559 |
{ |
| 560 |
log(exception); |
| 561 |
} |
| 562 |
return true; |
| 563 |
} |
565 |
} |
|
|
566 |
return false; |
| 564 |
} |
567 |
} |
| 565 |
return false; |
568 |
|
| 566 |
} |
569 |
}.readRegistry(); |
| 567 |
|
|
|
| 568 |
}.readRegistry(); |
| 569 |
|
570 |
|
| 570 |
new GeneratedPackageRegistryReader(getEPackageNsURIToGenModelLocationMap()).readRegistry(); |
571 |
new GeneratedPackageRegistryReader(getEPackageNsURIToGenModelLocationMap()).readRegistry(); |
| 571 |
new DynamicPackageRegistryReader().readRegistry(); |
572 |
new DynamicPackageRegistryReader().readRegistry(); |
|
Lines 575-587
Link Here
|
| 575 |
new ContentParserRegistryReader().readRegistry(); |
576 |
new ContentParserRegistryReader().readRegistry(); |
| 576 |
new ContentHandlerRegistryReader().readRegistry(); |
577 |
new ContentHandlerRegistryReader().readRegistry(); |
| 577 |
new URIMappingRegistryReader().readRegistry(); |
578 |
new URIMappingRegistryReader().readRegistry(); |
|
|
579 |
new ConstraintsDelegatorFactoryRegistryReader().readRegistry(); |
| 578 |
} |
580 |
} |
| 579 |
} |
581 |
} |
| 580 |
|
582 |
|
| 581 |
/** |
583 |
/** |
| 582 |
* The default registry implementation singleton. |
584 |
* The default registry implementation singleton. |
| 583 |
*/ |
585 |
*/ |
| 584 |
private static EPackage.Registry defaultRegistryImplementation; |
586 |
private static EPackage.Registry defaultRegistryImplementation; |
| 585 |
|
587 |
|
| 586 |
/** |
588 |
/** |
| 587 |
* Returns the default registry implementation singleton. |
589 |
* Returns the default registry implementation singleton. |
|
Lines 631-634
Link Here
|
| 631 |
public static final String SCHEME_PARSER_PPID = "scheme_parser"; |
633 |
public static final String SCHEME_PARSER_PPID = "scheme_parser"; |
| 632 |
public static final String URI_MAPPING_PPID = "uri_mapping"; |
634 |
public static final String URI_MAPPING_PPID = "uri_mapping"; |
| 633 |
public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation"; |
635 |
public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation"; |
|
|
636 |
public static final String CONSTRAINTS_DELEGATOR_FACTORY = "constraints_delegator_registry"; |
| 634 |
} |
637 |
} |