Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
60 jpm 1
package org.tela_botanica.client;
2
 
231 jp_milcent 3
import java.util.Iterator;
134 jpm 4
import java.util.List;
5
 
61 jpm 6
import org.tela_botanica.client.composants.AideFenetre;
60 jpm 7
import org.tela_botanica.client.composants.IdentificationFenetre;
66 jpm 8
import org.tela_botanica.client.composants.ParametreFenetre;
358 jp_milcent 9
import org.tela_botanica.client.i18n.Constantes;
119 jpm 10
import org.tela_botanica.client.interfaces.Rafraichissable;
61 jpm 11
import org.tela_botanica.client.modeles.Configuration;
156 jp_milcent 12
import org.tela_botanica.client.modeles.Information;
327 jp_milcent 13
import org.tela_botanica.client.modeles.MenuApplicationId;
142 gduche 14
import org.tela_botanica.client.modeles.Personne;
128 gduche 15
import org.tela_botanica.client.modeles.PersonneListe;
245 jp_milcent 16
import org.tela_botanica.client.modeles.Projet;
268 jp_milcent 17
import org.tela_botanica.client.modeles.ProjetListe;
107 aurelien 18
import org.tela_botanica.client.modeles.Publication;
19
import org.tela_botanica.client.modeles.PublicationListe;
60 jpm 20
import org.tela_botanica.client.modeles.Structure;
209 jp_milcent 21
import org.tela_botanica.client.modeles.StructureAPersonne;
231 jp_milcent 22
import org.tela_botanica.client.modeles.StructureAPersonneListe;
188 jp_milcent 23
import org.tela_botanica.client.modeles.StructureConservation;
69 jpm 24
import org.tela_botanica.client.modeles.StructureListe;
195 jp_milcent 25
import org.tela_botanica.client.modeles.StructureValorisation;
61 jpm 26
import org.tela_botanica.client.modeles.Utilisateur;
91 jpm 27
import org.tela_botanica.client.modeles.ValeurListe;
444 jp_milcent 28
import org.tela_botanica.client.vues.ContenuVue;
29
import org.tela_botanica.client.vues.EnteteVue;
438 gduche 30
import org.tela_botanica.client.vues.PersonneForm;
444 jp_milcent 31
import org.tela_botanica.client.vues.PublicationForm;
32
import org.tela_botanica.client.vues.StructureForm;
438 gduche 33
import org.tela_botanica.client.vues.PersonneDetailVue;
128 gduche 34
import org.tela_botanica.client.vues.PersonneVue;
332 gduche 35
import org.tela_botanica.client.vues.PopupChargement;
444 jp_milcent 36
import org.tela_botanica.client.vues.PublicationDetailVue;
107 aurelien 37
import org.tela_botanica.client.vues.PublicationVue;
443 jp_milcent 38
import org.tela_botanica.client.vues.StatutVue;
441 jp_milcent 39
import org.tela_botanica.client.vues.StructureDetailVue;
60 jpm 40
import org.tela_botanica.client.vues.StructureVue;
444 jp_milcent 41
import org.tela_botanica.client.vues.MenuVue;
60 jpm 42
 
43
import com.extjs.gxt.ui.client.Registry;
44
import com.extjs.gxt.ui.client.Style.LayoutRegion;
315 gduche 45
import com.extjs.gxt.ui.client.event.ComponentEvent;
46
import com.extjs.gxt.ui.client.event.Listener;
60 jpm 47
import com.extjs.gxt.ui.client.util.Margins;
315 gduche 48
import com.extjs.gxt.ui.client.widget.Dialog;
156 jp_milcent 49
import com.extjs.gxt.ui.client.widget.Info;
315 gduche 50
import com.extjs.gxt.ui.client.widget.MessageBox;
358 jp_milcent 51
import com.extjs.gxt.ui.client.widget.StatusBar;
60 jpm 52
import com.extjs.gxt.ui.client.widget.Viewport;
315 gduche 53
import com.extjs.gxt.ui.client.widget.button.Button;
60 jpm 54
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
55
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
91 jpm 56
import com.google.gwt.core.client.GWT;
60 jpm 57
import com.google.gwt.user.client.Window;
58
import com.google.gwt.user.client.ui.RootPanel;
59
 
