Subversion Repositories eFlore/Applications.coel

Rev

Rev 1046 | Rev 1063 | 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;
898 gduche 8
import org.tela_botanica.client.composants.LicenceFenetre;
1023 jpm 9
import org.tela_botanica.client.composants.AproposFenetre;
907 jpm 10
import org.tela_botanica.client.configuration.APropos;
11
import org.tela_botanica.client.configuration.Configuration;
358 jp_milcent 12
import org.tela_botanica.client.i18n.Constantes;
466 gduche 13
import org.tela_botanica.client.i18n.ErrorMessages;
119 jpm 14
import org.tela_botanica.client.interfaces.Rafraichissable;
156 jp_milcent 15
import org.tela_botanica.client.modeles.Information;
327 jp_milcent 16
import org.tela_botanica.client.modeles.MenuApplicationId;
61 jpm 17
import org.tela_botanica.client.modeles.Utilisateur;
1014 gduche 18
import org.tela_botanica.client.modeles.Valeur;
91 jpm 19
import org.tela_botanica.client.modeles.ValeurListe;
935 jpm 20
import org.tela_botanica.client.modeles.collection.Collection;
989 jpm 21
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
22
import org.tela_botanica.client.modeles.collection.CollectionACommentaireAsyncDao;
23
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe;
935 jpm 24
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
25
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe;
26
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
27
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe;
28
import org.tela_botanica.client.modeles.collection.CollectionListe;
985 jpm 29
import org.tela_botanica.client.modeles.commentaire.Commentaire;
30
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
935 jpm 31
import org.tela_botanica.client.modeles.personne.Personne;
32
import org.tela_botanica.client.modeles.personne.PersonneListe;
33
import org.tela_botanica.client.modeles.projet.Projet;
34
import org.tela_botanica.client.modeles.projet.ProjetListe;
35
import org.tela_botanica.client.modeles.publication.Publication;
36
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
37
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
38
import org.tela_botanica.client.modeles.publication.PublicationListe;
39
import org.tela_botanica.client.modeles.structure.Structure;
40
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
41
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
42
import org.tela_botanica.client.modeles.structure.StructureConservation;
43
import org.tela_botanica.client.modeles.structure.StructureListe;
44
import org.tela_botanica.client.modeles.structure.StructureValorisation;
918 jpm 45
import org.tela_botanica.client.util.Debug;
936 jpm 46
import org.tela_botanica.client.vues.ContenuVue;
444 jp_milcent 47
import org.tela_botanica.client.vues.EnteteVue;
641 jp_milcent 48
import org.tela_botanica.client.vues.Formulaire;
982 jpm 49
import org.tela_botanica.client.vues.NavigationVue;
332 gduche 50
import org.tela_botanica.client.vues.PopupChargement;
443 jp_milcent 51
import org.tela_botanica.client.vues.StatutVue;
444 jp_milcent 52
import org.tela_botanica.client.vues.MenuVue;
912 jpm 53
import org.tela_botanica.client.vues.accueil.AccueilVue;
934 jpm 54
import org.tela_botanica.client.vues.collection.CollectionForm;
55
import org.tela_botanica.client.vues.collection.CollectionListeVue;
56
import org.tela_botanica.client.vues.collection.CollectionVue;
989 jpm 57
import org.tela_botanica.client.vues.commentaire.CommentaireForm;
985 jpm 58
import org.tela_botanica.client.vues.commentaire.CommentaireVue;
935 jpm 59
import org.tela_botanica.client.vues.personne.PersonneForm;
60
import org.tela_botanica.client.vues.personne.PersonneVue;
61
import org.tela_botanica.client.vues.projet.ProjetForm;
62
import org.tela_botanica.client.vues.projet.ProjetVue;
63
import org.tela_botanica.client.vues.publication.PublicationForm;
64
import org.tela_botanica.client.vues.publication.PublicationVue;
65
import org.tela_botanica.client.vues.structure.StructureForm;
66
import org.tela_botanica.client.vues.structure.StructureVue;
467 jp_milcent 67
 
60 jpm 68
import com.extjs.gxt.ui.client.Registry;
69
import com.extjs.gxt.ui.client.Style.LayoutRegion;
315 gduche 70
import com.extjs.gxt.ui.client.event.Listener;
502 gduche 71
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
60 jpm 72
import com.extjs.gxt.ui.client.util.Margins;
646 jp_milcent 73
import com.extjs.gxt.ui.client.widget.Component;
315 gduche 74
import com.extjs.gxt.ui.client.widget.Dialog;
156 jp_milcent 75
import com.extjs.gxt.ui.client.widget.Info;
315 gduche 76
import com.extjs.gxt.ui.client.widget.MessageBox;
60 jpm 77
import com.extjs.gxt.ui.client.widget.Viewport;
315 gduche 78
import com.extjs.gxt.ui.client.widget.button.Button;
60 jpm 79
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
80
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
91 jpm 81
import com.google.gwt.core.client.GWT;
599 gduche 82
import com.google.gwt.i18n.client.Dictionary;
60 jpm 83
import com.google.gwt.user.client.Window;
84
import com.google.gwt.user.client.ui.RootPanel;
85
 
