From f3aa2b747f7fafed03a80da3d6bc8a86077b0392 Mon Sep 17 00:00:00 2001 From: Johannes Dicks Date: Fri, 24 Jun 2016 14:12:08 +0200 Subject: [PATCH] Create GMFResource if default/gernic domain does not exist and resource is not existing in filesystem --- .../sct/model/resource/SCTResourceFactory.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/org.yakindu.sct.model.resource/src/org/yakindu/sct/model/resource/SCTResourceFactory.java b/plugins/org.yakindu.sct.model.resource/src/org/yakindu/sct/model/resource/SCTResourceFactory.java index 7ba79874f5..ecf4f8eaf5 100644 --- a/plugins/org.yakindu.sct.model.resource/src/org/yakindu/sct/model/resource/SCTResourceFactory.java +++ b/plugins/org.yakindu.sct.model.resource/src/org/yakindu/sct/model/resource/SCTResourceFactory.java @@ -13,26 +13,33 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.URIConverter; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.gmf.runtime.emf.core.resources.GMFResource; import org.yakindu.sct.domain.extension.DomainRegistry; import org.yakindu.sct.domain.extension.IDomainDescriptor; import com.google.inject.Injector; /** - * * @author andreas muelder - Initial contribution and API - * */ public class SCTResourceFactory extends XMIResourceFactoryImpl { @Override public Resource createResource(URI uri) { + + // if file is not existing, AND no generic/default domain is available, resource creation will fail + if (!URIConverter.INSTANCE.exists(uri, null)) { + return new GMFResource(uri); + } + String determinedDomainID = DomainRegistry.determineDomainID(uri); IDomainDescriptor domainDescriptor = DomainRegistry.getDomainDescriptor(determinedDomainID); Injector injector = domainDescriptor.getDomainInjectorProvider().getResourceInjector(); Resource resource = injector.getInstance(Resource.class); + ResourceSet set = new ResourceSetImpl(); set.getResources().add(resource); resource.setURI(uri);