Search in sources :

Example 1 with ExtensibleURIConverterImpl

use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project tdi-studio-se by Talend.

the class ImportItemUtil method computeProperty.

private void computeProperty(ResourcesManager manager, ItemRecord itemRecord) {
    InputStream stream = null;
    try {
        stream = manager.getStream(itemRecord.getPath());
        final Resource resource = createResource(itemRecord, itemRecord.getPath(), false);
        URIConverter uriConverter = resource.getResourceSet().getURIConverter();
        resource.getResourceSet().setURIConverter(new ExtensibleURIConverterImpl() {

            /*
                 * (non-Javadoc)
                 * 
                 * @see org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl#createInputStream(org.eclipse.
                 * emf.common.util.URI, java.util.Map)
                 */
            @Override
            public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
                InputStream inputStream = null;
                EPackage ePackage = resource.getResourceSet().getPackageRegistry().getEPackage(uri.toString());
                if (ePackage != null || !"http".equals(uri.scheme())) {
                    inputStream = super.createInputStream(uri, options);
                } else {
                    inputStream = null;
                }
                return inputStream;
            }
        });
        EmfHelper.loadResource(resource, stream, null);
        resource.getResourceSet().setURIConverter(uriConverter);
        itemRecord.setProperty((Property) EcoreUtil.getObjectByType(resource.getContents(), PropertiesPackage.eINSTANCE.getProperty()));
    } catch (Exception e) {
    // ignore, must be one invalid or unknown item
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
            // ignore
            }
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CwmResource(org.talend.model.emf.CwmResource) TalendXMIResource(org.talend.commons.runtime.model.emf.TalendXMIResource) ByteArrayResource(org.talend.core.model.properties.helper.ByteArrayResource) Resource(org.eclipse.emf.ecore.resource.Resource) ExtensibleURIConverterImpl(org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl) IOException(java.io.IOException) URIConverter(org.eclipse.emf.ecore.resource.URIConverter) URI(org.eclipse.emf.common.util.URI) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with ExtensibleURIConverterImpl

use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project n4js by eclipse.

the class BuiltInSchemeAwareResource method createNewURIConverter.

private URIConverter createNewURIConverter() {
    URIConverter result = new ExtensibleURIConverterImpl();
    registrar.registerScheme(result);
    return result;
}
Also used : ExtensibleURIConverterImpl(org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl) URIConverter(org.eclipse.emf.ecore.resource.URIConverter)

Example 3 with ExtensibleURIConverterImpl

use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project xtext-core by eclipse.

the class ExternalContentSupportTest method testConfigureConverter.

@Test
public void testConfigureConverter() {
    URIConverter converter = new ExtensibleURIConverterImpl();
    support.configureConverter(converter, this);
    checkConverter(converter);
}
Also used : ExtensibleURIConverterImpl(org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl) URIConverter(org.eclipse.emf.ecore.resource.URIConverter) Test(org.junit.Test)

Example 4 with ExtensibleURIConverterImpl

use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project xtext-eclipse by eclipse.

the class PersistableResourceDescriptionsTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    with(new BuilderTestLanguageStandaloneSetup());
    SharedModule module = new SharedModule(null);
    builderInjector = Guice.createInjector(module);
    builderState = builderInjector.getInstance(ClusteringBuilderState.class);
    uriConverter = new ExtensibleURIConverterImpl() {

        @Override
        public InputStream createInputStream(org.eclipse.emf.common.util.URI uri, Map<?, ?> options) throws IOException {
            return new StringInputStream(fileSystem.get(uri.toString()));
        }
    };
}
Also used : URI(org.eclipse.emf.common.util.URI) StringInputStream(org.eclipse.xtext.util.StringInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) StringInputStream(org.eclipse.xtext.util.StringInputStream) ClusteringBuilderState(org.eclipse.xtext.builder.clustering.ClusteringBuilderState) SharedModule(org.eclipse.xtext.ui.shared.internal.SharedModule) BuilderTestLanguageStandaloneSetup(org.eclipse.xtext.builder.tests.BuilderTestLanguageStandaloneSetup) ExtensibleURIConverterImpl(org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl)

Example 5 with ExtensibleURIConverterImpl

use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project n4js by eclipse.

the class N4JSResource method createNewURIConverter.

private URIConverter createNewURIConverter() {
    URIConverter result = new ExtensibleURIConverterImpl();
    registrar.registerScheme(result);
    return result;
}
Also used : ExtensibleURIConverterImpl(org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl) URIConverter(org.eclipse.emf.ecore.resource.URIConverter)

Aggregations

ExtensibleURIConverterImpl (org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl)6 URIConverter (org.eclipse.emf.ecore.resource.URIConverter)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)2 URI (org.eclipse.emf.common.util.URI)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 IArchimateModel (com.archimatetool.model.IArchimateModel)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 JobGroup (org.eclipse.core.runtime.jobs.JobGroup)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 XMLResourceFactoryImpl (org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl)1