Example #1
0
 private void store(final Bok bok) {
   final String bokType = bok.getBokType();
   if (bokType.equals(Bok.SITE)) {
     setSite(bok);
   } else if (bokType.equals(Bok.PROJECT)) {
     setProject(bok);
     if (site == null) {
       eventBus.fireEvent(new OpenBokEvent(Bok.SITE, "1", null, null));
     }
   } else {
     byType.put(bokType, bok);
     if (project == null || !project.getId().equals(bok.getProjectId())) {
       eventBus.fireEvent(new OpenBokEvent(Bok.PROJECT, bok.getProjectId(), null, null));
     }
   }
 }
Example #2
0
 /**
  * Recommended way to send BokSelected events
  *
  * @param bok
  * @return
  */
 public boolean select(final Bok bok) {
   if (bok != null) {
     selected = bok;
     eventBus.fireEvent(new BokSelectedEvent(bok));
     return true;
   } else {
     return false;
   }
 }
Example #3
0
 public void addBokSelectedHandler(final String bokType, final BokSelectedHandler handler) {
   eventBus.addHandler(
       BokSelectedEvent.getType(),
       new BokSelectedHandler() {
         @Override
         public void onBokSelected(final BokSelectedEvent event) {
           if (event.isBokType(bokType)) {
             handler.onBokSelected(event);
           }
         }
       });
 }
Example #4
0
  @Inject
  public ClientSession(final EventBus eventBus) {
    this.eventBus = eventBus;
    byType = new HashMap<String, Bok>();

    eventBus.addHandler(
        BokRetrievedEvent.getType(),
        new BokRetrievedHandler() {
          @Override
          public void onBokRetrieved(final BokRetrievedEvent event) {
            store(event.getBok());
          }
        });
    eventBus.addHandler(
        BokSelectedEvent.getType(),
        new BokSelectedHandler() {
          @Override
          public void onBokSelected(final BokSelectedEvent event) {
            selected = event.getBok();
          }
        });
  }