Java 类org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl 实例源码

项目:grapheditor    文件:GraphEditorPersistence.java   
/**
 * Loads the sample saved in the given file.
 *
 * @param graphEditor the graph editor in which the loaded model will be set
 */
private void loadSample(final String file, final GraphEditor graphEditor) {

    final String samplePath = getClass().getResource(file).toExternalForm();

    final URI fileUri = URI.createURI(samplePath);
    final XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
    final Resource resource = resourceFactory.createResource(fileUri);

    try {
        resource.load(Collections.EMPTY_MAP);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof GModel) {

        final GModel model = (GModel) resource.getContents().get(0);
        graphEditor.setModel(model);
    }
}
项目:MBSE-Vacation-Manager    文件:Validate.java   
public Validate()
{
    Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("calender", new XMIResourceFactoryImpl());


    ResourceSet rs = new ResourceSetImpl();
    Resource r = rs.getResource(URI.createFileURI("model/mynew.calender"), true);

    EObject root = r.getContents().get(0);

    Iterator<EObject> i = r.getAllContents();
    while(i.hasNext())
        System.out.println(i.next());
}
项目:n4js    文件:UnicodeStandaloneSetupGenerated.java   
@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;
}
项目:gemoc-studio-modeldebugging    文件:CreateDSAWizardContextActionDSAK3.java   
private GenModel loadGenmodel(String path) {
    try {
        if (!EPackage.Registry.INSTANCE.containsKey(GenModelPackage.eNS_URI))
            EPackage.Registry.INSTANCE.put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);

        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());

        ResourceSet rs = new ResourceSetImpl();
        URI uri = URI.createURI(path);
        Resource pkg = rs.getResource(uri, true);

        return (GenModel) pkg.getContents().get(0);
    } catch (Exception e) {
        // ...
    }

    return null;
}
项目:gemoc-studio-modeldebugging    文件:CreateDSAProposal.java   
private GenModel loadGenmodel(String path) {
    try {
        if (!EPackage.Registry.INSTANCE.containsKey(GenModelPackage.eNS_URI))
            EPackage.Registry.INSTANCE.put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);

        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());

        ResourceSet rs = new ResourceSetImpl();
        URI uri = URI.createURI(path);
        Resource pkg = rs.getResource(uri, true);

        return (GenModel) pkg.getContents().get(0);
    } catch (Exception e) {
        // ...
    }

    return null;
}
项目:neoscada    文件:Generate.java   
/**
 * This can be used to update the resource set's resource factory registry
 * with all needed factories.
 * 
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated NOT
 */
@Override
public void registerResourceFactories ( final ResourceSet resourceSet )
{
    super.registerResourceFactories ( resourceSet );
    /*
     * TODO If you need additional resource factories registrations, you can register them here. the following line
     * (in comment) is an example of the resource factory registration for UML. If you want to change the content
     * of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to "@generated NOT".
     * Without this new tag, any compilation of the Acceleo module with the main template that has caused the creation
     * of this class will revert your modifications.
     * 
     * To learn more about the registration of Resource Factories, have a look at the Acceleo Launcher documentation (Help -> Help Contents). 
     */

    resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "protocol", new XMIResourceFactoryImpl () );
}
项目:neoscada    文件:Generate.java   
/**
 * This can be used to update the resource set's resource factory registry with all needed factories.
 * 
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated NOT
 */
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
    super.registerResourceFactories(resourceSet);
    /*
     * If you want to change the content of this method, do NOT forget to change the "@generated"
     * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
     * of the Acceleo module with the main template that has caused the creation of this class will
     * revert your modifications.
     */

    /*
     * TODO If you need additional resource factories registrations, you can register them here. the following line
     * (in comment) is an example of the resource factory registration for UML.
     *
     * If you want to use the generator in stand alone, the resource factory registration will be required.
     *  
     * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). 
     */ 

    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*.xmi", new XMIResourceFactoryImpl());
}
项目:neoscada    文件:ChartHelper.java   
public static Chart loadConfiguraton ( final String configurationUri )
{
    if ( configurationUri == null || configurationUri.isEmpty () )
    {
        return null;
    }

    // load
    ChartPackage.eINSTANCE.eClass ();

    final ResourceSet resourceSet = new ResourceSetImpl ();

    resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMIResourceFactoryImpl () ); //$NON-NLS-1$

    final Resource resource = resourceSet.getResource ( URI.createURI ( configurationUri ), true );

    for ( final EObject o : resource.getContents () )
    {
        if ( o instanceof Chart )
        {
            return (Chart)o;
        }
    }
    return null;
}
项目:neoscada    文件:DetailViewImpl.java   
private void load ()
{
    logger.info ( "Loading: {}", this.uri ); //$NON-NLS-1$

    final ResourceSet resourceSet = new ResourceSetImpl ();

    resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMIResourceFactoryImpl () ); //$NON-NLS-1$

    final URI file = URI.createURI ( this.uri );
    final Resource resource = resourceSet.getResource ( file, true );

    for ( final EObject o : resource.getContents () )
    {
        if ( o instanceof View )
        {
            createView ( (View)o );
        }
    }
}
项目:greycat-idea-plugin    文件:PrettyPrinter.java   
protected ResourceSet getEcoreModel(File ecorefile) {

        ResourceSetImpl rs = new ResourceSetImpl();
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
        try {
            URI fileUri = URI.createFileURI(ecorefile.getCanonicalPath());
            Resource resource = rs.createResource(fileUri);
            resource.load(null);
            EcoreUtil.resolveAll(resource);
            rs.getResources().add(resource);
            EcoreUtil.resolveAll(rs);

        } catch (IOException e) {
            e.printStackTrace();
        }
        return rs;
    }
