|
Re: Close Part Listener [message #847968 is a reply to message #847713] |
Tue, 17 April 2012 20:53 |
Eclipse User |
|
|
|
The framework sends events for a lot of event types and you can easily subscribe to those using the IEventBroker. Here is an addon that registers a listener like the one you require. I haven't tested it with compatibility layers but it should work.
public class TestAddon {
private EventHandler testHandler;
@PostConstruct
public void pc(IEventBroker eventBroker)
{
testHandler = new EventHandler() {
@Override
public void handleEvent(Event event) {
Object part = event.getProperty(UIEvents.EventTags.ELEMENT);
boolean tbr =(Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
if (part instanceof MPart){
System.out.println("Part "+((MPart)part).getElementId()+" is "+(!tbr?"NOT":"")+" visible");
}
}
};
eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, testHandler);
}
//....................
}
So the idea is:
- implement an event handler, check that the ELEMENT event tag is instance of MPart, get the new value (NEW_VALUE event tag) and do what you wish with it.
- subscribe this handler to the TOBERENDERED topic
- unsubscribe when you're done.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03438 seconds