Subversion Repositories eFlore/Applications.cel

Rev

Rev 2649 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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