Subversion Repositories eFlore/Applications.coel

Rev

Rev 765 | Rev 767 | 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;
466 gduche 10
import org.tela_botanica.client.i18n.ErrorMessages;
119 jpm 11
import org.tela_botanica.client.interfaces.Rafraichissable;
447 jp_milcent 12
import org.tela_botanica.client.modeles.Collection;
453 jp_milcent 13
import org.tela_botanica.client.modeles.CollectionListe;
61 jpm 14
import org.tela_botanica.client.modeles.Configuration;
156 jp_milcent 15
import org.tela_botanica.client.modeles.Information;
327 jp_milcent 16
import org.tela_botanica.client.modeles.MenuApplicationId;
142 gduche 17
import org.tela_botanica.client.modeles.Personne;
128 gduche 18
import org.tela_botanica.client.modeles.PersonneListe;
245 jp_milcent 19
import org.tela_botanica.client.modeles.Projet;
268 jp_milcent 20
import org.tela_botanica.client.modeles.ProjetListe;
107 aurelien 21
import org.tela_botanica.client.modeles.Publication;
22
import org.tela_botanica.client.modeles.PublicationListe;
60 jpm 23
import org.tela_botanica.client.modeles.Structure;
209 jp_milcent 24
import org.tela_botanica.client.modeles.StructureAPersonne;
231 jp_milcent 25
import org.tela_botanica.client.modeles.StructureAPersonneListe;
188 jp_milcent 26
import org.tela_botanica.client.modeles.StructureConservation;
69 jpm 27
import org.tela_botanica.client.modeles.StructureListe;
195 jp_milcent 28
import org.tela_botanica.client.modeles.StructureValorisation;
61 jpm 29
import org.tela_botanica.client.modeles.Utilisateur;
91 jpm 30
import org.tela_botanica.client.modeles.ValeurListe;
641 jp_milcent 31
import org.tela_botanica.client.vues.CollectionForm;
447 jp_milcent 32
import org.tela_botanica.client.vues.CollectionListeVue;
453 jp_milcent 33
import org.tela_botanica.client.vues.CollectionVue;
444 jp_milcent 34
import org.tela_botanica.client.vues.ContenuVue;
35
import org.tela_botanica.client.vues.EnteteVue;
641 jp_milcent 36
import org.tela_botanica.client.vues.Formulaire;
438 gduche 37
import org.tela_botanica.client.vues.PersonneForm;
444 jp_milcent 38
import org.tela_botanica.client.vues.PublicationForm;
39
import org.tela_botanica.client.vues.StructureForm;
128 gduche 40
import org.tela_botanica.client.vues.PersonneVue;
332 gduche 41
import org.tela_botanica.client.vues.PopupChargement;
107 aurelien 42
import org.tela_botanica.client.vues.PublicationVue;
443 jp_milcent 43
import org.tela_botanica.client.vues.StatutVue;
60 jpm 44
import org.tela_botanica.client.vues.StructureVue;
444 jp_milcent 45
import org.tela_botanica.client.vues.MenuVue;
467 jp_milcent 46
 
60 jpm 47
import com.extjs.gxt.ui.client.Registry;
48
import com.extjs.gxt.ui.client.Style.LayoutRegion;
315 gduche 49
import com.extjs.gxt.ui.client.event.Listener;
502 gduche 50
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
60 jpm 51
import com.extjs.gxt.ui.client.util.Margins;
646 jp_milcent 52
import com.extjs.gxt.ui.client.widget.Component;
315 gduche 53
import com.extjs.gxt.ui.client.widget.Dialog;
156 jp_milcent 54
import com.extjs.gxt.ui.client.widget.Info;
315 gduche 55
import com.extjs.gxt.ui.client.widget.MessageBox;
60 jpm 56
import com.extjs.gxt.ui.client.widget.Viewport;
315 gduche 57
import com.extjs.gxt.ui.client.widget.button.Button;
60 jpm 58
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
59
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
91 jpm 60
import com.google.gwt.core.client.GWT;
599 gduche 61
import com.google.gwt.i18n.client.Dictionary;
60 jpm 62
import com.google.gwt.user.client.Window;
63
import com.google.gwt.user.client.ui.RootPanel;
64
 
