|
Re: Processing all EObject from global action [message #647548 is a reply to message #647545] |
Fri, 07 January 2011 00:16 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Jay,
Comments below.
Jay Norwood wrote:
> I'm adding some global actions, and needed to figure out how to get at
> all the EObjects. So here is the code that I came up with, which
> works for my particular application. If you have some enhancements
> please feel encouraged to post.
> Jay
>
> EditingDomain editingDomain =
> ((IEditingDomainProvider)activeEditorPart).getEditingDomain( );
> // get the root
> Resource res = editingDomain.getResourceSet().getResources().get(0);
Don't you want to handle all resources? ResourceSet.getAllContents()
might be helpful; note that it yields resources and their contents...
> if (res instanceof XMIResourceImpl){
You're only interested in XMI resources?
> XMIResourceImpl xmi = (XMIResourceImpl) res;
> TreeIterator<EObject> iter =xmi.getAllContents();
> for (;iter.hasNext(); ) {
> EObject ob = (EObject)iter.next();
> }
> }
Note that any given resource might contain objects with references that
are unresolved proxies. EcoreUtil.resolveAll helps ensure that all
proxies are resolve.
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02751 seconds