Subversion Repositories eFlore/Applications.cel

Rev

Rev 2623 | 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
package org.tela_botanica.client.vues;
17
 
18
import org.tela_botanica.client.CarnetEnLigneMediateur;
2615 aurelien 19
import org.tela_botanica.client.i18n.Msg;
989 aurelien 20
import org.tela_botanica.client.modeles.objets.Configuration;
12 david 21
 
2081 mathias 22
import com.google.gwt.http.client.URL;
140 aurelien 23
import com.google.gwt.user.client.Window;
24
import com.gwtext.client.core.EventCallback;
25
import com.gwtext.client.core.EventObject;
26
import com.gwtext.client.core.Ext;
27
import com.gwtext.client.core.ExtElement;
28
import com.gwtext.client.widgets.Container;
12 david 29
import com.gwtext.client.widgets.Panel;
140 aurelien 30
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
12 david 31
 
32
/**
33
 * Un indicateur d'etat de connexion
34
 *
35
 * @author David Delon
36
 *
37
 */
38
 
39
public class EtatConnexionVue  extends Panel  {
40
 
41
	/**
42
	 * Médiateur associé à la vue
43
	 */
44
	private CarnetEnLigneMediateur carnetEnLigneMediateur = null ;
45
 
46
  /**
47
   * Texte lié à la connexion.
48
   *
49
   */
50
 
140 aurelien 51
  private String labelEtatConnexion = null;
2081 mathias 52
 
53
  /**
54
   * Ouh c'est pas beau, ça ! Mais avec Google Web Toolshit, ça
55
   * marche toujours mieux que quand on fait des trucs beaux :-)
56
   */
57
  private String liens = "<div id=\"liensExt\">"
2615 aurelien 58
		  + "<a id=\"lienRemarques\" title=\""+Msg.get("adresser-remarque-probleme")+"\""
2636 mathias 59
		  + 	" href=\"" + Configuration.getRemarquesBaseUrl() + "?lang=" + Msg.getLangue() + "&service=" + Configuration.getServiceContact()
2081 mathias 60
		  + 	"&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;\""
62
		  + " target=\"_blank\""
2623 aurelien 63
		  + ">"+Msg.get("remarques")+"</a>"
64
		  + "<a href=\"#\" id=\"lienAide\">"+Msg.get("aide")+"</a>"
2081 mathias 65
		  + "</div>" ;
12 david 66
 
67
  /**
2081 mathias 68
   * Booleen indiquant si utilisateur est connecte
12 david 69
   *
70
   */
71
  public EtatConnexionVue(CarnetEnLigneMediateur cm)  {
72
 
73
	carnetEnLigneMediateur=cm;
74
 
75
    this.setBodyBorder(false) ;
76
    this.setBorder(false) ;
226 aurelien 77
    this.setId("panneau_etat_connexion");
12 david 78
 
79
	// Pas de word wrap
140 aurelien 80
	labelEtatConnexion="";
12 david 81
 
140 aurelien 82
	this.setHtml(labelEtatConnexion+liens);
12 david 83
 
84
 
85
	ajouterListeners();
86
 
140 aurelien 87
 
12 david 88
  	}
89
 
90
   public void ajouterListeners() {
91
 
140 aurelien 92
	   ExtElement lienAide = Ext.get("lienAide");
93
		if(lienAide != null)
94
		{
95
			lienAide.removeAllListeners();
96
			lienAide.addListener("click", new EventCallback() {
12 david 97
 
1291 aurelien 98
				@Override
140 aurelien 99
				public void execute(EventObject e) {
100
					String aideUrl = Configuration.getAideBaseUrl() ;
101
					Window.open(aideUrl, "", "") ;
102
				}
103
			});
104
		}
105
		else
106
		{
107
			addListener(new ContainerListenerAdapter() {
1291 aurelien 108
				@Override
140 aurelien 109
				public void onAfterLayout(Container c) {
110
 
111
					ExtElement lienAide = Ext.get("lienAide");
112
					if(lienAide != null)
113
					{
114
						lienAide.removeAllListeners();
115
						lienAide.addListener("click", new EventCallback() {
116
 
1291 aurelien 117
							@Override
140 aurelien 118
							public void execute(EventObject e) {
119
								String aideUrl = Configuration.getAideBaseUrl() ;
120
								Window.open(aideUrl, "", "") ;
121
							}
122
						});
123
					}
124
				}
125
			});
126
		}
12 david 127
	}
128
 
129
/**
130
 * Affichage de l'etat de connexion
131
 * @param text
132
 * @param connecte
133
 */
140 aurelien 134
public void setEtat(String identifiant, boolean connecte) {
2081 mathias 135
 
140 aurelien 136
	if(connecte) {
2614 aurelien 137
		String[] params = {identifiant};
2615 aurelien 138
		labelEtatConnexion = "<div id=\"etatConnexion\">"+Msg.get("connecte-en-tant-que", params)+" <a id=\"lienDeconnexion\" href=\"#\">("+Msg.get("deconnexion")+")</a>" ;
140 aurelien 139
		labelEtatConnexion += "</div>" ;
140
 
141
 
142
		labelEtatConnexion += liens ;
143
		setHtml(labelEtatConnexion);
12 david 144
 
2081 mathias 145
		ExtElement lienDeco = Ext.get("lienDeconnexion");
140 aurelien 146
		if(lienDeco != null)
2081 mathias 147
		{
140 aurelien 148
			lienDeco.addListener("click", new EventCallback() {
149
 
1291 aurelien 150
				@Override
140 aurelien 151
				public void execute(EventObject e) {
152
					carnetEnLigneMediateur.deconnecterUtilisateur();
153
				}
154
 
155
			});
156
		}
157
		else
158
		{
159
			addListener(new ContainerListenerAdapter()
160
			{
1291 aurelien 161
				@Override
140 aurelien 162
				public void onAfterLayout(Container c)
163
				{
164
					ExtElement lienDeco = Ext.get("etatConnexion");
165
 
166
					lienDeco.addListener("click", new EventCallback() {
167
 
1291 aurelien 168
						@Override
140 aurelien 169
						public void execute(EventObject e) {
170
							carnetEnLigneMediateur.deconnecterUtilisateur();
171
							setEtat(null, false);
172
						}
173
 
174
					});
175
				}
176
			});
177
		}
178
	}
179
	else
180
	{
2615 aurelien 181
		labelEtatConnexion = "<div id=\"etatConnexion\"> "+Msg.get("cel-utilisation")+", <a id=\"lienConnexion\" href=\"#\">"+Msg.get("identifiez-vous")+"</a> "+Msg.get("pour-transmettre-tela")+"</div>";
140 aurelien 182
		labelEtatConnexion += liens ;
183
		setHtml(labelEtatConnexion);
184
		ExtElement lienCo = Ext.get("etatConnexion");
185
		if(lienCo != null) {
186
			lienCo.addListener("click", new EventCallback() {
187
 
1291 aurelien 188
				@Override
140 aurelien 189
				public void execute(EventObject e) {
190
 
191
					carnetEnLigneMediateur.afficherDialogueConnexion();
192
				}
193
 
194
			});
195
		}
196
		else
197
		{
198
			addListener(new ContainerListenerAdapter() {
1291 aurelien 199
				@Override
140 aurelien 200
				public void onAfterLayout(Container c) {
201
 
202
					ExtElement lienCo = Ext.get("etatConnexion");
203
 
204
					lienCo.addListener("click", new EventCallback() {
205
 
1291 aurelien 206
						@Override
140 aurelien 207
						public void execute(EventObject e) {
208
 
209
							carnetEnLigneMediateur.afficherDialogueConnexion();
210
						}
211
 
212
					});
213
				}
214
			});
215
		}
216
	}
1488 aurelien 217
 
140 aurelien 218
	ExtElement lienAide = Ext.get("lienAide");
219
	if(lienAide != null)
220
	{
221
		lienAide.removeAllListeners();
222
		lienAide.addListener("click", new EventCallback() {
12 david 223
 
1291 aurelien 224
			@Override
140 aurelien 225
			public void execute(EventObject e) {
226
				String aideUrl = Configuration.getAideBaseUrl() ;
227
				Window.open(aideUrl, "", "") ;
228
			}
229
		});
230
	}
231
	else
232
	{
233
		addListener(new ContainerListenerAdapter() {
1291 aurelien 234
			@Override
140 aurelien 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
 
1291 aurelien 243
						@Override
140 aurelien 244
						public void execute(EventObject e) {
245
							String aideUrl = Configuration.getAideBaseUrl() ;
246
							Window.open(aideUrl, "", "") ;
247
						}
248
					});
249
				}
250
			}
251
		});
252
	}
12 david 253
 
140 aurelien 254
 
255
}
12 david 256
 
257
}
258
 
259
 
260
/* +--Fin du code ---------------------------------------------------------------------------------------+
261
* $Log$
262
* Revision 1.1  2008-11-13 11:27:05  ddelon
263
* Reecriture gwt-ext
264
*
265
* Revision 1.1  2008-06-09 14:19:37  ddelon
266
* Initialisation observation
267
*
268
* Revision 1.2  2008-04-28 13:10:44  ddelon
269
* Integration MyGwt
270
*
271
* Revision 1.1  2008-01-02 21:26:04  ddelon
272
* mise en place mygwt
273
*
274
* Revision 1.6  2007-12-22 14:48:53  ddelon
275
* Documentation et refactorisation
276
*
277
* Revision 1.5  2007-09-17 19:25:34  ddelon
278
* Documentation
279
*
280
*
281
*/