|
|
|
Re: Command selected state [message #994973 is a reply to message #994964] |
Fri, 28 December 2012 19:01 |
Frank Benoit Messages: 179 Registered: July 2009 |
Senior Member |
|
|
Now I found a E4 solution.
I mark the HandledMenuItem and HandledToolbarItem with "MyTag" tag.
When the event occurs, I get the handledItem injected, to get the selected state. The previously ToggleState is no more needed.
Then find all UI contribs with EModelService.findElements and update them with setSelected.
@Execute
public void run( @Active MPart part, @Active MWindow window, MHandledItem handledItem ){
// handle the event ...
// find the other UI contribs and update the checked state
List<String> tags = new LinkedList<>();
tags.add("MyTag");
List<MHandledItem> elements = modelServ.findElements(window.getMainMenu(), null, MHandledItem.class, tags );
elements.addAll( modelServ.findElements(window, null, MHandledItem.class, tags ) );
for( MHandledItem hi : elements ){
System.out.println("element : "+hi.getElementId());
hi.setSelected(handledItem.isSelected());
}
}
What is not nice about this are two things:
1. the tags should not be needed. Is there a way with just refering to the command ID?
2. the findElements does not include the main menu. Is this a bug?
thanks Frank
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02315 seconds