use of org.yakindu.sct.domain.extension.IDomain in project statecharts by Yakindu.
the class DefaultSimulationEngineFactory method restore.
protected ExecutionContext restore(String context, Statechart statechart) {
try {
ResourceSet set = new ResourceSetImpl();
Resource resource = set.createResource(URI.createURI("snapshot.xmi"));
if (resource == null)
return null;
set.getResources().add(resource);
resource.load(new URIConverter.ReadableInputStream(context, "UTF_8"), Collections.emptyMap());
IDomain domain = DomainRegistry.getDomain(statechart);
Injector injector = domain.getInjector(IDomain.FEATURE_SIMULATION);
ITypeSystem typeSystem = injector.getInstance(ITypeSystem.class);
if (typeSystem instanceof AbstractTypeSystem) {
set.getResources().add(((AbstractTypeSystem) typeSystem).getResource());
}
EcoreUtil.resolveAll(resource);
ExecutionContext result = (ExecutionContext) resource.getContents().get(0);
result.setSnapshot(true);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations