How to find DirectMenuItem programmatically [message #946827] |
Tue, 16 October 2012 10:45  |
Eclipse User |
|
|
|
Hi,
I added a DirectMenuItem via Application Model
TrimmedWindow -> Main Menu -> Menu -> DirectMenuItem (elementId: myItem)
It is of type Check. Now I need to access that menu item in code to check its selection state. I'm trying to do it like shown in various tutorials:
@PostConstruct
public void createPartControl(Composite parent, IEclipseContext context, MApplication application, EModelService modelService) {
MDirectMenuItem showTooltipItem = (MDirectMenuItem) modelService.find("myItem", application);
...
}
But the EModelService always returns null.
How should I get access to a DirectMenuItem programmatically?
Greez,
Dirk
|
|
|
|
|
|
|
|
Re: How to find DirectMenuItem programmatically [message #946852 is a reply to message #946827] |
Tue, 16 October 2012 11:09   |
Eclipse User |
|
|
|
I think that this is because EModelService#find() only search through composition relation like MUIElementContainer#children, which does not include the MWindow#mainMenu relation and such.
You may want to do this in 2 steps: use find(id, root) to find the "container" of your Menu (here: the MTrimmedWindow) by its ID (or any other mean convenient to you), then call find(id, root) again, but using the menu as the search root this time.
MTrimmedWindow trim = modelService.find("myWindow", application).get(0);
MDirectMenuItem item = (MDirectMenuItem)modelService.find("myItem", trim.getMainMenu());
Hope this helps!
Edit: Ok, very, very late... nevermind me!
[Updated on: Tue, 16 October 2012 11:10] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.05005 seconds