277 jp_milcent 86
public class Mediateur implements Rafraichissable {
60 jpm 87
 
358 jp_milcent 88
	private Viewport viewport;
119 jpm 89
	private Modele modele = null;
582 jp_milcent 90
	public static final Constantes i18nC = getI18nConstante();
91
	public static final ErrorMessages i18nM = getI18nMessage();
119 jpm 92
 
444 jp_milcent 93
	private EnteteVue panneauNord = null;
982 jpm 94
	private NavigationVue panneauOuest = null;
444 jp_milcent 95
	private ContenuVue panneauCentre = null;
443 jp_milcent 96
	private StatutVue panneauSud = null;
60 jpm 97
 
358 jp_milcent 98
	private IdentificationFenetre fenetreIdentification = null;
1041 gduche 99
	private int nbElements = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage"));
60 jpm 100
	public Mediateur() {
101
		// Enregistrement du Médiateur dans le Registre
102
		Registry.register(RegistreId.MEDIATEUR, this);
765 jpm 103
 
104
		//Initialisation du Registre
105
		initialiserRegistre();
466 gduche 106
 
60 jpm 107
		// Création du Modèle qui s'enregistre lui même dans le Registre
119 jpm 108
		modele = new Modele();
535 jp_milcent 109
 
60 jpm 110
		// Création du Viewport qui contient la disposition globale de l'application
111
		viewport = new Viewport();
112
		viewport.setLayout(new BorderLayout());
552 jp_milcent 113
 
60 jpm 114
		// Création des différents panneaux
115
	    creerPanneauNord();
116
	    creerPanneauOuest();
117
	    creerPanneauCentral();
358 jp_milcent 118
	    creerPanneauSud();
535 jp_milcent 119
 
120
		// Connection de l'utilisateur
121
		connecterUtilisateur(null, null);
122
 
60 jpm 123
		// Retour à GWT du Viewport une fois constuit
124
		RootPanel.get().add(viewport);
125
	}
126
 
156 jp_milcent 127
	//+----------------------------------------------------------------------------------------------------------------+
535 jp_milcent 128
	//												GESTION de l'I18N et du REGISTRE
129
	//+----------------------------------------------------------------------------------------------------------------+
582 jp_milcent 130
	protected static Constantes getI18nConstante() {
535 jp_milcent 131
		return GWT.create(Constantes.class);
132
	}
133
 
582 jp_milcent 134
	protected static ErrorMessages getI18nMessage() {
535 jp_milcent 135
		return GWT.create(ErrorMessages.class);
136
	}
137
 
138
	protected void initialiserRegistre() {
139
		Registry.register(RegistreId.APPLI_NOM, i18nC.appliNom());
140
		Registry.register(RegistreId.APPLI_CODE, i18nC.appliCode());
141
		Registry.register(RegistreId.APPLI_VERSION, i18nC.appliVersionNumero());
907 jpm 142
 
143
		APropos apropos = new APropos();
1023 jpm 144
		Registry.register(RegistreId.APPLI_DEVELOPPEURS, apropos.getDeveloppeurs());
145
		Registry.register(RegistreId.APPLI_TRADUCTEURS, apropos.getTraducteurs());
146
		Registry.register(RegistreId.APPLI_LICENCE, apropos.getLicence());
907 jpm 147
		Registry.register(RegistreId.APPLI_REVISION, apropos.getRevisionGlobale());
148
		Registry.register(RegistreId.APPLI_COMPILATION_JAVA_VERSION, apropos.getVersionJavaCompilation());
149
		Registry.register(RegistreId.APPLI_COMPILATION_DATE_HEURE, apropos.getDateHeureCompilation());
535 jp_milcent 150
 
151
		Registry.register(RegistreId.CONFIG, new Configuration());
537 jp_milcent 152
		Registry.register(RegistreId.POPUP_CHARGEMENT, new PopupChargement(this));
766 jpm 153
		Registry.register(RegistreId.UTILISATEUR_COURANT, new Utilisateur());
535 jp_milcent 154
		Registry.register(RegistreId.PROJET_COURANT, new Projet());
155
	}
156
 
157
	//+----------------------------------------------------------------------------------------------------------------+
156 jp_milcent 158
	//												GESTION des PANNEAUX PRINCIPAUX
159
	//+----------------------------------------------------------------------------------------------------------------+
119 jpm 160
 
60 jpm 161
	private void creerPanneauNord() {
444 jp_milcent 162
		panneauNord = new EnteteVue(this);
60 jpm 163
 
164
		BorderLayoutData regionNord = new BorderLayoutData(LayoutRegion.NORTH, 100);
165
		regionNord.setCollapsible(true);
166
		regionNord.setFloatable(true);
167
		regionNord.setSplit(false);
168
		regionNord.setMargins(new Margins(5, 5, 0, 5));
169
 
170
		viewport.add(panneauNord, regionNord);
171
	}
172
 
173
	private void creerPanneauOuest() {
982 jpm 174
		panneauOuest = new NavigationVue(this);
60 jpm 175
 
176
		BorderLayoutData regionOuest = new BorderLayoutData(LayoutRegion.WEST, 200);
177
		regionOuest.setSplit(true);
178
		regionOuest.setCollapsible(true);
179
		regionOuest.setMargins(new Margins(5));
180
 
181
		viewport.add(panneauOuest, regionOuest);
182
	}
183
 
184
	private void creerPanneauCentral() {
444 jp_milcent 185
		panneauCentre = new ContenuVue(this);
60 jpm 186
 
187
		BorderLayoutData regionCentre = new BorderLayoutData(LayoutRegion.CENTER);
188
		regionCentre.setMargins(new Margins(5, 5, 5, 0));
189
 
190
		viewport.add(panneauCentre, regionCentre);
191
	}
358 jp_milcent 192
 
193
	private void creerPanneauSud() {
443 jp_milcent 194
		panneauSud = new StatutVue();
358 jp_milcent 195
 
369 jp_milcent 196
		BorderLayoutData regionSud = new BorderLayoutData(LayoutRegion.SOUTH, 20);
358 jp_milcent 197
		regionSud.setCollapsible(true);
198
		regionSud.setFloatable(true);
199
		regionSud.setSplit(false);
200
		regionSud.setMargins(new Margins(0));
201
 
202
		viewport.add(panneauSud, regionSud);
203
	}
60 jpm 204
 
369 jp_milcent 205
	public void actualiserPanneauCentral() {
206
		panneauCentre.layout();
207
	}
208
 
156 jp_milcent 209
	//+----------------------------------------------------------------------------------------------------------------+
210
	//												GESTION du MENU
211
	//+----------------------------------------------------------------------------------------------------------------+
212
 
327 jp_milcent 213
	public void clicMenu(String codeMenuClique) {
358 jp_milcent 214
		activerChargement(codeMenuClique);
982 jpm 215
		panneauOuest.getMenu().selectionMenu(codeMenuClique);
910 jpm 216
		if (codeMenuClique.equals(MenuApplicationId.ACCUEIL)) {
217
			afficherAccueil();
218
		} else if (codeMenuClique.equals(MenuApplicationId.PROJET)) {
928 jpm 219
			selectionnerProjet(panneauCentre, null);
910 jpm 220
		} else if (codeMenuClique.equals(MenuApplicationId.STRUCTURE)) {
646 jp_milcent 221
			selectionnerStructure(panneauCentre, null);
553 jp_milcent 222
		} else if (codeMenuClique.equals(MenuApplicationId.COLLECTION)) {
1041 gduche 223
			selectionnerCollection(panneauCentre, null, null);
553 jp_milcent 224
		} else if (codeMenuClique.equals(MenuApplicationId.PERSONNE)) {
599 gduche 225
			selectionnerPersonne(panneauCentre, null, null);
327 jp_milcent 226
		} else if (codeMenuClique.equals(MenuApplicationId.PUBLICATION)) {
918 jpm 227
			selectionnerPublication(panneauCentre, null);
985 jpm 228
		} else if (codeMenuClique.equals(MenuApplicationId.COMMENTAIRE)) {
229
			selectionnerCommentaire(panneauCentre, null);
379 jp_milcent 230
		} else {
841 gduche 231
			GWT.log(i18nM.nonImplemente(codeMenuClique), null);
60 jpm 232
		}
233
		panneauCentre.layout();
234
	}
836 aurelien 235
 
358 jp_milcent 236
	public void activerChargement(String message) {
918 jpm 237
		Debug.log(message);
358 jp_milcent 238
		afficherPopinChargement();
369 jp_milcent 239
		panneauSud.showBusy(i18nC.chargement()+" "+message);
358 jp_milcent 240
	}
241
 
242
	public void desactiverChargement() {
243
		masquerPopinChargement();
244
		panneauSud.clear();
245
	}
646 jp_milcent 246
 
156 jp_milcent 247
	//+----------------------------------------------------------------------------------------------------------------+
248
	//												GESTION DES FENÊTRES
249
	//+----------------------------------------------------------------------------------------------------------------+
60 jpm 250
 
61 jpm 251
	public void ouvrirAide() {
252
		AideFenetre aideFenetre = new AideFenetre();
253
		aideFenetre.show();
66 jpm 254
		// FIXME : apparament le fade In/Fade Out pose problème sur les navigateurs...
255
		//aideFenetre.el().fadeIn(FxConfig.NONE);
61 jpm 256
	}
257
 
258
	public void ouvrirParametres() {
1023 jpm 259
		AproposFenetre parametresFenetre = new AproposFenetre();
66 jpm 260
		parametresFenetre.show();
61 jpm 261
	}
262
 
263
	public void ouvrirIdentification() {
1017 jpm 264
		fenetreIdentification = new IdentificationFenetre(this);
358 jp_milcent 265
		fenetreIdentification.show();
61 jpm 266
	}
267
 
989 jpm 268
	public void ouvrirUrlExterne(String id) {
61 jpm 269
		if (id.equals(ComposantId.MENU_CEL)) {
989 jpm 270
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getUrl("cel"), "Carnet en ligne", "");
61 jpm 271
		} else if (id.equals(ComposantId.MENU_BEL)) {
989 jpm 272
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getUrl("cel"), "Biblio en ligne", "");
273
		} else if (id.equals(ComposantId.MENU_BOGUE)) {
274
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getUrl("bogue"), "Bogue", "");
275
		} else if (id.equals(ComposantId.MENU_COMMENTAIRE)) {
276
			Window.open(((Configuration) Registry.get(RegistreId.CONFIG)).getUrl("commentaire"), "Commentaire", "");
61 jpm 277
		}
278
	}
279
 
898 gduche 280
	public void afficherFenetreLicence(IdentificationFenetre vue)	{
281
		LicenceFenetre lf = new LicenceFenetre(vue);
282
	}
283
 
284
	public void accepterLicence(Rafraichissable vue)	{
285
		modele.accepterLicence(vue);
286
	}
156 jp_milcent 287
	//+----------------------------------------------------------------------------------------------------------------+
288
	//												GESTION de l'UTILISATEUR et de l'IDENTIFICATION
289
	//+----------------------------------------------------------------------------------------------------------------+
245 jp_milcent 290
	/**
291
	 * Retourne l'identifiant de l'utilisateur courrant de l'application.
292
	 */
156 jp_milcent 293
	public String getUtilisateurId() {
277 jp_milcent 294
		String id = null;
295
		Utilisateur utilisateurCourant = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
296
		if (!utilisateurCourant.getId().equals("")) {
297
			id = utilisateurCourant.getId();
298
		}
299
		return id;
156 jp_milcent 300
	}
301
 
912 jpm 302
	public Utilisateur getUtilisateur() {
303
		Utilisateur utilisateurCourant = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
304
		return utilisateurCourant;
305
	}
306
 
65 jpm 307
	public void connecterUtilisateur(String login, String mdp) {
277 jp_milcent 308
		modele.connecterUtilisateur(this, login, mdp);
64 jpm 309
	}
310
 
65 jpm 311
	public void deconnecterUtilisateur() {
277 jp_milcent 312
		modele.deconnecterUtilisateur(this);
64 jpm 313
	}
65 jpm 314
 
932 jpm 315
	public void repandreEtatIdentification(Utilisateur utilisateur) {
156 jp_milcent 316
		// Mise à jour du registre
277 jp_milcent 317
		Registry.register(RegistreId.UTILISATEUR_COURANT, utilisateur);
932 jpm 318
		// Propagation de l'information de mise à jour de l'utilisateur
319
		repandreInfoMiseAJourUtilisateur();
320
	}
321
 