项目:JavaGraph    文件:EcoreResource.java   
public EcoreResource(File typeTarget, File instanceTarget) {
    this.m_resourceSet = new ResourceSetImpl();
    this.m_resourceSet.getResourceFactoryRegistry()
        .getExtensionToFactoryMap()
        .put("*", new XMIResourceFactoryImpl());

    this.m_typeFile = typeTarget;
    this.m_instanceFile = instanceTarget;

    if (this.m_typeFile == this.m_instanceFile || this.m_typeFile == null
        || this.m_instanceFile == null) {
        this.relPath = "";
    } else {
        this.relPath =
            groove.io.Util.getRelativePath(new File(this.m_instanceFile.getAbsoluteFile()
                .getParent()), this.m_typeFile.getAbsoluteFile())
                .toString();
    }
}
项目:gemoc-studio    文件:DslStandaloneSetupGenerated.java   
@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;
}
项目:SurveyDSL    文件:SurveyGenerator.java   
private static Survey loadSurveyModel(String modulePath) {
    // Initialize the model
    QueryITPackage.eINSTANCE.eClass();

    Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("xmi", new XMIResourceFactoryImpl());
    m.put("ecore", new EcoreResourceFactoryImpl());

    // Obtain a new resource set
    ResourceSet resSet = new ResourceSetImpl();

    // Get the resource
    //Resource resource = resSet.getResource(URI.createFileURI(modulePath), true);
    Resource resource = resSet.getResource(URI.createURI(modulePath), true);

    // Get the first model element and cast it to the right type, in my
    // example everything is included in this first node
    Survey s = (Survey) resource.getContents().get(0);

    return s;
}
项目:benchmarx    文件:MediniQVTFamiliesToPersonsConfig.java   
/**
 * Allows to save the current state of the source and target models
 * 
 * @param name : Filename 
 */
public void saveModels(String name) {
    ResourceSet set = new ResourceSetImpl();
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
    URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
    URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
    Resource resSource = set.createResource(srcURI);
    Resource resTarget = set.createResource(trgURI);

    EObject colSource = EcoreUtil.copy(getSourceModel());
    EObject colTarget = EcoreUtil.copy(getTargetModel());

    resSource.getContents().add(colSource);
    resTarget.getContents().add(colTarget);

    try {
        resSource.save(null);
        resTarget.save(null);
    } catch (IOException e) {
        e.printStackTrace();
    }       
}
项目:benchmarx    文件:UbtXtendFamiliesToPersons.java   
/**
 * Initiates a synchronization between a source and a target model. The BXtend Transformation is
 * initialized and empty source, target and correspondence models are created.
 * Finally a FamilyRegister is added to the source model and an initial forward transformation is issued
 * to create a corresponding PersonRegister.
 */
@Override
public void initiateSynchronisationDialogue() {
    // Fix default preferences (which can be overwritten)
    setConfigurator(new Configurator<Decisions>()
        .makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true)
        .makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));          

    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("family", new XMIResourceFactoryImpl());
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("person", new XMIResourceFactoryImpl());
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("corr", new XMIResourceFactoryImpl());      

    source = set.createResource(URI.createURI("sourceModel.family"));
    target = set.createResource(URI.createURI("targetModel.person"));
    corr = set.createResource(URI.createURI("corrModel.corr"));
    FamilyRegister familiesRoot = FamiliesFactory.eINSTANCE.createFamilyRegister();
    source.getContents().add(familiesRoot);
    f2pt = new Family2PersonTransformation(source, target, corr);
    // Fix default preferences (which can be overwritten)
    setConfigurator(new Configurator<Decisions>()
            .makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true)
            .makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));

    // perform batch to establish consistent starting state
    f2pt.Family2Person();
}
项目:benchmarx    文件:UbtXtendFamiliesToPersons.java   
/**
 * Allows to save the current state of the source and target models
 * 
 * @param name : Filename 
 */