277 jp_milcent 60
public class Mediateur implements Rafraichissable {
60 jpm 61
 
358 jp_milcent 62
	private Viewport viewport;
119 jpm 63
	private Modele modele = null;
369 jp_milcent 64
	public Constantes i18nC;
119 jpm 65
 
444 jp_milcent 66
	private EnteteVue panneauNord = null;
67
	private MenuVue panneauOuest = null;
68
	private ContenuVue panneauCentre = null;
443 jp_milcent 69
	private StatutVue panneauSud = null;
156 jp_milcent 70
	private Rafraichissable contenuPanneauCentre = null;
60 jpm 71
 
358 jp_milcent 72
	private IdentificationFenetre fenetreIdentification = null;
73
 
60 jpm 74
	public Mediateur() {
75
		// Enregistrement du Médiateur dans le Registre
76
		Registry.register(RegistreId.MEDIATEUR, this);
358 jp_milcent 77
		// Gestion de l'i18n
369 jp_milcent 78
		i18nC = GWT.create(Constantes.class);
60 jpm 79
		// Création du Modèle qui s'enregistre lui même dans le Registre
119 jpm 80
		modele = new Modele();
277 jp_milcent 81
	    // Création de l'utilisateur courrant
82
		Registry.register(RegistreId.UTILISATEUR_COURANT, new Utilisateur(null, false));
65 jpm 83
		this.connecterUtilisateur(null, null);
277 jp_milcent 84
	    // Création du projet courrant
85
		Registry.register(RegistreId.PROJET_COURANT, new Projet());
65 jpm 86
 
60 jpm 87
		// Création du Viewport qui contient la disposition globale de l'application
88
		viewport = new Viewport();
89
		viewport.setLayout(new BorderLayout());
90
 
91
		// Création des différents panneaux
92
	    creerPanneauNord();
93
	    creerPanneauOuest();
94
	    creerPanneauCentral();
358 jp_milcent 95
	    creerPanneauSud();
60 jpm 96
 
97
		// Registry utile car présent partout!
98
		Registry.register(RegistreId.VIEWPORT, viewport);
99
		Registry.register(RegistreId.PANNEAU_OUEST, panneauOuest);
100
		Registry.register(RegistreId.PANNEAU_CENTRE, panneauCentre);
358 jp_milcent 101
		Registry.register(RegistreId.PANNEAU_SUD, panneauSud);
60 jpm 102
 
103
		// Chargement du menu
327 jp_milcent 104
		chargeMenuApplication();
60 jpm 105
 
106
		// Retour à GWT du Viewport une fois constuit
107
		RootPanel.get().add(viewport);
332 gduche 108
 
109
		masquerPopinChargement();
60 jpm 110
	}
111
 
156 jp_milcent 112
	//+----------------------------------------------------------------------------------------------------------------+
113
	//												GESTION des PANNEAUX PRINCIPAUX
114
	//+----------------------------------------------------------------------------------------------------------------+
119 jpm 115
 
60 jpm 116
	private void creerPanneauNord() {
444 jp_milcent 117
		panneauNord = new EnteteVue(this);
60 jpm 118
 
119
		BorderLayoutData regionNord = new BorderLayoutData(LayoutRegion.NORTH, 100);
120
		regionNord.setCollapsible(true);
121
		regionNord.setFloatable(true);
122
		regionNord.setSplit(false);
123
		regionNord.setMargins(new Margins(5, 5, 0, 5));
124
 
125
		viewport.add(panneauNord, regionNord);
126
	}
127
 
128
	private void creerPanneauOuest() {
444 jp_milcent 129
		panneauOuest = new MenuVue(this);
60 jpm 130
 
131
		BorderLayoutData regionOuest = new BorderLayoutData(LayoutRegion.WEST, 200);
132
		regionOuest.setSplit(true);
133
		regionOuest.setCollapsible(true);
134
		regionOuest.setMargins(new Margins(5));
135
 
136
		viewport.add(panneauOuest, regionOuest);
137
	}
138
 
139
	private void creerPanneauCentral() {
444 jp_milcent 140
		panneauCentre = new ContenuVue(this);
60 jpm 141
 
142
		BorderLayoutData regionCentre = new BorderLayoutData(LayoutRegion.CENTER);
143
		regionCentre.setMargins(new Margins(5, 5, 5, 0));
144
 
145
		viewport.add(panneauCentre, regionCentre);
146
	}
358 jp_milcent 147
 
148
	private void creerPanneauSud() {
443 jp_milcent 149
		panneauSud = new StatutVue();
358 jp_milcent 150
 
369 jp_milcent 151
		BorderLayoutData regionSud = new BorderLayoutData(LayoutRegion.SOUTH, 20);
358 jp_milcent 152
		regionSud.setCollapsible(true);
153
		regionSud.setFloatable(true);
154
		regionSud.setSplit(false);
155
		regionSud.setMargins(new Margins(0));
156
 
157
		viewport.add(panneauSud, regionSud);
158
	}
60 jpm 159
 
369 jp_milcent 160
	public void actualiserPanneauCentral() {
414 gduche 161
		System.out.println(panneauCentre);
369 jp_milcent 162
		panneauCentre.layout();
163
	}
164
 
156 jp_milcent 165
	//+----------------------------------------------------------------------------------------------------------------+
166
	//												GESTION du MENU
167
	//+----------------------------------------------------------------------------------------------------------------+
168
 
327 jp_milcent 169
	public void chargeMenuApplication() {
444 jp_milcent 170
		((MenuVue) Registry.get(RegistreId.PANNEAU_OUEST)).chargerMenus();
60 jpm 171
	}
172
 
327 jp_milcent 173
	public void clicMenu(String codeMenuClique) {
358 jp_milcent 174
		activerChargement(codeMenuClique);
60 jpm 175
		panneauCentre.removeAll();
327 jp_milcent 176
		if (codeMenuClique.equals(MenuApplicationId.STRUCTURE)) {
277 jp_milcent 177
			modele.selectionnerStructure(panneauCentre, getProjetId(), null);
327 jp_milcent 178
		} else if (codeMenuClique.equals(MenuApplicationId.PUBLICATION)) {
277 jp_milcent 179
			modele.selectionnerPublications(panneauCentre);
327 jp_milcent 180
		} else if (codeMenuClique.equals(MenuApplicationId.PERSONNE)) {
414 gduche 181
 
277 jp_milcent 182
			modele.selectionnerPersonne(panneauCentre, null, getProjetId(), null);
379 jp_milcent 183
		} else {
327 jp_milcent 184
			GWT.log("Non implémenté! Menu id : "+codeMenuClique, null);
60 jpm 185
		}
186
		panneauCentre.layout();
187
	}
188
 
358 jp_milcent 189
	public void activerChargement(String message) {
190
		afficherPopinChargement();
369 jp_milcent 191
		panneauSud.showBusy(i18nC.chargement()+" "+message);
358 jp_milcent 192
	}
193
 
194
	public void desactiverChargement() {
195
		masquerPopinChargement();
196
		panneauSud.clear();
197
	}
198
 
156 jp_milcent 199
	//+----------------------------------------------------------------------------------------------------------------+
200
	//												GESTION DES FENÊTRES
201
	//+----------------------------------------------------------------------------------------------------------------+
60 jpm 202
 
61 jpm 203
	public void ouvrirAide() {
204
		AideFenetre aideFenetre = new AideFenetre();
205
		aideFenetre.show();
66 jpm 206
		// FIXME : apparament le fade In/Fade Out pose problème sur les navigateurs...
207
		//aideFenetre.el().fadeIn(FxConfig.NONE);
61 jpm 208
	}
209
 
210
	public void ouvrirParametres() {
66 jpm 211
		ParametreFenetre parametresFenetre = new ParametreFenetre();
212
		parametresFenetre.show();
61 jpm 213
	}
214
 
215
	public void ouvrirIdentification() {
358 jp_milcent 216
		fenetreIdentification = new IdentificationFenetre();
217
		fenetreIdentification.show();
61 jpm 218
	}
219
 
220
	public void ouvrirApplis(String id) {
221
		if (id.equals(ComposantId.MENU_CEL)) {
222
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getCelUrl(), "Carnet en ligne", "");
223
		} else if (id.equals(ComposantId.MENU_BEL)) {
134 jpm 224
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getCelUrl(), "Biblio en ligne", "");
61 jpm 225
		}