277 jp_milcent 65
public class Mediateur implements Rafraichissable {
60 jpm 66
 
358 jp_milcent 67
	private Viewport viewport;
119 jpm 68
	private Modele modele = null;
582 jp_milcent 69
	public static final Constantes i18nC = getI18nConstante();
70
	public static final ErrorMessages i18nM = getI18nMessage();
119 jpm 71
 
444 jp_milcent 72
	private EnteteVue panneauNord = null;
73
	private MenuVue panneauOuest = null;
74
	private ContenuVue panneauCentre = null;
443 jp_milcent 75
	private StatutVue panneauSud = null;
60 jpm 76
 
358 jp_milcent 77
	private IdentificationFenetre fenetreIdentification = null;
78
 
60 jpm 79
	public Mediateur() {
80
		// Enregistrement du Médiateur dans le Registre
81
		Registry.register(RegistreId.MEDIATEUR, this);
765 jpm 82
 
83
		//Initialisation du Registre
84
		initialiserRegistre();
466 gduche 85
 
60 jpm 86
		// Création du Modèle qui s'enregistre lui même dans le Registre
119 jpm 87
		modele = new Modele();
535 jp_milcent 88
 
60 jpm 89
		// Création du Viewport qui contient la disposition globale de l'application
90
		viewport = new Viewport();
91
		viewport.setLayout(new BorderLayout());
552 jp_milcent 92
 
60 jpm 93
		// Création des différents panneaux
94
	    creerPanneauNord();
95
	    creerPanneauOuest();
96
	    creerPanneauCentral();
358 jp_milcent 97
	    creerPanneauSud();
535 jp_milcent 98
 
99
		// Connection de l'utilisateur
100
		connecterUtilisateur(null, null);
101
 
60 jpm 102
		// Retour à GWT du Viewport une fois constuit
103
		RootPanel.get().add(viewport);
104
	}
105
 
156 jp_milcent 106
	//+----------------------------------------------------------------------------------------------------------------+
535 jp_milcent 107
	//												GESTION de l'I18N et du REGISTRE
108
	//+----------------------------------------------------------------------------------------------------------------+
582 jp_milcent 109
	protected static Constantes getI18nConstante() {
535 jp_milcent 110
		return GWT.create(Constantes.class);
111
	}
112
 
582 jp_milcent 113
	protected static ErrorMessages getI18nMessage() {
535 jp_milcent 114
		return GWT.create(ErrorMessages.class);
115
	}
116
 
117
	protected void initialiserRegistre() {
118
		Registry.register(RegistreId.APPLI_NOM, i18nC.appliNom());
119
		Registry.register(RegistreId.APPLI_CODE, i18nC.appliCode());
120
		Registry.register(RegistreId.APPLI_VERSION, i18nC.appliVersionNumero());
121
		Registry.register(RegistreId.APPLI_REVISION, "$Revision: 501 $");
122
 
123
		Registry.register(RegistreId.CONFIG, new Configuration());
537 jp_milcent 124
		Registry.register(RegistreId.POPUP_CHARGEMENT, new PopupChargement(this));
766 jpm 125
		Registry.register(RegistreId.UTILISATEUR_COURANT, new Utilisateur());
535 jp_milcent 126
		Registry.register(RegistreId.PROJET_COURANT, new Projet());
127
	}
128
 
129
	//+----------------------------------------------------------------------------------------------------------------+
156 jp_milcent 130
	//												GESTION des PANNEAUX PRINCIPAUX
131
	//+----------------------------------------------------------------------------------------------------------------+
119 jpm 132
 
60 jpm 133
	private void creerPanneauNord() {
444 jp_milcent 134
		panneauNord = new EnteteVue(this);
60 jpm 135
 
136
		BorderLayoutData regionNord = new BorderLayoutData(LayoutRegion.NORTH, 100);
137
		regionNord.setCollapsible(true);
138
		regionNord.setFloatable(true);
139
		regionNord.setSplit(false);
140
		regionNord.setMargins(new Margins(5, 5, 0, 5));
141
 
142
		viewport.add(panneauNord, regionNord);
143
	}
144
 
145
	private void creerPanneauOuest() {
444 jp_milcent 146
		panneauOuest = new MenuVue(this);
60 jpm 147
 
148
		BorderLayoutData regionOuest = new BorderLayoutData(LayoutRegion.WEST, 200);
149
		regionOuest.setSplit(true);
150
		regionOuest.setCollapsible(true);
151
		regionOuest.setMargins(new Margins(5));
152
 
153
		viewport.add(panneauOuest, regionOuest);
154
	}
155
 
156
	private void creerPanneauCentral() {
444 jp_milcent 157
		panneauCentre = new ContenuVue(this);
60 jpm 158
 
159
		BorderLayoutData regionCentre = new BorderLayoutData(LayoutRegion.CENTER);
160
		regionCentre.setMargins(new Margins(5, 5, 5, 0));
161
 
162
		viewport.add(panneauCentre, regionCentre);
163
	}
358 jp_milcent 164
 
165
	private void creerPanneauSud() {
443 jp_milcent 166
		panneauSud = new StatutVue();
358 jp_milcent 167
 
369 jp_milcent 168
		BorderLayoutData regionSud = new BorderLayoutData(LayoutRegion.SOUTH, 20);
358 jp_milcent 169
		regionSud.setCollapsible(true);
170
		regionSud.setFloatable(true);
171
		regionSud.setSplit(false);
172
		regionSud.setMargins(new Margins(0));
173
 
174
		viewport.add(panneauSud, regionSud);
175
	}
60 jpm 176
 
369 jp_milcent 177
	public void actualiserPanneauCentral() {
178
		panneauCentre.layout();
179
	}
180
 
156 jp_milcent 181
	//+----------------------------------------------------------------------------------------------------------------+
182
	//												GESTION du MENU
183
	//+----------------------------------------------------------------------------------------------------------------+
184
 
327 jp_milcent 185
	public void clicMenu(String codeMenuClique) {
358 jp_milcent 186
		activerChargement(codeMenuClique);
327 jp_milcent 187
		if (codeMenuClique.equals(MenuApplicationId.STRUCTURE)) {
646 jp_milcent 188
			selectionnerStructure(panneauCentre, null);
553 jp_milcent 189
		} else if (codeMenuClique.equals(MenuApplicationId.COLLECTION)) {
190
			selectionnerCollection(panneauCentre, null);
191
		} else if (codeMenuClique.equals(MenuApplicationId.PERSONNE)) {
599 gduche 192
			selectionnerPersonne(panneauCentre, null, null);
327 jp_milcent 193
		} else if (codeMenuClique.equals(MenuApplicationId.PUBLICATION)) {
715 aurelien 194
			modele.selectionnerPublication(panneauCentre,null,null,null);
379 jp_milcent 195
		} else {
327 jp_milcent 196
			GWT.log("Non implémenté! Menu id : "+codeMenuClique, null);
60 jpm 197
		}
198
		panneauCentre.layout();
199
	}
200
 
358 jp_milcent 201
	public void activerChargement(String message) {
202
		afficherPopinChargement();
369 jp_milcent 203
		panneauSud.showBusy(i18nC.chargement()+" "+message);
358 jp_milcent 204
	}
205
 
206
	public void desactiverChargement() {
207
		masquerPopinChargement();
208
		panneauSud.clear();
209
	}
646 jp_milcent 210
 
156 jp_milcent 211
	//+----------------------------------------------------------------------------------------------------------------+
212
	//												GESTION DES FENÊTRES
213
	//+----------------------------------------------------------------------------------------------------------------+
60 jpm 214
 
61 jpm 215
	public void ouvrirAide() {
216
		AideFenetre aideFenetre = new AideFenetre();
217
		aideFenetre.show();
66 jpm 218
		// FIXME : apparament le fade In/Fade Out pose problème sur les navigateurs...
219
		//aideFenetre.el().fadeIn(FxConfig.NONE);
61 jpm 220
	}
221
 
222
	public void ouvrirParametres() {
66 jpm 223
		ParametreFenetre parametresFenetre = new ParametreFenetre();
224
		parametresFenetre.show();
61 jpm 225
	}
226
 
227
	public void ouvrirIdentification() {
358 jp_milcent 228
		fenetreIdentification = new IdentificationFenetre();
229
		fenetreIdentification.show();
61 jpm 230
	}
231
 
232
	public void ouvrirApplis(String id) {
233
		if (id.equals(ComposantId.MENU_CEL)) {
234
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getCelUrl(), "Carnet en ligne", "");
235
		} else if (id.equals(ComposantId.MENU_BEL)) {
134 jpm 236
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getCelUrl(), "Biblio en ligne", "");
61 jpm 237
		}
