Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How do I programmatically select an EMF element in the Project Explorer?(Coordinating EMF selection with Project Explorer selection)
How do I programmatically select an EMF element in the Project Explorer? [message #1497128] Wed, 03 December 2014 15:09 Go to next message
Paul C. Brown is currently offline Paul C. BrownFriend
Messages: 18
Registered: October 2013
Junior Member
Given an element selected in the EMF editor, I want to select the corresponding element in the Project Explorer. I have tried two approaches so far, neither of which has worked.

Approach 1: Extend the Navigate->Show In->Project Explorer functionality. Here I have modified the EMF Editor's IShowInSource. getShowInContext() to return the model element, but the Project Explorer does not understand that selection nor can I figure out how to configure it to map that selection into an actual element of the tree.

Approach 2: Create a new operation (pop-up menu) to perform this action. Here I am struggling with the implementation of the handler. Given the model element, how do I locate the corresponding tree node in the Project Explorer?

Can anyone help me with either of these approaches (or offer a third alternative)?
Re: How do I programmatically select an EMF element in the Project Explorer? [message #1504501 is a reply to message #1497128] Tue, 09 December 2014 10:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Paul,

I don't have significant experience with the common navigator
framework. Is the tree for your model actually shown in the Project
explorer? More comments below.


On 03/12/2014 4:09 PM, Paul C. Brown wrote:
> Given an element selected in the EMF editor, I want to select the
> corresponding element in the Project Explorer. I have tried two
> approaches so far, neither of which has worked.
Keep in mind that it may well be the case that the explorer is showing
different objects (from a different resource set) than is the editor
itself (depending on whether your using the transaction framework to
share editing domains.
>
> Approach 1: Extend the Navigate->Show In->Project Explorer
> functionality. Here I have modified the EMF Editor's IShowInSource.
> getShowInContext() to return the model element, but the Project
> Explorer does not understand that selection nor can I figure out how
> to configure it to map that selection into an actual element of the tree.
The issue with the editor and the explore using different objects could
well be a problem here, but as I said, I don't understand the details of
how the project explorer works. That's why I ask if your model is
actually showing children in the explorer. If so you must have done
something to make that work....
>
> Approach 2: Create a new operation (pop-up menu) to perform this
> action. Here I am struggling with the implementation of the handler.
> Given the model element, how do I locate the corresponding tree node
> in the Project Explorer?
Also a good question, but it's similar to approach 1 where you've
returned the selection in the editor, but the outline in the explorer is
likely using different object instances than in the editor...
> Can anyone help me with either of these approaches (or offer a third
> alternative)?
I have no deep experience. Hopefully someone else will suggest something...
Previous Topic:CWM usage in EMF
Next Topic:Error while running my Eclipse application
Goto Forum:
  


Current Time: Sat Oct 19 19:24:16 GMT 2019

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

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

Back to the top