Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Access Menu at runtime (How to search Context for a MMenuItem)
Access Menu at runtime [message #1062477] Fri, 07 June 2013 22:25 Go to previous message
Don Smyth is currently offline Don SmythFriend
Messages: 35
Registered: April 2013
Member
I would like to disable/enable a HandledMenuItem based on user interaction.

Using the EModelService I can find MParts, MTrimmedWindows etc, but cannot find a MMenu (see Eclipse Bug 383403 EModelService.findElement() does not find all elements).

There is a reference in the Bug 383403 Comment 25 to "using the EModel service to get my main window, and using that window as the context in find(...) to get the menu item".

I am having trouble searching the context for the menu item via the menu item id.

private void findObjectById(MApplication application,
EModelService service) {
List<MTrimmedWindow> findElements = service.findElements(application,
"com.test.ui.mainwindow",MTrimmedWindow.class, null);

//This window is found OK
System.out.println("Found part by id: " + findElements.size());
if (findElements.size() == 1){
MTrimmedWindow window = findElements.get(0);
IEclipseContext windowContext = window.getContext();

//doesn't contain key
boolean hasKey = windowContext.containsKey("com.test.ui.filesubmenu");
if (hasKey){
System.out.println("Key found");
}

//not found in the context
Object menuItem = windowContext.get("com.test.ui.filesubmenu");
if (menuItem !=null){
System.out.println("Found in context: "+ menuItem.toString());
}
}
}

Has anyone found a way to access menu items at runtime?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:@Optional resource not being injected
Next Topic:[CSS] Changing the size of Radio Buttons and CheckButtons
Goto Forum:
  


Current Time: Sat Jul 22 09:19:53 GMT 2017

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

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