322
	public void repandreInfoMiseAJourUtilisateur() {
912 jpm 323
		// Création de l'information de mise à jour de l'utilisateur
324
		Information info = new Information("maj_utilisateur");
325
 
326
		// Rafraichissement de la fenêtre d'Identification
941 jpm 327
		if (fenetreIdentification != null && fenetreIdentification.isVisible()) {
912 jpm 328
			fenetreIdentification.rafraichir(info);
329
		}
898 gduche 330
 
912 jpm 331
		// Rafraichissement du panneau Nord
332
		panneauNord.rafraichir(info);
333
 
334
		// Rafraichissement du panneau Centre
335
		if (panneauCentre != null) {
336
			panneauCentre.rafraichir(info);
932 jpm 337
		}
912 jpm 338
	}
898 gduche 339
 
912 jpm 340
	public void modifierUtilisateur()	{
341
		Utilisateur utilisateurCourant = (Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT);
342
		panneauNord.rafraichir(utilisateurCourant);
343
		modele.modifierUtilisateur(this, utilisateurCourant);
61 jpm 344
	}
898 gduche 345
 
346
	public void mettreAJourPersonneAnnuaire(Utilisateur utilisateur)	{
347
		panneauNord.rafraichir(utilisateur);
348
		modele.mettreAJourPersonneAnnuaire(this, utilisateur);
349
	}
66 jpm 350
 
156 jp_milcent 351
	//+----------------------------------------------------------------------------------------------------------------+
447 jp_milcent 352
	//												GESTION DES VALEURS ET LISTES
353
	//+----------------------------------------------------------------------------------------------------------------+
354
 
568 jp_milcent 355
	public void obtenirListeValeurEtRafraichir(Rafraichissable vueARafraichir, String listeId)	{
356
		modele.obtenirListeValeurs(vueARafraichir, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId));
453 jp_milcent 357
	}
447 jp_milcent 358
 
453 jp_milcent 359
	public void obtenirValeurEtRafraichir(Rafraichissable vue, String listeId, String identifiantValeur)	{
360
		modele.obtenirValeur(vue, "abv", ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(listeId), identifiantValeur);
361
	}
362
 
363
	public void obtenirListeRegionsEtRafraichir(Rafraichissable vue, String strListeId, String strPays)	{
364
		modele.obtenirListeRegion(vue, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId(strListeId), strPays+".__");
365
	}
366
 
447 jp_milcent 367
	//+----------------------------------------------------------------------------------------------------------------+
910 jpm 368
	//												GESTION des APPLETS de l'ACCUEIL
369
	//+----------------------------------------------------------------------------------------------------------------+
370
 
371
	public void afficherAccueil() {
372
		if (!(panneauCentre.getContenu() instanceof AccueilVue)) {
373
			panneauCentre.removeAll();
374
			panneauCentre.add(new AccueilVue(this));
375
		}
376
	}
377
 
378
	//+----------------------------------------------------------------------------------------------------------------+
447 jp_milcent 379
	//												GESTION des PROJETS
380
	//+----------------------------------------------------------------------------------------------------------------+
381
 
928 jpm 382
	public void afficherFormProjet(String projetId) {
383
		panneauCentre.removeAll();
384
		ProjetForm projetForm = new ProjetForm(this, projetId);
385
		panneauCentre.add(projetForm);
386
 
387
		panneauCentre.layout();
388
	}
389
 
390
	public void afficherListeProjets(ProjetListe projetsACharger)	{
391
		if (!(panneauCentre.getContenu() instanceof ProjetVue))	{
392
			panneauCentre.removeAll();
393
			panneauCentre.add(new ProjetVue(this));
394
			panneauCentre.setId(ComposantId.PANNEAU_PROJET_LISTE);
395
			panneauCentre.layout();
396
		}
397
 
398
		panneauCentre.getContenu().rafraichir(projetsACharger);
399
	}
400
 
401
	public void clicListeProjet(Projet projet) {
402
		panneauCentre.getContenu().rafraichir(projet);
403
	}
404
 
405
	public void clicSupprimerProjet(final List<Projet> projetListe) {
406
		if (projetListe.size() <= 0) {
407
			MessageBox.alert("Attention", "Vous devez sélectionner un projet", null);
408
		} else {
409
			String message = "Voulez-vous vraiment supprimer ces projets ?";
410
			if (projetListe.size() == 1) {
411
				message = "Voulez-vous vraiment supprimer ce projet ?";
412
			}
413
 
414
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
415
				public void handleEvent(MessageBoxEvent ce) {
416
					Dialog dialog = (Dialog) ce.getComponent();
417
				    Button btn = ce.getButtonClicked();
418
 
419
				    if (btn.getText().equals(dialog.yesText)) {
420
				    	modele.supprimerProjet(panneauCentre.getContenu(), projetListe);
421
				    }
422
				}
423
			};
424
 
425
			MessageBox.confirm("Supprimer un projet", message, listenerSuppression);
426
		}
427
 
428
	}
429
 
430
	public void clicModifierProjet(List<Projet> projetsSelectionnes) {
431
		if (projetsSelectionnes.size() == 0) {
432
			Info.display("Information", "Veuillez sélectionner un projet.");
433
		} else if (projetsSelectionnes.size() > 1) {
434
			Info.display("Information", "Veuillez sélectionner un seul projet à la fois.");
435
		} else if (projetsSelectionnes.size() == 1) {
436
			afficherFormProjet(projetsSelectionnes.get(0).getId());
437
		} else {
438
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierProjet() du Médiateur.");
439
		}
440
	}
441
 
442
	public void clicAjouterProjet() {
443
		afficherFormProjet(null);
444
	}
445
 
446
	public void selectionnerProjet(Rafraichissable vueARafraichir, String projetId) {
1045 gduche 447
		selectionnerProjet(vueARafraichir, projetId, null, 0, nbElements);
928 jpm 448
	}
1045 gduche 449
 
450
	public void selectionnerProjet(Rafraichissable vueARafraichir, String projetId, String nom, int start, int nbElements) {
451
		modele.selectionnerProjet(vueARafraichir, projetId, nom, start, this.nbElements);
452
	}
928 jpm 453
 
454
	public void ajouterProjet(Rafraichissable vueARafraichir, Projet projetCollecte) {
455
		modele.ajouterProjet(vueARafraichir, projetCollecte);
456
	}
457
 
458
	public void modifierProjet(Rafraichissable vueARafraichir, Projet projetCollecte) {
459
		modele.modifierProjet(vueARafraichir, projetCollecte);
460
	}
461
 
462
	//+----------------------------------------------------------------------------------------------------------------+
463
	// SELECTION : projet
447 jp_milcent 464
	/**
465
	 * Retourne l'identifiant du projet courrant de l'application.
466
	 */
467
	public String getProjetId() {
468
		String id = null;
469
		Projet projetCourant = (Projet) Registry.get(RegistreId.PROJET_COURANT);
470
		if (projetCourant != null && !projetCourant.getId().equals("")) {
471
			id = projetCourant.getId();
472
		}
473
		return id;
474
	}
928 jpm 475
 
447 jp_milcent 476
	public void selectionnerProjetCourant(Projet projetSelectionne) {
477
		Registry.register(RegistreId.PROJET_COURANT, projetSelectionne);
928 jpm 478
		if (panneauCentre.getContenu() instanceof ProjetVue)	{
479
			selectionnerProjet(panneauCentre.getContenu(), null);
646 jp_milcent 480
		} else if (panneauCentre.getContenu() instanceof StructureVue)	{
928 jpm 481
			selectionnerStructure(panneauCentre.getContenu(), null);
646 jp_milcent 482
		} else if (panneauCentre.getContenu() instanceof CollectionVue)	{
1041 gduche 483
			selectionnerCollection(panneauCentre.getContenu(), null, null);
928 jpm 484
		} else if (panneauCentre.getContenu() instanceof PersonneVue) {
485
			selectionnerPersonne(panneauCentre.getContenu(), null, getProjetId());
486
		} else if (panneauCentre.getContenu() instanceof PublicationVue) {
487
			selectionnerPublication(panneauCentre.getContenu(), null);
987 jpm 488
		} else if (panneauCentre.getContenu() instanceof CommentaireVue) {
489
			selectionnerCommentaire(panneauCentre.getContenu(), null);
447 jp_milcent 490
		}
491
	}
492
 
928 jpm 493
 
447 jp_milcent 494
	//+----------------------------------------------------------------------------------------------------------------+
495
	//												GESTION DES STRUCTURES
496
	//+----------------------------------------------------------------------------------------------------------------+
497
 
453 jp_milcent 498
	public void afficherListeStructures(StructureListe structuresACharger) {
646 jp_milcent 499
		if (!(panneauCentre.getContenu() instanceof StructureVue))	{
626 gduche 500
			panneauCentre.removeAll();
646 jp_milcent 501
			panneauCentre.add(new StructureVue(this));
626 gduche 502
		}
646 jp_milcent 503
		panneauCentre.getContenu().rafraichir(structuresACharger);
453 jp_milcent 504
	}
