本文整理汇总了Java中org.eclipse.emf.ecore.resource.Resource.getEObject方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getEObject方法的具体用法?Java Resource.getEObject怎么用?Java Resource.getEObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.resource.Resource
的用法示例。
在下文中一共展示了Resource.getEObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDocSafely
import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
* Same as {@link #getDoc(EObject)}, but will never change the containing resource of the given element.
* <p>
* If the containing resource of the given element is not fully loaded (i.e. AST not loaded yet because only the
* TModule was loaded from the Xtext index), then the given resource set will be used to load the resource, then the
* corresponding EObject for element will be searched in that temporary resource, and the documentation will be
* retrieved from there.
*/
public String getDocSafely(ResourceSet resourceSetForDocRetrieval, EObject element) {
if (resourceSetForDocRetrieval == null)
throw new IllegalArgumentException("resourceSetForDocRetrieval may not be null");
if (element == null || element.eIsProxy())
throw new IllegalArgumentException("element may not be null or a proxy");
final Resource res = element.eResource();
final ResourceSet resSet = res != null ? res.getResourceSet() : null;
if (resSet == null || res == null)
throw new IllegalArgumentException("element must be contained in a resource set");
if (resourceSetForDocRetrieval != resSet) {
final Resource resSafe = resourceSetForDocRetrieval.getResource(res.getURI(), true);
final EObject elementSafe = resSafe.getEObject(res.getURIFragment(element));
return elementSafe != null ? getDoc(elementSafe) : null;
} else {
return getDoc(element);
}
}
示例2: updateMainElementName
import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
* Update _entryPointModelElement with pretty name
*/
private void updateMainElementName(){
try {
Resource model = getModel();
EObject mainElement = null;
if(model != null){
mainElement = model.getEObject(_entryPointModelElementText.getText());
}
if(mainElement != null){
org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider nameprovider = new DefaultDeclarativeQualifiedNameProvider();
QualifiedName qname = nameprovider.getFullyQualifiedName(mainElement);
String objectName = qname != null ? qname.toString(): mainElement.toString();
String prettyName = objectName+ " : "+mainElement.eClass().getName();
_entryPointModelElementLabel.setText(prettyName);
}
} catch (Exception e) { }
}
示例3: load
import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
@Test
public void load() throws IOException {
final Resource builtinTypesResource = fromUri(BuiltinType.RESOURCE_URI);
assertThat(builtinTypesResource.getErrors()).hasSize(0);
assertThat(builtinTypesResource).isNotNull();
for (final BuiltinType builtinType : BuiltinType.values()) {
final EObject anyType = builtinTypesResource.getEObject("/types/" + builtinType.getName());
assertThat(anyType).isNotNull();
assertThat(anyType).isInstanceOf(AnyType.class);
final AnyType type = (AnyType) anyType;
final AnyType superType = type.getType();
assertThat(superType).isNull();
final EObject anyAnnotationType = builtinTypesResource.getEObject("/annotationTypes/" + builtinType.getName());
assertThat(anyAnnotationType).isNotNull();
assertThat(anyAnnotationType).isInstanceOf(AnyAnnotationType.class);
final AnyAnnotationType annotationType = (AnyAnnotationType) anyAnnotationType;
final AnyAnnotationType superAnnotationType = annotationType.getType();
assertThat(superAnnotationType).isNull();
}
}
示例4: resolveObject
import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
* {@link EcoreUtil#resolve(EObject, EObject)} pretty much does the same thing but will eagerly load the resource.
* We are happy with the content that we just put into it.
*/
private EObject resolveObject(URI objectURI, Resource resource) {
if (resource.isLoaded())
throw new IllegalStateException("Should not be loaded beforehand");
EObject result = resource.getEObject(objectURI.fragment());
if (resource.isLoaded())
throw new IllegalStateException("Should not be loaded due to fragment traversal");
return result;
}