Package com.google.web.bindery.event.shared

Examples of com.google.web.bindery.event.shared.SimpleEventBus


  public String getModuleName() {
    return "com.google.web.bindery.event.EventBinder";
  }

  public void testEventBinder() {
    EventBus eventBus = new SimpleEventBus();
    TestPresenter presenter = new TestPresenter();
    TestPresenter.MyEventBinder binder = GWT.create(TestPresenter.MyEventBinder.class);
    binder.bindEventHandlers(presenter, eventBus);

    // Test one event
    assertEquals(0, presenter.firstEventsHandled);
    eventBus.fireEvent(new FirstEvent());
    assertEquals(1, presenter.firstEventsHandled);
    assertEquals(1, presenter.firstEventsWithoutParameterHandled);
    assertEquals(1, presenter.firstAndSecondEventsHandled);

    // Test another event twice
    assertEquals(0, presenter.secondEventsHandled);
    eventBus.fireEvent(new SecondEvent());
    eventBus.fireEvent(new SecondEvent());
    assertEquals(2, presenter.secondEventsHandled);
    assertEquals(3, presenter.firstAndSecondEventsHandled);
  }
View Full Code Here


    assertEquals(2, presenter.secondEventsHandled);
    assertEquals(3, presenter.firstAndSecondEventsHandled);
  }

  public void testEventBinder_unbindEventHandlers() {
    EventBus eventBus = new SimpleEventBus();
    TestPresenter presenter = new TestPresenter();
    TestPresenter.MyEventBinder binder = GWT.create(TestPresenter.MyEventBinder.class);
    HandlerRegistration registration = binder.bindEventHandlers(presenter, eventBus);
    assertEquals(0, presenter.firstEventsHandled);
    assertEquals(0, presenter.firstEventsWithoutParameterHandled);
    assertEquals(0, presenter.secondEventsHandled);

    // Before unregistering
    eventBus.fireEvent(new FirstEvent());
    eventBus.fireEvent(new SecondEvent());
    assertEquals(1, presenter.firstEventsHandled);
    assertEquals(1, presenter.firstEventsWithoutParameterHandled);
    assertEquals(1, presenter.secondEventsHandled);
    assertEquals(2, presenter.firstAndSecondEventsHandled);

    // After unregistering
    registration.removeHandler();
    eventBus.fireEvent(new FirstEvent());
    eventBus.fireEvent(new SecondEvent());
    assertEquals(1, presenter.firstEventsHandled);
    assertEquals(1, presenter.firstEventsWithoutParameterHandled);
    assertEquals(1, presenter.secondEventsHandled);
    assertEquals(2, presenter.firstAndSecondEventsHandled);

    // After re-registering
    binder.bindEventHandlers(presenter, eventBus);
    eventBus.fireEvent(new FirstEvent());
    eventBus.fireEvent(new SecondEvent());
    assertEquals(2, presenter.firstEventsHandled);
    assertEquals(2, presenter.firstEventsWithoutParameterHandled);
    assertEquals(2, presenter.secondEventsHandled);
    assertEquals(4, presenter.firstAndSecondEventsHandled);
  }
View Full Code Here

    eventBus.fireEvent(new FirstEvent());
    assertEquals(1, presenter.firstEventsHandled);
  }

  public void testEventBinder_withHandlersInSuperclass() {
    EventBus eventBus = new SimpleEventBus();
    SubPresenter presenter = new SubPresenter();
    SubPresenter.MyEventBinder binder = GWT.create(SubPresenter.MyEventBinder.class);
    binder.bindEventHandlers(presenter, eventBus);

    eventBus.fireEvent(new FirstEvent());
    eventBus.fireEvent(new SecondEvent());
    eventBus.fireEvent(new ThirdEvent());

    // FirstEvent has a handler in both classes, so it should be handled twice
    assertEquals(1, presenter.firstEventsHandled);
    assertEquals(1, presenter.firstEventsWithoutParameterHandled);
    assertEquals(1, presenter.subclassFirstEventsHandled);
View Full Code Here

    private final NavigationDelegate navigationDelegate;

    @Inject
    public InteractionCoordinator(Dialog dialog, StatementContext parentContext, NavigationDelegate navigationDelegate) {
        this.dialog = dialog;
        this.bus = new SimpleEventBus();
        this.navigationDelegate = navigationDelegate;
        this.dialogState = new DialogState(dialog, parentContext, this);

        // coordinator handles all events except presentation & system events
        bus.addHandler(InteractionEvent.TYPE, this);
View Full Code Here

    private final NavigationDelegate navigationDelegate;

    @Inject
    public InteractionCoordinator(Dialog dialog, StatementContext parentContext, NavigationDelegate navigationDelegate) {
        this.dialog = dialog;
        this.bus = new SimpleEventBus();
        this.navigationDelegate = navigationDelegate;
        this.dialogState = new DialogState(dialog, parentContext, this);

        // coordinator handles all events except presentation & system events
        bus.addHandler(InteractionEvent.TYPE, this);
View Full Code Here

  private final KeyedCounter<Type<?>> firedCounts = new KeyedCounter<Event.Type<?>> ();
  private final KeyedCounter<TypeSourcePair> sourceCounts = new KeyedCounter<TypeSourcePair>();
  private final EventBus wrapped;

  public CountingEventBus() {
    this(new SimpleEventBus());
  }
View Full Code Here

  private CountingEventBus eventBus;

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    eventBus = new CountingEventBus(new SimpleEventBus());
  }
View Full Code Here

    });
  }

  protected Factory createFactory() {
    Factory toReturn = GWT.create(Factory.class);
    toReturn.initialize(new SimpleEventBus());
    return toReturn;
  }
View Full Code Here

    });
  }

  protected Factory1 createFactory1() {
    Factory1 toReturn = GWT.create(Factory1.class);
    toReturn.initialize(new SimpleEventBus());
    return toReturn;
  }
View Full Code Here

    return toReturn;
  }

  protected Factory2 createFactory2() {
    Factory2 toReturn = GWT.create(Factory2.class);
    toReturn.initialize(new SimpleEventBus());
    return toReturn;
  }
View Full Code Here

TOP

Related Classes of com.google.web.bindery.event.shared.SimpleEventBus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.