226
	}
227
 
156 jp_milcent 228
	//+----------------------------------------------------------------------------------------------------------------+
229
	//												GESTION de l'UTILISATEUR et de l'IDENTIFICATION
230
	//+----------------------------------------------------------------------------------------------------------------+
245 jp_milcent 231
	/**
232
	 * Retourne l'identifiant de l'utilisateur courrant de l'application.
233
	 */
156 jp_milcent 234
	public String getUtilisateurId() {
277 jp_milcent 235
		String id = null;
236
		Utilisateur utilisateurCourant = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
237
		if (!utilisateurCourant.getId().equals("")) {
238
			id = utilisateurCourant.getId();
239
		}
240
		return id;
156 jp_milcent 241
	}
242
 
65 jpm 243
	public void connecterUtilisateur(String login, String mdp) {
277 jp_milcent 244
		modele.connecterUtilisateur(this, login, mdp);
64 jpm 245
	}
246
 
65 jpm 247
	public void deconnecterUtilisateur() {
277 jp_milcent 248
		modele.deconnecterUtilisateur(this);
64 jpm 249
	}
65 jpm 250
 
64 jpm 251
	public void mettreAJourEtatIdentification(Utilisateur utilisateur) {
156 jp_milcent 252
		// Mise à jour du registre
277 jp_milcent 253
		Registry.register(RegistreId.UTILISATEUR_COURANT, utilisateur);
156 jp_milcent 254
		// Création de l'information de mise à jour de l'utilisateur
255
		Information info = new Information("maj_utilisateur");
358 jp_milcent 256
 
257
		// Rafraichissement de la fenêtre d'Identification
258
		if (fenetreIdentification != null) {
259
			fenetreIdentification.rafraichir(info);
260
		}
156 jp_milcent 261
 
262
		// Rafraichissement du panneau Nord
263
		panneauNord.rafraichir(info);
264
 
265
		// Rafraichissement du panneau Centre
266
		if (contenuPanneauCentre != null) {
267
			contenuPanneauCentre.rafraichir(info);
268
		}
61 jpm 269
	}