505
 
580 jp_milcent 506
	public void afficherFormStructure(String structureId) {
641 jp_milcent 507
		String mode = Formulaire.MODE_AJOUTER;
580 jp_milcent 508
		if (structureId != null) {
641 jp_milcent 509
			mode = Formulaire.MODE_MODIFIER;
580 jp_milcent 510
		}
511
 
512
		panneauCentre.removeAll();
513
		StructureForm structureForm = new StructureForm(this, mode);
514
		panneauCentre.add(structureForm);
515
 
641 jp_milcent 516
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
580 jp_milcent 517
			selectionnerStructure(structureForm, structureId);
518
			selectionnerStructureAPersonne(structureForm, structureId, StructureAPersonne.ROLE_EQUIPE);
519
		}
520
 
521
		panneauCentre.layout();
522
	}
523
 
447 jp_milcent 524
	public void clicListeStructure(Structure structure) {
646 jp_milcent 525
		panneauCentre.getContenu().rafraichir(structure);
609 jp_milcent 526
		if (structure != null && structure.getPersonnel() == null) {
646 jp_milcent 527
			selectionnerStructureAPersonne(panneauCentre.getContenu(), structure.getId(), StructureAPersonne.ROLE_EQUIPE);
919 jpm 528
		}
447 jp_milcent 529
	}
530
 
531
	public void clicAjouterStructure() {
580 jp_milcent 532
		afficherFormStructure(null);
447 jp_milcent 533
	}
534
 
535
	public void clicModifierStructure(List<Structure> structureSelection) {
536
		if (structureSelection.size() == 0) {
537
			Info.display("Information", "Veuillez sélectionner une structure.");
538
		} else if (structureSelection.size() > 1) {
539
			Info.display("Information", "Veuillez sélectionner une seule structure à la fois.");
540
		} else if (structureSelection.size() == 1) {
609 jp_milcent 541
			afficherFormStructure(structureSelection.get(0).getId());
447 jp_milcent 542
		} else {
543
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierStructure() du Médiateur.");
544
		}
545
	}
546
 
547
	public void clicSupprimerStructure(final Rafraichissable vue, final List<Structure> structureSelection) {
548
		if (structureSelection.size() == 0) {
549
			Info.display("Information", "Veuillez sélectionner une structure.");
550
		} else if(structureSelection.size() > 0) {
609 jp_milcent 551
			String titre = "Supprimer des structures";
447 jp_milcent 552
			String message = "Êtes vous sur de vouloir supprimer les structures sélectionnées ?";
553
			if (structureSelection.size() == 1) {
609 jp_milcent 554
				titre = "Supprimer une structure";
447 jp_milcent 555
				message = "Êtes vous sur de vouloir supprimer la structure sélectionnée ?";
556
			}
557
 
502 gduche 558
			final Listener<MessageBoxEvent> suppressionEcouteur = new Listener<MessageBoxEvent>() {
559
				public void handleEvent(MessageBoxEvent ce) {
560
					Dialog dialog = (Dialog) ce.getComponent();
561
					Button btn = ce.getButtonClicked();
453 jp_milcent 562
 
563
					if (btn.getText().equals(dialog.yesText))	{
564
						String idStr = "" ;
565
						for(int i = 0 ; i < structureSelection.size() ; i++) {
609 jp_milcent 566
							idStr += structureSelection.get(i).getId()+",";
453 jp_milcent 567
						}
923 jpm 568
						supprimerStructure(vue, idStr);
453 jp_milcent 569
					}
570
				}
571
			};
447 jp_milcent 572
 
609 jp_milcent 573
			MessageBox.confirm(titre, message, suppressionEcouteur);
447 jp_milcent 574
		} else {
575
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerStructure() du Médiateur.");
576
		}
577
	}
578
 
769 jpm 579
	public void selectionnerStructure(Rafraichissable vueARafraichir, String structureId) {
1040 gduche 580
		modele.selectionnerStructure(vueARafraichir, getProjetId(), structureId, null, 0, nbElements);
447 jp_milcent 581
	}
582
 
1040 gduche 583
	public void selectionnerStructure(Rafraichissable vueARafraichir, String structureId, String projetId, String nom, int start, int nbElements)	{
584
		modele.selectionnerStructure(vueARafraichir, getProjetId(), structureId, nom, start, nbElements);
585
	}
586
 
775 jpm 587
	public void selectionnerStructureParProjet(Rafraichissable vueARafraichir, String projetId) {
1040 gduche 588
		modele.selectionnerStructure(vueARafraichir, projetId, null, null, 0, -1);
775 jpm 589
	}
590
 
769 jpm 591
	public void ajouterStructure(Rafraichissable vueARafraichir, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
592
		modele.ajouterStructure(vueARafraichir, structure, conservation, valorisation);
447 jp_milcent 593
	}
594
 
769 jpm 595
	public void modifierStructure(Rafraichissable vueARafraichir, String structureId, Structure structure, StructureConservation conservation, StructureValorisation valorisation) {
596
		modele.modifierStructure(vueARafraichir, structureId, structure, conservation, valorisation);
447 jp_milcent 597
	}
453 jp_milcent 598
 
599
	public void supprimerStructure(Rafraichissable vueARafraichir, String IdentifiantsStructureSepareParVirgule) {
769 jpm 600
		modele.supprimerStructure(vueARafraichir, IdentifiantsStructureSepareParVirgule);
453 jp_milcent 601
	}
602
 
447 jp_milcent 603
	//+----------------------------------------------------------------------------------------------------------------+
604
	// GESTION de la relation STRUCTURE A PERSONNE
769 jpm 605
	public void selectionnerStructureAPersonne(Rafraichissable vueARafraichir, String structureId, String roleId) {
606
		modele.selectionnerStructureAPersonne(vueARafraichir, structureId, roleId);
447 jp_milcent 607
	}
608
 
769 jpm 609
	public void ajouterStructureAPersonne(Rafraichissable vueARafraichir, String structureId, StructureAPersonneListe personnelAjoute) {
453 jp_milcent 610
		if (personnelAjoute != null && personnelAjoute.size() > 0) {
611
			for (Iterator<String> it = personnelAjoute.keySet().iterator(); it.hasNext();) {
769 jpm 612
				modele.ajouterStructureAPersonne(vueARafraichir, structureId, (StructureAPersonne) personnelAjoute.get(it.next()));
453 jp_milcent 613
			}
614
		}
615
	}
616
 
769 jpm 617
	public void modifierStructureAPersonne(Rafraichissable vueARafraichir, StructureAPersonneListe personnelModifie) {
447 jp_milcent 618
		if (personnelModifie != null && personnelModifie.size() > 0) {
619
			for (Iterator<String> it = personnelModifie.keySet().iterator(); it.hasNext();) {
769 jpm 620
				modele.modifierStructureAPersonne(vueARafraichir, (StructureAPersonne) personnelModifie.get(it.next()));
447 jp_milcent 621
			}
622
		}
623
	}
624
 
769 jpm 625
	public void supprimerStructureAPersonne(Rafraichissable vueARafraichir, StructureAPersonneListe personnelSupprime) {
447 jp_milcent 626
		if (personnelSupprime != null && personnelSupprime.size() > 0) {
769 jpm 627
			String idStructureAPersonneSepareParVirgule = "" ;
923 jpm 628
			Iterator<String> it = personnelSupprime.keySet().iterator();
629
			while (it.hasNext()) {
901 jpm 630
				idStructureAPersonneSepareParVirgule += personnelSupprime.get(it.next()).getId();
923 jpm 631
				idStructureAPersonneSepareParVirgule += (it.hasNext()) ? "," : "";
447 jp_milcent 632
			}
923 jpm 633
			supprimerStructureAPersonne(vueARafraichir, idStructureAPersonneSepareParVirgule);
447 jp_milcent 634
		}
635
	}
923 jpm 636
 
637
	public void supprimerStructureAPersonne(Rafraichissable vueARafraichir, String idStructureAPersonneSeparesParVirgule) {
638
		modele.supprimerStructureAPersonne(vueARafraichir, idStructureAPersonneSeparesParVirgule);
639
	}
640
 
641
	public void supprimerStructureAPersonne(final Rafraichissable vueARafraichir, final List<Structure> structuresListe) {
642
		if (structuresListe.size() != 0) {
643
			String idStructureSepareParVirgule = "" ;
644
			Iterator<Structure> it = structuresListe.iterator();
645
			while (it.hasNext()) {
646
				Structure structure = it.next();
647
				idStructureSepareParVirgule += structure.getId();
648
				idStructureSepareParVirgule += it.hasNext() ? "," : "";
649
			}
650
			supprimerStructureAPersonne(vueARafraichir, idStructureSepareParVirgule);
651
		}
652
	}
