Subversion Repositories eFlore/Applications.cel

Rev

Rev 144 | 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;
140 aurelien 22
import org.tela_botanica.client.modeles.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
 
140 aurelien 60
  private String liens = "<div id=\"liensExt\"><a href=\"#\" id=\"lienAide\">Aide</a>  <a href=\"#\" id=\"lienBugs\">Bugs </a></div>" ;
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) ;
74
 
75
	// Pas de word wrap
140 aurelien 76
	labelEtatConnexion="";
12 david 77
 
140 aurelien 78
	this.setHtml(labelEtatConnexion+liens);
12 david 79
 
80
 
81
	ajouterListeners();
82
 
140 aurelien 83
 
12 david 84
  	}
85
 
86
   public void ajouterListeners() {
87
 
140 aurelien 88
	   ExtElement lienAide = Ext.get("lienAide");
89
		if(lienAide != null)
90
		{
91
			lienAide.removeAllListeners();
92
			lienAide.addListener("click", new EventCallback() {
12 david 93
 
140 aurelien 94
				public void execute(EventObject e) {
95
					String aideUrl = Configuration.getAideBaseUrl() ;
96
					Window.open(aideUrl, "", "") ;
97
				}
98
			});
99
		}
100
		else
101
		{
102
			addListener(new ContainerListenerAdapter() {
103
				public void onAfterLayout(Container c) {
104
 
105
					ExtElement lienAide = Ext.get("lienAide");
106
					if(lienAide != null)
107
					{
108
						lienAide.removeAllListeners();
109
						lienAide.addListener("click", new EventCallback() {
110
 
111
							public void execute(EventObject e) {
112
								String aideUrl = Configuration.getAideBaseUrl() ;
113
								Window.open(aideUrl, "", "") ;
114
							}
115
						});
116
					}
117
				}
118
			});
119
		}
120
 
121
		ExtElement lienBugs = Ext.get("lienBugs");
122
		if(lienBugs != null)
123
		{
124
			lienBugs.removeAllListeners();
125
			lienBugs.addListener("click", new EventCallback() {
12 david 126
 
140 aurelien 127
				public void execute(EventObject e) {
128
					String bugsURL = Configuration.getSuiviBugUrl() ;
129
					Window.open(bugsURL, "", "") ;
130
				}
131
			});
132
		}
133
		else
134
		{
135
			addListener(new ContainerListenerAdapter() {
136
				public void onAfterLayout(Container c) {
137
 
138
					ExtElement lienBugs = Ext.get("lienBugs");
139
					if(lienBugs != null)
140
					{
141
						lienBugs.removeAllListeners();
142
						lienBugs.addListener("click", new EventCallback() {
143
 
144
							public void execute(EventObject e) {
145
								String bugsURL = Configuration.getSuiviBugUrl() ;
146
								Window.open(bugsURL, "", "") ;
147
							}
148
						});
149
					}
150
				}
151
			});
152
		}
12 david 153
 
154
	}
155
 
156
 
157
 
158
 
159
/**
160
 * Affichage de l'etat de connexion
161
 * @param text
162
 * @param connecte
163
 */
