在一个独立的ViewPart中,我设法在OutlineView中选择了EObjectNode。我现在需要得到它引用的EObject,但我看不出如何。
答案 0 :(得分:0)
if (selection instanceof IStructuredSelection) {
Object first = ((IStructuredSelection)selection).getFirstElement();
EObjectNode enode = (EObjectNode)first;
ResourceSet resourceSet = new ResourceSetImpl();
Resource inResource = resourceSet.getResource(enode.getEObjectURI(),true);
MyEcoreElement element = (MyEcoreElement)inResource.getEObject(enode.getEObjectURI().fragment());
//....
}