Subversion Repositories eFlore/Applications.cel

Rev

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

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