653
 
447 jp_milcent 654
	//+----------------------------------------------------------------------------------------------------------------+
655
	//												GESTION des COLLECTIONS
656
	//+----------------------------------------------------------------------------------------------------------------+
657
 
453 jp_milcent 658
	public void afficherListeCollections(CollectionListe collectionsACharger) {
646 jp_milcent 659
		if (!(panneauCentre.getContenu() instanceof CollectionVue)) {
626 gduche 660
			panneauCentre.removeAll();
646 jp_milcent 661
			panneauCentre.add(new CollectionVue(this));
662
		}
626 gduche 663
 
646 jp_milcent 664
		panneauCentre.getContenu().rafraichir(collectionsACharger);
453 jp_milcent 665
	}
666
 
641 jp_milcent 667
	public void afficherFormCollection(String collectionId) {
668
		panneauCentre.removeAll();
883 jpm 669
		CollectionForm collectionForm = new CollectionForm(this, collectionId);
641 jp_milcent 670
		panneauCentre.add(collectionForm);
671
 
672
		panneauCentre.layout();
673
	}
674
 
453 jp_milcent 675
	public void clicListeCollection(Collection collectionCliquee) {
646 jp_milcent 676
		panneauCentre.getContenu().rafraichir(collectionCliquee);
883 jpm 677
		if (collectionCliquee != null) {
678
			selectionnerCollectionAPersonne(panneauCentre.getContenu(), collectionCliquee.getId(), null);
679
			selectionnerCollectionAPublication(panneauCentre.getContenu(), collectionCliquee.getId());
997 jpm 680
			selectionnerCollectionACommentaire(panneauCentre.getContenu(), collectionCliquee.getId());
883 jpm 681
		}
453 jp_milcent 682
	}
683
 
447 jp_milcent 684
	public void clicAjouterCollection() {
775 jpm 685
		afficherFormCollection(null);
447 jp_milcent 686
	}
687
 
688
	public void clicModifierCollection(List<Collection> selection) {
641 jp_milcent 689
		if (selection.size() == 0) {
690
			Info.display("Information", "Veuillez sélectionner une collection.");
691
		} else if (selection.size() > 1) {
692
			Info.display("Information", "Veuillez sélectionner une seule collection à la fois.");
693
		} else if (selection.size() == 1) {
694
			afficherFormCollection(selection.get(0).getId());
695
		} else {
696
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierCollection() du Médiateur.");
697
		}
447 jp_milcent 698
	}
699
 
968 jpm 700
	public void clicSupprimerCollection(CollectionListeVue collectionListeVue, final List<Collection> collectionsASupprimer) {
701
		if (collectionsASupprimer.size() <= 0) {
702
			MessageBox.alert("Attention", "Vous devez sélectionner au moins une collection", null);
703
		} else {
704
			String message = "Voulez-vous vraiment supprimer ces collections ?";
705
			if (collectionsASupprimer.size() == 1) {
706
				message = "Voulez-vous vraiment supprimer cette collection ?";
707
			}
708
 
709
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
710
				public void handleEvent(MessageBoxEvent ce) {
711
					Dialog dialog = (Dialog) ce.getComponent();
712
				    Button btn = ce.getButtonClicked();
713
 
714
				    if (btn.getText().equals(dialog.yesText)) {
715
				    	supprimerCollection(panneauCentre.getContenu(), collectionsASupprimer);
716
				    }
717
				}
718
			};
719
 
720
			MessageBox.confirm("Supprimer une collection", message, listenerSuppression);
721
		}
447 jp_milcent 722
	}
723
 
1041 gduche 724
	public void selectionnerCollection(Rafraichissable vueARafraichir, String collectionId, String nom) {
725
 
726
		System.out.println(nbElements);
727
		selectionnerCollection(vueARafraichir, collectionId, nom, 0, nbElements);
453 jp_milcent 728
	}
729
 
1041 gduche 730
	public void selectionnerCollection(Rafraichissable vueARafraichir, String collectionId, String nom, int start, int nbElements)	{
731
		modele.selectionnerCollection(vueARafraichir, getProjetId(), collectionId, nom, start, this.nbElements);
732
	}
733
 
775 jpm 734
	public void selectionnerCollectionParProjet(Rafraichissable vueARafraichir, String projetId) {
1041 gduche 735
		modele.selectionnerCollection(vueARafraichir, projetId, null, null, 0, nbElements);
775 jpm 736
	}
737
 
453 jp_milcent 738
	public void ajouterCollection(Rafraichissable vueARafraichir, Collection collection) {
968 jpm 739
		modele.ajouterCollection(vueARafraichir, collection);
453 jp_milcent 740
	}
741
 
742
	public void modifierCollection(Rafraichissable vueARafraichir, Collection collection) {
872 jpm 743
		modele.modifierCollection(vueARafraichir, collection);
453 jp_milcent 744
	}
745
 
968 jpm 746
	public void supprimerCollection(Rafraichissable vueARafraichir, List<Collection> collectionsListe) {
747
		if (collectionsListe != null && collectionsListe.size() > 0) {
748
			String idCollectionSeparesParVirgule = "" ;
749
			Iterator<Collection> it = collectionsListe.iterator();
750
			while (it.hasNext()) {
751
				idCollectionSeparesParVirgule += it.next().getId();
752
				if (it.hasNext()) {
753
					idCollectionSeparesParVirgule += ",";
754
				}
755
			}
756
			modele.supprimerCollection(vueARafraichir, idCollectionSeparesParVirgule);
757
			modele.supprimerCollectionAPersonne(vueARafraichir, idCollectionSeparesParVirgule);
758
			modele.supprimerCollectionAPublication(vueARafraichir, idCollectionSeparesParVirgule);
759
			//modele.supprimerCollectionACommentaire(vueARafraichir, idCollectionSeparesParVirgule);
760
		}
761
 
453 jp_milcent 762
	}
763
 
447 jp_milcent 764
	//+----------------------------------------------------------------------------------------------------------------+
875 jpm 765
	// GESTION de la relation COLLECTION A PERSONNE
766
 
767
	public void selectionnerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, String roleId) {
768
		modele.selectionnerCollectionAPersonne(vueARafraichir, collectionId, roleId);
769
	}
770
 
771
	public void ajouterCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, CollectionAPersonneListe personnesAjoutees) {
772
		if (personnesAjoutees != null && personnesAjoutees.size() > 0) {
773
			for (Iterator<String> it = personnesAjoutees.keySet().iterator(); it.hasNext();) {
774
				modele.ajouterCollectionAPersonne(vueARafraichir, collectionId, (CollectionAPersonne) personnesAjoutees.get(it.next()));
775
			}
776
		}
777
	}
778
 
779
	public void modifierCollectionAPersonne(Rafraichissable vueARafraichir, CollectionAPersonneListe personnesModifiees) {
780
		if (personnesModifiees != null && personnesModifiees.size() > 0) {
781
			for (Iterator<String> it = personnesModifiees.keySet().iterator(); it.hasNext();) {
782
				modele.modifierCollectionAPersonne(vueARafraichir, (CollectionAPersonne) personnesModifiees.get(it.next()));
783
			}
784
		}
785
	}
786
 
787
	public void supprimerCollectionAPersonne(Rafraichissable vueARafraichir, CollectionAPersonneListe personnesSupprimees) {
788
		if (personnesSupprimees != null && personnesSupprimees.size() > 0) {
789
			String idCollectionAPersonneSeparesParVirgule = "" ;
790
			for (Iterator<String> it = personnesSupprimees.keySet().iterator(); it.hasNext();) {
901 jpm 791
				idCollectionAPersonneSeparesParVirgule += personnesSupprimees.get(it.next()).getId();
792
				if (it.hasNext()) {
793
					idCollectionAPersonneSeparesParVirgule += ",";
794
				}
875 jpm 795
			}
796
			modele.supprimerCollectionAPersonne(vueARafraichir, idCollectionAPersonneSeparesParVirgule);
797
		}
798
	}
799
 
800
	//+----------------------------------------------------------------------------------------------------------------+
801
	// GESTION de la relation COLLECTION A PUBLICATION
802
 
883 jpm 803
	public void selectionnerCollectionAPublication(Rafraichissable vueARafraichir, String collectionId) {
804
		modele.selectionnerCollectionAPublication(vueARafraichir, collectionId);
805
	}
806
 
807
	public void ajouterCollectionAPublication(Rafraichissable vueARafraichir, String collectionId, CollectionAPublicationListe publicationsAjoutees) {
808
		if (publicationsAjoutees != null && publicationsAjoutees.size() > 0) {
809
			for (Iterator<String> it = publicationsAjoutees.keySet().iterator(); it.hasNext();) {
810
				modele.ajouterCollectionAPublication(vueARafraichir, collectionId, (CollectionAPublication) publicationsAjoutees.get(it.next()));
811
			}
812
		}
813
	}
