Subversion Repositories eFlore/Applications.cel

Rev

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

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