238
	}
239
 
156 jp_milcent 240
	//+----------------------------------------------------------------------------------------------------------------+
241
	//												GESTION de l'UTILISATEUR et de l'IDENTIFICATION
242
	//+----------------------------------------------------------------------------------------------------------------+
245 jp_milcent 243
	/**
244
	 * Retourne l'identifiant de l'utilisateur courrant de l'application.
245
	 */
156 jp_milcent 246
	public String getUtilisateurId() {
277 jp_milcent 247
		String id = null;
248
		Utilisateur utilisateurCourant = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
249
		if (!utilisateurCourant.getId().equals("")) {
250
			id = utilisateurCourant.getId();
251
		}
252
		return id;
156 jp_milcent 253
	}
254
 
65 jpm 255
	public void connecterUtilisateur(String login, String mdp) {
277 jp_milcent 256
		modele.connecterUtilisateur(this, login, mdp);
64 jpm 257
	}
258
 
65 jpm 259
	public void deconnecterUtilisateur() {
277 jp_milcent 260
		modele.deconnecterUtilisateur(this);
64 jpm 261
	}
65 jpm 262
 
64 jpm 263
	public void mettreAJourEtatIdentification(Utilisateur utilisateur) {
156 jp_milcent 264
		// Mise à jour du registre
277 jp_milcent 265
		Registry.register(RegistreId.UTILISATEUR_COURANT, utilisateur);
156 jp_milcent 266
		// Création de l'information de mise à jour de l'utilisateur
267
		Information info = new Information("maj_utilisateur");
358 jp_milcent 268
 
269
		// Rafraichissement de la fenêtre d'Identification
270
		if (fenetreIdentification != null) {
271
			fenetreIdentification.rafraichir(info);
272
		}
156 jp_milcent 273
 
274
		// Rafraichissement du panneau Nord
275
		panneauNord.rafraichir(info);
276
 
277
		// Rafraichissement du panneau Centre
646 jp_milcent 278
		if (panneauCentre != null) {
279
			panneauCentre.rafraichir(info);
156 jp_milcent 280
		}
61 jpm 281
	}
66 jpm 282
 
156 jp_milcent 283
	//+----------------------------------------------------------------------------------------------------------------+
447 jp_milcent 284
	//												GESTION DES VALEURS ET LISTES
285
	//+----------------------------------------------------------------------------------------------------------------+
286
 
568 jp_milcent 287
	public void obtenirListeValeurEtRafraichir(Rafraichissable vueARafraichir, String listeId)	{
288
		modele.obtenirListeValeurs(vueARafraichir, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId));
453 jp_milcent 289
	}
447 jp_milcent 290
 
453 jp_milcent 291
	public void obtenirValeurEtRafraichir(Rafraichissable vue, String listeId, String identifiantValeur)	{
292
		modele.obtenirValeur(vue, "abv", ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId), identifiantValeur);
