Subversion Repositories eFlore/Applications.coel

Rev

Rev 414 | Rev 429 | 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;
60 jpm 28
import org.tela_botanica.client.vues.ContenuPanneauVue;
29
import org.tela_botanica.client.vues.EntetePanneauVue;
196 gduche 30
import org.tela_botanica.client.vues.FormPersonneVue;
223 aurelien 31
import org.tela_botanica.client.vues.FormPublicationVue;
69 jpm 32
import org.tela_botanica.client.vues.FormStructureVue;
142 gduche 33
import org.tela_botanica.client.vues.PersonneDetailPanneauVue;
128 gduche 34
import org.tela_botanica.client.vues.PersonneVue;
332 gduche 35
import org.tela_botanica.client.vues.PopupChargement;
107 aurelien 36
import org.tela_botanica.client.vues.PublicationDetailPanneauVue;
37
import org.tela_botanica.client.vues.PublicationVue;
358 jp_milcent 38
import org.tela_botanica.client.vues.StatutPanneauVue;
60 jpm 39
import org.tela_botanica.client.vues.StructureDetailPanneauVue;
40
import org.tela_botanica.client.vues.StructureVue;
41
import org.tela_botanica.client.vues.MenuPanneauVue;
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
 
60 jpm 66
	private EntetePanneauVue panneauNord = null;
67
	private MenuPanneauVue panneauOuest = null;
68
	private ContenuPanneauVue panneauCentre = null;
