Skip to content
Last updated

Windowevent

This type of event is generated when a window is created or deleted.

Event registration can be done as follows, where this is the class that implements IEventSubscriber<WindowEvent>

    EventBroadcaster.getInstance().subscribe(WindowEvent.class, this);

In the example below, we want to be notified if a certain layer is deleted. We do this in method onEvent which implements the IEventSubscriber<WindowEvent> interface:

    private IWindow myWindow; // the window we want to keep track of
    public void onEvent(WindowEvent event) {
        if (event.getEventType().equals(WindowEvent.WINDOW_DELETED_EVENT_TYPE)) {
                                   IWindow window = event.getWindow();
                if (window == myWindow) {
                   // do some cleanup
                   EventBroadcaster.getInstance().unsubscribe(WindowEvent.class, this);
                   myWindow = null;
                   ....
            }
        }
    }