Michael wrote:
Hi,
If we contribute an action to popup menu using the extension
point: org.eclipse.ui.popupMenus, we can define an objectContribution.
Then, the Eclipse know how to configure the popup menu based on type
of object that is a model of the right-clicked UI elment. What I am
wandering is how Eclipse know the mapping from the chosed UI element
to the underlying model of this object. I really don't know what part
eclipse API handle this mechinism. Do you have any idea about this?
Thanks.
Best regards.
Michael.
Hello Michael,
have a look at how selection service works in Eclipse:
http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html
It's basically that, when you'd like your view to support e.g.
objectContribution, you first have to make it a selection provider. In
other words, when user selects an element in your view, you notify the
rest of Eclipse that new object is selected.
Then everyone, who's interested (e.g. context menu manger, or properties
view), updates it's contents. You can also listen to such selection
notifications by making your class implement ISelectionListener and
registering it appropriately.