Example usage for com.google.gwt.event.shared SimpleEventBus addHandler

List of usage examples for com.google.gwt.event.shared SimpleEventBus addHandler

Introduction

In this page you can find the example usage for com.google.gwt.event.shared SimpleEventBus addHandler.

Prototype

@Override
    public <H> HandlerRegistration addHandler(Type<H> type, H handler) 

Source Link

Usage

From source file:org.penpusher.client.Penpusher.java

License:Open Source License

@Override
public void onModuleLoad() {
    final SimpleEventBus eventBus = new SimpleEventBus();
    final ApplicationModel model = ApplicationModel.create(eventBus);
    final ApplicationController ctrl = new ApplicationController(eventBus);

    // Instantiates view
    final RootLayoutPanel root = RootLayoutPanel.get();
    final MainPanel mainPane = new MainPanel(ctrl, model);
    root.add(mainPane);/*from  w  w  w. j  a v  a2s  .  co m*/

    eventBus.addHandler(SessionEvent.TYPE, new SessionEventHandler() {
        @Override
        public void onSession(final SessionEvent event) {
            // Load forms and categories. Forms must be loaded first.
            ctrl.loadForms(model.getFormModel());
            ctrl.loadCategories(model.getCategoryModel());
        }
    });

    eventBus.addHandler(SignOutCompletedEvent.TYPE, new SignOutCompletedEventHandler() {
        @Override
        public void onSignOutCompleted(final SignOutCompletedEvent event) {
            root.remove(mainPane);
            root.add(new SignOutPanel());
        }
    });

    // Gets session information
    ctrl.getSession(model);
}