public PlatformBus(){
History.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
String token = event.getValue();
eventBus.fireEvent(new PlatformPlaceChangeEvent(new PlatformPlace(token)));
}
});
eventBus.addHandler(PlatformPlaceChangeEvent.TYPE, new PlatformPlaceChangeEvent.Handler() {
public void onPlaceChange(PlatformPlaceChangeEvent event) {
PlatformPlace pp=event.getNewPlace();
if(pp.getCurrent()!=null){
if(event.isLogHistory() && pp.isOriginal()){
event.setLogHistory(false);
History.newItem(pp.getToken(), false);
}
String key=pp.getCurrent().key;
PlaceHandler handler=handlerMap.get(key);
if(handler!=null){
handler.handle(event);
}
if(!event.isAsyncCall()){
if(pp.next()){
onPlaceChange(event);
}
}
}
}
});
eventBus.addHandler(StartEvent.TYPE, new StartEvent.StartEventHandler() {
public void start() {
if(History.getToken()!=null && !"".equals(History.getToken().trim())){
eventBus.fireEvent(new PlatformPlaceChangeEvent(new PlatformPlace(History.getToken())));
}else{
eventBus.fireEvent(new PlatformPlaceChangeEvent(new PlacePath().toApp(App.Home).create(),true));
}
}
});
}