Subversion Repositories eFlore/Applications.cel

Rev

Rev 431 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
17
package org.tela_botanica.client.vues;
18
 
19
 
20
 
21
import org.tela_botanica.client.CarnetEnLigneMediateur;
989 aurelien 22
import org.tela_botanica.client.modeles.objets.Configuration;
12 david 23
 
140 aurelien 24
import com.google.gwt.user.client.Window;
12 david 25
 
140 aurelien 26
import com.gwtext.client.core.EventCallback;
27
import com.gwtext.client.core.EventObject;
28
import com.gwtext.client.core.Ext;
29
import com.gwtext.client.core.ExtElement;
30
import com.gwtext.client.widgets.Container;
12 david 31
import com.gwtext.client.widgets.Panel;
140 aurelien 32
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
12 david 33
 
34
 
35
 
36
/**
37
 * Un indicateur d'etat de connexion
38
 *
39
 * @author David Delon
40
 *
41
 */
42
 
43
 
44
 
45
public class EtatConnexionVue  extends Panel  {
46
 
47
 
48
	/**
49
	 * Médiateur associé à la vue
50
	 */
51
	private CarnetEnLigneMediateur carnetEnLigneMediateur = null ;
52
 
53
  /**
54
   * Texte lié à la connexion.
55
   *
56
   */
57
 
140 aurelien 58
  private String labelEtatConnexion = null;
12 david 59
 
431 aurelien 60
  private String liens = "<div id=\"liensExt\"><a href=\"#\" id=\"lienAide\">Aide</a>  <a href=\"#\" id=\"lienBugs\">Bugs</a> <a href=\"mailto:"+Configuration.getEmailContact()+"\" id=\"nousContacter\"> Nous contacter</a></div>" ;
140 aurelien 61
 
12 david 62
  /**
63
   * Booleen indiquant si utilisateur connecte
64
   *
65
   */
66
 
67
 
68
  public EtatConnexionVue(CarnetEnLigneMediateur cm)  {
69
 
70
	carnetEnLigneMediateur=cm;
71
 
72
    this.setBodyBorder(false) ;
73
    this.setBorder(false) ;
226 aurelien 74
    this.setId("panneau_etat_connexion");
12 david 75
 
76
	// Pas de word wrap
140 aurelien 77
	labelEtatConnexion="";
12 david 78
 
140 aurelien 79
	this.setHtml(labelEtatConnexion+liens);
12 david 80
 
81
 
82
	ajouterListeners();
83
 
140 aurelien 84
 
12 david 85
  	}
86
 
87
   public void ajouterListeners() {
88
 
140 aurelien 89
	   ExtElement lienAide = Ext.get("lienAide");
90
		if(lienAide != null)
91
		{
92
			lienAide.removeAllListeners();
93
			lienAide.addListener("click", new EventCallback() {
12 david 94
 
140 aurelien 95
				public void execute(EventObject e) {
96
					String aideUrl = Configuration.getAideBaseUrl() ;
97
					Window.open(aideUrl, "", "") ;
98
				}
99
			});
100
		}
101
		else
102
		{
103
			addListener(new ContainerListenerAdapter() {
104
				public void onAfterLayout(Container c) {
105
 
106
					ExtElement lienAide = Ext.get("lienAide");
107
					if(lienAide != null)
108
					{
109
						lienAide.removeAllListeners();
110
						lienAide.addListener("click", new EventCallback() {
111
 
112
							public void execute(EventObject e) {
113
								String aideUrl = Configuration.getAideBaseUrl() ;
114
								Window.open(aideUrl, "", "") ;
115
							}
116
						});
117
					}
118
				}
119
			});
120
		}
121
 
122
		ExtElement lienBugs = Ext.get("lienBugs");
123
		if(lienBugs != null)
124
		{
125
			lienBugs.removeAllListeners();
126
			lienBugs.addListener("click", new EventCallback() {
12 david 127
 
140 aurelien 128
				public void execute(EventObject e) {
129
					String bugsURL = Configuration.getSuiviBugUrl() ;
130
					Window.open(bugsURL, "", "") ;
131
				}
132
			});
133
		}
134
		else
135
		{
136
			addListener(new ContainerListenerAdapter() {
137
				public void onAfterLayout(Container c) {
138
 
139
					ExtElement lienBugs = Ext.get("lienBugs");
140
					if(lienBugs != null)
141
					{
142
						lienBugs.removeAllListeners();
143
						lienBugs.addListener("click", new EventCallback() {
144
 
145
							public void execute(EventObject e) {
146
								String bugsURL = Configuration.getSuiviBugUrl() ;
147
								Window.open(bugsURL, "", "") ;
148
							}
149
						});
150
					}
151
				}
152
			});
153
		}
12 david 154
 
155
	}
156
 
157
 
158
 
159
 
160
/**
161
 * Affichage de l'etat de connexion
162
 * @param text
163
 * @param connecte
164
 */
140 aurelien 165
public void setEtat(String identifiant, boolean connecte) {
166
 
167
	if(connecte) {
144 aurelien 168
		labelEtatConnexion = "<div id=\"etatConnexion\">Connecté en tant que "+identifiant+" <a id=\"lienDeconnexion\" href=\"#\">(deconnexion)</a>" ;
140 aurelien 169
		labelEtatConnexion += "</div>" ;
170
 
171
 
172
		labelEtatConnexion += liens ;
173
		setHtml(labelEtatConnexion);
12 david 174
 
140 aurelien 175
		ExtElement lienDeco = Ext.get("etatConnexion");
176
		if(lienDeco != null)
177
		{
178
			lienDeco.addListener("click", new EventCallback() {
179
 
180
				public void execute(EventObject e) {
181
					carnetEnLigneMediateur.deconnecterUtilisateur();
182
				}
183
 
184
			});
185
		}
186
		else
187
		{
188
			addListener(new ContainerListenerAdapter()
189
			{
190
				public void onAfterLayout(Container c)
191
				{
192
					ExtElement lienDeco = Ext.get("etatConnexion");
193
 
194
					lienDeco.addListener("click", new EventCallback() {
195
 
196
						public void execute(EventObject e) {
197
							carnetEnLigneMediateur.deconnecterUtilisateur();
198
							setEtat(null, false);
199
						}
200
 
201
					});
202
				}
203
			});
204
		}
205
	}
206
	else
207
	{
208
		labelEtatConnexion = "<div id=\"etatConnexion\"> Utilisez ce carnet en ligne pour saisir vos observations, <a id=\"lienConnexion\" href=\"#\">identifiez-vous</a> pour les transmettre à Tela Botanica</div>";
209
		labelEtatConnexion += liens ;
210
		setHtml(labelEtatConnexion);
211
		ExtElement lienCo = Ext.get("etatConnexion");
212
		if(lienCo != null) {
213
			lienCo.addListener("click", new EventCallback() {
214
 
215
				public void execute(EventObject e) {
216
 
217
					carnetEnLigneMediateur.afficherDialogueConnexion();
218
				}
219
 
220
			});
221
		}
222
		else
223
		{
224
			addListener(new ContainerListenerAdapter() {
225
				public void onAfterLayout(Container c) {
226
 
227
					ExtElement lienCo = Ext.get("etatConnexion");
228
 
229
					lienCo.addListener("click", new EventCallback() {
230
 
231
						public void execute(EventObject e) {
232
 
233
							carnetEnLigneMediateur.afficherDialogueConnexion();
234
						}
235
 
236
					});
237
				}
238
			});
239
		}
240
	}
12 david 241
 
140 aurelien 242
	ExtElement lienBugs = Ext.get("lienBugs");
243
	if(lienBugs != null)
244
	{
245
		lienBugs.removeAllListeners();
246
		lienBugs.addListener("click", new EventCallback() {
247
 
248
			public void execute(EventObject e) {
249
				String bugsURL = Configuration.getSuiviBugUrl() ;
250
				Window.open(bugsURL, "", "") ;
251
			}
252
		});
253
	}
254
	else
255
	{
256
		addListener(new ContainerListenerAdapter() {
257
			public void onAfterLayout(Container c) {
258
 
259
				ExtElement lienBugs = Ext.get("lienBugs");
260
				if(lienBugs != null)
261
				{
262
					lienBugs.removeAllListeners();
263
					lienBugs.addListener("click", new EventCallback() {
264
 
265
						public void execute(EventObject e) {
266
							String bugsURL = Configuration.getSuiviBugUrl() ;
267
							Window.open(bugsURL, "", "") ;
268
						}
269
					});
270
				}
271
			}
272
		});
273
	}
12 david 274
 
140 aurelien 275
	ExtElement lienAide = Ext.get("lienAide");
276
	if(lienAide != null)
277
	{
278
		lienAide.removeAllListeners();
279
		lienAide.addListener("click", new EventCallback() {
12 david 280
 
140 aurelien 281
			public void execute(EventObject e) {
282
				String aideUrl = Configuration.getAideBaseUrl() ;
283
				Window.open(aideUrl, "", "") ;
284
			}
285
		});
286
	}
287
	else
288
	{
289
		addListener(new ContainerListenerAdapter() {
290
			public void onAfterLayout(Container c) {
291
 
292
				ExtElement lienAide = Ext.get("lienAide");
293
				if(lienAide != null)
294
				{
295
					lienAide.removeAllListeners();
296
					lienAide.addListener("click", new EventCallback() {
297
 
298
						public void execute(EventObject e) {
299
							String aideUrl = Configuration.getAideBaseUrl() ;
300
							Window.open(aideUrl, "", "") ;
301
						}
302
					});
303
				}
304
			}
305
		});
306
	}
12 david 307
 
140 aurelien 308
 
309
}
12 david 310
 
311
}
312
 
313
 
314
/* +--Fin du code ---------------------------------------------------------------------------------------+
315
* $Log$
316
* Revision 1.1  2008-11-13 11:27:05  ddelon
317
* Reecriture gwt-ext
318
*
319
* Revision 1.1  2008-06-09 14:19:37  ddelon
320
* Initialisation observation
321
*
322
* Revision 1.2  2008-04-28 13:10:44  ddelon
323
* Integration MyGwt
324
*
325
* Revision 1.1  2008-01-02 21:26:04  ddelon
326
* mise en place mygwt
327
*
328
* Revision 1.6  2007-12-22 14:48:53  ddelon
329
* Documentation et refactorisation
330
*
331
* Revision 1.5  2007-09-17 19:25:34  ddelon
332
* Documentation
333
*
334
*
335
*/