Subversion Repositories eFlore/Applications.cel

Rev

Rev 2617 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2617 Rev 2649
1
package org.tela_botanica.client;
1
package org.tela_botanica.client;
2
 
2
 
3
import org.tela_botanica.client.i18n.Msg;
3
import org.tela_botanica.client.i18n.Msg;
4
import org.tela_botanica.client.modeles.objets.Configuration;
4
import org.tela_botanica.client.modeles.objets.Configuration;
-
 
5
import org.tela_botanica.client.util.Util;
5
 
6
 
6
import com.google.gwt.ajaxloader.client.AjaxLoader;
7
import com.google.gwt.ajaxloader.client.AjaxLoader;
7
import com.google.gwt.ajaxloader.client.AjaxLoader.AjaxLoaderOptions;
8
import com.google.gwt.ajaxloader.client.AjaxLoader.AjaxLoaderOptions;
8
import com.google.gwt.core.client.EntryPoint;
9
import com.google.gwt.core.client.EntryPoint;
-
 
10
import com.google.gwt.dom.client.Element;
-
 
11
import com.google.gwt.user.client.DOM;
9
import com.google.gwt.user.client.Timer;
12
import com.google.gwt.user.client.Timer;
10
import com.google.gwt.user.client.Window.Location;
13
import com.google.gwt.user.client.Window.Location;
11
import com.gwtext.client.core.Ext;
14
import com.gwtext.client.core.Ext;
12
import com.gwtext.client.widgets.Viewport;
15
import com.gwtext.client.widgets.Viewport;
13
 
16
 
14
/**
17
/**
15
 * Entry point classes define <code>onModuleLoad()</code>.
18
 * Entry point classes define <code>onModuleLoad()</code>.
16
 */
19
 */