66 jpm 270
 
156 jp_milcent 271
	//+----------------------------------------------------------------------------------------------------------------+
272
	//												GESTION DES PERSONNES
273
	//+----------------------------------------------------------------------------------------------------------------+
274
 
275
	public void clicListePersonne(Personne personne)	{
438 gduche 276
		((PersonneDetailVue) Registry.get(RegistreId.PANNEAU_PERSONNE_DETAIL)).rafraichir(personne);
156 jp_milcent 277
 
69 jpm 278
	}
279
 
278 jp_milcent 280
	public void afficherListePersonnes(PersonneListe personnesACharger)	{
414 gduche 281
 
282
		PersonneVue personneVue = new PersonneVue();
283
		contenuPanneauCentre = personneVue;
284
		panneauCentre.add(personneVue);
285
 
278 jp_milcent 286
		contenuPanneauCentre.rafraichir(personnesACharger);
287
		//contenuPanneauCentre.layout();
156 jp_milcent 288
	}
289
 
128 gduche 290
	public void clicAjouterPersonne()	{
332 gduche 291
 
292
		afficherPopinChargement();
293
 
277 jp_milcent 294
		panneauCentre.removeAll();
438 gduche 295
		PersonneForm formulairePersonneVue = new PersonneForm();
277 jp_milcent 296
		contenuPanneauCentre = formulairePersonneVue;
297
		panneauCentre.add(formulairePersonneVue);
298
		panneauCentre.layout();
128 gduche 299
	}
300
 
285 gduche 301
	public void clicModifierPersonne(Personne personne)	{
302
		if (personne!=null)	{
303
			panneauCentre.removeAll();
438 gduche 304
			PersonneForm formulairePersonneVue = new PersonneForm();
285 gduche 305
			contenuPanneauCentre = formulairePersonneVue;
306
			panneauCentre.add(formulairePersonneVue);
349 gduche 307
 
308
			selectionnerPersonne(formulairePersonneVue, personne);
309
 
310
			panneauCentre.layout();
311
 
312
 
285 gduche 313
		}
314
	}
315
 
349 gduche 316
	public void selectionnerPersonne(Rafraichissable vue, Personne personne)	{
317
		modele.selectionnerPersonne(vue, personne.getId(), null, null);
318
	}
285 gduche 319
 
315 gduche 320
	public void clicSupprimerPersonne(final Rafraichissable vue,final List<Personne> personneSelection) {
245 jp_milcent 321
 
322
		String ids = "" ;
323
 
324
		if (personneSelection.size() == 0) {
325
			Info.display("Information", "Veuillez sélectionner une personne.");
326
		} else if(personneSelection.size() > 0) {
327
			String message = "Êtes vous sur de vouloir supprimer les personnes sélectionnées ?";
328
			if (personneSelection.size() == 1) {
329
				message = "Êtes vous sur de vouloir supprimer la personne sélectionnée ?";
330
			}
315 gduche 331
 
332
 
333
			final Listener listenerSuppression = new Listener<ComponentEvent>() {
334
 
327 jp_milcent 335
				public void handleEvent(ComponentEvent ce) {
336
					Dialog dialog = (Dialog) ce.component;
337
					Button btn = dialog.getButtonPressed();
338
 
339
					if (btn.getText().equals(dialog.yesText)) {
340
						String idStr = "" ;
347 gduche 341
						Iterator<Personne> itPersonne = personneSelection.iterator();
342
						while (itPersonne.hasNext()) {
343
							Personne personneCourante = itPersonne.next();
344
							idStr += personneCourante.getId();
389 gduche 345
							idStr +=",";
327 jp_milcent 346
						}
329 jp_milcent 347
						modele.supprimerPersonne(vue, idStr);
327 jp_milcent 348
					}
349
				}
350
			};
315 gduche 351
 
352
			MessageBox.confirm("Supprimer une personne", message, listenerSuppression);
245 jp_milcent 353
		} else {
354
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerPersonne() du Médiateur.");
355
		}
356
	}