814
 
815
	public void modifierCollectionAPublication(Rafraichissable vueARafraichir, CollectionAPublicationListe publicationsModifiees) {
816
		if (publicationsModifiees != null && publicationsModifiees.size() > 0) {
817
			for (Iterator<String> it = publicationsModifiees.keySet().iterator(); it.hasNext();) {
818
				modele.modifierCollectionAPublication(vueARafraichir, (CollectionAPublication) publicationsModifiees.get(it.next()));
819
			}
820
		}
821
	}
822
 
907 jpm 823
	public void supprimerCollectionAPublication(Rafraichissable vueARafraichir, CollectionAPublicationListe publicationsSupprimees) {
883 jpm 824
		if (publicationsSupprimees != null && publicationsSupprimees.size() > 0) {
825
			String idCollectionAPublicationSeparesParVirgule = "" ;
826
			for (Iterator<String> it = publicationsSupprimees.keySet().iterator(); it.hasNext();) {
901 jpm 827
				idCollectionAPublicationSeparesParVirgule += publicationsSupprimees.get(it.next()).getId();
828
				if (it.hasNext()) {
829
					idCollectionAPublicationSeparesParVirgule += ",";
830
				}
883 jpm 831
			}
832
			modele.supprimerCollectionAPublication(vueARafraichir, idCollectionAPublicationSeparesParVirgule);
833
		}
834
	}
941 jpm 835
 
875 jpm 836
	//+----------------------------------------------------------------------------------------------------------------+
837
	// GESTION de la relation COLLECTION A COMMENTAIRE
838
 
997 jpm 839
	public void selectionnerCollectionACommentaire(Rafraichissable vueARafraichir, String collectionId) {
840
		modele.selectionnerCollectionACommentaire(vueARafraichir, collectionId);
989 jpm 841
	}
842
 
997 jpm 843
	public void ajouterCollectionACommentaire(Rafraichissable vueARafraichir, String collectionId, CollectionACommentaireListe commentairesAjoutees) {
989 jpm 844
		if (commentairesAjoutees != null && commentairesAjoutees.size() > 0) {
845
			for (Iterator<String> it = commentairesAjoutees.keySet().iterator(); it.hasNext();) {
997 jpm 846
				modele.ajouterCollectionACommentaire(vueARafraichir, collectionId, (CollectionACommentaire) commentairesAjoutees.get(it.next()));
989 jpm 847
			}
848
		}
849
	}
850
 
851
	public void modifierCollectionACommentaire(Rafraichissable vueARafraichir, CollectionACommentaireListe commentairesModifiees) {
852
		if (commentairesModifiees != null && commentairesModifiees.size() > 0) {
853
			for (Iterator<String> it = commentairesModifiees.keySet().iterator(); it.hasNext();) {
854
				modele.modifierCollectionACommentaire(vueARafraichir, (CollectionACommentaire) commentairesModifiees.get(it.next()));
855
			}
856
		}
857
	}
858
 
859
	public void supprimerCollectionACommentaire(Rafraichissable vueARafraichir, CollectionACommentaireListe commentairesSupprimees) {
860
		if (commentairesSupprimees != null && commentairesSupprimees.size() > 0) {
861
			String idCollectionACommentaireSeparesParVirgule = "" ;
862
			for (Iterator<String> it = commentairesSupprimees.keySet().iterator(); it.hasNext();) {
863
				idCollectionACommentaireSeparesParVirgule += commentairesSupprimees.get(it.next()).getId();
864
				if (it.hasNext()) {
865
					idCollectionACommentaireSeparesParVirgule += ",";
866
				}
867
			}
868
			modele.supprimerCollectionACommentaire(vueARafraichir, idCollectionACommentaireSeparesParVirgule, CollectionACommentaireAsyncDao.SUPPRESSION_PAR_COLLECTION);
869
		}
870
	}
875 jpm 871
	//+----------------------------------------------------------------------------------------------------------------+
156 jp_milcent 872
	//												GESTION DES PERSONNES
873
	//+----------------------------------------------------------------------------------------------------------------+
874
 
278 jp_milcent 875
	public void afficherListePersonnes(PersonneListe personnesACharger)	{
646 jp_milcent 876
		if (!(panneauCentre.getContenu() instanceof PersonneVue))	{
626 gduche 877
			panneauCentre.removeAll();
646 jp_milcent 878
			panneauCentre.add(new PersonneVue(this));
673 aurelien 879
			panneauCentre.setId(ComposantId.PANNEAU_PERSONNE_LISTES);
626 gduche 880
		}
599 gduche 881
 
646 jp_milcent 882
		panneauCentre.getContenu().rafraichir(personnesACharger);
156 jp_milcent 883
	}
918 jpm 884
 
885
	public void afficherFormPersonne(String personneId)	{
886
		panneauCentre.removeAll();
887
		PersonneForm personneForm = new PersonneForm(this, personneId);
888
		panneauCentre.add(personneForm);
889
 
890
		panneauCentre.layout();
891
	}
156 jp_milcent 892
 
918 jpm 893
	public void clicListePersonne(Personne personne)	{
894
		panneauCentre.getContenu().rafraichir(personne);
895
	}
896
 
128 gduche 897
	public void clicAjouterPersonne()	{
918 jpm 898
		afficherFormPersonne(null);
128 gduche 899
	}
900
 
918 jpm 901
	public void clicModifierPersonne(List<Personne> selection)	{
902
		if (selection.size() == 0) {
903
			Info.display("Information", "Veuillez sélectionner une personne.");
904
		} else if (selection.size() > 1) {
905
			Info.display("Information", "Veuillez sélectionner une seule personne à la fois.");
906
		} else if (selection.size() == 1) {
907
			afficherFormPersonne(selection.get(0).getId());
908
		} else {
909
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierPersonne() du Médiateur.");
910
		}
841 gduche 911
	}
912
 
285 gduche 913
 
919 jpm 914
	public void clicSupprimerPersonne(final Rafraichissable vue, final List<Personne> personneSelection) {
663 gduche 915
		//Empecher suppression utilisateur
916
		for (int i=0; i < personneSelection.size(); i++)	{
917
			Personne courante = personneSelection.get(i);
918
			if (courante.getId().equals(getUtilisateurId()))	{
772 jpm 919
				Info.display("Information", "Vous ne pouvez pas supprimer votre compte");
663 gduche 920
				personneSelection.remove(courante);
921
			}
922
		}
923
 
245 jp_milcent 924
		if (personneSelection.size() == 0) {
925
			Info.display("Information", "Veuillez sélectionner une personne.");
926
		} else if(personneSelection.size() > 0) {
927
			String message = "Êtes vous sur de vouloir supprimer les personnes sélectionnées ?";
928
			if (personneSelection.size() == 1) {
929
				message = "Êtes vous sur de vouloir supprimer la personne sélectionnée ?";
930
			}
315 gduche 931
 
502 gduche 932
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
933
				public void handleEvent(MessageBoxEvent ce) {
934
					Dialog dialog = (Dialog) ce.getComponent();
935
					Button btn = ce.getButtonClicked();
327 jp_milcent 936
 
937
					if (btn.getText().equals(dialog.yesText)) {
772 jpm 938
						String idPersonneSepareParVirgule = "" ;
347 gduche 939
						Iterator<Personne> itPersonne = personneSelection.iterator();
940
						while (itPersonne.hasNext()) {
941
							Personne personneCourante = itPersonne.next();
772 jpm 942
							idPersonneSepareParVirgule += personneCourante.getId();
943
							idPersonneSepareParVirgule +=",";
327 jp_milcent 944
						}
772 jpm 945
						modele.supprimerPersonne(vue, idPersonneSepareParVirgule);
327 jp_milcent 946
					}
947
				}
948
			};
453 jp_milcent 949
 
315 gduche 950
			MessageBox.confirm("Supprimer une personne", message, listenerSuppression);
245 jp_milcent 951
		} else {
952
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicSupprimerPersonne() du Médiateur.");
953
		}
954
	}
277 jp_milcent 955
 
918 jpm 956
	public void selectionnerPersonne(Rafraichissable vueARafraichir, Personne personne, String projetId)	{
957
		selectionnerPersonne(vueARafraichir, personne, projetId, 0, nbElements);
775 jpm 958
	}
959
 
918 jpm 960
	public void selectionnerPersonne(Rafraichissable vueARafraichir, Personne personne, String projetId, int start, int nbElements)	{
775 jpm 961
		String personneId = null;
1040 gduche 962
		String personneNom = null;
775 jpm 963
		if (personne != null)	{
964
			personneId = personne.getId();
1040 gduche 965
			personneNom = personne.getNom();
775 jpm 966
		}
1040 gduche 967
		modele.selectionnerPersonne(vueARafraichir, personneId, projetId, personneNom, start, nbElements);
775 jpm 968
	}
969
 
