Rev 14 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.del.client.navigation.event;
import org.tela_botanica.del.client.cache.ClientCache;
import org.tela_botanica.del.client.history.NavigationStatesConstants;
import org.tela_botanica.del.client.modeles.Observation;
import org.tela_botanica.del.client.navigation.event.validateobservation.ValidateImageEvent;
import org.tela_botanica.del.client.navigation.event.validateobservation.ValidateImageEventHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.History;
public class EventBus extends HandlerManager {
private static EventBus instance;
private EventBus() {
super(null);
instance = this;
createHandlers();
}
public static EventBus getInstance() {
if (instance == null) {
instance = new EventBus();
}
return instance;
}
private void createHandlers() {
addHandler(ValidateImageEvent.TYPE, new ValidateImageEventHandler() {
@Override
public void onValidateImage(ValidateImageEvent event) {
doValidateImage(event.getImageCel());
}
});
}
private void doValidateImage(Observation observation) {
ClientCache.getInstance().setCurrentImageCel(observation);
History.newItem(NavigationStatesConstants.VALIDATION_PAGE, true);
History.fireCurrentHistoryState();
}
}