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);
}
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();
}
Aggregations