Search in sources :

Example 1 with Event

use of ol.Collection.Event in project gwt-ol3 by TDesjardins.

the class CollectionTest method testCollectionEvents.

public void testCollectionEvents() {
    this.injectUrlAndTest(() -> {
        Collection<Control> controls = new Collection<Control>();
        assertFalse(this.elementAddedEventFired);
        assertFalse(this.elementRemovedEventFired);
        controls.addElementAddedListener(new EventListener<Collection.Event<Control>>() {

            @Override
            public void onEvent(Event<Control> event) {
                elementAddedEventFired = true;
            }
        });
        controls.addElementRemovedListener(new EventListener<Collection.Event<Control>>() {

            @Override
            public void onEvent(Event<Control> event) {
                elementRemovedEventFired = true;
            }
        });
        controls.push(new Attribution());
        assertTrue(this.elementAddedEventFired);
        assertFalse(this.elementRemovedEventFired);
        controls.removeAt(0);
        assertTrue(this.elementAddedEventFired);
        assertTrue(this.elementRemovedEventFired);
    });
}
Also used : Control(ol.control.Control) Event(ol.Collection.Event) Attribution(ol.control.Attribution)

Aggregations

Event (ol.Collection.Event)1 Attribution (ol.control.Attribution)1 Control (ol.control.Control)1