Search in sources :

Example 11 with IDomain

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;
}
Also used : ITypeSystem(org.yakindu.base.types.typesystem.ITypeSystem) IDomain(org.yakindu.sct.domain.extension.IDomain) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) ExecutionContext(org.yakindu.sct.model.sruntime.ExecutionContext) Injector(com.google.inject.Injector) AbstractTypeSystem(org.yakindu.base.types.typesystem.AbstractTypeSystem) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URIConverter(org.eclipse.emf.ecore.resource.URIConverter) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IDomain (org.yakindu.sct.domain.extension.IDomain)11 Injector (com.google.inject.Injector)4 CoreException (org.eclipse.core.runtime.CoreException)2 EObject (org.eclipse.emf.ecore.EObject)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 Label (org.eclipse.swt.widgets.Label)2 ITypeSystem (org.yakindu.base.types.typesystem.ITypeSystem)2 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IEMFValueProperty (org.eclipse.emf.databinding.IEMFValueProperty)1 URIConverter (org.eclipse.emf.ecore.resource.URIConverter)1 XMIResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)1 IViewerObservableValue (org.eclipse.jface.databinding.viewers.IViewerObservableValue)1 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1