293
	}
294
 
295
	public void obtenirListeRegionsEtRafraichir(Rafraichissable vue, String strListeId, String strPays)	{
296
		modele.obtenirListeRegion(vue, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(strListeId), strPays+".__");
297
	}
298
 
447 jp_milcent 299
	//+----------------------------------------------------------------------------------------------------------------+
300
	//												GESTION des PROJETS
301
	//+----------------------------------------------------------------------------------------------------------------+
302
 
303
	/**
304
	 * Retourne l'identifiant du projet courrant de l'application.
305
	 */
306
	public String getProjetId() {
307
		String id = null;
308
		Projet projetCourant = (Projet) Registry.get(RegistreId.PROJET_COURANT);
309
		if (projetCourant != null && !projetCourant.getId().equals("")) {
310
			id = projetCourant.getId();
311
		}
312
		return id;
313
	}
314
 
315
	//Greg : ajout d'un écouteur pour le changement liste projet
552 jp_milcent 316
	public void selectionnerProjets(Rafraichissable vueARafraichir)	{
317
		modele.selectionnerProjets(vueARafraichir);
447 jp_milcent 318
	}
319
 
320
	public void afficherListeProjets(ProjetListe projets)	{
321
		panneauOuest.rafraichir(projets);
322
	}
323
 
324
	public void selectionnerProjetCourant(Projet projetSelectionne) {
325
		Registry.register(RegistreId.PROJET_COURANT, projetSelectionne);
646 jp_milcent 326
		if (panneauCentre.getContenu() instanceof PersonneVue) {
599 gduche 327
			//modele.selectionnerPersonne(contenuPanneauCentre, null, getProjetId(), null);
646 jp_milcent 328
			selectionnerPersonne(panneauCentre, null, getProjetId());
447 jp_milcent 329
			//FIXME Le rafraichissement du panneau ne se fait pas!
646 jp_milcent 330
		} else if (panneauCentre.getContenu() instanceof StructureVue)	{
331
			modele.selectionnerStructure(panneauCentre.getContenu(), getProjetId(), null);
332
		} else if (panneauCentre.getContenu() instanceof CollectionVue)	{
333
			modele.selectionnerCollection(panneauCentre.getContenu(), getProjetId(), null);
447 jp_milcent 334
		}
335
	}
336
 
337
	//+----------------------------------------------------------------------------------------------------------------+
338
	//												GESTION DES STRUCTURES
339
	//+----------------------------------------------------------------------------------------------------------------+
340
 
453 jp_milcent 341
	public void afficherListeStructures(StructureListe structuresACharger) {
646 jp_milcent 342
		if (!(panneauCentre.getContenu() instanceof StructureVue))	{
626 gduche 343
			panneauCentre.removeAll();
646 jp_milcent 344
			panneauCentre.add(new StructureVue(this));
626 gduche 345
		}
646 jp_milcent 346
		panneauCentre.getContenu().rafraichir(structuresACharger);
453 jp_milcent 347
	}
348
 
580 jp_milcent 349
	public void afficherFormStructure(String structureId) {
641 jp_milcent 350
		String mode = Formulaire.MODE_AJOUTER;
580 jp_milcent 351
		if (structureId != null) {
641 jp_milcent 352
			mode = Formulaire.MODE_MODIFIER;
580 jp_milcent 353
		}
354
 
355
		panneauCentre.removeAll();
356
		StructureForm structureForm = new StructureForm(this, mode);
357
		panneauCentre.add(structureForm);
358
 
641 jp_milcent 359
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
580 jp_milcent 360
			selectionnerStructure(structureForm, structureId);
361
			selectionnerStructureAPersonne(structureForm, structureId, StructureAPersonne.ROLE_EQUIPE);
362
		}
363
 
364
		panneauCentre.layout();
365
	}
366
 
447 jp_milcent 367
	public void clicListeStructure(Structure structure) {
646 jp_milcent 368
		panneauCentre.getContenu().rafraichir(structure);
609 jp_milcent 369
		if (structure != null && structure.getPersonnel() == null) {
646 jp_milcent 370
			selectionnerStructureAPersonne(panneauCentre.getContenu(), structure.getId(), StructureAPersonne.ROLE_EQUIPE);
447 jp_milcent 371
		} else {
372
			GWT.log("OK personnel déjà chargé", null);
373
		}
374
	}
375
 
376
	public void clicAjouterStructure() {
580 jp_milcent 377
		afficherFormStructure(null);
447 jp_milcent 378
	}
379
 
380
	public void clicModifierStructure(List<Structure> structureSelection) {
381
		if (structureSelection.size() == 0) {
382
			Info.display("Information", "Veuillez sélectionner une structure.");
383
		} else if (structureSelection.size() > 1) {
384
			Info.display("Information", "Veuillez sélectionner une seule structure à la fois.");
385
		} else if (structureSelection.size() == 1) {
609 jp_milcent 386
			afficherFormStructure(structureSelection.get(0).getId());
447 jp_milcent 387
		} else {
388
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierStructure() du Médiateur.");
389
		}
390
	}
391
 
