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


Java ResourceSetImpl.getResource方法代码示例

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


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

示例1: checkMenuNewChildElementTypeIdRefs

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
/**
 * Check that referenced element type are in the registry
 */
@Test
public void checkMenuNewChildElementTypeIdRefs() {
	URI createPlatformPluginURI = URI.createPlatformPluginURI(NEW_CHILD_MENU_PATH, true);
	ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	Resource resource = resourceSetImpl.getResource(createPlatformPluginURI, true);

	TreeIterator<EObject> allContents = resource.getAllContents();
	while (allContents.hasNext()) {
		EObject eObject = (EObject) allContents.next();
		if (eObject instanceof CreationMenu) {
			String iconPath = ((CreationMenu) eObject).getIcon();
			 if (iconPath != null && !"".equals(iconPath)){
					try {
						Assert.assertNotNull("The icon "+iconPath+" can't be found", FileLocator.find(new URL(iconPath)));
					} catch (MalformedURLException e) {
						Assert.fail("The new child menu is refering to a malformed url "+iconPath);
					}
			 }
		}
	}
}
 
开发者ID:bmaggi,项目名称:library-training,代码行数:25,代码来源:NewChildTest.java

示例2: testBug261630_duplicateImports

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
/**
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=261630
 */
@Test public void testBug261630_duplicateImports() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("foo.importuritestlanguage", "import 'bar.importuritestlanguage' import 'bar.importuritestlanguage' import 'bar.importuritestlanguage' type foo extends bar type bar extends bar2");
	models.addModel("bar.importuritestlanguage", "type bar type bar2 extends bar");

	Resource resource = rs.getResource(URI.createURI("foo.importuritestlanguage"), true);
	Main main = (Main) resource.getContents().get(0);
	assertEquals("bar", main.getTypes().get(0).getExtends().getName());
	assertEquals("bar2", main.getTypes().get(0).getExtends().getExtends().getName());
	assertEquals("bar", main.getTypes().get(0).getExtends().getExtends().getExtends().getName());
	assertNull(main.getTypes().get(0).getExtends().getExtends().getExtends().getExtends());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:SimpleNameScopeProviderTest.java

示例3: testGetAllContents

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testGetAllContents() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("foo.importuritestlanguage", "import 'bar.importuritestlanguage' type Foo");
	models.addModel("bar.importuritestlanguage", "type A type B type C");

	Resource resource = rs.getResource(URI.createURI("foo.importuritestlanguage"), true);
	
	IScope scope = getScopeProvider().getScope(((Main)resource.getContents().get(0)).getTypes().get(0), ImportedURIPackage.Literals.TYPE__EXTENDS);
	HashSet<IEObjectDescription> set = Sets.newHashSet(scope.getAllElements());
	assertEquals(4,set.size());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:SimpleNameScopeProviderTest.java

示例4: loadInstanceModel

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
/**
 * Gets root EObject of given xmi file path
 *
 * @param xmiFileFullPath file path of xmi file
 * @return root @EObject
 * @throws IOException
 */
@SuppressWarnings({"rawtypes", "unchecked"})
public static Resource loadInstanceModel(final String xmiFileFullPath) throws IOException {
  final Map options = new HashMap();
  options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

  final ResourceSetImpl resourceSet = new ResourceSetImpl();
  resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
      .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
  Resource resource =
      resourceSet.getResource(URI.createPlatformResourceURI(xmiFileFullPath, true), true);
  if (resource == null) {
    resource = resourceSet.getResource(URI.createFileURI(xmiFileFullPath), true);
    if (resource == null) {
      resource =
          resourceSet.getResource(URI.createPlatformPluginURI(xmiFileFullPath, true), true);
      if (resource == null) {
        resource = resourceSet.getResource(URI.createURI(xmiFileFullPath), true);
      }
    }
  }
  resource.load(options);
  if (resource.isLoaded()) {
    return resource;
  }
  return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:EcoreUtilities.java

示例5: testSimple

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testSimple() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("foo.importuritestlanguage", "import 'bar.importuritestlanguage' type foo extends bar");
	models.addModel("bar.importuritestlanguage", "type bar");

	Resource resource = rs.getResource(URI.createURI("foo.importuritestlanguage"), true);
	Main main = (Main) resource.getContents().get(0);
	assertEquals("bar", main.getTypes().get(0).getExtends().getName());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:SimpleNameScopeProviderTest.java

示例6: testRelativeScope

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testRelativeScope() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("testfile://my/folder/foo.importuritestlanguage", "import 'bar.importuritestlanguage' type foo extends bar type bar extends bar2");
	models.addModel("testfile://my/folder/bar.importuritestlanguage", "type bar type bar2 extends bar");

	Resource resource = rs.getResource(URI.createURI("testfile://my/folder/foo.importuritestlanguage"), true);
	Main main = (Main) resource.getContents().get(0);
	assertEquals("bar", main.getTypes().get(0).getExtends().getName());
	assertEquals("bar2", main.getTypes().get(0).getExtends().getExtends().getName());
	assertEquals("bar", main.getTypes().get(0).getExtends().getExtends().getExtends().getName());
	assertNull(main.getTypes().get(0).getExtends().getExtends().getExtends().getExtends());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:SimpleNameScopeProviderTest.java

示例7: testRelativeScopeWithPath

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testRelativeScopeWithPath() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);
	models.addModel("testfile://my/folder/foo.importuritestlanguage", "import './../folder/bar.importuritestlanguage' type foo extends bar type bar extends bar2");

	models.addModel("testfile://my/folder/bar.importuritestlanguage", "type bar type bar2 extends bar");

	Resource resource = rs.getResource(URI.createURI("testfile://my/folder/foo.importuritestlanguage"), true);
	Main main = (Main) resource.getContents().get(0);
	assertEquals("bar", main.getTypes().get(0).getExtends().getName());
	assertEquals("bar2", main.getTypes().get(0).getExtends().getExtends().getName());
	assertEquals("bar", main.getTypes().get(0).getExtends().getExtends().getExtends().getName());
	assertNull(main.getTypes().get(0).getExtends().getExtends().getExtends().getExtends());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:SimpleNameScopeProviderTest.java