@Override
public void saveModels(String name) {
    ResourceSet set = new ResourceSetImpl();
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
    URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
    URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
    Resource resSource = set.createResource(srcURI);
    Resource resTarget = set.createResource(trgURI);

    EObject colSource = EcoreUtil.copy(getSourceModel());
    EObject colTarget = EcoreUtil.copy(getTargetModel());

    resSource.getContents().add(colSource);
    resTarget.getContents().add(colTarget);

    try {
        resSource.save(null);
        resTarget.save(null);
    } catch (IOException e) {
        e.printStackTrace();
    }           
}
项目:benchmarx    文件:EMoflonFamiliesToPersons.java   
public void saveModels(String name) {
    ResourceSet set = new ResourceSetImpl();
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
    URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
    URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
    Resource resSource = set.createResource(srcURI);
    Resource resTarget = set.createResource(trgURI);

    EObject colSource = EcoreUtil.copy(getSourceModel());
    EObject colTarget = EcoreUtil.copy(getTargetModel());

    resSource.getContents().add(colSource);
    resTarget.getContents().add(colTarget);

    try {
        resSource.save(null);
        resTarget.save(null);
    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:xtext-extras    文件:XtypeStandaloneSetupGenerated.java   
@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;
}
项目:M2Doc    文件:ServerWithoutAuthentication.java   
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
    server = new CDOServer(false);
    server.start();
    IConnector connector = M2DocCDOUtils
            .getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
    CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
            CDOServer.PASSWORD);
    final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
    final CDOResource resource = transaction.createResource("anydsl.ecore");
    final ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
    final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
    resource.getContents().addAll(anyDSLResource.getContents());
    resource.save(null);
    transaction.commit();
    transaction.close();
    session.close();
    connector.close();

    if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
        ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
        M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
    }
}
项目:M2Doc    文件:ServerWithAuthentication.java   
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
    server = new CDOServer(true);
    server.start();
    IConnector connector = M2DocCDOUtils
            .getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
    CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
            CDOServer.PASSWORD);
    final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
    final CDOResource resource = transaction.createResource("anydsl.ecore");
    final ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
    final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
    resource.getContents().addAll(anyDSLResource.getContents());
    resource.save(null);
    transaction.commit();
    transaction.close();
    session.close();
    connector.close();

    if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
        ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
        M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
    }
}
项目:Vitruv    文件:Models.java   
public static Resource loadModel(URL modelURL) {

        ResourceSet resSet = new ResourceSetImpl();
        resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
                new XMIResourceFactoryImpl());

        EcoreResourceFactoryImpl ecoreResFact = new EcoreResourceFactoryImpl();
        URI fileName = BasicTestCase.getURI(modelURL);
        LOGGER.info("Trying to load " + fileName);
        Resource ecoreRes = ecoreResFact.createResource(fileName);
        try {
            ecoreRes.load(null);
        } catch (IOException e) {
            fail("Could not load " + Files.EXAMPLEMODEL_ECORE.getFile() + ". Reason: " + e);
        }

        resSet.getResources().add(ecoreRes);

        return ecoreRes;
    }