392
	public void clicSupprimerStructure(final Rafraichissable vue, final List<Structure> structureSelection) {
393
		if (structureSelection.size() == 0) {
394
			Info.display("Information", "Veuillez sélectionner une structure.");
395
		} else if(structureSelection.size() > 0) {
609 jp_milcent 396
			String titre = "Supprimer des structures";
447 jp_milcent 397
			String message = "Êtes vous sur de vouloir supprimer les structures sélectionnées ?";
398
			if (structureSelection.size() == 1) {
609 jp_milcent 399
				titre = "Supprimer une structure";
447 jp_milcent 400
				message = "Êtes vous sur de vouloir supprimer la structure sélectionnée ?";
401
			}
402
 
502 gduche 403
			final Listener<MessageBoxEvent> suppressionEcouteur = new Listener<MessageBoxEvent>() {
404
				public void handleEvent(MessageBoxEvent ce) {
405
					Dialog dialog = (Dialog) ce.getComponent();
406
					Button btn = ce.getButtonClicked();
453 jp_milcent 407
 
408
					if (btn.getText().equals(dialog.yesText))	{
409
						String idStr = "" ;
410
						for(int i = 0 ; i < structureSelection.size() ; i++) {
609 jp_milcent 411
							idStr += structureSelection.get(i).getId()+",";
453 jp_milcent 412
						}
413
						supprimerStructure(vue, idStr);
414
					}
415
				}
416
			};
447 jp_milcent 417
 
609 jp_milcent 418
			MessageBox.confirm(titre, message, suppressionEcouteur);
447 jp_milcent 419
		} else {
420
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerStructure() du Médiateur.");
421
		}
422
	}
423
 
424
	public void selectionnerStructure(Rafraichissable vue, String structureId) {
453 jp_milcent 425
		modele.selectionnerStructure(vue, getProjetId(), structureId);
447 jp_milcent 426
	}
427
 
428
	public void ajouterStructure(Rafraichissable vue, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
429
		modele.ajouterStructure(vue, getUtilisateurId(), structure, conservation, valorisation);
430
	}
431
 
432
	public void modifierStructure(Rafraichissable vue, String structureId, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
433
		modele.modifierStructure(vue, getUtilisateurId(), structureId, structure, conservation, valorisation);
434
	}
453 jp_milcent 435
 
436
	public void supprimerStructure(Rafraichissable vueARafraichir, String IdentifiantsStructureSepareParVirgule) {
437
		modele.supprimerStructure(vueARafraichir, getUtilisateurId(), IdentifiantsStructureSepareParVirgule);
438
	}
439
 
447 jp_milcent 440
	//+----------------------------------------------------------------------------------------------------------------+
441
	// GESTION de la relation STRUCTURE A PERSONNE
442
	public void selectionnerStructureAPersonne(Rafraichissable vue, String structureId, String roleId) {
443
		GWT.log("Structure : "+structureId, null);
444
		modele.selectionnerStructureAPersonne(vue, getUtilisateurId(), null, structureId, roleId);
445
	}
446
 
453 jp_milcent 447
	public void ajouterStructureAPersonne(Rafraichissable vue, String structureId, StructureAPersonneListe personnelAjoute) {
448
		if (personnelAjoute != null && personnelAjoute.size() > 0) {
449
			for (Iterator<String> it = personnelAjoute.keySet().iterator(); it.hasNext();) {
450
				modele.ajouterStructureAPersonne(vue, getUtilisateurId(), structureId, (StructureAPersonne) personnelAjoute.get(it.next()));
451
			}
452
		}
453
	}
454
 
447 jp_milcent 455
	public void modifierStructureAPersonne(Rafraichissable vue, StructureAPersonneListe personnelModifie) {
456
		if (personnelModifie != null && personnelModifie.size() > 0) {
457
			GWT.log("Mediateur :modif", null);
458
			for (Iterator<String> it = personnelModifie.keySet().iterator(); it.hasNext();) {
459
				modele.modifierStructureAPersonne(vue, getUtilisateurId(), (StructureAPersonne) personnelModifie.get(it.next()));
460
			}
461
		}
462
	}
463
 
464
	public void supprimerStructureAPersonne(Rafraichissable vue, StructureAPersonneListe personnelSupprime) {
465
		if (personnelSupprime != null && personnelSupprime.size() > 0) {
466
			String idStrAPer = "" ;
467
			for (Iterator<String> it = personnelSupprime.keySet().iterator(); it.hasNext();) {
468
					idStrAPer += personnelSupprime.get(it.next()).getId()+"," ;
469
			}
470
			modele.supprimerStructureAPersonne(vue, getUtilisateurId(), idStrAPer);
471
		}
472
	}
473
 
474
	//+----------------------------------------------------------------------------------------------------------------+
475
	//												GESTION des COLLECTIONS
476
	//+----------------------------------------------------------------------------------------------------------------+
477
 
453 jp_milcent 478
	public void afficherListeCollections(CollectionListe collectionsACharger) {
646 jp_milcent 479
		if (!(panneauCentre.getContenu() instanceof CollectionVue)) {
626 gduche 480
			panneauCentre.removeAll();
646 jp_milcent 481
			panneauCentre.add(new CollectionVue(this));
482
		}
626 gduche 483
 
646 jp_milcent 484
		panneauCentre.getContenu().rafraichir(collectionsACharger);
453 jp_milcent 485
	}
486
 