277 jp_milcent 357
 
358
	public void selectionnerPersonneParNomComplet(Rafraichissable vue, String projetId, String nomComplet) {
359
		modele.selectionnerPersonne(vue, null, projetId, nomComplet);
360
	}
245 jp_milcent 361
 
389 gduche 362
	public void enregistrerPersonne(Rafraichissable vue, Personne personne){
429 gduche 363
		if (personne.getId()!=null && !personne.getId().trim().equals("")) {
364
			modele.modifierPersonne(vue, personne);
365
		}	else {
366
			modele.ajouterPersonne(vue, personne);
367
		}
368
 
389 gduche 369
	}
370
 
156 jp_milcent 371
	//+----------------------------------------------------------------------------------------------------------------+
372
	//												GESTION DES VALEURS ET LISTES
373
	//+----------------------------------------------------------------------------------------------------------------+
374
 
91 jpm 375
	public void afficherListeValeurs(ValeurListe nouvelleDonnees) {
156 jp_milcent 376
		if (panneauCentre.getId().equals(ComposantId.PANNEAU_STRUCTURE_FORM)) {
444 jp_milcent 377
			((StructureForm) panneauCentre.getItem(0)).rafraichir(nouvelleDonnees);
91 jpm 378
		} else {
379
			GWT.log("Aucun panneau trouvé pour afficher la liste de valeur", null);
380
		}
381
	}
382
 
156 jp_milcent 383
	//+----------------------------------------------------------------------------------------------------------------+
384
	//												GESTION DES PUBLICATIONS
385
	//+----------------------------------------------------------------------------------------------------------------+
386
 
107 aurelien 387
	public void afficherListePublication(PublicationListe nouvelleDonnees) {
388
		PublicationVue publicationVue = new PublicationVue() ;
228 aurelien 389
		panneauCentre.removeAll();
107 aurelien 390
		panneauCentre.add(publicationVue);
186 gduche 391
		contenuPanneauCentre = publicationVue;
107 aurelien 392
		publicationVue.rafraichir(nouvelleDonnees);
393
 
394
	}
395
 
396
	public void clicListePublication(Publication publication) {
379 jp_milcent 397
		panneauCentre.rafraichir(publication);
107 aurelien 398
	}
399
 
400
	public void clicAjouterPublication() {
223 aurelien 401
		panneauCentre.removeAll();
444 jp_milcent 402
		PublicationForm publicationForm = new PublicationForm();
403
		panneauCentre.add(publicationForm);
223 aurelien 404
		panneauCentre.setId(ComposantId.PANNEAU_FORM_PUBLICATION);
405
		panneauCentre.layout();
107 aurelien 406
	}
156 jp_milcent 407
 
245 jp_milcent 408
	public void clicModifierPublication(List<Publication> publicationListe) {
409
		if(publicationListe.size() <= 0) {
315 gduche 410
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 411
		} else {
245 jp_milcent 412
			Publication pubAModifier = publicationListe.get(publicationListe.size() -1);
413
			panneauCentre.removeAll();
444 jp_milcent 414
			PublicationForm publicationForm = new PublicationForm();
415
			panneauCentre.add(publicationForm);
245 jp_milcent 416
			panneauCentre.setId(ComposantId.PANNEAU_FORM_PUBLICATION);
417
			panneauCentre.layout();
444 jp_milcent 418
			publicationForm.rafraichir(pubAModifier);
245 jp_milcent 419
		}
420
	}
421
 
