org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl Java Examples

The following examples show how to use org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtextTerminalsTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: DetailViewImpl.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
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 );
        }
    }
}
 
Example #3
Source File: XtypeStandaloneSetupGenerated.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #4
Source File: AbstractTemplatesTestSuite.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
protected ResourceSet getResourceSetForModel(final List<Exception> exceptions) {
    final ResourceSet rs = new ResourceSetImpl();

    final XMIResourceFactoryImpl xmiResourceFactory = new XMIResourceFactoryImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", xmiResourceFactory);
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", xmiResourceFactory);
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(GenconfUtils.GENCONF_EXTENSION_FILE,
            xmiResourceFactory);
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml", xmiResourceFactory);

    final ResourceSet res = M2DocUtils.createResourceSetForModels(exceptions, generation, rs,
            GenconfUtils.getOptions(generation));
    res.getURIConverter().getURIHandlers().add(0, uriHandler);

    return res;
}
 
Example #5
Source File: Generate.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 () );
}
 
Example #6
Source File: Generate.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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());
}
 
Example #7
Source File: Bug347012TestLanguageStandaloneSetupGenerated.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #8
Source File: ContentAssistNoTerminalExtensionTestLanguageStandaloneSetupGenerated.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #9
Source File: Bug303200TestLanguageStandaloneSetupGenerated.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #10
Source File: EncodingUiTestLanguageStandaloneSetupGenerated.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #11
Source File: CodetemplatesStandaloneSetupGenerated.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #12
Source File: Bug406914TestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #13
Source File: Bug301935TestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #14
Source File: HiddenTerminalsTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #15
Source File: Bug292245TestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #16
Source File: TerminalsStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #17
Source File: TerminalRulesTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #18
Source File: EcoreTerminalsTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #19
Source File: EncodingTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #20
Source File: IndentationAwareTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #21
Source File: BacktrackingLexerTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #22
Source File: IgnoreCaseLexerTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #23
Source File: GamlStandaloneSetupGenerated.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #24
Source File: GraphEditorPersistence.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #25
Source File: GraphEditorPersistence.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #26
Source File: GraphEditorPersistence.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #27
Source File: DummyDataFactory.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 GraphPackage packageInstance = GraphPackage.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;
    }
}
 
Example #28
Source File: ProcessEngineConfigurationImpl.java    From fixflow with Apache License 2.0 6 votes vote down vote up
private void initDataVariableConfig() {
	ResourceSet resourceSet = new ResourceSetImpl();
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMIResourceFactoryImpl());
	String classPath = getDataVariableConfigPath();
	URL url = this.getClass().getClassLoader().getResource(classPath);
	if(url == null){
		log.error("未能从{}目录下加载到datavariableconfig文件",classPath);
		throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION_FILENOTFOUND, classPath);
	}
	String filePath = url.toString();
	Resource resource = null;
	try {
		if (!filePath.startsWith("jar")) {
			filePath = java.net.URLDecoder.decode(ReflectUtil.getResource(classPath).getFile(), "utf-8");
			resource = resourceSet.createResource(URI.createFileURI(filePath));
		} else {
			resource = resourceSet.createResource(URI.createURI(filePath));
		}
		resourceSet.getPackageRegistry().put(VariableconfigPackage.eINSTANCE.getNsURI(), VariableconfigPackage.eINSTANCE);
		resource.load(null);
	} catch (Exception e) {
		log.error("datavariableconfig.xml文件加载失败");
		throw new FixFlowException("datavariableconfig.xml文件加载失败", e);
	}
	dataVariableConfig = (DataVariableConfig) resource.getContents().get(0);
}
 
Example #29
Source File: Ecore2UimaTypeSystem.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Converts an Ecore model to a UIMA TypeSytemDescription.
 * 
 * @param aEcoreFilePath
 *          file path to a .ecore model file
 * @param aOptions
 *          a Map defining options for the conversion. Valid keys for this map are defined as
 *          constants on this class.
 * 
 * @return The UIMA TypeSystemDescription corresponding to the Ecore model
 * @throws URISyntaxException
 *           if there is a problem finding or reading the .ecore file
 */
public static TypeSystemDescription ecore2UimaTypeSystem(String aEcoreFilePath, Map aOptions)
        throws URISyntaxException {
  // register default resource factory
  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
          new XMIResourceFactoryImpl());
  // create resource set to hold the resource we're loading and its dependent resources
  ResourceSet resourceSet = new ResourceSetImpl();
  // convert file path to absolute path -- seems to be required for propery proxy resolution
  File inputFile = new File(aEcoreFilePath);
  URI absoluteInputURI = URI.createFileURI(inputFile.getAbsolutePath());
  // load the resource
  Resource resource = resourceSet.getResource(absoluteInputURI, true);
  // convert to UIMA TypeSystem
  return ecore2UimaTypeSystem(resource, aOptions);
}
 
Example #30
Source File: FindingsTemplateService.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private String createXMI(FindingsTemplates findingsTemplates){
	Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
	Map<String, Object> m = reg.getExtensionToFactoryMap();
	m.put("xmi", new XMIResourceFactoryImpl());
	ResourceSet resSet = new ResourceSetImpl();
	Resource resource = resSet.createResource(URI.createURI("findingsTemplate.xml"));
	resource.getContents().add(findingsTemplates);
	ByteArrayOutputStream os = new ByteArrayOutputStream();
	
	try {
		resource.save(os, Collections.EMPTY_MAP);
		os.flush();
		String aString = new String(os.toByteArray(), "UTF-8");
		os.close();
		return aString;
	} catch (IOException e) {
		LoggerFactory.getLogger(FindingsTemplateService.class).error("", e);
	}
	return null;
}