Get view from Widget reference
In Eclipse, can I get the View ID given a reference to one of its widgets? I don't want to enumerate all view开发者_开发问答s and traverse their hierarchies.
Use Control.getParent() API to go up the widget hierarchy starting with your widget. At some point, you will find the view part. Then you can get the info you need. I'd do this in the debugger first to make it easier to identify the class that the view part will have in the controls tree. It should be pretty obvious when you see it.
Ended up using SWTbot and some manual bookkeeping for the purpose.
精彩评论