本文整理汇总了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 () );
}
}
示例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 );
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}