示例8: testScopeFileName

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testScopeFileName() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("foo.importuritestlanguage", "import 'bar.importuritestlanguage' type foo extends bar type bar extends bar2");
	models.addModel("bar.importuritestlanguage", "type bar type bar2 extends bar");

	Resource resource = rs.getResource(URI.createURI("foo.importuritestlanguage"), true);
	Main main = (Main) resource.getContents().get(0);
	assertEquals("bar", main.getTypes().get(0).getExtends().getName());
	assertEquals("bar2", main.getTypes().get(0).getExtends().getExtends().getName());
	assertEquals("bar", main.getTypes().get(0).getExtends().getExtends().getExtends().getName());
	assertNull(main.getTypes().get(0).getExtends().getExtends().getExtends().getExtends());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:SimpleNameScopeProviderTest.java

示例9: testUnresolvableImport

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testUnresolvableImport() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("testfile://my/folder/foo.importuritestlanguage",
			"import 'unknownfile.importuritestlanguage' type foo extends bar type bar extends bar2");

	Resource resource = rs.getResource(URI.createURI("testfile://my/folder/foo.importuritestlanguage"), true);
	assertNotNull(resource);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:SimpleNameScopeProviderTest.java

示例10: testCircularImport

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
@Test public void testCircularImport() throws Exception {
	SyntheticModelAwareURIConverter models = new SyntheticModelAwareURIConverter();
	ResourceSetImpl rs = new ResourceSetImpl();
	rs.setURIConverter(models);

	models.addModel("foo.importuritestlanguage", "import 'bar.importuritestlanguage' type foo extends bar");
	models.addModel("bar.importuritestlanguage", "import 'foo.importuritestlanguage' type bar extends foo");

	Resource resource = rs.getResource(URI.createURI("foo.importuritestlanguage"), true);
	Main main = (Main) resource.getContents().get(0);
	assertEquals("bar", main.getTypes().get(0).getExtends().getName());
	assertEquals("foo", main.getTypes().get(0).getExtends().getExtends().getName());
	assertSame(main.getTypes().get(0).getExtends().getExtends(), main.getTypes().get(0));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:SimpleNameScopeProviderTest.java

示例11: checkPaletteIds

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入方法依赖的package包/类
/**
 * Check palette ids and element type reference
 */
@Test
public void checkPaletteIds() {
	URI createPlatformPluginURI = URI.createPlatformPluginURI(PALETTE_PATH, true);
	ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	Resource resource = resourceSetImpl.getResource(createPlatformPluginURI, true);

	TreeIterator<EObject> allContents = resource.getAllContents();
	while (allContents.hasNext()) {
		EObject eObject = (EObject) allContents.next();

		if (eObject instanceof PaletteConfiguration) {
			PaletteConfiguration p = (PaletteConfiguration) eObject;
			EList<DrawerConfiguration> drawerConfigurations = p.getDrawerConfigurations();
			for (DrawerConfiguration drawerConfiguration : drawerConfigurations) {
				EList<ChildConfiguration> ownedConfigurations = drawerConfiguration.getOwnedConfigurations();
				for (ChildConfiguration childConfiguration : ownedConfigurations) {

					// check id
					String id = childConfiguration.getId();
					Assert.assertTrue("Malformed palette id : " + id, assertPaletteId(id));

					if (childConfiguration instanceof ToolConfiguration) {
						ToolConfiguration toolConfiguration = (ToolConfiguration) childConfiguration;

						// check icon file
						IconDescriptor icon = toolConfiguration.getIcon();
						String iconPath = "platform:/plugin/" + icon.getPluginID() + "/" + icon.getIconPath();
						if (iconPath != null && !"".equals(iconPath)) {
							try {
								URL url = new URL(iconPath);
								Assert.assertNotNull("The icon " + iconPath + "(for : " + toolConfiguration.getId()
										+ ") can't be found", FileLocator.find(url));
							} catch (MalformedURLException e) {
								Assert.fail("The new child menu is refering to a malformed url " + iconPath);
							}
						}
					}
				}
			}
		}
	}
}
 
开发者ID:bmaggi,项目名称:library-training,代码行数:46,代码来源:PaletteTest.java


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