|
|
|
|
|
|
|
|
|
Re: Correct way to listen to a part activation/visibility change? [message #1735867 is a reply to message #1735524] |
Thu, 23 June 2016 11:25 |
Alexander Bunkowski Messages: 29 Registered: February 2014 |
Junior Member |
|
|
Not sure if I understand your Problem, but ill try to give some hints:
For B it should help to get the EPartService from the part context you want to watch.
MPart yourTargetPart = {somehow get you part here}
EPartService ePartService = yourTargetPart.getContext().get(EPartService.class);
ePartService.addPartListener(new PartListenerAdapter() {
@Override
public void partBroughtToTop(MPart part) {
if (yourTargetPart == targetMPart) {
//react here
}
}
});
If you have problems when switching perspectives you can try to subscribe to the PERSPECTIVE_SET_TOPIC. Idea is to see if you part is visible after a perspective has been switched and then react to it.
private static final String PERSPECTIVE_SET_TOPIC = "org/eclipse/e4/ui/model/ui/ElementContainer/selectedElement/SET";
eventBroker.subscribe(PERSPECTIVE_SET_TOPIC, new EventHandler() {
@Override
public void handleEvent(Event event) {
Object property = event.getProperty(UIEvents.EventTags.ELEMENT);
if (property != null && property instanceof MPerspectiveStack && partService.isPartVisible(yourTargetPart )) {
//react here
}
}
});
[Updated on: Thu, 23 June 2016 11:34] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05486 seconds