Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Finding references in EMF generated Editor
Finding references in EMF generated Editor [message #1765407] Fri, 09 June 2017 09:16 Go to next message
Jan-Patrick Osterloh is currently offline Jan-Patrick OsterlohFriend
Messages: 6
Registered: September 2014
Junior Member
Hi,

I have an ecore model A, for which I generate the edit and editor plug-ins. I use that to specify my model. In the model, there are multiple objects with references to other objects. I know that I can find the instance of a reference in the properties view via the "Locate Value" button, but is there also the other way around, i.e. how can I locate all references of an object in other objects?

I cannot find a menu for that, maybe someone can help? I find it also interesting, that in the generated editor, the "Find/Replace" in the Edit menu is disabled. Can I somehow enable that, so I can maybe find references with that?

Best regards
Jan-Patrick

Re: Finding references in EMF generated Editor [message #1765429 is a reply to message #1765407] Fri, 09 June 2017 11:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
You could use org.eclipse.emf.ecore.util.EcoreUtil.UsageCrossReferencer or org.eclipse.emf.ecore.util.ECrossReferenceAdapter for finding all references to an object and add menu support for that.

In Oomph there are extensions to EMF that support find and replace. They're generic so could be used in any application. You could look at Oomph's Setup Editor to see how that's integrated.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Finding references in EMF generated Editor [message #1765444 is a reply to message #1765429] Fri, 09 June 2017 14:28 Go to previous messageGo to next message
Jan-Patrick Osterloh is currently offline Jan-Patrick OsterlohFriend
Messages: 6
Registered: September 2014
Junior Member
Hi Ed,

thanks for your reply!

The UsageCrossReferencer seems indeed a good starting point. Is there a view in Eclipse, that can I use to display the result, or do I have to write this myself?

I had a look at Oomph, even cloned the complete git repository, but I weren't able to find UsageCrossReferencer or the ECrossReferenceAdapter to be used in this code somewhere.

Tanks
Jan-Patrick
Re: Finding references in EMF generated Editor [message #1765447 is a reply to message #1765444] Fri, 09 June 2017 15:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
As far as I know, there isn't such a view for showing usages. Perhaps an extension to the search results view, but I have no experience with that.

The other part of my answer was related to find and replace support. In particular, org.eclipse.oomph.internal.ui.FindAndReplaceTarget.FindAndReplaceTarget(IWorkbenchPart) in the org.eclipse.oomph.ui plugin. It can be added to an EMF generated editor like this
  public Object getAdapter(Class adapter)
  {
    Object result = FindAndReplaceTarget.getAdapter(adapter, this);
    if (result != null)
    {
      return result;
    }


The Oomph project has quite a few cool extension to EMF. E.g., much improved drag and drop support, and improved use of the system clipboard to support copy and paste even between VMs, for examples.

You can see, for example, how Find and Replace work in the Setup Editor by doing Navigate -> Open Setup -> User in your IDE (since Mars they all have Oomph installed), and then using Ctrl-F. It even searches in the values of properties and highlights the matches in the Properties view.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Finding references in EMF generated Editor [message #1765970 is a reply to message #1765447] Wed, 14 June 2017 16:01 Go to previous messageGo to next message
Jan-Patrick Osterloh is currently offline Jan-Patrick OsterlohFriend
Messages: 6
Registered: September 2014
Junior Member
Hi Ed,

thanks for your valuable help!

With that, and some code from http://codeandme.blogspot.de/2015/07/a-custom-search-provider.html I was able to write a plug-in that provides a nice way on finding references within my editor.

In case anyone has this issue, too, I'm attaching my solution to this message.

Best regards
Jan-Patrick
Re: Finding references in EMF generated Editor [message #1765972 is a reply to message #1765970] Wed, 14 June 2017 16:07 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jan-Patrick,

That's very nice of you to share your results. Thanks!


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Delcare imports when generating operation body [SOLVED]
Next Topic:Error: There may not be two classifiers named 'CatchClause_CatchClause'
Goto Forum:
  


Current Time: Wed Apr 24 23:46:19 GMT 2024

Powered by FUDForum. Page generated in 0.03569 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top