358 jp_milcent 69
	private StatutPanneauVue 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() {
370 jp_milcent 117
		panneauNord = new EntetePanneauVue(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() {
423 jp_milcent 129
		panneauOuest = new MenuPanneauVue(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() {
373 jp_milcent 140
		panneauCentre = new ContenuPanneauVue(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() {
149
		panneauSud = new StatutPanneauVue();
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() {
170
		((MenuPanneauVue) 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)	{
276
		((PersonneDetailPanneauVue) Registry.get(RegistreId.PANNEAU_PERSONNE_DETAIL)).rafraichir(personne);
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();
295
		FormPersonneVue formulairePersonneVue = new FormPersonneVue();
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();
304
			FormPersonneVue formulairePersonneVue = new FormPersonneVue();
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){
363
			modele.enregistrerPersonne(vue, personne);
364
	}
365
 
156 jp_milcent 366
	//+----------------------------------------------------------------------------------------------------------------+
367
	//												GESTION DES VALEURS ET LISTES
368
	//+----------------------------------------------------------------------------------------------------------------+
369
 
91 jpm 370
	public void afficherListeValeurs(ValeurListe nouvelleDonnees) {
156 jp_milcent 371
		if (panneauCentre.getId().equals(ComposantId.PANNEAU_STRUCTURE_FORM)) {
91 jpm 372
			((FormStructureVue) panneauCentre.getItem(0)).rafraichir(nouvelleDonnees);
373
		} else {
374
			GWT.log("Aucun panneau trouvé pour afficher la liste de valeur", null);
375
		}
376
	}
377
 
156 jp_milcent 378
	//+----------------------------------------------------------------------------------------------------------------+
379
	//												GESTION DES PUBLICATIONS
380
	//+----------------------------------------------------------------------------------------------------------------+
381
 
107 aurelien 382
	public void afficherListePublication(PublicationListe nouvelleDonnees) {
383
		PublicationVue publicationVue = new PublicationVue() ;
228 aurelien 384
		panneauCentre.removeAll();
107 aurelien 385
		panneauCentre.add(publicationVue);
186 gduche 386
		contenuPanneauCentre = publicationVue;
107 aurelien 387
		publicationVue.rafraichir(nouvelleDonnees);
388
 
389
	}
390
 
391
	public void clicListePublication(Publication publication) {
379 jp_milcent 392
		panneauCentre.rafraichir(publication);
107 aurelien 393
	}
394
 
395
	public void clicAjouterPublication() {
223 aurelien 396
		panneauCentre.removeAll();
397
		FormPublicationVue formPublicationVue = new FormPublicationVue();
398
		panneauCentre.add(formPublicationVue);
399
		panneauCentre.setId(ComposantId.PANNEAU_FORM_PUBLICATION);
400
		panneauCentre.layout();
107 aurelien 401
	}
156 jp_milcent 402
 
245 jp_milcent 403
	public void clicModifierPublication(List<Publication> publicationListe) {
404
		if(publicationListe.size() <= 0) {
315 gduche 405
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 406
		} else {
245 jp_milcent 407
			Publication pubAModifier = publicationListe.get(publicationListe.size() -1);
408
			panneauCentre.removeAll();
409
			FormPublicationVue formPublicationVue = new FormPublicationVue();
410
			panneauCentre.add(formPublicationVue);
411
			panneauCentre.setId(ComposantId.PANNEAU_FORM_PUBLICATION);
412
			panneauCentre.layout();
413
			formPublicationVue.rafraichir(pubAModifier);
414
		}
415
	}
416
 
315 gduche 417
	public void clicSupprimerPublication(final List<Publication> publicationListe) {
245 jp_milcent 418
		if(publicationListe.size() <= 0) {
315 gduche 419
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 420
		} else {
245 jp_milcent 421
			String message = "" ;
422
			if(publicationListe.size() == 1) {
423
				message = "Voulez-vous vraiment supprimer cette publication ?";
424
			}
425
			else {
426
				message = "Voulez-vous vraiment supprimer ces publication ?";
427
			}
315 gduche 428
 
429
 
430
			final Listener listenerSuppression = new Listener<ComponentEvent>() {
431
				public void handleEvent(ComponentEvent ce) {
432
 
433
					Dialog dialog = (Dialog) ce.component;
434
				    Button btn = dialog.getButtonPressed();
435
 
379 jp_milcent 436
				    if (btn.getText().equals(dialog.yesText)) {
315 gduche 437
				    	modele.supprimerPublication(contenuPanneauCentre, getUtilisateurId(),publicationListe);
438
				    }
439
				}
440
			};
441
 
442
			MessageBox.confirm("Supprimer une publication", message, listenerSuppression);
245 jp_milcent 443
		}
444
 
445
	}
446
 
277 jp_milcent 447
	public void ajouterPublication(FormPublicationVue formPublicationVue, Publication publi) {
448
		modele.ajouterPublication(contenuPanneauCentre, getUtilisateurId(),publi);
245 jp_milcent 449
	}
450
 
451
	public void modifierPublication(FormPublicationVue formPublicationVue, Publication publi) {
277 jp_milcent 452
		modele.modifierPublication(contenuPanneauCentre, getUtilisateurId(),publi);
245 jp_milcent 453
	}
454
 
277 jp_milcent 455
	public void clicObtenirListeEditeurs(Rafraichissable vue) {
456
		modele.selectionnerStructure(vue, null, null);
245 jp_milcent 457
	}
458
 
277 jp_milcent 459
	public void clicObtenirListeAuteurs(Rafraichissable vue) {
460
		modele.selectionnerPersonne(vue, null, null, null);
245 jp_milcent 461
	}
462
 
156 jp_milcent 463
	//+----------------------------------------------------------------------------------------------------------------+
464
	//												GESTION DES STRUCTURES
465
	//+----------------------------------------------------------------------------------------------------------------+
466
 
379 jp_milcent 467
	public void clicListeStructure(Structure structure) {
468
		contenuPanneauCentre.rafraichir(structure);
469
		if (structure.getPersonnel() == null) {
470
			selectionnerStructureAPersonne(contenuPanneauCentre, structure.getId(), StructureAPersonne.ROLE_EQUIPE);
471
		} else {
472
			GWT.log("OK personnel déjà chargé", null);
473
		}
156 jp_milcent 474
	}
475
 
278 jp_milcent 476
	public void afficherListeStructures(StructureListe structuresACharger) {
156 jp_milcent 477
		// TODO : créer dès l'initialisation de l'application InsitutionVue et la cacher
373 jp_milcent 478
		StructureVue institutionVue = new StructureVue(this);
156 jp_milcent 479
		panneauCentre.add(institutionVue);
480
		panneauCentre.setId(ComposantId.PANNEAU_STRUCTURE_LISTE);
481
		contenuPanneauCentre = institutionVue;
278 jp_milcent 482
		institutionVue.rafraichir(structuresACharger);
156 jp_milcent 483
	}
484
 
485
	public void clicAjouterStructure() {
486
		panneauCentre.removeAll();
402 jp_milcent 487
		FormStructureVue formStructureVue = new FormStructureVue(this, FormStructureVue.MODE_AJOUTER);
156 jp_milcent 488
		panneauCentre.add(formStructureVue);
489
		panneauCentre.setId(ComposantId.PANNEAU_STRUCTURE_FORM);
490
		panneauCentre.layout();
491
	}
492
 
265 jp_milcent 493
	public void clicModifierStructure(List<Structure> structureSelection) {
494
		if (structureSelection.size() == 0) {
495
			Info.display("Information", "Veuillez sélectionner une structure.");
379 jp_milcent 496
		} else if (structureSelection.size() > 1) {
265 jp_milcent 497
			Info.display("Information", "Veuillez sélectionner une seule structure à la fois.");
379 jp_milcent 498
		} else if (structureSelection.size() == 1) {
265 jp_milcent 499
			panneauCentre.removeAll();
402 jp_milcent 500
			FormStructureVue formStructureVue = new FormStructureVue(this, FormStructureVue.MODE_MODIFIER);
265 jp_milcent 501
			panneauCentre.add(formStructureVue);
502
			panneauCentre.setId(ComposantId.PANNEAU_STRUCTURE_FORM);
503
 
504
			selectionnerStructure(formStructureVue, structureSelection.get(0).getId());
505
			selectionnerStructureAPersonne(formStructureVue, structureSelection.get(0).getId(), StructureAPersonne.ROLE_EQUIPE);
506
 
507
			panneauCentre.layout();
508
		} else {
509
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierStructure() du Médiateur.");
510
		}
511
 
119 jpm 512
	}
265 jp_milcent 513
 
315 gduche 514
	public void clicSupprimerStructure(final Rafraichissable vue, final List<Structure> structureSelection) {
156 jp_milcent 515
		if (structureSelection.size() == 0) {
516
			Info.display("Information", "Veuillez sélectionner une structure.");
517
		} else if(structureSelection.size() > 0) {
518
			String message = "Êtes vous sur de vouloir supprimer les structures sélectionnées ?";
519
			if (structureSelection.size() == 1) {
520
				message = "Êtes vous sur de vouloir supprimer la structure sélectionnée ?";
521
			}
315 gduche 522
 
523
 
524
			final Listener listenerSuppression = new Listener<ComponentEvent>() {
525
 
526
			       public void handleEvent(ComponentEvent ce) {
527
 
528
			    	   Dialog dialog = (Dialog) ce.component;
529
			    	   Button btn = dialog.getButtonPressed();
530
 
531
			    	   if (btn.getText().equals(dialog.yesText))	{
532
			    		   	String idStr = "" ;
533
							for(int i = 0 ; i < structureSelection.size() ; i++) {
534
								idStr += structureSelection.get(i).getId()+"," ;
535
							}
536
							modele.supprimerStructure(vue, getUtilisateurId(), idStr);
537
					       }
538
				      }
539
				     };
540
 
541
			MessageBox.confirm("Supprimer une structure", message, listenerSuppression);
542
 
134 jpm 543
		} else {
156 jp_milcent 544
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerStructure() du Médiateur.");
134 jpm 545
		}
546
	}
142 gduche 547
 
265 jp_milcent 548
	public void selectionnerStructure(Rafraichissable vue, String structureId) {
549
		GWT.log("Structure : "+structureId, null);
277 jp_milcent 550
		modele.selectionnerStructure(vue, null, structureId);
156 jp_milcent 551
	}
552
 
265 jp_milcent 553
	/**
554
	 * TODO : afficher un message du type "Structure ajoutée".
555
	 * Lance la creation d'une structure
556
	 * @param les données de la structure saisie
557
	 */
277 jp_milcent 558
	public void ajouterStructure(Rafraichissable vue, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
559
		modele.ajouterStructure(vue, getUtilisateurId(), structure, conservation, valorisation);
265 jp_milcent 560
	}
561
 
306 jp_milcent 562
	public void modifierStructure(Rafraichissable vue, String structureId, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
563
		modele.modifierStructure(vue, getUtilisateurId(), structureId, structure, conservation, valorisation);
156 jp_milcent 564
	}
231 jp_milcent 565
 
265 jp_milcent 566
	//+----------------------------------------------------------------------------------------------------------------+
567
	// GESTION de la relation STRUCTURE A PERSONNE
231 jp_milcent 568
	public void selectionnerStructureAPersonne(Rafraichissable vue, String structureId, String roleId) {
265 jp_milcent 569
		GWT.log("Structure : "+structureId, null);
570
		modele.selectionnerStructureAPersonne(vue, getUtilisateurId(), null, structureId, roleId);
231 jp_milcent 571
	}
156 jp_milcent 572
 
231 jp_milcent 573
	public void modifierStructureAPersonne(Rafraichissable vue, StructureAPersonneListe personnelModifie) {
574
		if (personnelModifie != null && personnelModifie.size() > 0) {
575
			GWT.log("Mediateur :modif", null);
576
			for (Iterator<String> it = personnelModifie.keySet().iterator(); it.hasNext();) {
577
				modele.modifierStructureAPersonne(vue, getUtilisateurId(), (StructureAPersonne) personnelModifie.get(it.next()));
578
			}
579
		}
580
	}
581
 
582
	public void ajouterStructureAPersonne(Rafraichissable vue, String structureId, StructureAPersonneListe personnelAjoute) {
583
		if (personnelAjoute != null && personnelAjoute.size() > 0) {
584
			for (Iterator<String> it = personnelAjoute.keySet().iterator(); it.hasNext();) {
585
				modele.ajouterStructureAPersonne(vue, getUtilisateurId(), structureId, (StructureAPersonne) personnelAjoute.get(it.next()));
586
			}
587
		}
588
	}
589
 
590
	public void supprimerStructureAPersonne(Rafraichissable vue, StructureAPersonneListe personnelSupprime) {
591
		if (personnelSupprime != null && personnelSupprime.size() > 0) {
592
			String idStrAPer = "" ;
593
			for (Iterator<String> it = personnelSupprime.keySet().iterator(); it.hasNext();) {
594
					idStrAPer += personnelSupprime.get(it.next()).getId()+"," ;
595
			}
596
			modele.supprimerStructureAPersonne(vue, getUtilisateurId(), idStrAPer);
597
		}
598
	}
599
 
156 jp_milcent 600
	//+----------------------------------------------------------------------------------------------------------------+
601
	//												GESTION des PROJETS
602
	//+----------------------------------------------------------------------------------------------------------------+
603
 
245 jp_milcent 604
	/**
605
	 * Retourne l'identifiant du projet courrant de l'application.
606
	 */
607
	public String getProjetId() {
277 jp_milcent 608
		String id = null;
609
		Projet projetCourant = (Projet) Registry.get(RegistreId.PROJET_COURANT);
279 jp_milcent 610
		if (projetCourant != null && !projetCourant.getId().equals("")) {
277 jp_milcent 611
			id = projetCourant.getId();
612
		}
613
		return id;
245 jp_milcent 614
	}
615
 
142 gduche 616
	//Greg : ajout d'un écouteur pour le changement liste projet
277 jp_milcent 617
	public void selectionnerProjets(Rafraichissable vue)	{
618
		modele.selectionnerProjets(vue);
142 gduche 619
	}
620
 
268 jp_milcent 621
	public void afficherListeProjets(ProjetListe projets)	{
277 jp_milcent 622
		panneauOuest.rafraichir(projets);
142 gduche 623
	}
159 gduche 624
 
277 jp_milcent 625
	public void selectionnerProjetCourant(Projet projetSelectionne) {
626
		Registry.register(RegistreId.PROJET_COURANT, projetSelectionne);
186 gduche 627
		if (contenuPanneauCentre instanceof PersonneVue)	{
277 jp_milcent 628
			modele.selectionnerPersonne(contenuPanneauCentre, null, getProjetId(), null);
186 gduche 629
			//FIXME Le rafraichissement du panneau ne se fait pas!
277 jp_milcent 630
		} else if (contenuPanneauCentre instanceof StructureVue)	{
631
			modele.obtenirListeStructures(contenuPanneauCentre, getProjetId());
186 gduche 632
		}
159 gduche 633
	}
237 aurelien 634
 
277 jp_milcent 635
	//+----------------------------------------------------------------------------------------------------------------+
636
	//	RAFRAICHISSEMENT
637
	//+----------------------------------------------------------------------------------------------------------------+
638
 
639
	public void rafraichir(Object nouvelleDonnees) {
640
		if (nouvelleDonnees instanceof Utilisateur) {
641
			mettreAJourEtatIdentification((Utilisateur) nouvelleDonnees);
278 jp_milcent 642
		} else {
643
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
277 jp_milcent 644
		}
645
	}
281 gduche 646
 
647
	/**
648
	 * Récupère la liste et rafraichit la vue donnée
649
	 *
650
	 * @param la vue à rafraichir
651
	 * @param l'id de la liste à récupérer
652
	 * */
369 jp_milcent 653
	public void obtenirListeValeurEtRafraichir(Rafraichissable vue, String listeId)	{
654
		modele.obtenirListeValeurs(vue, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId));
281 gduche 655
	}
288 gduche 656
 
369 jp_milcent 657
	public void obtenirValeurEtRafraichir(Rafraichissable vue, String listeId, String identifiantValeur)	{
658
		modele.obtenirValeur(vue, "abv", ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId), identifiantValeur);
301 gduche 659
	}
660
 
288 gduche 661
	public void obtenirListeRegionsEtRafraichir(Rafraichissable vue, String strListeId, String strPays)	{
662
		modele.obtenirListeRegion(vue, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(strListeId), strPays+".__");
663
	}
332 gduche 664
 
665
	/**
666
	 * 	Affiche la popin de chargement
667
	 */
668
	public void afficherPopinChargement()	{
669
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).center();
670
	}
671
 
672
 
673
	public void masquerPopinChargement()	{
674
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).hide();
675
	}
277 jp_milcent 676
}