Search in sources :

Example 36 with XMIResourceFactoryImpl

use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project xtext-eclipse by eclipse.

the class Bug287941TestLanguageStandaloneSetupGenerated method createInjectorAndDoEMFRegistration.

@Override
public Injector createInjectorAndDoEMFRegistration() {
    // register default ePackages
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xtextbin", new BinaryGrammarResourceFactoryImpl());
    if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
        EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
    Injector injector = createInjector();
    register(injector);
    return injector;
}
Also used : EcoreResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl) Injector(com.google.inject.Injector) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) BinaryGrammarResourceFactoryImpl(org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl)

Example 37 with XMIResourceFactoryImpl

use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project xtext-eclipse by eclipse.

the class Bug303200TestLanguageStandaloneSetupGenerated method createInjectorAndDoEMFRegistration.

@Override
public Injector createInjectorAndDoEMFRegistration() {
    // register default ePackages
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xtextbin", new BinaryGrammarResourceFactoryImpl());
    if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
        EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
    Injector injector = createInjector();
    register(injector);
    return injector;
}
Also used : EcoreResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl) Injector(com.google.inject.Injector) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) BinaryGrammarResourceFactoryImpl(org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl)

Example 38 with XMIResourceFactoryImpl

use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project xtext-eclipse by eclipse.

the class Bug347012TestLanguageStandaloneSetupGenerated method createInjectorAndDoEMFRegistration.

@Override
public Injector createInjectorAndDoEMFRegistration() {
    // register default ePackages
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xtextbin", new BinaryGrammarResourceFactoryImpl());
    if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
        EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
    Injector injector = createInjector();
    register(injector);
    return injector;
}
Also used : EcoreResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl) Injector(com.google.inject.Injector) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) BinaryGrammarResourceFactoryImpl(org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl)

Example 39 with XMIResourceFactoryImpl

use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project iobserve-analysis by research-iobserve.

the class AbstractModelHandler method load.

/**
 * Load the model.
 *
 * @param readModelURI
 *            the uri from which the model is read
 * @return returns the loaded model
 */
@SuppressWarnings("unchecked")
public T load(final URI readModelURI) {
    this.getPackage().eClass();
    final Resource.Factory.Registry resourceRegistry = Resource.Factory.Registry.INSTANCE;
    final Map<String, Object> map = resourceRegistry.getExtensionToFactoryMap();
    map.put("*", new XMIResourceFactoryImpl());
    final ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.setResourceFactoryRegistry(resourceRegistry);
    final Resource resource = resourceSet.getResource(readModelURI, true);
    try {
        resource.load(null);
    } catch (final IOException e) {
        e.printStackTrace();
    }
    EcoreUtil.resolveAll(resourceSet);
    T model = null;
    if (!resource.getContents().isEmpty()) {
        model = (T) resource.getContents().get(0);
    }
    if (model == null) {
        AbstractModelHandler.LOGGER.debug("Model at {} could not be loaded!", readModelURI.toString());
    }
    return model;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) Resource(org.eclipse.emf.ecore.resource.Resource) LoggerFactory(org.slf4j.LoggerFactory) EObject(org.eclipse.emf.ecore.EObject) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IOException(java.io.IOException)

Example 40 with XMIResourceFactoryImpl

use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project InformationSystem by ObeoNetwork.

the class AbstractTransformationTest method createResource.

/**
 * This will create a {@link Resource} given the model extension it is
 * intended for and a ResourceSet.
 *
 * @param modelURI
 *            {@link org.eclipse.emf.common.util.URI URI} where the model is
 *            stored.
 * @param resourceSet
 *            The {@link ResourceSet} to load the model in.
 * @return The {@link Resource} given the model extension it is intended
 *         for.
 */
protected Resource createResource(URI modelURI, ResourceSet resourceSet) {
    String fileExtension = modelURI.fileExtension();
    if (fileExtension == null || fileExtension.length() == 0) {
        fileExtension = Resource.Factory.Registry.DEFAULT_EXTENSION;
    }
    // First search the resource set for our resource factory
    Resource.Factory.Registry registry = resourceSet.getResourceFactoryRegistry();
    Object resourceFactory = registry.getExtensionToFactoryMap().get(fileExtension);
    if (resourceFactory == null) {
        // then the global registry
        registry = Resource.Factory.Registry.INSTANCE;
        resourceFactory = registry.getExtensionToFactoryMap().get(fileExtension);
        if (resourceFactory != null) {
            resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(fileExtension, resourceFactory);
        } else {
            resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(fileExtension, new XMIResourceFactoryImpl());
        }
    }
    return resourceSet.createResource(modelURI);
}
Also used : XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) ScaffoldFactory(fr.gouv.mindef.safran.database.scaffold.ScaffoldFactory) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Aggregations

XMIResourceFactoryImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl)50 Injector (com.google.inject.Injector)20 EcoreResourceFactoryImpl (org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl)20 BinaryGrammarResourceFactoryImpl (org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl)20 Resource (org.eclipse.emf.ecore.resource.Resource)19 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)18 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)15 IOException (java.io.IOException)12 EObject (org.eclipse.emf.ecore.EObject)11 URI (org.eclipse.emf.common.util.URI)10 File (java.io.File)4 FSM (org.softlang.metalib.emf.fsml.fsml.FSM)3 MelangeResourceFactoryImpl (fr.inria.diverse.melange.resource.MelangeResourceFactoryImpl)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Decisions (org.benchmarx.examples.familiestopersons.testsuite.Decisions)2 Diagnostic (org.eclipse.emf.common.util.Diagnostic)2 EPackage (org.eclipse.emf.ecore.EPackage)2 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)2 LoggerFactory (org.slf4j.LoggerFactory)2