17
public class cel2 implements EntryPoint {
20
public class cel2 implements EntryPoint {
18
 
21
 
19
	/**
22
	/**
20
	 * This is the entry point method.
23
	 * This is the entry point method.
21
	 */
24
	 */
22
	@Override
25
	@Override
23
	public void onModuleLoad() {	
26
	public void onModuleLoad() {	
24
		
27
		
25
		/*
28
		/*
26
		// A décommenter + compiler en detailed dans le cas d'une erreur
29
		// A décommenter + compiler en detailed dans le cas d'une erreur
27
		// survernant uniquement sur le serveur
30
		// survernant uniquement sur le serveur
28
		GWT.setUncaughtExceptionHandler(null);
31
		GWT.setUncaughtExceptionHandler(null);
29
		GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {	
32
		GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {	
30
			@Override
33
			@Override
31
			public void onUncaughtException(Throwable e) {
34
			public void onUncaughtException(Throwable e) {
32
					Window.alert("uncaught: " + e.getMessage());
35
					Window.alert("uncaught: " + e.getMessage());
33
					String s = buildStackTrace(e, "RuntimeException:\n");
36
					String s = buildStackTrace(e, "RuntimeException:\n");
34
					Window.alert(s);
37
					Window.alert(s);
35
					e.printStackTrace();
38
					e.printStackTrace();
36
			}
39
			}
37
		});
40
		});
38
		*/
41
		*/
-
 
42
		
39
		// TODO: config devrait être un singleton
43
		// TODO: config devrait être un singleton
40
		Configuration config = new Configuration();	
44
		Configuration config = new Configuration();	
41
		// Si la langue est précisée dans l'url on la prend, sinon on prend celle par défaut
45
		// Si la langue est précisée dans l'url on la prend, sinon on prend celle par défaut
42
		// @TODO: avertissement si la langue indiquée dans l'url n'est pas la bonne
46
		// @TODO: avertissement si la langue indiquée dans l'url n'est pas la bonne
43
		String langueURL = Location.getParameter("lang");
47
		String langueURL = Location.getParameter("lang");
44
		if (! Msg.init()) {
48
		if (! Msg.init()) {
45
			cel2.LogVersFirebug("La langue par défaut \"" + Msg.getLangueDefaut() + "\" n'a pas pu être chargée");
49
			Util.LogVersFirebug("La langue par défaut \"" + Msg.getLangueDefaut() + "\" n'a pas pu être chargée");
46
		}	
50
		}	
47
		if (langueURL != null && ! langueURL.equals("")) {
51
		if (langueURL != null && ! langueURL.equals("")) {
48
			cel2.LogVersFirebug("Langue passée dans l'URL: " + langueURL);
52
			Util.LogVersFirebug("Langue passée dans l'URL: " + langueURL);
49
			if (! Msg.setLangue(langueURL)) {
53
			if (! Msg.setLangue(langueURL)) {
50
				cel2.LogVersFirebug("La langue demandée \"" + langueURL + "\" n'a pas pu être chargée");
54
				Util.LogVersFirebug("La langue demandée \"" + langueURL + "\" n'a pas pu être chargée");
51
			}
55
			}
52
		}
56
		}
-
 
57
		
-
 
58
		Element elem = DOM.getElementById("texte_chargement");
-
 
59
		elem.setInnerText(Msg.get("chargement"));
53
 
60
 
54
		// Chargement de l'api google maps v3 avant l'initialisation pour 
61
		// Chargement de l'api google maps v3 avant l'initialisation pour 
55
		// éviter des "complications"
62
		// éviter des "complications"
56
		// TODO: fabriquer une classe qui cherche dans la config une liste d'api
63
		// TODO: fabriquer une classe qui cherche dans la config une liste d'api
57
		// à charger, les instancie et ensuite lance l'application
64
		// à charger, les instancie et ensuite lance l'application
58
		AjaxLoaderOptions optAj = AjaxLoaderOptions.newInstance();
65
		AjaxLoaderOptions optAj = AjaxLoaderOptions.newInstance();
59
		optAj.setOtherParms("key="+Configuration.getCleGoogleMaps()+"&sensor=false");
66
		optAj.setOtherParms("key="+Configuration.getCleGoogleMaps()+"&sensor=false");
60
			
67
			
61
		Runnable callback = new Runnable() {
68
		Runnable callback = new Runnable() {
62
			public void run() {
69
			public void run() {
63
				initialiserCel();
70
				initialiserCel();
64
			};
71
			};
65
		};
72
		};
66
		AjaxLoader.loadApi("maps", "3", callback, optAj);
73
		AjaxLoader.loadApi("maps", "3", callback, optAj);
67
	}
74
	}
68
	
75
	
69
	private void initialiserCel() {
76
	private void initialiserCel() {
70
		CarnetEnLigneMediateur carnetEnLigneMediateur= CarnetEnLigneMediateur.Instance();
77
		CarnetEnLigneMediateur carnetEnLigneMediateur= CarnetEnLigneMediateur.Instance();
71
		new Viewport(carnetEnLigneMediateur.getPanneauPrincipalCarnetEnLigne()) ;
78
		new Viewport(carnetEnLigneMediateur.getPanneauPrincipalCarnetEnLigne()) ;
72
		carnetEnLigneMediateur.getEtatUtilisateur() ;
79
		carnetEnLigneMediateur.getEtatUtilisateur() ;
73
 
80
 
74
		Timer t = new Timer() {
81
		Timer t = new Timer() {
75
			@Override
82
			@Override
76
			public void run() {
83
			public void run() {
77
				 Ext.get("loading").hide();
84
				Ext.get("loading").hide();
78
			}
85
			}
79
		};
86
		};
80
		
87
		
81
		t.schedule(3000);
88
		t.schedule(1500);
82
	}
-
 
83
	
-
 
84
	/*private String buildStackTrace(Throwable t, String log) {
-
 
85
	     if (t != null) {
-
 
86
		     log += t.getClass().toString();
-
 
87
		     log += t.getMessage();
-
 
88
		     //
-
 
89
		     StackTraceElement[] stackTrace = t.getStackTrace();
-
 
90
		     if (stackTrace != null) {
-
 
91
		    	 StringBuffer trace = new StringBuffer();
-
 
92
		    
-
 
93
			     for (int i = 0; i < stackTrace.length; i++) {
-
 
94
			    	 trace.append(stackTrace[i].getClassName() + "." + stackTrace[i].getMethodName() + "("
-
 
95
			    			 + stackTrace[i].getFileName() + ":" + stackTrace[i].getLineNumber());
-
 
96
			     }
-
 
97
		    
-
 
98
			     log += trace.toString();
-
 
99
		     }
-
 
100
		     //
-
 
101
		     Throwable cause = t.getCause();
-
 
102
		     if (cause != null && cause != t) {
-
 
103
		    	 log += buildStackTrace(cause, "CausedBy:\n");
-
 
104
		     }
-
 
105
	     }
-
 
106
	     return log;
-
 
107
	}*/
-
 
108
 
-
 
109
	public static native void  LogVersFirebug(Object o) /*-{
-
 
110
		if (!!($wnd.console && $wnd.console.log)) {
-
 
111
			console.log(o);
-
 
112
		}
-
 
113
	}-*/;
89
	}
114
}
90
}