当前位置: 首页>>代码示例>>Java>>正文


Java ResourceSetImpl.createResource方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceSetImpl.createResource方法的具体用法?Java ResourceSetImpl.createResource怎么用?Java ResourceSetImpl.createResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.resource.impl.ResourceSetImpl的用法示例。


在下文中一共展示了ResourceSetImpl.createResource方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setChartConfiguration

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
public void setChartConfiguration ( final Chart chart )
{
    if ( chart == null )
    {
        this.viewer.setInput ( null );
    }
    else
    {
        if ( chart.eResource () == null )
        {
            final ResourceSetImpl rs = new ResourceSetImpl ();
            final Resource r = rs.createResource ( URI.createURI ( "urn:dummy" ) );
            r.getContents ().add ( chart );
        }

        if ( chart.eResource ().getURI () == null )
        {
            chart.eResource ().setURI ( URI.createURI ( "urn:dummy" ) );
        }

        this.viewer.setInput ( chart.eResource () );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ChartConfiguratorView.java

示例2: startServer

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
public Collection<? extends ServerDescriptor> startServer ( final URI exporterFileUri, final String locationLabel ) throws CoreException
{
    final ResourceSetImpl resourceSet = new ResourceSetImpl ();

    resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ExporterResourceFactoryImpl () );

    final Resource resource = resourceSet.createResource ( exporterFileUri );
    try
    {
        resource.load ( null );
    }
    catch ( final IOException e )
    {
        throw new CoreException ( StatusHelper.convertStatus ( HivesPlugin.PLUGIN_ID, "Failed to load configuration", e ) );
    }

    final DocumentRoot root = (DocumentRoot)EcoreUtil.getObjectByType ( resource.getContents (), ExporterPackage.Literals.DOCUMENT_ROOT );
    if ( root == null )
    {
        throw new CoreException ( new Status ( IStatus.ERROR, HivesPlugin.PLUGIN_ID, "Failed to locate exporter configuration in: " + exporterFileUri ) );
    }
    return startServer ( root, locationLabel );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ServerHostImpl.java

示例3: getEcoreModel

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
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;
    }
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:18,代码来源:PrettyPrinter.java

示例4: testResolveLazyCrossReferences_02

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testResolveLazyCrossReferences_02() throws Exception {
	with(lazyLinkingTestLangaugeSetup());
	ResourceSetImpl rs = new ResourceSetImpl();
	final Resource res1 = rs.createResource(URI.createURI("file1.lazylinkingtestlanguage"));
	Resource res2 = rs.createResource(URI.createURI("file2.lazylinkingtestlanguage"));
	res1.load(new StringInputStream("type Foo { } type Baz { Foo Bar prop; } }"), null);
	res2.load(new StringInputStream("type Bar { }"), null);
	res1.eAdapters().add(notificationAlert);
	
	Model m = (Model) res1.getContents().get(0);
	Type t = m.getTypes().get(1);
	Property p = t.getProperties().get(0);
	final InternalEList<Type> types = (InternalEList<Type>) p.getType();
	assertEquals(2, types.size());
	for (Iterator<Type> it = types.basicIterator(); it.hasNext();) {
		final Type tt = it.next();
		assertTrue(tt.eIsProxy());
	}
	((LazyLinkingResource) res1).resolveLazyCrossReferences(CancelIndicator.NullImpl);
	assertFalse(types.basicGet(0).eIsProxy());
	assertTrue(types.basicGet(1).eIsProxy());
	res1.eAdapters().remove(notificationAlert);
   	EcoreUtil.resolveAll(res1);
	assertFalse(types.basicGet(0).eIsProxy());
	assertFalse(types.basicGet(1).eIsProxy());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:LazyLinkingResourceTest.java

示例5: _privk3_execute

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
protected static void _privk3_execute(final TransformationAspectTransformationAspectProperties _self_, final Transformation _self) {
  try {
    EList<Rule> _rules = _self.getRules();
    for (final Rule r : _rules) {
      RuleAspect.apply(r);
    }
    if (((!Objects.equal(TransformationAspect.outputFilePath(_self), null)) && (!Objects.equal(TransformationAspect.outputFilePath(_self), "")))) {
      final ResourceSetImpl rs = new ResourceSetImpl();
      String _outputFilePath = TransformationAspect.outputFilePath(_self);
      final File outputFile = new File(_outputFilePath);
      boolean _exists = outputFile.exists();
      if (_exists) {
        outputFile.delete();
      }
      File _parentFile = outputFile.getParentFile();
      _parentFile.mkdirs();
      String _absolutePath = outputFile.getAbsolutePath();
      final URI outputModelURI = URI.createFileURI(_absolutePath);
      final Resource outputModelResource = rs.createResource(outputModelURI);
      EList<EObject> _contents = outputModelResource.getContents();
      List<EObject> _outputModel = TransformationAspect.outputModel(_self);
      _contents.addAll(_outputModel);
      outputModelResource.save(null);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:tetrabox,项目名称:minitl,代码行数:29,代码来源:TransformationAspect.java

示例6: testClone

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testClone() throws Exception {
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
			new XMIResourceFactoryImpl());
	EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE);
	
	ResourceSetImpl rs = new ResourceSetImpl();
	Resource r1 = rs.createResource(URI.createURI("foo.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
	Resource r2 = rs.createResource(URI.createURI("bar.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
	EClass a = EcoreFactory.eINSTANCE.createEClass();
	a.setName("a");
	EClass b = EcoreFactory.eINSTANCE.createEClass();
	r1.getContents().add(a);
	b.setName("b");
	b.getESuperTypes().add(a);
	r2.getContents().add(b);
	
	ResourceSetImpl clone = EcoreUtil2.clone(new ResourceSetImpl(), rs);
	EList<Resource> list = clone.getResources();
	
	Resource resA = list.get(0);
	assertEquals(URI.createURI("foo.xmi"),resA.getURI());
	assertNotSame(resA, r1);
	
	Resource resB = list.get(1);
	assertEquals(URI.createURI("bar.xmi"),resB.getURI());
	assertNotSame(resB, r2);
	
	EClass a1 = (EClass)resA.getContents().get(0);
	EClass b1 = (EClass)resB.getContents().get(0);
	assertEquals("a", a1.getName());
	assertNotSame(a, a1);
	assertEquals("b", b1.getName());
	assertNotSame(b, b1);
	assertSame(b1.getESuperTypes().get(0),a1);
	assertSame(b.getESuperTypes().get(0),a);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:EcoreUtil2Test.java

示例7: testClone_2

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test
public void testClone_2() throws Exception {
	ResourceSetImpl sourceSet = new DerivedStateAwareResourceSet();
	DerivedStateAwareResource resource = (DerivedStateAwareResource) sourceSet.createResource(URI
			.createURI("http://derived.res"));
	boolean stateToCheck = !resource.isFullyInitialized();
	resource.setFullyInitialized(stateToCheck);
	
	Resource targetRes = EcoreUtil2.clone(new DerivedStateAwareResourceSet(), sourceSet).getResources().get(0);
	
	assertTrue(targetRes instanceof DerivedStateAwareResource);
	assertEquals("FullyInitialized flag not copied ", stateToCheck, ((DerivedStateAwareResource) targetRes).isFullyInitialized());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:EcoreUtil2Test.java

示例8: testResolveLazyCrossReferences

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testResolveLazyCrossReferences() throws Exception {
   	with(testLangaugeSetup());
   	ResourceSetImpl rs = new ResourceSetImpl();
	final Resource res1 = rs.createResource(URI.createURI("file1.indextestlanguage"));
	Resource res2 = rs.createResource(URI.createURI("file2.indextestlanguage"));
	res1.load(new StringInputStream(
			  "foo { " 
			+ "  import bar.Bar" 
			+ "  entity Foo {" 
			+ "    Bar a1" 
			+ "    Foo a2" 
			+ "  }"
			+ "}"), null);
	res2.load(new StringInputStream(
			  "bar {" 
			+ "  entity Bar{}" 
			+ "}"), null);
	res1.eAdapters().add(notificationAlert);
	
	Entity e = (Entity) find(EcoreUtil2.eAllContents(res1.getContents().get(0)),new Predicate<EObject>() {
		@Override
		public boolean apply(EObject input) {
			return input instanceof Entity;
		}
	});
	
	assertTrue(((EObject)e.getProperties().get(0).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
	assertTrue(((EObject)e.getProperties().get(1).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
	((LazyLinkingResource)res1).resolveLazyCrossReferences(CancelIndicator.NullImpl);
	assertTrue(((EObject)e.getProperties().get(0).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
	assertFalse(((EObject)e.getProperties().get(1).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
	res1.eAdapters().remove(notificationAlert);
	EcoreUtil.resolveAll(res1);
	assertFalse(((EObject)e.getProperties().get(0).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
	assertFalse(((EObject)e.getProperties().get(1).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:LazyLinkingResourceTest.java

示例9: testResolveLazyCrossReferences_01

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testResolveLazyCrossReferences_01() throws Exception {
 	with(testLangaugeSetup());
 	ResourceSetImpl rs = new ResourceSetImpl();
 	final Resource res1 = rs.createResource(URI.createURI("file1.indextestlanguage"));
 	Resource res2 = rs.createResource(URI.createURI("file2.indextestlanguage"));
 	res1.load(new StringInputStream(
 			"foo { " 
 			+ "  import bar.Bar" 
 			+ "  entity Foo {" 
 			+ "    Bar a1" 
 			+ "    Foo a2" 
 			+ "    Unresolvable a2" 
 			+ "  }"
 			+ "}"), null);
 	res2.load(new StringInputStream(
 			"bar {" 
 			+ "  entity Bar{}" 
 			+ "}"), null);
 	res1.eAdapters().add(notificationAlert);
 	Entity e = (Entity) find(EcoreUtil2.eAllContents(res1.getContents().get(0)),new Predicate<EObject>() {
 		@Override
public boolean apply(EObject input) {
 			return input instanceof Entity;
 		}
 	});
 	assertEquals(0,res1.getErrors().size());
 	assertTrue(((EObject)e.getProperties().get(0).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	assertTrue(((EObject)e.getProperties().get(1).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	assertTrue(((EObject)e.getProperties().get(2).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	((LazyLinkingResource)res1).resolveLazyCrossReferences(CancelIndicator.NullImpl);
 	assertEquals(1,res1.getErrors().size());
 	assertTrue(((EObject)e.getProperties().get(0).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	assertFalse(((EObject)e.getProperties().get(1).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	assertTrue(((EObject)e.getProperties().get(2).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	res1.eAdapters().remove(notificationAlert);
 	EcoreUtil.resolveAll(res1);
 	assertEquals(1,res1.getErrors().size());
 	assertFalse(((EObject)e.getProperties().get(0).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	assertFalse(((EObject)e.getProperties().get(1).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 	assertTrue(((EObject)e.getProperties().get(2).eGet(IndexTestLanguagePackage.Literals.PROPERTY__TYPE, false)).eIsProxy());
 }
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:42,代码来源:LazyLinkingResourceTest.java


注:本文中的org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。