Search in sources :

Example 1 with EPackageService

use of org.eclipse.sirius.components.emf.compatibility.EPackageService in project sirius-components by eclipse-sirius.

the class CreateInstanceOperationHandlerTests method initialize.

@BeforeEach
public void initialize() {
    this.operationTestContext = new OperationTestContext();
    AdapterFactoryEditingDomain editingDomain = new EditingDomainFactory().create();
    EditingContext editingContext = new EditingContext(UUID.randomUUID().toString(), editingDomain);
    this.operationTestContext.getVariables().put(IEditingContext.EDITING_CONTEXT, editingContext);
    this.createInstanceOperation = ToolFactory.eINSTANCE.createCreateInstance();
    this.createInstanceOperationHandler = new CreateInstanceOperationHandler(this.operationTestContext.getObjectService(), this.operationTestContext.getRepresentationMetadataSearchService(), this.operationTestContext.getIdentifierProvider(), this.operationTestContext.getInterpreter(), new EPackageService(), new ChildModelOperationHandler(List.of()), this.createInstanceOperation);
}
Also used : AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) EPackageService(org.eclipse.sirius.components.emf.compatibility.EPackageService) CreateInstanceOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateInstanceOperationHandler) EditingDomainFactory(org.eclipse.sirius.components.emf.services.EditingDomainFactory) ChildModelOperationHandler(org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with EPackageService

use of org.eclipse.sirius.components.emf.compatibility.EPackageService in project sirius-components by eclipse-sirius.

the class ToolImageProvider method getInstance.

private Optional<EObject> getInstance(String domainClass) {
    Matcher matcher = SEPARATOR.matcher(domainClass);
    if (matcher.find()) {
        String packageName = domainClass.substring(0, matcher.start());
        String className = domainClass.substring(matcher.end());
        var optionalEPackage = new EPackageService().findEPackage(this.ePackageRegistry, packageName);
        if (optionalEPackage.isPresent()) {
            EPackage ePackage = optionalEPackage.get();
            EcoreIntrinsicExtender ecoreIntrinsicExtender = new EcoreIntrinsicExtender();
            ecoreIntrinsicExtender.updateMetamodels(List.of(new EcoreMetamodelDescriptor(ePackage)));
            EObject instance = ecoreIntrinsicExtender.createInstance(className);
            return Optional.ofNullable(instance);
        }
    }
    return Optional.empty();
}
Also used : Matcher(java.util.regex.Matcher) EPackageService(org.eclipse.sirius.components.emf.compatibility.EPackageService) EObject(org.eclipse.emf.ecore.EObject) EcoreIntrinsicExtender(org.eclipse.sirius.ecore.extender.business.internal.accessor.ecore.EcoreIntrinsicExtender) EcoreMetamodelDescriptor(org.eclipse.sirius.ecore.extender.business.api.accessor.EcoreMetamodelDescriptor) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

EPackageService (org.eclipse.sirius.components.emf.compatibility.EPackageService)2 Matcher (java.util.regex.Matcher)1 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 AdapterFactoryEditingDomain (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 ChildModelOperationHandler (org.eclipse.sirius.components.emf.compatibility.modeloperations.ChildModelOperationHandler)1 CreateInstanceOperationHandler (org.eclipse.sirius.components.emf.compatibility.modeloperations.CreateInstanceOperationHandler)1 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)1 EditingDomainFactory (org.eclipse.sirius.components.emf.services.EditingDomainFactory)1 EcoreMetamodelDescriptor (org.eclipse.sirius.ecore.extender.business.api.accessor.EcoreMetamodelDescriptor)1 EcoreIntrinsicExtender (org.eclipse.sirius.ecore.extender.business.internal.accessor.ecore.EcoreIntrinsicExtender)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1