當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。