项目:xtext-core    文件:TerminalsStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:Bug406914TestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:Bug301935TestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:HiddenTerminalsTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:Bug292245TestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:XtextTerminalsTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:TerminalRulesTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:EcoreTerminalsTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:EncodingTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:IndentationAwareTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:BacktrackingLexerTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:xtext-core    文件:IgnoreCaseLexerTestLanguageStandaloneSetupGenerated.java   
@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;
}
项目:haetae    文件:XML2EcoreTranslator.java   
public void testParse() throws ParserConfigurationException, SAXException, IOException
{
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

    URL url = getClass().getResource("library.xml");
    File file = new File(url.getPath());

    document = documentBuilder.parse(file);
    String packageName = getRoot().getNodeName();
    String prefix = packageName.toLowerCase();
    String nsURI = "http://" + packageName + "/1.0";
    ePackage.setName(packageName);
    ePackage.setNsPrefix(prefix);
    ePackage.setNsURI(nsURI);
    createEClass((Element) getRoot());

    ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
    Resource resource = resourceSet.createResource(URI.createFileURI(new File("library.ecore").getAbsolutePath()));
    resource.getContents().add(ePackage);
    System.out.println(resourceSet.getPackageRegistry().toString());
    System.out.println(EPackage.Registry.INSTANCE.toString());
    resource.save(null);    
}
项目:haetae    文件:ProgramPerformanceAnalyser.java   
public void visit(EOLModule program)
{
    ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
    Resource resource = resourceSet.createResource(URI.createFileURI(new File("test.xmi").getAbsolutePath()));
    resource.getContents().add(program);

    model = new InMemoryEmfModel("EOL", program.eResource(), EolPackage.eINSTANCE);
    try {
        matchSelectPatterOne(program);
        matchSelectPatterTwo(program);
        matchSelectPatterThree(program);
        matchSelectPatterFour(program);
        matchSelectPatterFive(program);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:grapheditor    文件:GraphEditorPersistence.java   
/**
 * Saves the graph editor's model state in the given file.
 *
 * @param file the {@link File} the model state will be saved in
 * @param model the {@link GModel} to be saved
 */
private void saveModel(final File file, final GModel model) {

    String absolutePath = file.getAbsolutePath();
    if (!absolutePath.endsWith(FILE_EXTENSION)) {
        absolutePath += FILE_EXTENSION;
    }

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);

    final URI fileUri = URI.createFileURI(absolutePath);
    final XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
    final Resource resource = resourceFactory.createResource(fileUri);
    resource.getContents().add(model);

    try {
        resource.save(Collections.EMPTY_MAP);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    editingDomain.getResourceSet().getResources().clear();
    editingDomain.getResourceSet().getResources().add(resource);

    initialDirectory = file.getParentFile();
}
项目:grapheditor    文件:GraphEditorPersistence.java   
/**
 * Loads the model from the given file and sets it in the given graph editor.
 *
 * @param file the {@link File} to be loaded
 * @param graphEditor the {@link GraphEditor} in which the loaded model will be set
 */
private void loadModel(final File file, final GraphEditor graphEditor) {

    final URI fileUri = URI.createFileURI(file.getAbsolutePath());

    final XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
    final Resource resource = resourceFactory.createResource(fileUri);

    try {
        resource.load(Collections.EMPTY_MAP);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof GModel) {

        final GModel model = (GModel) resource.getContents().get(0);
        graphEditor.setModel(model);
    }

    initialDirectory = file.getParentFile();
}
项目:grapheditor    文件:DummyDataFactory.java   
/**
 * Creates a new dummy model instance from a test file.
 *
 * @return a new dummy {@link GModel} instance from a test file
 */
public static GModel createModel() {

    // Need to instantiate this to make metamodel available in unit tests.
    @SuppressWarnings("unused")
    final ModelPackage packageInstance = ModelPackage.eINSTANCE;

    final String testFilePath = DummyDataFactory.class.getResource(TEST_FILE).toExternalForm();

    final URI fileUri = URI.createURI(testFilePath);
    final XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
    final Resource resource = resourceFactory.createResource(fileUri);

    try {
        resource.load(Collections.EMPTY_MAP);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof GModel) {
        return (GModel) resource.getContents().get(0);
    } else {
        return null;
    }
}
项目:Source    文件:WorkspaceMappingBaseListenerTests.java   
/**
 * Creates a {@link Base} {@link IFile} in the given container containing the given {@link Base}.
 * 
 * @param container
 *            the {@link IContainer}
 * @param base
 *            the {@link Base}
 * @return the created {@link IFile} if any, <code>null</code> otherwise
 */
private IFile createBaseFile(IContainer container, Base base) {
    final String fileName = "test.mapping";
    IFile res = container.getFile(new Path(fileName));

    try {
        final ResourceSet resourceSet = new ResourceSetImpl();
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(MappingPackage.eNAME,
                new XMIResourceFactoryImpl());

        final Resource resource = resourceSet.createResource(URI.createPlatformResourceURI(container
                .getFullPath().toString() + "/" + fileName, true));
        if (base != null) {
            resource.getContents().add(base);
        }
        resource.save(null);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        res = null;
    }

    return res;
}
项目:melange    文件:StandaloneSetup.java   
public void doEMFRegistration() {
  EPackage.Registry.INSTANCE.put(
    fsm.FsmPackage.eNS_URI,
    fsm.FsmPackage.eINSTANCE
  );
  EPackage.Registry.INSTANCE.put(
    timedfsm.fsm.TimedfsmPackage.eNS_URI,
    timedfsm.fsm.TimedfsmPackage.eINSTANCE
  );

  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
    "*",
    new XMIResourceFactoryImpl()
  );
  Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(
    "melange",
    new MelangeResourceFactoryImpl()
  );
}