// Path: src/main/java/com/java33/vizpres/client/event/DataEvent.java
// public class DataEvent extends GwtEvent<DataEvent.DataEventHandler> {
//   public interface DataEventHandler extends EventHandler {
//     void onData(DataEvent event, IsDataSync dataSync);
//   }
// 
//   public static Type<DataEventHandler> TYPE = new Type<DataEventHandler>();
// 
//   public IsDataSync target;
// 
//   @Override
//   public Type<DataEventHandler> getAssociatedType() {
//     return TYPE;
//   }
// 
//   @Override
//   protected void dispatch(final DataEventHandler handler) {
//     handler.onData(this, target);
//   }
// }
// 
// Path: src/main/java/com/java33/vizpres/client/gin/AppInjector.java
// @GinModules(AppModule.class)
// public interface AppInjector extends Ginjector {
//   AppController getAppController();
// 
//   MainPresenter getMainPresenter();
// }
// 
// Path: src/main/java/com/java33/vizpres/client/presenter/Presenter.java
// public interface Presenter {
//   public void go(final HasWidgets container);
// }
// 
// Path: src/main/java/com/java33/vizpres/client/view/visualization/IsDataSync.java
// public interface IsDataSync {
// 
//   /**
//    * Pushes the data values into the data sync.
//    *
//    * @param values Is a list of percentage values.
//    */
//   void setData(final List<PercentValue> values);
// }
// 
// Path: src/main/java/com/java33/vizpres/shared/service/PercentServiceAsync.java
// public interface PercentServiceAsync extends RestService {
//   String PREFERRED_MEDIA_TYPE = "application/vnd.vizpres+json";
// 
//   @GET
//   @Produces(PREFERRED_MEDIA_TYPE)
//   void getPercents(MethodCallback<List<PercentValue>> values);
// }
// 
// Path: src/main/java/com/java33/vizpres/shared/model/PercentValue.java
// public class PercentValue {
//   public int percentage;
// 
//   public PercentValue(final int value) {
//     this.percentage = value;
//   }
// 
//   public PercentValue() {
//     this(0);
//   }
// 
//   @Override
//   public String toString() {
//     return "PercentValue{" +
//         "percentage=" + percentage +
//         '}';
//   }
// }


