0

在一个独立的 ViewPart 中,我设法在 OutlineView 中选择了 EObjectNode。我现在需要获取它引用的 EObject,但我不知道如何。

4

1 回答 1

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());
        //....  
 }     
于 2013-02-17T19:00:00.627 回答