|
Lines 20-26
Link Here
|
| 20 |
|
20 |
|
| 21 |
import org.eclipse.core.runtime.CoreException; |
21 |
import org.eclipse.core.runtime.CoreException; |
| 22 |
import org.eclipse.core.runtime.IConfigurationElement; |
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
|
23 |
import org.eclipse.core.runtime.IContributor; |
| 24 |
import org.eclipse.core.runtime.IExtension; |
| 25 |
import org.eclipse.core.runtime.IPluginDescriptor; |
| 23 |
import org.eclipse.core.runtime.IStatus; |
26 |
import org.eclipse.core.runtime.IStatus; |
|
|
27 |
import org.eclipse.core.runtime.InvalidRegistryObjectException; |
| 24 |
import org.eclipse.core.runtime.Platform; |
28 |
import org.eclipse.core.runtime.Platform; |
| 25 |
import org.eclipse.core.runtime.Status; |
29 |
import org.eclipse.core.runtime.Status; |
| 26 |
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions; |
30 |
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions; |
|
Lines 351-356
Link Here
|
| 351 |
element.getDeclaringExtension().getNamespaceIdentifier()).getEntry("/"); //$NON-NLS-1$ |
355 |
element.getDeclaringExtension().getNamespaceIdentifier()).getEntry("/"); //$NON-NLS-1$ |
| 352 |
} |
356 |
} |
| 353 |
} |
357 |
} |
|
|
358 |
|
| 359 |
/** |
| 360 |
* Loads a configuration element from the specified <code>url</code> |
| 361 |
* |
| 362 |
* @param url the location of the XML document |
| 363 |
* @return the configuration element representing the XML document |
| 364 |
* @throws CoreException on any problem parsing an XML file |
| 365 |
* @see #load(IConfigurationElement, URL) |
| 366 |
*/ |
| 367 |
public static IConfigurationElement load(URL url) |
| 368 |
throws CoreException { |
| 369 |
return load(new DummyConfigurationElement(), url); |
| 370 |
} |
| 354 |
|
371 |
|
| 355 |
/** |
372 |
/** |
| 356 |
* Loads a <tt><constraints></tt> element from the specified |
373 |
* Loads a <tt><constraints></tt> element from the specified |
|
Lines 410-415
Link Here
|
| 410 |
} |
427 |
} |
| 411 |
} |
428 |
} |
| 412 |
|
429 |
|
|
|
430 |
/** |
| 431 |
* Returns the children of the configuration element that matches the given |
| 432 |
* <code>extensionPoint</code>, searches recursively the given parent element. |
| 433 |
* |
| 434 |
* @param extensionPoint The name of the extension point to match |
| 435 |
* @param parent The top level configuration element to search |
| 436 |
* @return the matching configuration element children or null if not found |
| 437 |
*/ |
| 438 |
public static IConfigurationElement[] findExtensionPoint(String extensionPoint, IConfigurationElement parent) { |
| 439 |
if (parent.getAttribute("point") != null && parent.getAttribute("point").equals(extensionPoint)) { |
| 440 |
return parent.getChildren(); |
| 441 |
} |
| 442 |
else { |
| 443 |
// Recurse |
| 444 |
IConfigurationElement[] children = parent.getChildren(); |
| 445 |
if (children != null) { |
| 446 |
for (int i = 0; i < children.length; i++) { |
| 447 |
IConfigurationElement[] result = findExtensionPoint(extensionPoint, children[i]); |
| 448 |
if (result != null) { |
| 449 |
return result; |
| 450 |
} |
| 451 |
} |
| 452 |
} |
| 453 |
} |
| 454 |
return null; |
| 455 |
} |
| 456 |
|
| 413 |
/** |
457 |
/** |
| 414 |
* Flushes the resource bundles that were loaded for localization of strings |
458 |
* Flushes the resource bundles that were loaded for localization of strings |
| 415 |
* in an XML constraint provider's XML constraint declarations. |
459 |
* in an XML constraint provider's XML constraint declarations. |
|
Lines 440-443
Link Here
|
| 440 |
|
484 |
|
| 441 |
return result; |
485 |
return result; |
| 442 |
} |
486 |
} |
|
|
487 |
|
| 488 |
// Inner classes |
| 489 |
|
| 490 |
/** |
| 491 |
* A mock configuration element used to supply a valid extension namespace identifier |
| 492 |
* <p> |
| 493 |
* This class is not intended to be used outside of the validation framework. |
| 494 |
* </p> |
| 495 |
* @see XmlConfig#load(URL) |
| 496 |
*/ |
| 497 |
private static class DummyConfigurationElement implements IConfigurationElement { |
| 498 |
|
| 499 |
IExtension dummyExtension = new DummyExtension("org.eclipse.emf.validation.internal"); |
| 500 |
|
| 501 |
public IExtension getDeclaringExtension() throws InvalidRegistryObjectException { |
| 502 |
return dummyExtension; |
| 503 |
} |
| 504 |
|
| 505 |
// Unused Methods |
| 506 |
|
| 507 |
public Object createExecutableExtension(String propertyName) throws CoreException { |
| 508 |
return null; |
| 509 |
} |
| 510 |
|
| 511 |
public String getAttribute(String name) throws InvalidRegistryObjectException { |
| 512 |
return null; |
| 513 |
} |
| 514 |
|
| 515 |
public String getAttributeAsIs(String name) throws InvalidRegistryObjectException { |
| 516 |
return null; |
| 517 |
} |
| 518 |
|
| 519 |
public String[] getAttributeNames() throws InvalidRegistryObjectException { |
| 520 |
return null; |
| 521 |
} |
| 522 |
|
| 523 |
public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException { |
| 524 |
return null; |
| 525 |
} |
| 526 |
|
| 527 |
public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException { |
| 528 |
return null; |
| 529 |
} |
| 530 |
|
| 531 |
public IContributor getContributor() throws InvalidRegistryObjectException { |
| 532 |
return null; |
| 533 |
} |
| 534 |
|
| 535 |
public String getName() throws InvalidRegistryObjectException { |
| 536 |
return null; |
| 537 |
} |
| 538 |
|
| 539 |
public String getNamespace() throws InvalidRegistryObjectException { |
| 540 |
return null; |
| 541 |
} |
| 542 |
|
| 543 |
public String getNamespaceIdentifier() throws InvalidRegistryObjectException { |
| 544 |
return null; |
| 545 |
} |
| 546 |
|
| 547 |
public Object getParent() throws InvalidRegistryObjectException { |
| 548 |
return null; |
| 549 |
} |
| 550 |
|
| 551 |
public String getValue() throws InvalidRegistryObjectException { |
| 552 |
return null; |
| 553 |
} |
| 554 |
|
| 555 |
public String getValueAsIs() throws InvalidRegistryObjectException { |
| 556 |
return null; |
| 557 |
} |
| 558 |
|
| 559 |
public boolean isValid() { |
| 560 |
return false; |
| 561 |
} |
| 562 |
|
| 563 |
} |
| 564 |
|
| 565 |
/** |
| 566 |
* A mock extension used to supply a valid namespace identifier |
| 567 |
* <p> |
| 568 |
* This class is not intended to be used outside of the validation framework. |
| 569 |
* </p> |
| 570 |
* @see XmlConfig#load(URL) |
| 571 |
*/ |
| 572 |
private static class DummyExtension implements IExtension { |
| 573 |
|
| 574 |
String namespaceIndentifier = null; |
| 575 |
|
| 576 |
public DummyExtension(String namespaceIdentifier) { |
| 577 |
this.namespaceIndentifier = namespaceIdentifier; |
| 578 |
} |
| 579 |
|
| 580 |
public String getNamespaceIdentifier() throws InvalidRegistryObjectException { |
| 581 |
return namespaceIndentifier; |
| 582 |
} |
| 583 |
|
| 584 |
// Unused Methods |
| 585 |
|
| 586 |
public IConfigurationElement[] getConfigurationElements() throws InvalidRegistryObjectException { |
| 587 |
return null; |
| 588 |
} |
| 589 |
|
| 590 |
public IContributor getContributor() throws InvalidRegistryObjectException { |
| 591 |
return null; |
| 592 |
} |
| 593 |
|
| 594 |
public IPluginDescriptor getDeclaringPluginDescriptor() throws InvalidRegistryObjectException { |
| 595 |
return null; |
| 596 |
} |
| 597 |
|
| 598 |
public String getExtensionPointUniqueIdentifier() throws InvalidRegistryObjectException { |
| 599 |
return null; |
| 600 |
} |
| 601 |
|
| 602 |
public String getLabel() throws InvalidRegistryObjectException { |
| 603 |
return null; |
| 604 |
} |
| 605 |
|
| 606 |
public String getNamespace() throws InvalidRegistryObjectException { |
| 607 |
return null; |
| 608 |
} |
| 609 |
|
| 610 |
public String getSimpleIdentifier() throws InvalidRegistryObjectException { |
| 611 |
return null; |
| 612 |
} |
| 613 |
|
| 614 |
public String getUniqueIdentifier() throws InvalidRegistryObjectException { |
| 615 |
return null; |
| 616 |
} |
| 617 |
|
| 618 |
public boolean isValid() { |
| 619 |
return false; |
| 620 |
} |
| 621 |
} |
| 443 |
} |
622 |
} |