641 jp_milcent 487
	public void afficherFormCollection(String collectionId) {
488
		String mode = Formulaire.MODE_AJOUTER;
489
		if (collectionId != null) {
490
			mode = Formulaire.MODE_MODIFIER;
491
		}
492
 
493
		panneauCentre.removeAll();
494
		CollectionForm collectionForm = new CollectionForm(this, mode);
495
		panneauCentre.add(collectionForm);
496
 
497
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
498
			selectionnerCollection(collectionForm, collectionId);
499
		}
500
 
501
		panneauCentre.layout();
502
	}
503
 
453 jp_milcent 504
	public void clicListeCollection(Collection collectionCliquee) {
646 jp_milcent 505
		panneauCentre.getContenu().rafraichir(collectionCliquee);
453 jp_milcent 506
	}
507
 
447 jp_milcent 508
	public void clicAjouterCollection() {
509
		// TODO Auto-generated method stub
510
 
511
	}
512
 
513
	public void clicModifierCollection(List<Collection> selection) {
641 jp_milcent 514
		if (selection.size() == 0) {
515
			Info.display("Information", "Veuillez sélectionner une collection.");
516
		} else if (selection.size() > 1) {
517
			Info.display("Information", "Veuillez sélectionner une seule collection à la fois.");
518
		} else if (selection.size() == 1) {
519
			afficherFormCollection(selection.get(0).getId());
520
		} else {
521
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierCollection() du Médiateur.");
522
		}
447 jp_milcent 523
	}
524
 
453 jp_milcent 525
	public void clicSupprimerCollection(CollectionListeVue collectionListeVue, List<Collection> collectionsASupprimer) {
447 jp_milcent 526
		// TODO Auto-generated method stub
527
 
528
	}
529
 
467 jp_milcent 530
	public void selectionnerCollection(Rafraichissable vueARafraichir, String collectionId) {
531
		modele.selectionnerCollection(vueARafraichir, getProjetId(), collectionId);
453 jp_milcent 532
	}
533
 
534
	public void ajouterCollection(Rafraichissable vueARafraichir, Collection collection) {
535
		modele.ajouterCollection(vueARafraichir, getUtilisateurId(), collection);
536
	}
537
 
538
	public void modifierCollection(Rafraichissable vueARafraichir, Collection collection) {
539
		modele.modifierCollection(vueARafraichir, getUtilisateurId(), collection);
540
	}
541
 
542
	public void supprimerCollection(Rafraichissable vueARafraichir, String IdentifiantsCollectionSepareParVirgule) {
543
		modele.supprimerCollection(vueARafraichir, getUtilisateurId(), IdentifiantsCollectionSepareParVirgule);
544
	}
545
 
447 jp_milcent 546
	//+----------------------------------------------------------------------------------------------------------------+
156 jp_milcent 547
	//												GESTION DES PERSONNES
548
	//+----------------------------------------------------------------------------------------------------------------+
549
 
550
	public void clicListePersonne(Personne personne)	{
646 jp_milcent 551
		panneauCentre.getContenu().rafraichir(personne);
69 jpm 552
	}
553
 
278 jp_milcent 554
	public void afficherListePersonnes(PersonneListe personnesACharger)	{
646 jp_milcent 555
		if (!(panneauCentre.getContenu() instanceof PersonneVue))	{
626 gduche 556
			panneauCentre.removeAll();
646 jp_milcent 557
			panneauCentre.add(new PersonneVue(this));
673 aurelien 558
			panneauCentre.setId(ComposantId.PANNEAU_PERSONNE_LISTES);
626 gduche 559
		}
599 gduche 560
 
646 jp_milcent 561
		panneauCentre.getContenu().rafraichir(personnesACharger);
156 jp_milcent 562
	}
563
 
128 gduche 564
	public void clicAjouterPersonne()	{
332 gduche 565
		afficherPopinChargement();
566
 
277 jp_milcent 567
		panneauCentre.removeAll();
454 gduche 568
		PersonneForm formulairePersonneVue = new PersonneForm(PersonneForm.MODE_AJOUTER);
277 jp_milcent 569
		panneauCentre.add(formulairePersonneVue);
570
		panneauCentre.layout();
128 gduche 571
	}
572
 
285 gduche 573
	public void clicModifierPersonne(Personne personne)	{
574
		if (personne!=null)	{
575
			panneauCentre.removeAll();
454 gduche 576
			PersonneForm formulairePersonneVue = new PersonneForm(PersonneForm.MODE_MODIFIER);
285 gduche 577
			panneauCentre.add(formulairePersonneVue);
349 gduche 578
 
599 gduche 579
			selectionnerPersonne(formulairePersonneVue, personne, null);
349 gduche 580
 
581
			panneauCentre.layout();
285 gduche 582
		}
583
	}
599 gduche 584
 
585
	public void selectionnerPersonne(Rafraichissable vue, Personne personne, String projetId)	{
586
		int nbElements = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage"));
587
		selectionnerPersonne(vue, personne, projetId, 0, nbElements);
588
	}
285 gduche 589
 
599 gduche 590
	public void selectionnerPersonne(Rafraichissable vue, Personne personne, String projetId, int start, int nbElements)	{
560 gduche 591
		String personneId = null;
592
		if (personne!=null)	{
593
			personneId = personne.getId();
594
		}
599 gduche 595
		modele.selectionnerPersonne(vue, personneId, projetId, null, start, nbElements);
349 gduche 596
	}