315 gduche 422
	public void clicSupprimerPublication(final List<Publication> publicationListe) {
245 jp_milcent 423
		if(publicationListe.size() <= 0) {
315 gduche 424
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 425
		} else {
245 jp_milcent 426
			String message = "" ;
427
			if(publicationListe.size() == 1) {
428
				message = "Voulez-vous vraiment supprimer cette publication ?";
429
			}
430
			else {
431
				message = "Voulez-vous vraiment supprimer ces publication ?";
432
			}
315 gduche 433
 
434
 
435
			final Listener listenerSuppression = new Listener<ComponentEvent>() {
436
				public void handleEvent(ComponentEvent ce) {
437
 
438
					Dialog dialog = (Dialog) ce.component;
439
				    Button btn = dialog.getButtonPressed();
440
 
379 jp_milcent 441
				    if (btn.getText().equals(dialog.yesText)) {
315 gduche 442
				    	modele.supprimerPublication(contenuPanneauCentre, getUtilisateurId(),publicationListe);
443
				    }
444
				}
445
			};
446
 
447
			MessageBox.confirm("Supprimer une publication", message, listenerSuppression);
245 jp_milcent 448
		}
449
 
450
	}
451
 
444 jp_milcent 452
	public void ajouterPublication(PublicationForm publicationForm, Publication publi) {
277 jp_milcent 453
		modele.ajouterPublication(contenuPanneauCentre, getUtilisateurId(),publi);
245 jp_milcent 454
	}
455
 
444 jp_milcent 456
	public void modifierPublication(PublicationForm publicationForm, Publication publi) {
277 jp_milcent 457
		modele.modifierPublication(contenuPanneauCentre, getUtilisateurId(),publi);
245 jp_milcent 458
	}
459
 
277 jp_milcent 460
	public void clicObtenirListeEditeurs(Rafraichissable vue) {
461
		modele.selectionnerStructure(vue, null, null);
245 jp_milcent 462
	}
463
 
277 jp_milcent 464
	public void clicObtenirListeAuteurs(Rafraichissable vue) {
465
		modele.selectionnerPersonne(vue, null, null, null);
245 jp_milcent 466
	}
467
 
156 jp_milcent 468
	//+----------------------------------------------------------------------------------------------------------------+
469
	//												GESTION DES STRUCTURES
470
	//+----------------------------------------------------------------------------------------------------------------+
471
 
379 jp_milcent 472
	public void clicListeStructure(Structure structure) {
473
		contenuPanneauCentre.rafraichir(structure);
474
		if (structure.getPersonnel() == null) {
475
			selectionnerStructureAPersonne(contenuPanneauCentre, structure.getId(), StructureAPersonne.ROLE_EQUIPE);
476
		} else {
477
			GWT.log("OK personnel déjà chargé", null);
478
		}
156 jp_milcent 479
	}
480
 
278 jp_milcent 481
	public void afficherListeStructures(StructureListe structuresACharger) {
156 jp_milcent 482
		// TODO : créer dès l'initialisation de l'application InsitutionVue et la cacher
373 jp_milcent 483
		StructureVue institutionVue = new StructureVue(this);
156 jp_milcent 484
		panneauCentre.add(institutionVue);
485
		panneauCentre.setId(ComposantId.PANNEAU_STRUCTURE_LISTE);
486
		contenuPanneauCentre = institutionVue;
278 jp_milcent 487
		institutionVue.rafraichir(structuresACharger);
156 jp_milcent 488
	}
489
 
490
	public void clicAjouterStructure() {
491
		panneauCentre.removeAll();
444 jp_milcent 492
		StructureForm structureForm = new StructureForm(this, StructureForm.MODE_AJOUTER);
493
		panneauCentre.add(structureForm);
156 jp_milcent 494
		panneauCentre.setId(ComposantId.PANNEAU_STRUCTURE_FORM);
495
		panneauCentre.layout();
496
	}
497
 
265 jp_milcent 498
	public void clicModifierStructure(List<Structure> structureSelection) {
499
		if (structureSelection.size() == 0) {
500
			Info.display("Information", "Veuillez sélectionner une structure.");
379 jp_milcent 501
		} else if (structureSelection.size() > 1) {
265 jp_milcent 502
			Info.display("Information", "Veuillez sélectionner une seule structure à la fois.");
379 jp_milcent 503
		} else if (structureSelection.size() == 1) {
265 jp_milcent 504
			panneauCentre.removeAll();
444 jp_milcent 505
			StructureForm structureForm = new StructureForm(this, StructureForm.MODE_MODIFIER);
506
			panneauCentre.add(structureForm);
265 jp_milcent 507
			panneauCentre.setId(ComposantId.PANNEAU_STRUCTURE_FORM);
508
 
444 jp_milcent 509
			selectionnerStructure(structureForm, structureSelection.get(0).getId());
510
			selectionnerStructureAPersonne(structureForm, structureSelection.get(0).getId(), StructureAPersonne.ROLE_EQUIPE);
265 jp_milcent 511
 
512
			panneauCentre.layout();
513
		} else {
514
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierStructure() du Médiateur.");
515
		}
516
 
119 jpm 517
	}
