--- /dev/null
+package com.pentila.evalcomp.client;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.gwtext.client.widgets.Viewport;
+import com.pentila.evalcomp.client.i18n.Messages;
+import com.pentila.evalcomp.client.services.ServiceAbstract;
+import com.pentila.evalcomp.client.utilities.Tools;
+import com.pentila.evalcomp.client.utilities.UserTools;
+import com.pentila.evalcomp.client.utilities.bridge.BridgeMethods;
+import com.pentila.evalcomp.client.widget.MainCenterPanel;
+import com.pentila.evalcomp.domain.User;
+import com.pentila.evalcomp.domain.transit.Activity;
+import com.pentila.evalcomp.domain.transit.ContextRef;
+import com.pentila.evalcomp.domain.transit.Session;
+import com.pentila.evalcomp.domain.transit.Todo;
+import com.smartgwt.client.util.SC;
+
+
+public class ServiceEntryPoint implements EntryPoint {
+
+ private void initializeInterface() {
+
+
+ final AsyncCallback<Todo> callback2 = new AsyncCallback<Todo>() {
+
+ public void onFailure(Throwable arg0) {
+
+ Tools.hideLoading();
+ }
+
+ public void onSuccess(Todo result) {
+
+ String activityId = getActivityId();
+ Activity a = null;
+
+ for (Activity ac : result.getProcess().getActivities()){
+ if (ac.getId().equals(activityId)){
+ a = ac;
+ break;
+ }
+ }
+
+ if(null != a){
+ MainCenterPanel mcp = new MainCenterPanel(null);
+ mcp.show();
+ mcp.doLayout();
+ new Viewport(mcp);
+ mcp.showService(result, a);
+ Tools.hideLoading();
+ }
+ else{
+ Tools.hideLoading();
+ SC.say("L'activité " + '"' + activityId + '"' + " est introuvable");
+ }
+
+ }
+
+ };
+
+ AsyncCallback<Set<ContextRef>> callback1 = new AsyncCallback<Set<ContextRef>>() {
+
+ public void onFailure(Throwable caught) {
+ Tools.hideLoading();
+ }
+
+ public void onSuccess(Set<ContextRef> result) {
+
+ Set<Todo> todos = new HashSet<Todo>();
+
+ // On récupère la liste de tous les todos
+ for (ContextRef cr2 : result){
+ for (Session s : cr2.getSessions().values()) {
+ todos.addAll(s.getTodos());
+ }
+ }
+
+ String siidString = getScenarioInstanceId();
+ Long siId = Long.parseLong(siidString);
+
+ // On cherche le bon todo
+ Todo good = null;
+ for(Todo t : todos){
+ if (t.getScenarioInstanceAbstract().getId().equals(siId)){
+ good = t;
+ break;
+ }
+ }
+
+ RequestBuilder rb2 = ConnexionServer.instanceService.updateTodo(good, 0, ServiceAbstract.pageSize, null, null,
+ callback2);
+ rb2.setHeader("code", "A9");
+ ConnexionServer.doSend(rb2);
+
+ }
+
+
+ };
+ Tools.showLoading(Messages.getString("Chargement"),
+ Messages.getString("Chargement"));
+ RequestBuilder rb = ConnexionServer.instanceService.getTodoLists(
+ UserTools.getUser().getUid(), callback1);
+ ConnexionServer.doSend(rb);
+
+
+ }
+
+ private void initializeUser() {
+ AsyncCallback<User> callback = new AsyncCallback<User>() {
+
+ public void onFailure(Throwable caught) {
+ System.out.println(Messages
+ .getString("Probleme_recuperation_utilisateur")); //$NON-NLS-1$
+ }
+
+ public void onSuccess(User result) {
+ UserTools.setUser(result);
+ initializeInterface();
+ }
+ };
+
+ RequestBuilder b = ConnexionServer.entityService
+ .getCurrentUser(callback);
+ b.setHeader("code", "A1");
+ ConnexionServer.doSend(b);
+
+ }
+
+ public void onModuleLoad() {
+ /* initialisation de l'utilisateur authentifié */
+ extCompatMode();
+ BridgeMethods.defineBridgeMethod();
+ Tools.interfaceShown = Tools.USER_INTERFACE;
+ this.initializeUser();
+ }
+
+ /**
+ * Ext compat mode.
+ */
+ private static native void extCompatMode()/*-{
+ $wnd.Array.prototype.remove = function (obj) {
+ var index = this.indexOf(obj);
+ if (index == -1) return this;
+
+ for (var i = index; i < this.length; i++) this[i] = this[i+1];
+ this.length = this.length-1;
+
+ this.dataChanged();
+
+ return this;
+ }
+ }-*/;
+
+
+ private final native String getScenarioInstanceId() /*-{
+ return $wnd.siid;
+ }-*/;
+
+ private final native String getActivityId() /*-{
+ return $wnd.activity;
+ }-*/;
+}
\ No newline at end of file