140 aurelien 164
public void setEtat(String identifiant, boolean connecte) {
165
 
166
	if(connecte) {
144 aurelien 167
		labelEtatConnexion = "<div id=\"etatConnexion\">Connecté en tant que "+identifiant+" <a id=\"lienDeconnexion\" href=\"#\">(deconnexion)</a>" ;
140 aurelien 168
		labelEtatConnexion += "</div>" ;
169
 
170
 
171
		labelEtatConnexion += liens ;
172
		setHtml(labelEtatConnexion);
12 david 173
 
140 aurelien 174
		ExtElement lienDeco = Ext.get("etatConnexion");
175
		if(lienDeco != null)
176
		{
177
			lienDeco.addListener("click", new EventCallback() {
178
 
179
				public void execute(EventObject e) {
180
					carnetEnLigneMediateur.deconnecterUtilisateur();
181
				}
182
 
183
			});
184
		}
185
		else
186
		{
187
			addListener(new ContainerListenerAdapter()
188
			{
189
				public void onAfterLayout(Container c)
190
				{
191
					ExtElement lienDeco = Ext.get("etatConnexion");
192
 
193
					lienDeco.addListener("click", new EventCallback() {
194
 
195
						public void execute(EventObject e) {
196
							carnetEnLigneMediateur.deconnecterUtilisateur();
197
							setEtat(null, false);
198
						}
199
 
200
					});
201
				}
202
			});
203
		}
204
	}
205
	else
206
	{
207
		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>";
208
		labelEtatConnexion += liens ;
209
		setHtml(labelEtatConnexion);
210
		ExtElement lienCo = Ext.get("etatConnexion");
211
		if(lienCo != null) {
212
			lienCo.addListener("click", new EventCallback() {
213
 
214
				public void execute(EventObject e) {
215
 
216
					carnetEnLigneMediateur.afficherDialogueConnexion();
217
				}
218
 
219
			});
220
		}
221
		else
222
		{
223
			addListener(new ContainerListenerAdapter() {
224
				public void onAfterLayout(Container c) {
225
 
226
					ExtElement lienCo = Ext.get("etatConnexion");
227
 
228
					lienCo.addListener("click", new EventCallback() {
229
 
230
						public void execute(EventObject e) {
231
 
232
							carnetEnLigneMediateur.afficherDialogueConnexion();
233
						}
234
 
235
					});
236
				}
237
			});
238
		}
239
	}
12 david 240
 
140 aurelien 241
	ExtElement lienBugs = Ext.get("lienBugs");
242
	if(lienBugs != null)
243
	{
244
		lienBugs.removeAllListeners();
245
		lienBugs.addListener("click", new EventCallback() {
246
 
247
			public void execute(EventObject e) {
248
				String bugsURL = Configuration.getSuiviBugUrl() ;
249
				Window.open(bugsURL, "", "") ;
250
			}
251
		});
252
	}
253
	else
254
	{
255
		addListener(new ContainerListenerAdapter() {
256
			public void onAfterLayout(Container c) {
257
 
258
				ExtElement lienBugs = Ext.get("lienBugs");
259
				if(lienBugs != null)
260
				{
261
					lienBugs.removeAllListeners();
262
					lienBugs.addListener("click", new EventCallback() {
263
 
264
						public void execute(EventObject e) {
265
							String bugsURL = Configuration.getSuiviBugUrl() ;
266
							Window.open(bugsURL, "", "") ;
267
						}
268
					});
269
				}
270
			}
271
		});
272
	}
12 david 273
 
140 aurelien 274
	ExtElement lienAide = Ext.get("lienAide");
275
	if(lienAide != null)
276
	{
277
		lienAide.removeAllListeners();
278
		lienAide.addListener("click", new EventCallback() {
12 david 279
 
140 aurelien 280
			public void execute(EventObject e) {
281
				String aideUrl = Configuration.getAideBaseUrl() ;
282
				Window.open(aideUrl, "", "") ;
283
			}
284
		});
285
	}
286
	else
287
	{
288
		addListener(new ContainerListenerAdapter() {
289
			public void onAfterLayout(Container c) {
290
 
291
				ExtElement lienAide = Ext.get("lienAide");
292
				if(lienAide != null)
293
				{
294
					lienAide.removeAllListeners();
295
					lienAide.addListener("click", new EventCallback() {
296
 
297
						public void execute(EventObject e) {
298
							String aideUrl = Configuration.getAideBaseUrl() ;
299
							Window.open(aideUrl, "", "") ;
300
						}
301
					});
302
				}
303
			}
304
		});
305
	}
12 david 306
 
140 aurelien 307
 
308
}
12 david 309
 
310
}
311
 
312
 
313
/* +--Fin du code ---------------------------------------------------------------------------------------+
314
* $Log$
315
* Revision 1.1  2008-11-13 11:27:05  ddelon
316
* Reecriture gwt-ext
317
*
318
* Revision 1.1  2008-06-09 14:19:37  ddelon
319
* Initialisation observation
320
*
321
* Revision 1.2  2008-04-28 13:10:44  ddelon
322
* Integration MyGwt
323
*
324
* Revision 1.1  2008-01-02 21:26:04  ddelon
325
* mise en place mygwt
326
*
327
* Revision 1.6  2007-12-22 14:48:53  ddelon
328
* Documentation et refactorisation
329
*
330
* Revision 1.5  2007-09-17 19:25:34  ddelon
331
* Documentation
332
*
333
*
334
*/