265 jp_milcent 518
 
315 gduche 519
	public void clicSupprimerStructure(final Rafraichissable vue, final List<Structure> structureSelection) {
156 jp_milcent 520
		if (structureSelection.size() == 0) {
521
			Info.display("Information", "Veuillez sélectionner une structure.");
522
		} else if(structureSelection.size() > 0) {
523
			String message = "Êtes vous sur de vouloir supprimer les structures sélectionnées ?";
524
			if (structureSelection.size() == 1) {
525
				message = "Êtes vous sur de vouloir supprimer la structure sélectionnée ?";
526
			}
315 gduche 527
 
528
 
529
			final Listener listenerSuppression = new Listener<ComponentEvent>() {
530
 
531
			       public void handleEvent(ComponentEvent ce) {
532
 
533
			    	   Dialog dialog = (Dialog) ce.component;
534
			    	   Button btn = dialog.getButtonPressed();
535
 
536
			    	   if (btn.getText().equals(dialog.yesText))	{
537
			    		   	String idStr = "" ;
538
							for(int i = 0 ; i < structureSelection.size() ; i++) {
539
								idStr += structureSelection.get(i).getId()+"," ;
540
							}
541
							modele.supprimerStructure(vue, getUtilisateurId(), idStr);
542
					       }
543
				      }
544
				     };
545
 
546
			MessageBox.confirm("Supprimer une structure", message, listenerSuppression);
547
 
134 jpm 548
		} else {
156 jp_milcent 549
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerStructure() du Médiateur.");
134 jpm 550
		}
551
	}
142 gduche 552
 
265 jp_milcent 553
	public void selectionnerStructure(Rafraichissable vue, String structureId) {
554
		GWT.log("Structure : "+structureId, null);
277 jp_milcent 555
		modele.selectionnerStructure(vue, null, structureId);
156 jp_milcent 556
	}
557
 
265 jp_milcent 558
	/**
559
	 * TODO : afficher un message du type "Structure ajoutée".
560
	 * Lance la creation d'une structure
561
	 * @param les données de la structure saisie
562
	 */
277 jp_milcent 563
	public void ajouterStructure(Rafraichissable vue, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
564
		modele.ajouterStructure(vue, getUtilisateurId(), structure, conservation, valorisation);
265 jp_milcent 565
	}
566
 
306 jp_milcent 567
	public void modifierStructure(Rafraichissable vue, String structureId, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
568
		modele.modifierStructure(vue, getUtilisateurId(), structureId, structure, conservation, valorisation);
156 jp_milcent 569
	}
231 jp_milcent 570
 
265 jp_milcent 571
	//+----------------------------------------------------------------------------------------------------------------+
572
	// GESTION de la relation STRUCTURE A PERSONNE
231 jp_milcent 573
	public void selectionnerStructureAPersonne(Rafraichissable vue, String structureId, String roleId) {
265 jp_milcent 574
		GWT.log("Structure : "+structureId, null);
575
		modele.selectionnerStructureAPersonne(vue, getUtilisateurId(), null, structureId, roleId);
231 jp_milcent 576
	}
156 jp_milcent 577
 
231 jp_milcent 578
	public void modifierStructureAPersonne(Rafraichissable vue, StructureAPersonneListe personnelModifie) {
579
		if (personnelModifie != null && personnelModifie.size() > 0) {
580
			GWT.log("Mediateur :modif", null);
581
			for (Iterator<String> it = personnelModifie.keySet().iterator(); it.hasNext();) {
582
				modele.modifierStructureAPersonne(vue, getUtilisateurId(), (StructureAPersonne) personnelModifie.get(it.next()));
583
			}
584
		}
585
	}
586
 
587
	public void ajouterStructureAPersonne(Rafraichissable vue, String structureId, StructureAPersonneListe personnelAjoute) {
588
		if (personnelAjoute != null && personnelAjoute.size() > 0) {
589
			for (Iterator<String> it = personnelAjoute.keySet().iterator(); it.hasNext();) {
590
				modele.ajouterStructureAPersonne(vue, getUtilisateurId(), structureId, (StructureAPersonne) personnelAjoute.get(it.next()));
591
			}
592
		}
593
	}