285 gduche 597
 
315 gduche 598
	public void clicSupprimerPersonne(final Rafraichissable vue,final List<Personne> personneSelection) {
663 gduche 599
 
600
		//Empecher suppression utilisateur
601
		for (int i=0; i < personneSelection.size(); i++)	{
602
			Personne courante = personneSelection.get(i);
603
			if (courante.getId().equals(getUtilisateurId()))	{
604
				Info.display("Information", "Vous ne pouvez supprimer votre compte");
605
				personneSelection.remove(courante);
606
			}
607
		}
608
 
245 jp_milcent 609
		if (personneSelection.size() == 0) {
610
			Info.display("Information", "Veuillez sélectionner une personne.");
611
		} else if(personneSelection.size() > 0) {
612
			String message = "Êtes vous sur de vouloir supprimer les personnes sélectionnées ?";
613
			if (personneSelection.size() == 1) {
614
				message = "Êtes vous sur de vouloir supprimer la personne sélectionnée ?";
615
			}
315 gduche 616
 
502 gduche 617
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
618
				public void handleEvent(MessageBoxEvent ce) {
619
					Dialog dialog = (Dialog) ce.getComponent();
620
					Button btn = ce.getButtonClicked();
327 jp_milcent 621
 
622
					if (btn.getText().equals(dialog.yesText)) {
623
						String idStr = "" ;
347 gduche 624
						Iterator<Personne> itPersonne = personneSelection.iterator();
625
						while (itPersonne.hasNext()) {
626
							Personne personneCourante = itPersonne.next();
627
							idStr += personneCourante.getId();
389 gduche 628
							idStr +=",";
327 jp_milcent 629
						}
329 jp_milcent 630
						modele.supprimerPersonne(vue, idStr);
327 jp_milcent 631
					}
632
				}
633
			};
453 jp_milcent 634
 
315 gduche 635
			MessageBox.confirm("Supprimer une personne", message, listenerSuppression);
245 jp_milcent 636
		} else {
637
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerPersonne() du Médiateur.");
638
		}
639
	}
277 jp_milcent 640
 
599 gduche 641
	public void selectionnerPersonneParNomComplet(Rafraichissable vueARafraichir, String projetId, String nomComplet) {
642
		modele.selectionnerPersonne(vueARafraichir, null, projetId, nomComplet, 0, -1);
277 jp_milcent 643
	}
245 jp_milcent 644
 
389 gduche 645
	public void enregistrerPersonne(Rafraichissable vue, Personne personne){
429 gduche 646
		if (personne.getId()!=null && !personne.getId().trim().equals("")) {
647
			modele.modifierPersonne(vue, personne);
648
		}	else {
649
			modele.ajouterPersonne(vue, personne);
650
		}
389 gduche 651
	}
652
 
156 jp_milcent 653
	//+----------------------------------------------------------------------------------------------------------------+
654
	//												GESTION DES PUBLICATIONS
655
	//+----------------------------------------------------------------------------------------------------------------+
656
 
107 aurelien 657
	public void afficherListePublication(PublicationListe nouvelleDonnees) {
673 aurelien 658
 
659
		if (!(panneauCentre.getContenu() instanceof PublicationVue))	{
626 gduche 660
			panneauCentre.removeAll();
673 aurelien 661
			PublicationVue publicationVue = new PublicationVue(this) ;
662
			panneauCentre.setId(ComposantId.PANNEAU_PUBLICATION_LISTE);
663
			panneauCentre.add(publicationVue);
664
			panneauCentre.layout(true);
626 gduche 665
		}
666
 
715 aurelien 667
		masquerPopinChargement();
668
 
646 jp_milcent 669
		panneauCentre.getContenu().rafraichir(nouvelleDonnees);
107 aurelien 670
	}
715 aurelien 671
 
672
	public void rechargerListePublication() {
741 aurelien 673
		if (!(panneauCentre.getContenu() instanceof PublicationVue))	{
674
			panneauCentre.removeAll();
675
			PublicationVue publicationVue = new PublicationVue(this) ;
676
			panneauCentre.setId(ComposantId.PANNEAU_PUBLICATION_LISTE);
677
			panneauCentre.add(publicationVue);
678
			panneauCentre.layout(true);
679
		}
680
		masquerPopinChargement();
715 aurelien 681
		modele.selectionnerPublication(panneauCentre.getContenu(),null,null,null);
682
	}
107 aurelien 683
 
684
	public void clicListePublication(Publication publication) {
675 aurelien 685
		if(publication != null) {
686
			panneauCentre.getContenu().rafraichir(publication);
687
		}
107 aurelien 688
	}
689
 
690
	public void clicAjouterPublication() {
223 aurelien 691
		panneauCentre.removeAll();
444 jp_milcent 692
		PublicationForm publicationForm = new PublicationForm();
693
		panneauCentre.add(publicationForm);
223 aurelien 694
		panneauCentre.layout();
107 aurelien 695
	}
156 jp_milcent 696
 
