You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.8 KiB
Java
89 lines
2.8 KiB
Java
package org.gcube.portlets.user.accountingdashboard.client.application.controller;
|
|
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.error.ErrorPresenter;
|
|
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter;
|
|
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.monitor.MonitorPresenter;
|
|
import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent;
|
|
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardServiceAsync;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
|
|
|
|
import com.google.gwt.event.shared.EventBus;
|
|
import com.google.gwt.event.shared.EventHandler;
|
|
import com.google.gwt.event.shared.GwtEvent;
|
|
import com.google.gwt.event.shared.HandlerRegistration;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.inject.Inject;
|
|
import com.google.inject.name.Named;
|
|
|
|
/**
|
|
*
|
|
* @author Giancarlo Panichi
|
|
*
|
|
*/
|
|
public class Controller {
|
|
private static Logger logger = java.util.logging.Logger.getLogger("");
|
|
|
|
private EventBus eventBus;
|
|
private AccountingDashboardServiceAsync service;
|
|
private ApplicationCache cache;
|
|
private MonitorPresenter monitorPresenter;
|
|
private ErrorPresenter errorPresenter;
|
|
private InfoPresenter infoPresenter;
|
|
|
|
@Inject
|
|
Controller(@Named("ControllerEventBus") EventBus eventBus, AccountingDashboardServiceAsync service,
|
|
MonitorPresenter monitorPresenter, ErrorPresenter errorPresenter, InfoPresenter infoPresenter) {
|
|
this.eventBus = eventBus;
|
|
this.service = service;
|
|
this.monitorPresenter = monitorPresenter;
|
|
this.errorPresenter = errorPresenter;
|
|
this.infoPresenter = infoPresenter;
|
|
this.cache = new ApplicationCache();
|
|
}
|
|
|
|
public void fireEvent(GwtEvent<?> event) {
|
|
eventBus.fireEventFromSource(event, this);
|
|
}
|
|
|
|
public final <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, H handler) {
|
|
return eventBus.addHandler(type, handler);
|
|
}
|
|
|
|
public EventBus getEventBus() {
|
|
return eventBus;
|
|
}
|
|
|
|
public void hello() {
|
|
eventBus.fireEvent(new HelloEvent());
|
|
}
|
|
|
|
public void callHello() {
|
|
/* String groupId= GCubeClientContext.getCurrentContextId(); */
|
|
|
|
// String token = Window.Location.getParameter(Constants.TOKEN);
|
|
// logger.log(Level.FINE,"Token: " + token);
|
|
|
|
// MaterialLoader.showLoading(true);
|
|
service.hello(new AsyncCallback<UserInfo>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
logger.log(Level.FINE, "Error in Hello(): ", caught);
|
|
errorPresenter.errorMessage(caught.getLocalizedMessage());
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(UserInfo result) {
|
|
logger.log(Level.FINE, "Hello: " + result.getUsername());
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
}
|