import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.inject.Inject;
import com.java33.vizpres.client.event.DataEvent;
import com.java33.vizpres.client.gin.AppInjector;
import com.java33.vizpres.client.presenter.Presenter;
import com.java33.vizpres.client.view.visualization.IsDataSync;
import com.java33.vizpres.shared.service.PercentServiceAsync;
import com.java33.vizpres.shared.model.PercentValue;
import org.fusesource.restygwt.client.Method;
import org.fusesource.restygwt.client.MethodCallback;
import org.fusesource.restygwt.client.Resource;
import org.fusesource.restygwt.client.RestServiceProxy;
import java.util.List;
import java.util.logging.Logger;
   * Bind handlers to the application's events.
   */
  private void bind() {
    History.addValueChangeHandler(this);

    eventBus.addHandler(DataEvent.TYPE, new DataEvent.DataEventHandler() {
      public void onData(final DataEvent event, final IsDataSync dataSync) {
        doRequestData(dataSync);
      }
    });

  }

  /**
   * Performs the request for data and asynchronously receives the response or failure notice.
   * A response's data is pushed to the dataSync.
   *
   * @param dataSync Is the receiver of a data response's payload.
   */
  private void doRequestData(final IsDataSync dataSync) {
    final Resource resource = new Resource("/dataset");
    final PercentServiceAsync percentServiceAsync = GWT.create(PercentServiceAsync.class);
    ((RestServiceProxy) percentServiceAsync).setResource(resource);
    percentServiceAsync.getPercents(new MethodCallback<List<PercentValue>>() {
      @Override
      public void onFailure(final Method method, final Throwable throwable) {
        logger.warning(throwable.toString());
      }

      @Override
// Path: src/main/java/com/java33/vizpres/client/event/DataEvent.java
// public class DataEvent extends GwtEvent<DataEvent.DataEventHandler> {
//   public interface DataEventHandler extends EventHandler {
//     void onData(DataEvent event, IsDataSync dataSync);
//   }
// 
//   public static Type<DataEventHandler> TYPE = new Type<DataEventHandler>();
// 
//   public IsDataSync target;
// 
//   @Override
//   public Type<DataEventHandler> getAssociatedType() {
//     return TYPE;
//   }
// 
//   @Override
//   protected void dispatch(final DataEventHandler handler) {
//     handler.onData(this, target);
//   }
// }
// 
// Path: src/main/java/com/java33/vizpres/client/gin/AppInjector.java
// @GinModules(AppModule.class)
// public interface AppInjector extends Ginjector {
//   AppController getAppController();
// 
//   MainPresenter getMainPresenter();
// }
// 
// Path: src/main/java/com/java33/vizpres/client/presenter/Presenter.java
// public interface Presenter {
//   public void go(final HasWidgets container);
// }
// 
// Path: src/main/java/com/java33/vizpres/client/view/visualization/IsDataSync.java
// public interface IsDataSync {
// 
//   /**
//    * Pushes the data values into the data sync.
//    *
//    * @param values Is a list of percentage values.
//    */
//   void setData(final List<PercentValue> values);
// }
// 
// Path: src/main/java/com/java33/vizpres/shared/service/PercentServiceAsync.java
// public interface PercentServiceAsync extends RestService {
//   String PREFERRED_MEDIA_TYPE = "application/vnd.vizpres+json";
// 
//   @GET
//   @Produces(PREFERRED_MEDIA_TYPE)
//   void getPercents(MethodCallback<List<PercentValue>> values);
// }
// 
// Path: src/main/java/com/java33/vizpres/shared/model/PercentValue.java
// public class PercentValue {
//   public int percentage;
// 
//   public PercentValue(final int value) {
//     this.percentage = value;
//   }
// 
//   public PercentValue() {
//     this(0);
//   }
// 
//   @Override
//   public String toString() {
//     return "PercentValue{" +
//         "percentage=" + percentage +
//         '}';
//   }
// }


// Path: src/main/java/com/java33/vizpres/client/AppController.java
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.inject.Inject;
import com.java33.vizpres.client.event.DataEvent;
import com.java33.vizpres.client.gin.AppInjector;
import com.java33.vizpres.client.presenter.Presenter;
import com.java33.vizpres.client.view.visualization.IsDataSync;
import com.java33.vizpres.shared.service.PercentServiceAsync;
import com.java33.vizpres.shared.model.PercentValue;
import org.fusesource.restygwt.client.Method;
import org.fusesource.restygwt.client.MethodCallback;
import org.fusesource.restygwt.client.Resource;
import org.fusesource.restygwt.client.RestServiceProxy;
import java.util.List;
import java.util.logging.Logger;

   * Bind handlers to the application's events.
   */
  private void bind() {
    History.addValueChangeHandler(this);

    eventBus.addHandler(DataEvent.TYPE, new DataEvent.DataEventHandler() {
      public void onData(final DataEvent event, final IsDataSync dataSync) {
        doRequestData(dataSync);
      }
    });

  }

  /**
   * Performs the request for data and asynchronously receives the response or failure notice.
   * A response's data is pushed to the dataSync.
   *
   * @param dataSync Is the receiver of a data response's payload.
   */
  private void doRequestData(final IsDataSync dataSync) {
    final Resource resource = new Resource("/dataset");
    final PercentServiceAsync percentServiceAsync = GWT.create(PercentServiceAsync.class);
    ((RestServiceProxy) percentServiceAsync).setResource(resource);
    percentServiceAsync.getPercents(new MethodCallback<List<PercentValue>>() {
      @Override
      public void onFailure(final Method method, final Throwable throwable) {
        logger.warning(throwable.toString());
      }

      @Override
      public void onSuccess(final Method method, final List<PercentValue> values) {