594
 
595
	public void supprimerStructureAPersonne(Rafraichissable vue, StructureAPersonneListe personnelSupprime) {
596
		if (personnelSupprime != null && personnelSupprime.size() > 0) {
597
			String idStrAPer = "" ;
598
			for (Iterator<String> it = personnelSupprime.keySet().iterator(); it.hasNext();) {
599
					idStrAPer += personnelSupprime.get(it.next()).getId()+"," ;
600
			}
601
			modele.supprimerStructureAPersonne(vue, getUtilisateurId(), idStrAPer);
602
		}
603
	}
604
 
156 jp_milcent 605
	//+----------------------------------------------------------------------------------------------------------------+
606
	//												GESTION des PROJETS
607
	//+----------------------------------------------------------------------------------------------------------------+
608
 
245 jp_milcent 609
	/**
610
	 * Retourne l'identifiant du projet courrant de l'application.
611
	 */
612
	public String getProjetId() {
277 jp_milcent 613
		String id = null;
614
		Projet projetCourant = (Projet) Registry.get(RegistreId.PROJET_COURANT);
279 jp_milcent 615
		if (projetCourant != null && !projetCourant.getId().equals("")) {
277 jp_milcent 616
			id = projetCourant.getId();
617
		}
618
		return id;
245 jp_milcent 619
	}
620
 
142 gduche 621
	//Greg : ajout d'un écouteur pour le changement liste projet
277 jp_milcent 622
	public void selectionnerProjets(Rafraichissable vue)	{
623
		modele.selectionnerProjets(vue);
142 gduche 624
	}
625
 
268 jp_milcent 626
	public void afficherListeProjets(ProjetListe projets)	{
277 jp_milcent 627
		panneauOuest.rafraichir(projets);
142 gduche 628
	}
159 gduche 629
 
277 jp_milcent 630
	public void selectionnerProjetCourant(Projet projetSelectionne) {
631
		Registry.register(RegistreId.PROJET_COURANT, projetSelectionne);
186 gduche 632
		if (contenuPanneauCentre instanceof PersonneVue)	{
277 jp_milcent 633
			modele.selectionnerPersonne(contenuPanneauCentre, null, getProjetId(), null);
186 gduche 634
			//FIXME Le rafraichissement du panneau ne se fait pas!
277 jp_milcent 635
		} else if (contenuPanneauCentre instanceof StructureVue)	{
636
			modele.obtenirListeStructures(contenuPanneauCentre, getProjetId());
186 gduche 637
		}
159 gduche 638
	}
237 aurelien 639
 
277 jp_milcent 640
	//+----------------------------------------------------------------------------------------------------------------+
641
	//	RAFRAICHISSEMENT
642
	//+----------------------------------------------------------------------------------------------------------------+
643
 
644
	public void rafraichir(Object nouvelleDonnees) {
645
		if (nouvelleDonnees instanceof Utilisateur) {
646
			mettreAJourEtatIdentification((Utilisateur) nouvelleDonnees);
278 jp_milcent 647
		} else {
648
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
277 jp_milcent 649
		}
650
	}
281 gduche 651
 
652
	/**
653
	 * Récupère la liste et rafraichit la vue donnée
654
	 *
655
	 * @param la vue à rafraichir
656
	 * @param l'id de la liste à récupérer
657
	 * */
369 jp_milcent 658
	public void obtenirListeValeurEtRafraichir(Rafraichissable vue, String listeId)	{
659
		modele.obtenirListeValeurs(vue, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId));
281 gduche 660
	}
288 gduche 661
 
369 jp_milcent 662
	public void obtenirValeurEtRafraichir(Rafraichissable vue, String listeId, String identifiantValeur)	{
663
		modele.obtenirValeur(vue, "abv", ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId), identifiantValeur);
301 gduche 664
	}
665
 
288 gduche 666
	public void obtenirListeRegionsEtRafraichir(Rafraichissable vue, String strListeId, String strPays)	{
667
		modele.obtenirListeRegion(vue, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(strListeId), strPays+".__");
668
	}
332 gduche 669
 
670
	/**
671
	 * 	Affiche la popin de chargement
672
	 */
673
	public void afficherPopinChargement()	{
674
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).center();
675
	}
676
 
677
 
678
	public void masquerPopinChargement()	{
679
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).hide();
680
	}
277 jp_milcent 681
}