| 12 |
david |
1 |
/**
|
|
|
2 |
David Delon david.delon@clapas.net 2007
|
|
|
3 |
|
|
|
4 |
*/
|
|
|
5 |
|
|
|
6 |
/*
|
|
|
7 |
* EtatConnexionVue.java : affichage information portant sur le statut de la connexion utilisateur
|
|
|
8 |
*
|
|
|
9 |
*
|
|
|
10 |
* 1: Le programme affiche le statut connecte si l'utilisateur s'est connecte precedemment, sinon s'affiche le statut deconnecte
|
|
|
11 |
* 2: Le programme arme les actions liees a la connection ou a la deconnection
|
|
|
12 |
* - Connection : affichage de la boite de connexion
|
|
|
13 |
* - Deconnexion : appel du service de deconnexion, et appel de la re-initialisation de l'affichage pour le nouvel identifiant utilisateur obtenu (identifiant de session)
|
|
|
14 |
*/
|
|
|
15 |
|
|
|
16 |
package org.tela_botanica.client.vues;
|
|
|
17 |
|
| 2656 |
aurelien |
18 |
import java.util.Iterator;
|
|
|
19 |
import java.util.List;
|
|
|
20 |
|
| 12 |
david |
21 |
import org.tela_botanica.client.CarnetEnLigneMediateur;
|
| 2615 |
aurelien |
22 |
import org.tela_botanica.client.i18n.Msg;
|
| 989 |
aurelien |
23 |
import org.tela_botanica.client.modeles.objets.Configuration;
|
| 12 |
david |
24 |
|
| 2656 |
aurelien |
25 |
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
26 |
import com.google.gwt.event.dom.client.ChangeHandler;
|
| 2081 |
mathias |
27 |
import com.google.gwt.http.client.URL;
|
| 140 |
aurelien |
28 |
import com.google.gwt.user.client.Window;
|
| 2656 |
aurelien |
29 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
30 |
import com.google.gwt.user.client.ui.ListBox;
|
| 140 |
aurelien |
31 |
import com.gwtext.client.core.EventCallback;
|
|
|
32 |
import com.gwtext.client.core.EventObject;
|
|
|
33 |
import com.gwtext.client.core.Ext;
|
|
|
34 |
import com.gwtext.client.core.ExtElement;
|
|
|
35 |
import com.gwtext.client.widgets.Container;
|
| 12 |
david |
36 |
import com.gwtext.client.widgets.Panel;
|
| 140 |
aurelien |
37 |
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
|
| 12 |
david |
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Un indicateur d'etat de connexion
|
|
|
41 |
*
|
|
|
42 |
* @author David Delon
|
|
|
43 |
*
|
|
|
44 |
*/
|
|
|
45 |
|
|
|
46 |
public class EtatConnexionVue extends Panel {
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Médiateur associé à la vue
|
|
|
50 |
*/
|
|
|
51 |
private CarnetEnLigneMediateur carnetEnLigneMediateur = null ;
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Texte lié à la connexion.
|
|
|
55 |
*
|
|
|
56 |
*/
|
| 2656 |
aurelien |
57 |
private HTML htmlEtatConnexion = new HTML();
|
|
|
58 |
private String labelEtatConnexion = null;
|
| 12 |
david |
59 |
|
| 2656 |
aurelien |
60 |
private ListBox listeLangues = null;
|
| 2081 |
mathias |
61 |
|
|
|
62 |
/**
|
|
|
63 |
* Ouh c'est pas beau, ça ! Mais avec Google Web Toolshit, ça
|
|
|
64 |
* marche toujours mieux que quand on fait des trucs beaux :-)
|
|
|
65 |
*/
|
|
|
66 |
private String liens = "<div id=\"liensExt\">"
|
| 2615 |
aurelien |
67 |
+ "<a id=\"lienRemarques\" title=\""+Msg.get("adresser-remarque-probleme")+"\""
|
| 2636 |
mathias |
68 |
+ " href=\"" + Configuration.getRemarquesBaseUrl() + "?lang=" + Msg.getLangue() + "&service=" + Configuration.getServiceContact()
|
| 2081 |
mathias |
69 |
+ "&pageSource=" + URL.encodeQueryString(Window.Location.getHref()) + "\""
|
|
|
70 |
+ " onClick=\"javascript:window.open(this.getAttribute('href'), 'Tela Botanica - Remarques', config='height=700, width=640, scrollbars=yes, resizable=yes'); return false;\""
|
|
|
71 |
+ " target=\"_blank\""
|
| 2623 |
aurelien |
72 |
+ ">"+Msg.get("remarques")+"</a>"
|
|
|
73 |
+ "<a href=\"#\" id=\"lienAide\">"+Msg.get("aide")+"</a>"
|
| 2081 |
mathias |
74 |
+ "</div>" ;
|
| 12 |
david |
75 |
|
|
|
76 |
/**
|
| 2081 |
mathias |
77 |
* Booleen indiquant si utilisateur est connecte
|
| 12 |
david |
78 |
*
|
|
|
79 |
*/
|
|
|
80 |
public EtatConnexionVue(CarnetEnLigneMediateur cm) {
|
|
|
81 |
|
|
|
82 |
carnetEnLigneMediateur=cm;
|
|
|
83 |
|
|
|
84 |
this.setBodyBorder(false) ;
|
|
|
85 |
this.setBorder(false) ;
|
| 226 |
aurelien |
86 |
this.setId("panneau_etat_connexion");
|
| 12 |
david |
87 |
|
|
|
88 |
// Pas de word wrap
|
| 140 |
aurelien |
89 |
labelEtatConnexion="";
|
| 12 |
david |
90 |
|
| 2656 |
aurelien |
91 |
initialiserListeLangues();
|
| 12 |
david |
92 |
|
| 2656 |
aurelien |
93 |
this.add(listeLangues);
|
|
|
94 |
htmlEtatConnexion.setHTML(labelEtatConnexion+liens);
|
|
|
95 |
this.add(htmlEtatConnexion);
|
| 12 |
david |
96 |
|
| 2656 |
aurelien |
97 |
ajouterListeners();
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
private void initialiserListeLangues() {
|
|
|
101 |
listeLangues = new ListBox();
|
|
|
102 |
listeLangues.getElement().setId("liste_selection_langue");
|
|
|
103 |
List<String> languesDispos = Msg.getLanguesDisponibles();
|
|
|
104 |
int indexLangue = 0;
|
|
|
105 |
for (Iterator<String> iterator = languesDispos.iterator(); iterator.hasNext();) {
|
|
|
106 |
String langue = iterator.next();
|
|
|
107 |
listeLangues.addItem(Msg.get("intitule-langue", langue), langue);
|
|
|
108 |
if(langue.equals(Msg.getLangue())) {
|
|
|
109 |
listeLangues.setSelectedIndex(indexLangue);
|
|
|
110 |
}
|
|
|
111 |
indexLangue++;
|
|
|
112 |
}
|
|
|
113 |
}
|
| 12 |
david |
114 |
|
| 2656 |
aurelien |
115 |
private void ajouterListeners() {
|
|
|
116 |
listeLangues.addChangeHandler(new ChangeHandler() {
|
|
|
117 |
@Override
|
|
|
118 |
public void onChange(ChangeEvent event) {
|
|
|
119 |
int indexLangue = listeLangues.getSelectedIndex();
|
|
|
120 |
String urlCourante = Window.Location.getHref();
|
|
|
121 |
String urlBase = urlCourante;
|
| 2675 |
aurelien |
122 |
if(urlBase.contains("?")) {
|
|
|
123 |
urlBase = urlBase.substring(0, urlCourante.indexOf("?"));
|
| 2656 |
aurelien |
124 |
}
|
| 2675 |
aurelien |
125 |
if(urlBase.contains("#")) {
|
|
|
126 |
urlBase = urlBase.replace("#", "");
|
|
|
127 |
}
|
| 2656 |
aurelien |
128 |
String urlLangue = urlBase+"?lang="+listeLangues.getValue(indexLangue);
|
|
|
129 |
Window.Location.replace(urlLangue);
|
|
|
130 |
|
|
|
131 |
return;
|
| 140 |
aurelien |
132 |
}
|
| 2656 |
aurelien |
133 |
});
|
| 12 |
david |
134 |
|
| 2656 |
aurelien |
135 |
ExtElement lienAide = Ext.get("lienAide");
|
|
|
136 |
if(lienAide != null)
|
|
|
137 |
{
|
|
|
138 |
lienAide.removeAllListeners();
|
|
|
139 |
lienAide.addListener("click", new EventCallback() {
|
| 2081 |
mathias |
140 |
|
| 2656 |
aurelien |
141 |
@Override
|
|
|
142 |
public void execute(EventObject e) {
|
|
|
143 |
String aideUrl = Configuration.getAideBaseUrl() ;
|
|
|
144 |
Window.open(aideUrl, "", "") ;
|
|
|
145 |
}
|
|
|
146 |
});
|
|
|
147 |
}
|
|
|
148 |
else
|
|
|
149 |
{
|
|
|
150 |
addListener(new ContainerListenerAdapter() {
|
|
|
151 |
@Override
|
|
|
152 |
public void onAfterLayout(Container c) {
|
| 12 |
david |
153 |
|
| 2656 |
aurelien |
154 |
ExtElement lienAide = Ext.get("lienAide");
|
|
|
155 |
if(lienAide != null)
|
|
|
156 |
{
|
|
|
157 |
lienAide.removeAllListeners();
|
|
|
158 |
lienAide.addListener("click", new EventCallback() {
|
| 140 |
aurelien |
159 |
|
| 2656 |
aurelien |
160 |
@Override
|
|
|
161 |
public void execute(EventObject e) {
|
|
|
162 |
String aideUrl = Configuration.getAideBaseUrl() ;
|
|
|
163 |
Window.open(aideUrl, "", "") ;
|
|
|
164 |
}
|
|
|
165 |
});
|
|
|
166 |
}
|
|
|
167 |
}
|
|
|
168 |
});
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
}
|
| 140 |
aurelien |
173 |
|
| 2656 |
aurelien |
174 |
/**
|
|
|
175 |
* Affichage de l'etat de connexion
|
|
|
176 |
* @param text
|
|
|
177 |
* @param connecte
|
|
|
178 |
*/
|
|
|
179 |
public void setEtat(String identifiant, boolean connecte) {
|
| 140 |
aurelien |
180 |
|
| 2656 |
aurelien |
181 |
if(connecte) {
|
|
|
182 |
String[] params = {identifiant};
|
|
|
183 |
labelEtatConnexion = "<div id=\"etatConnexion\">"+Msg.get("connecte-en-tant-que", params)+" <a id=\"lienDeconnexion\" href=\"#\">("+Msg.get("deconnexion")+")</a>" ;
|
|
|
184 |
labelEtatConnexion += "</div>" ;
|
| 140 |
aurelien |
185 |
|
| 12 |
david |
186 |
|
| 2656 |
aurelien |
187 |
labelEtatConnexion += liens ;
|
|
|
188 |
htmlEtatConnexion.setHTML(labelEtatConnexion);
|
| 12 |
david |
189 |
|
| 2656 |
aurelien |
190 |
ExtElement lienDeco = Ext.get("lienDeconnexion");
|
|
|
191 |
if(lienDeco != null)
|
|
|
192 |
{
|
|
|
193 |
lienDeco.addListener("click", new EventCallback() {
|
| 12 |
david |
194 |
|
| 2656 |
aurelien |
195 |
@Override
|
|
|
196 |
public void execute(EventObject e) {
|
|
|
197 |
carnetEnLigneMediateur.deconnecterUtilisateur();
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
});
|
|
|
201 |
}
|
|
|
202 |
else
|
|
|
203 |
{
|
|
|
204 |
addListener(new ContainerListenerAdapter()
|
|
|
205 |
{
|
|
|
206 |
@Override
|
|
|
207 |
public void onAfterLayout(Container c)
|
|
|
208 |
{
|
|
|
209 |
ExtElement lienDeco = Ext.get("etatConnexion");
|
|
|
210 |
|
|
|
211 |
lienDeco.addListener("click", new EventCallback() {
|
|
|
212 |
|
|
|
213 |
@Override
|
|
|
214 |
public void execute(EventObject e) {
|
|
|
215 |
carnetEnLigneMediateur.deconnecterUtilisateur();
|
|
|
216 |
setEtat(null, false);
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
});
|
|
|
220 |
}
|
|
|
221 |
});
|
|
|
222 |
}
|
|
|
223 |
}
|
|
|
224 |
else
|
|
|
225 |
{
|
|
|
226 |
labelEtatConnexion = "<div id=\"etatConnexion\"> "+Msg.get("cel-utilisation")+", <a id=\"lienConnexion\" href=\"#\">"+Msg.get("identifiez-vous")+"</a> "+Msg.get("pour-transmettre-tela")+"</div>";
|
|
|
227 |
labelEtatConnexion += liens ;
|
|
|
228 |
htmlEtatConnexion.setHTML(labelEtatConnexion);
|
|
|
229 |
ExtElement lienCo = Ext.get("etatConnexion");
|
|
|
230 |
if(lienCo != null) {
|
|
|
231 |
lienCo.addListener("click", new EventCallback() {
|
|
|
232 |
|
|
|
233 |
@Override
|
|
|
234 |
public void execute(EventObject e) {
|
|
|
235 |
|
|
|
236 |
carnetEnLigneMediateur.afficherDialogueConnexion();
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
});
|
|
|
240 |
}
|
|
|
241 |
else
|
|
|
242 |
{
|
|
|
243 |
addListener(new ContainerListenerAdapter() {
|
|
|
244 |
@Override
|
|
|
245 |
public void onAfterLayout(Container c) {
|
|
|
246 |
|
|
|
247 |
ExtElement lienCo = Ext.get("etatConnexion");
|
|
|
248 |
|
|
|
249 |
lienCo.addListener("click", new EventCallback() {
|
|
|
250 |
|
|
|
251 |
@Override
|
|
|
252 |
public void execute(EventObject e) {
|
|
|
253 |
|
|
|
254 |
carnetEnLigneMediateur.afficherDialogueConnexion();
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
});
|
|
|
258 |
}
|
|
|
259 |
});
|
|
|
260 |
}
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
ExtElement lienAide = Ext.get("lienAide");
|
|
|
264 |
if(lienAide != null)
|
|
|
265 |
{
|
|
|
266 |
lienAide.removeAllListeners();
|
|
|
267 |
lienAide.addListener("click", new EventCallback() {
|
|
|
268 |
|
|
|
269 |
@Override
|
|
|
270 |
public void execute(EventObject e) {
|
|
|
271 |
String aideUrl = Configuration.getAideBaseUrl() ;
|
|
|
272 |
Window.open(aideUrl, "", "") ;
|
|
|
273 |
}
|
|
|
274 |
});
|
|
|
275 |
}
|
|
|
276 |
else
|
|
|
277 |
{
|
|
|
278 |
addListener(new ContainerListenerAdapter() {
|
|
|
279 |
@Override
|
|
|
280 |
public void onAfterLayout(Container c) {
|
|
|
281 |
|
|
|
282 |
ExtElement lienAide = Ext.get("lienAide");
|
|
|
283 |
if(lienAide != null)
|
|
|
284 |
{
|
|
|
285 |
lienAide.removeAllListeners();
|
|
|
286 |
lienAide.addListener("click", new EventCallback() {
|
|
|
287 |
|
|
|
288 |
@Override
|
|
|
289 |
public void execute(EventObject e) {
|
|
|
290 |
String aideUrl = Configuration.getAideBaseUrl() ;
|
|
|
291 |
Window.open(aideUrl, "", "") ;
|
|
|
292 |
}
|
|
|
293 |
});
|
|
|
294 |
}
|
|
|
295 |
}
|
|
|
296 |
});
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
|
|
|
300 |
}
|
|
|
301 |
|
| 12 |
david |
302 |
}
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
306 |
* $Log$
|
|
|
307 |
* Revision 1.1 2008-11-13 11:27:05 ddelon
|
|
|
308 |
* Reecriture gwt-ext
|
|
|
309 |
*
|
|
|
310 |
* Revision 1.1 2008-06-09 14:19:37 ddelon
|
|
|
311 |
* Initialisation observation
|
|
|
312 |
*
|
|
|
313 |
* Revision 1.2 2008-04-28 13:10:44 ddelon
|
|
|
314 |
* Integration MyGwt
|
|
|
315 |
*
|
|
|
316 |
* Revision 1.1 2008-01-02 21:26:04 ddelon
|
|
|
317 |
* mise en place mygwt
|
|
|
318 |
*
|
|
|
319 |
* Revision 1.6 2007-12-22 14:48:53 ddelon
|
|
|
320 |
* Documentation et refactorisation
|
|
|
321 |
*
|
|
|
322 |
* Revision 1.5 2007-09-17 19:25:34 ddelon
|
|
|
323 |
* Documentation
|
|
|
324 |
*
|
|
|
325 |
*
|
|
|
326 |
*/
|