599 gduche 970
	public void selectionnerPersonneParNomComplet(Rafraichissable vueARafraichir, String projetId, String nomComplet) {
971
		modele.selectionnerPersonne(vueARafraichir, null, projetId, nomComplet, 0, -1);
277 jp_milcent 972
	}
245 jp_milcent 973
 
775 jpm 974
	public void selectionnerPersonneParProjet(Rafraichissable vueARafraichir, String projetId) {
975
		modele.selectionnerPersonne(vueARafraichir, null, projetId, null, 0, -1);
976
	}
977
 
389 gduche 978
	public void enregistrerPersonne(Rafraichissable vue, Personne personne){
774 jpm 979
		if (personne.getId() != null && !personne.getId().trim().equals("")) {
429 gduche 980
			modele.modifierPersonne(vue, personne);
981
		}	else {
982
			modele.ajouterPersonne(vue, personne);
983
		}
389 gduche 984
	}
985
 
156 jp_milcent 986
	//+----------------------------------------------------------------------------------------------------------------+
987
	//												GESTION DES PUBLICATIONS
988
	//+----------------------------------------------------------------------------------------------------------------+
989
 
107 aurelien 990
	public void afficherListePublication(PublicationListe nouvelleDonnees) {
673 aurelien 991
		if (!(panneauCentre.getContenu() instanceof PublicationVue))	{
626 gduche 992
			panneauCentre.removeAll();
918 jpm 993
			panneauCentre.add(new PublicationVue(this));
626 gduche 994
		}
995
 
646 jp_milcent 996
		panneauCentre.getContenu().rafraichir(nouvelleDonnees);
107 aurelien 997
	}
715 aurelien 998
 
775 jpm 999
	public void afficherFormPublication(String publicationId) {
1000
		panneauCentre.removeAll();
781 jpm 1001
		PublicationForm publicationForm = new PublicationForm(this, publicationId);
775 jpm 1002
		panneauCentre.add(publicationForm);
1003
 
1004
		panneauCentre.layout();
715 aurelien 1005
	}
775 jpm 1006
 
107 aurelien 1007
	public void clicListePublication(Publication publication) {
775 jpm 1008
		if (publication != null) {
675 aurelien 1009
			panneauCentre.getContenu().rafraichir(publication);
1010
		}
107 aurelien 1011
	}
1012
 
1013
	public void clicAjouterPublication() {
775 jpm 1014
		afficherFormPublication(null);
107 aurelien 1015
	}
156 jp_milcent 1016
 
775 jpm 1017
	public void clicModifierPublication(List<Publication> selection) {
1018
		if (selection.size() == 0) {
1019
			Info.display("Information", "Veuillez sélectionner une publication.");
1020
		} else if (selection.size() > 1) {
1021
			Info.display("Information", "Veuillez sélectionner une seule publication à la fois.");
1022
		} else if (selection.size() == 1) {
1023
			afficherFormPublication(selection.get(0).getId());
379 jp_milcent 1024
		} else {
775 jpm 1025
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierPublication() du Médiateur.");
245 jp_milcent 1026
		}
1027
	}
1028
 
315 gduche 1029
	public void clicSupprimerPublication(final List<Publication> publicationListe) {
453 jp_milcent 1030
		if (publicationListe.size() <= 0) {
315 gduche 1031
			MessageBox.alert("Attention", "Vous devez sélectionner une publication", null);
379 jp_milcent 1032
		} else {
673 aurelien 1033
			String message = "Voulez-vous vraiment supprimer ces publications ?";
775 jpm 1034
			if (publicationListe.size() == 1) {
245 jp_milcent 1035
				message = "Voulez-vous vraiment supprimer cette publication ?";
1036
			}
315 gduche 1037
 
502 gduche 1038
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
1039
				public void handleEvent(MessageBoxEvent ce) {
1040
					Dialog dialog = (Dialog) ce.getComponent();
1041
				    Button btn = ce.getButtonClicked();
315 gduche 1042
 
379 jp_milcent 1043
				    if (btn.getText().equals(dialog.yesText)) {
919 jpm 1044
				    	supprimerPublication(panneauCentre.getContenu(), publicationListe);
315 gduche 1045
				    }
1046
				}
1047
			};
1048
 
1049
			MessageBox.confirm("Supprimer une publication", message, listenerSuppression);
245 jp_milcent 1050
		}
1051
	}
709 jp_milcent 1052
 
1053
	public void selectionnerPublication(Rafraichissable vueARafraichir, String publicationId) {
1046 gduche 1054
		selectionnerPublication(vueARafraichir, getProjetId(), publicationId, null, 0, nbElements);
709 jp_milcent 1055
	}
1056
 
1057
	public void selectionnerPublicationParNomComplet(Rafraichissable vueARafraichir, String projetId, String nomComplet) {
1046 gduche 1058
		selectionnerPublication(vueARafraichir, projetId, null, nomComplet, 0, nbElements);
709 jp_milcent 1059
	}
1060
 
1046 gduche 1061
	public void selectionnerPublication(Rafraichissable vueARafraichir, String projetId, String publicationId, String nomComplet, int pageCourante, int nbElements) {
1062
		modele.selectionnerPublication(vueARafraichir, publicationId, projetId, nomComplet, nbElements, pageCourante);
1063
	}
1064
 
786 jpm 1065
	public void ajouterPublication(Rafraichissable vueARafraichir, Publication publication) {
1066
		modele.ajouterPublication(vueARafraichir, publication);
245 jp_milcent 1067
	}
1068
 
786 jpm 1069
	public void modifierPublication(Rafraichissable vueARafraichir, Publication publication) {
1070
		modele.modifierPublication(vueARafraichir, publication);
245 jp_milcent 1071
	}
919 jpm 1072
 
1073
	public void supprimerPublication(Rafraichissable vueARafraichir, List<Publication> publicationsListe) {
1074
		if (publicationsListe != null && publicationsListe.size() > 0) {
1075
			String idPublicationSeparesParVirgule = "" ;
1076
			Iterator<Publication> it = publicationsListe.iterator();
1077
			while (it.hasNext()) {
1078
				idPublicationSeparesParVirgule += it.next().getId();
1079
				if (it.hasNext()) {
1080
					idPublicationSeparesParVirgule += ",";
1081
				}
1082
			}
1083
			modele.supprimerPublication(vueARafraichir, idPublicationSeparesParVirgule);
1084
			modele.supprimerPublicationAPersonne(vueARafraichir, idPublicationSeparesParVirgule);
1085
		}
1086
	}
245 jp_milcent 1087
 
453 jp_milcent 1088
	public void clicObtenirListeEditeurs(Rafraichissable vueARafraichir) {
775 jpm 1089
		selectionnerStructureParProjet(vueARafraichir, null);
245 jp_milcent 1090
	}
1091
 
453 jp_milcent 1092
	public void clicObtenirListeAuteurs(Rafraichissable vueARafraichir) {
775 jpm 1093
		selectionnerPersonneParProjet(vueARafraichir, null);
245 jp_milcent 1094
	}
1095
 
156 jp_milcent 1096
	//+----------------------------------------------------------------------------------------------------------------+
822 jpm 1097
	// GESTION de la relation PUBLICATION A PERSONNE
1098
 
1099
	public void selectionnerPublicationAPersonne(Rafraichissable vueARafraichir, String publicationId, String personnesId, String roleId) {
1100
		modele.selectionPublicationAPersonne(vueARafraichir, publicationId, personnesId, roleId);
1101
	}
1102
 
1014 gduche 1103
	public void selectionnerPublicationAPersonne(Rafraichissable vueARafraichir, String publicationId, String personnesId, List roleId) {
1104
		String roleIds = "";
1105
		Iterator<Valeur> itRole = roleId.iterator();
1106
		while (itRole.hasNext())	{
1107
			roleIds+= itRole.next().getId();
1108
			if (itRole.hasNext())	{
1109
				roleIds+=",";
1110
			}
1111
		}
1112
		modele.selectionPublicationAPersonne(vueARafraichir, publicationId, personnesId, roleIds);
1113
	}
1114
 
901 jpm 1115
	public void ajouterPublicationAPersonne(Rafraichissable vueARafraichir, String publicationId, PublicationAPersonneListe personnesAjoutees, String roleId) {
1116
		if (personnesAjoutees != null && personnesAjoutees.size() > 0) {
1117
			String idPublicationAPersonneSepareParVirgule = "" ;
1118
			for (Iterator<String> it = personnesAjoutees.keySet().iterator(); it.hasNext();) {
1119
				idPublicationAPersonneSepareParVirgule += personnesAjoutees.get(it.next()).getIdPersonne();
1120
				if (it.hasNext()) {
1121
					idPublicationAPersonneSepareParVirgule += ",";
1122
				}
1123
			}
1124
			modele.ajouterPublicationAPersonne(vueARafraichir, publicationId, idPublicationAPersonneSepareParVirgule, roleId);
1125
		}
822 jpm 1126
	}