245 jp_milcent 697
	public void clicModifierPublication(List<Publication> publicationListe) {
698
		if(publicationListe.size() <= 0) {
315 gduche 699
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 700
		} else {
245 jp_milcent 701
			Publication pubAModifier = publicationListe.get(publicationListe.size() -1);
702
			panneauCentre.removeAll();
444 jp_milcent 703
			PublicationForm publicationForm = new PublicationForm();
704
			panneauCentre.add(publicationForm);
245 jp_milcent 705
			panneauCentre.setId(ComposantId.PANNEAU_FORM_PUBLICATION);
706
			panneauCentre.layout();
444 jp_milcent 707
			publicationForm.rafraichir(pubAModifier);
245 jp_milcent 708
		}
709
	}
710
 
315 gduche 711
	public void clicSupprimerPublication(final List<Publication> publicationListe) {
453 jp_milcent 712
		if (publicationListe.size() <= 0) {
315 gduche 713
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 714
		} else {
673 aurelien 715
			String message = "Voulez-vous vraiment supprimer ces publications ?";
245 jp_milcent 716
			if(publicationListe.size() == 1) {
717
				message = "Voulez-vous vraiment supprimer cette publication ?";
718
			}
315 gduche 719
 
502 gduche 720
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
721
				public void handleEvent(MessageBoxEvent ce) {
722
					Dialog dialog = (Dialog) ce.getComponent();
723
				    Button btn = ce.getButtonClicked();
315 gduche 724
 
379 jp_milcent 725
				    if (btn.getText().equals(dialog.yesText)) {
764 jpm 726
				    	modele.supprimerPublication(panneauCentre.getContenu(), publicationListe);
315 gduche 727
				    }
728
				}
729
			};
730
 
731
			MessageBox.confirm("Supprimer une publication", message, listenerSuppression);
245 jp_milcent 732
		}
733
	}
709 jp_milcent 734
 
735
	public void selectionnerPublication(Rafraichissable vueARafraichir, String publicationId) {
736
		modele.selectionnerPublication(vueARafraichir, publicationId, getProjetId(), null);
737
	}
738
 
739
	public void selectionnerPublicationParNomComplet(Rafraichissable vueARafraichir, String projetId, String nomComplet) {
740
		modele.selectionnerPublication(vueARafraichir, null, projetId, nomComplet);
741
	}
742
 
444 jp_milcent 743
	public void ajouterPublication(PublicationForm publicationForm, Publication publi) {
764 jpm 744
		modele.ajouterPublication(panneauCentre.getContenu(), publi);
245 jp_milcent 745
	}
746
 
444 jp_milcent 747
	public void modifierPublication(PublicationForm publicationForm, Publication publi) {
764 jpm 748
		modele.modifierPublication(panneauCentre.getContenu(), publi);
245 jp_milcent 749
	}
750
 
453 jp_milcent 751
	public void clicObtenirListeEditeurs(Rafraichissable vueARafraichir) {
752
		modele.selectionnerStructure(vueARafraichir, null, null);
245 jp_milcent 753
	}
754
 
453 jp_milcent 755
	public void clicObtenirListeAuteurs(Rafraichissable vueARafraichir) {
599 gduche 756
		//modele.selectionnerPersonne(vueARafraichir, null, null, null);
757
		selectionnerPersonne(vueARafraichir, null, null);
245 jp_milcent 758
	}
759
 
156 jp_milcent 760
	//+----------------------------------------------------------------------------------------------------------------+
447 jp_milcent 761
	//												RAFRAICHISSEMENT
156 jp_milcent 762
	//+----------------------------------------------------------------------------------------------------------------+
763
 
277 jp_milcent 764
	public void rafraichir(Object nouvelleDonnees) {
765
		if (nouvelleDonnees instanceof Utilisateur) {
766
			mettreAJourEtatIdentification((Utilisateur) nouvelleDonnees);
278 jp_milcent 767
		} else {
768
			GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
277 jp_milcent 769
		}
770
	}
281 gduche 771
 
453 jp_milcent 772
	//+----------------------------------------------------------------------------------------------------------------+
773
	//												GESTION du STATUT
774
	//+----------------------------------------------------------------------------------------------------------------+
288 gduche 775
 
332 gduche 776
	public void afficherPopinChargement()	{
777
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).center();
778
	}
453 jp_milcent 779
 
332 gduche 780
	public void masquerPopinChargement()	{
781
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).hide();
782
	}
447 jp_milcent 783
 
741 aurelien 784
	public void ajouterAuteurPublication(Rafraichissable vueArafraichir,
785
			String idAuteurs, String role, String idPublication) {
762 jpm 786
		modele.ajouterAuteurPublication(vueArafraichir, idAuteurs, role, idPublication);
715 aurelien 787
 
788
	}
789
 
741 aurelien 790
	public void modifierAuteurPublication(Rafraichissable vueArafraichir,
791
			String idAuteurs, String idPublication) {
762 jpm 792
		modele.modifierAuteurPublication(vueArafraichir, idAuteurs, idPublication);
741 aurelien 793
	}
750 aurelien 794
 
795
	public void selectionnerAuteurAPublication(Rafraichissable vueARafraichir,
796
			String idPublication) {
759 aurelien 797
		modele.selectionPublicationAPersonne(vueARafraichir, null, idPublication, "2360");
750 aurelien 798
	}
741 aurelien 799
 
277 jp_milcent 800
}