Search in sources :

Example 11 with EPackageRegistryImpl

use of org.eclipse.emf.ecore.impl.EPackageRegistryImpl in project sirius-components by eclipse-sirius.

the class ViewValidatorTests method testNodeStyleDescriptionValidQualifiedDomainInPackageRegistry.

@Test
public void testNodeStyleDescriptionValidQualifiedDomainInPackageRegistry() {
    Map<Object, Object> defaultContext = Diagnostician.INSTANCE.createDefaultContext();
    NodeDescription nodeDescription = ViewFactory.eINSTANCE.createNodeDescription();
    // $NON-NLS-1$
    nodeDescription.setDomainType(SAMPLE_DOMAIN_NAME + "::" + SAMPLE_ENTITY_NAME);
    ResourceSetImpl resourceSet = new ResourceSetImpl();
    XMIResourceImpl viewResource = new XMIResourceImpl();
    viewResource.getContents().add(nodeDescription);
    resourceSet.getResources().add(viewResource);
    EPackageRegistryImpl packageRegistryImpl = new EPackageRegistryImpl();
    EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
    ePackage.setName(SAMPLE_DOMAIN_NAME);
    ePackage.setNsPrefix(SAMPLE_DOMAIN_NAME);
    // $NON-NLS-1$
    ePackage.setNsURI("domain://sample");
    EClass sampleClass = EcoreFactory.eINSTANCE.createEClass();
    sampleClass.setName(SAMPLE_ENTITY_NAME);
    ePackage.getEClassifiers().add(sampleClass);
    packageRegistryImpl.put(ePackage.getNsURI(), ePackage);
    resourceSet.setPackageRegistry(packageRegistryImpl);
    BasicDiagnostic diagnosticChain = new BasicDiagnostic(Diagnostic.OK, null, 0, null, null);
    boolean validationResult = new DiagramDescriptionValidator().validate(nodeDescription.eClass(), nodeDescription, diagnosticChain, defaultContext);
    assertThat(validationResult).isTrue();
    assertThat(diagnosticChain).isEqualTo(new BasicDiagnostic(Diagnostic.OK, null, 0, null, null));
}
Also used : NodeDescription(org.eclipse.sirius.components.view.NodeDescription) EClass(org.eclipse.emf.ecore.EClass) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) EPackageRegistryImpl(org.eclipse.emf.ecore.impl.EPackageRegistryImpl) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) XMIResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl) EPackage(org.eclipse.emf.ecore.EPackage) DiagramDescriptionValidator(org.eclipse.sirius.components.emf.view.diagram.DiagramDescriptionValidator) Test(org.junit.jupiter.api.Test)

Example 12 with EPackageRegistryImpl

use of org.eclipse.emf.ecore.impl.EPackageRegistryImpl in project sirius-components by eclipse-sirius.

the class EditService method getPackageRegistry.

private EPackage.Registry getPackageRegistry(String editingContextId) {
    EPackageRegistryImpl ePackageRegistry = new EPackageRegistryImpl();
    this.globalEPackageRegistry.forEach(ePackageRegistry::put);
    List<EPackage> additionalEPackages = this.editingContextEPackageService.getEPackages(editingContextId);
    additionalEPackages.forEach(ePackage -> ePackageRegistry.put(ePackage.getNsURI(), ePackage));
    return ePackageRegistry;
}
Also used : EPackageRegistryImpl(org.eclipse.emf.ecore.impl.EPackageRegistryImpl) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

EPackageRegistryImpl (org.eclipse.emf.ecore.impl.EPackageRegistryImpl)12 EPackage (org.eclipse.emf.ecore.EPackage)9 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)6 URI (org.eclipse.emf.common.util.URI)5 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)5 ECrossReferenceAdapter (org.eclipse.emf.ecore.util.ECrossReferenceAdapter)5 Resource (org.eclipse.emf.ecore.resource.Resource)4 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)4 DocumentEntity (org.eclipse.sirius.web.persistence.entities.DocumentEntity)4 Test (org.junit.jupiter.api.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 List (java.util.List)3 BasicCommandStack (org.eclipse.emf.common.command.BasicCommandStack)3 XMIResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)3 AdapterFactoryEditingDomain (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain)3 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)3 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)3 SiriusWebJSONResourceFactoryImpl (org.eclipse.sirius.components.emf.services.SiriusWebJSONResourceFactoryImpl)3 JsonResource (org.eclipse.sirius.emfjson.resource.JsonResource)3