901 jpm 1127
 
1128
	public void supprimerPublicationAPersonne(Rafraichissable vueARafraichir, PublicationAPersonneListe personnesSupprimees) {
1129
		if (personnesSupprimees != null && personnesSupprimees.size() > 0) {
1130
			String idPublicationAPersonneSepareParVirgule = "" ;
1131
			for (Iterator<String> it = personnesSupprimees.keySet().iterator(); it.hasNext();) {
1132
				idPublicationAPersonneSepareParVirgule += personnesSupprimees.get(it.next()).getId();
1133
				if (it.hasNext()) {
1134
					idPublicationAPersonneSepareParVirgule += ",";
1135
				}
1136
			}
968 jpm 1137
			modele.supprimerPublicationAPersonne(vueARafraichir, idPublicationAPersonneSepareParVirgule);
901 jpm 1138
		}
822 jpm 1139
	}
1140
 
996 gduche 1141
	//Lier plusieurs publication à une personne
1142
	public void ajouterPublicationAPersonne(Rafraichissable vueARafraichir, PublicationAPersonneListe listePublications, String personneId, String roleId) {
1143
		if (listePublications!=null && listePublications.size()>0)	{
1144
			String idsPubli = "";
1014 gduche 1145
			String rolesIds = "";
996 gduche 1146
			for (Iterator<String> it = listePublications.keySet().iterator(); it.hasNext();) {
1014 gduche 1147
				PublicationAPersonne publi = listePublications.get(it.next());
1148
				idsPubli += publi.getId();
1149
				rolesIds += publi.getRole();
996 gduche 1150
				if (it.hasNext()) {
1151
					idsPubli += ",";
1014 gduche 1152
					rolesIds += ",";
996 gduche 1153
				}
1154
			}
1014 gduche 1155
			modele.ajouterPublicationAPersonne(vueARafraichir, idsPubli, personneId, rolesIds);
996 gduche 1156
		}
1157
	}
1158
 
822 jpm 1159
	//+----------------------------------------------------------------------------------------------------------------+
985 jpm 1160
	//												GESTION DES COMMENTAIRES
1161
	//+----------------------------------------------------------------------------------------------------------------+
1162
 
1163
	public void afficherListeCommentaire(CommentaireListe nouvelleDonnees) {
1164
		if (!(panneauCentre.getContenu() instanceof CommentaireVue)) {
1165
			panneauCentre.removeAll();
1166
			panneauCentre.add(new CommentaireVue(this));
1167
		}
1168
 
1169
		panneauCentre.getContenu().rafraichir(nouvelleDonnees);
1170
	}
1171
 
1172
	public void afficherFormCommentaire(String commentaireId) {
1173
		panneauCentre.removeAll();
989 jpm 1174
		CommentaireForm commentaireForm = new CommentaireForm(this, commentaireId);
985 jpm 1175
		panneauCentre.add(commentaireForm);
1176
 
1177
		panneauCentre.layout();
1178
	}
1179
 
1180
	public void clicListeCommentaire(Commentaire commentaire) {
1181
		if (commentaire != null) {
1182
			panneauCentre.getContenu().rafraichir(commentaire);
1183
		}
1184
	}
1185
 
1186
	public void clicAjouterCommentaire() {
1187
		afficherFormCommentaire(null);
1188
	}
1189
 
1190
	public void clicModifierCommentaire(List<Commentaire> selection) {
1191
		if (selection.size() == 0) {
1192
			Info.display("Information", "Veuillez sélectionner un commentaire.");
1193
		} else if (selection.size() > 1) {
1194
			Info.display("Information", "Veuillez sélectionner un seul commentaire à la fois.");
1195
		} else if (selection.size() == 1) {
1196
			afficherFormCommentaire(selection.get(0).getId());
1197
		} else {
1198
			Info.display("Erreur", "Une erreur est survenue dans la méthode clicModifierCommentaire() du Médiateur.");
1199
		}
1200
	}
1201
 
1202
	public void clicSupprimerCommentaire(final List<Commentaire> commentaireListe) {
1203
		if (commentaireListe.size() <= 0) {
1204
			MessageBox.alert("Attention", "Vous devez sélectionner un commentaire", null);
1205
		} else {
1206
			String message = "Voulez-vous vraiment supprimer ces commentaires ?";
1207
			if (commentaireListe.size() == 1) {
1208
				message = "Voulez-vous vraiment supprimer ce commentaire ?";
1209
			}
1210
 
1211
			final Listener<MessageBoxEvent> listenerSuppression = new Listener<MessageBoxEvent>() {
1212
				public void handleEvent(MessageBoxEvent ce) {
1213
					Dialog dialog = (Dialog) ce.getComponent();
1214
				    Button btn = ce.getButtonClicked();
1215
 
1216
				    if (btn.getText().equals(dialog.yesText)) {
1217
				    	supprimerCommentaire(panneauCentre.getContenu(), commentaireListe);
1218
				    }
1219
				}
1220
			};
1221
 
1222
			MessageBox.confirm("Supprimer un commentaire", message, listenerSuppression);
1223
		}
1224
	}
1225
 
1226
	public void selectionnerCommentaire(Rafraichissable vueARafraichir, String commentaireId) {
1048 gduche 1227
		selectionnerCommentaire(vueARafraichir, commentaireId, null, 0, nbElements);
985 jpm 1228
	}
1048 gduche 1229
	public void selectionnerCommentaire(Rafraichissable vueARafraichir, String commentaireId, String titre, int pageCourante, int nbElements) {
1230
		modele.selectionnerCommentaire(vueARafraichir, commentaireId, getProjetId(), titre, pageCourante, nbElements);
1231
	}
985 jpm 1232
 
997 jpm 1233
	public void selectionnerCommentaireParTitre(Rafraichissable vueARafraichir, String titre) {
1048 gduche 1234
		selectionnerCommentaire(vueARafraichir, null, titre, 0, nbElements);
997 jpm 1235
	}
1236
 
985 jpm 1237
	public void ajouterCommentaire(Rafraichissable vueARafraichir, Commentaire commentaire) {
1238
		modele.ajouterCommentaire(vueARafraichir, commentaire);
1239
	}
1240
 
1241
	public void modifierCommentaire(Rafraichissable vueARafraichir, Commentaire commentaire) {
1242
		modele.modifierCommentaire(vueARafraichir, commentaire);
1243
	}
1244
 
1245
	public void supprimerCommentaire(Rafraichissable vueARafraichir, List<Commentaire> commentairesListe) {
1246
		if (commentairesListe != null && commentairesListe.size() > 0) {
1247
			String idCommentaireSeparesParVirgule = "" ;
1248
			Iterator<Commentaire> it = commentairesListe.iterator();
1249
			while (it.hasNext()) {
1250
				idCommentaireSeparesParVirgule += it.next().getId();
1251
				if (it.hasNext()) {
1252
					idCommentaireSeparesParVirgule += ",";
1253
				}
1254
			}
1255
			modele.supprimerCommentaire(vueARafraichir, idCommentaireSeparesParVirgule);
989 jpm 1256
			modele.supprimerCollectionACommentaire(vueARafraichir, idCommentaireSeparesParVirgule, CollectionACommentaireAsyncDao.SUPPRESSION_PAR_COMMENTAIRE);
985 jpm 1257
		}
1258
	}
1259
 
1260
	//+----------------------------------------------------------------------------------------------------------------+
447 jp_milcent 1261
	//												RAFRAICHISSEMENT
156 jp_milcent 1262
	//+----------------------------------------------------------------------------------------------------------------+
1263
 
898 gduche 1264
	public void rafraichir(Object nouvellesDonnees) {
1265
		if (nouvellesDonnees instanceof Utilisateur) {
932 jpm 1266
			repandreEtatIdentification((Utilisateur) nouvellesDonnees);
1267
		} else if (nouvellesDonnees instanceof Information) {
1268
			Information info = (Information) nouvellesDonnees;
1269
			if (info.getType().equals("modification_personne")) {
1270
				repandreInfoMiseAJourUtilisateur();
1271
			}
1272
		} else {
898 gduche 1273
			GWT.log(i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
277 jp_milcent 1274
		}
1275
	}
281 gduche 1276
 
453 jp_milcent 1277
	//+----------------------------------------------------------------------------------------------------------------+
1278
	//												GESTION du STATUT
1279
	//+----------------------------------------------------------------------------------------------------------------+
288 gduche 1280
 
332 gduche 1281
	public void afficherPopinChargement()	{
1282
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).center();
1283
	}
453 jp_milcent 1284
 
332 gduche 1285
	public void masquerPopinChargement()	{
1286
		((PopupChargement) Registry.get(RegistreId.POPUP_CHARGEMENT)).hide();
1287
	}
447 jp_milcent 1288
 
277 jp_milcent 1289
}