Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
935 jpm 1
package org.tela_botanica.client.vues.publication;
219 aurelien 2
 
227 aurelien 3
import java.util.ArrayList;
4
import java.util.Iterator;
365 jp_milcent 5
import java.util.List;
227 aurelien 6
 
981 jpm 7
import org.tela_botanica.client.ComposantClass;
219 aurelien 8
import org.tela_botanica.client.Mediateur;
1329 cyprien 9
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
1284 gduche 10
import org.tela_botanica.client.composants.InfoLogger;
1369 cyprien 11
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
1329 cyprien 12
import org.tela_botanica.client.composants.pagination.ProxyProjets;
13
import org.tela_botanica.client.composants.pagination.ProxyStructures;
822 jpm 14
import org.tela_botanica.client.images.Images;
219 aurelien 15
import org.tela_botanica.client.interfaces.Rafraichissable;
705 aurelien 16
import org.tela_botanica.client.modeles.Information;
775 jpm 17
import org.tela_botanica.client.modeles.MenuApplicationId;
1329 cyprien 18
import org.tela_botanica.client.modeles.Valeur;
1284 gduche 19
import org.tela_botanica.client.modeles.aDonnee;
935 jpm 20
import org.tela_botanica.client.modeles.personne.Personne;
21
import org.tela_botanica.client.modeles.personne.PersonneListe;
1032 jpm 22
import org.tela_botanica.client.modeles.projet.Projet;
23
import org.tela_botanica.client.modeles.projet.ProjetListe;
935 jpm 24
import org.tela_botanica.client.modeles.publication.Publication;
25
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
26
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
27
import org.tela_botanica.client.modeles.structure.Structure;
28
import org.tela_botanica.client.modeles.structure.StructureListe;
1322 gduche 29
import org.tela_botanica.client.synchronisation.Sequenceur;
1329 cyprien 30
import org.tela_botanica.client.util.Debug;
792 jpm 31
import org.tela_botanica.client.util.Pattern;
782 jpm 32
import org.tela_botanica.client.util.UtilArray;
884 jpm 33
import org.tela_botanica.client.util.UtilString;
1284 gduche 34
import org.tela_botanica.client.vues.FenetreForm;
935 jpm 35
import org.tela_botanica.client.vues.Formulaire;
1284 gduche 36
import org.tela_botanica.client.vues.FormulaireBarreValidation;
37
import org.tela_botanica.client.vues.personne.PersonneForm;
219 aurelien 38
 
1284 gduche 39
import com.extjs.gxt.ui.client.Style.Scroll;
40
import com.extjs.gxt.ui.client.Style.SortDir;
1329 cyprien 41
import com.extjs.gxt.ui.client.core.XTemplate;
42
import com.extjs.gxt.ui.client.data.ModelData;
43
import com.extjs.gxt.ui.client.data.ModelType;
1284 gduche 44
import com.extjs.gxt.ui.client.event.BaseEvent;
505 jp_milcent 45
import com.extjs.gxt.ui.client.event.ButtonEvent;
1284 gduche 46
import com.extjs.gxt.ui.client.event.ComponentEvent;
980 jpm 47
import com.extjs.gxt.ui.client.event.Events;
1284 gduche 48
import com.extjs.gxt.ui.client.event.KeyListener;
49
import com.extjs.gxt.ui.client.event.Listener;
219 aurelien 50
import com.extjs.gxt.ui.client.event.SelectionListener;
51
import com.extjs.gxt.ui.client.store.ListStore;
1284 gduche 52
import com.extjs.gxt.ui.client.store.Store;
53
import com.extjs.gxt.ui.client.store.StoreEvent;
1329 cyprien 54
import com.extjs.gxt.ui.client.widget.ContentPanel;
55
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
1095 jpm 56
import com.extjs.gxt.ui.client.widget.Info;
219 aurelien 57
import com.extjs.gxt.ui.client.widget.LayoutContainer;
705 aurelien 58
import com.extjs.gxt.ui.client.widget.MessageBox;
1284 gduche 59
import com.extjs.gxt.ui.client.widget.Text;
219 aurelien 60
import com.extjs.gxt.ui.client.widget.button.Button;
1284 gduche 61
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
219 aurelien 62
import com.extjs.gxt.ui.client.widget.form.ComboBox;
1032 jpm 63
import com.extjs.gxt.ui.client.widget.form.Field;
219 aurelien 64
import com.extjs.gxt.ui.client.widget.form.FieldSet;
1284 gduche 65
import com.extjs.gxt.ui.client.widget.form.FormPanel;
219 aurelien 66
import com.extjs.gxt.ui.client.widget.form.TextField;
1032 jpm 67
import com.extjs.gxt.ui.client.widget.form.Validator;
219 aurelien 68
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
1329 cyprien 69
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
1284 gduche 70
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
1329 cyprien 71
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
1284 gduche 72
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
73
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
1329 cyprien 74
import com.extjs.gxt.ui.client.widget.grid.Grid;
75
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
1284 gduche 76
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
1329 cyprien 77
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
78
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
1284 gduche 79
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
219 aurelien 80
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
81
import com.extjs.gxt.ui.client.widget.layout.FormData;
82
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
1284 gduche 83
import com.extjs.gxt.ui.client.widget.layout.RowData;
84
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
85
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
86
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
705 aurelien 87
import com.google.gwt.core.client.GWT;
219 aurelien 88
 
877 aurelien 89
 
775 jpm 90
public class PublicationForm extends Formulaire implements Rafraichissable {
219 aurelien 91
 
1322 gduche 92
	//Variables de classe:
93
	// Relatives à la publication
786 jpm 94
	private Publication publication;
1322 gduche 95
 
96
	// Relatives aux auteurs
1133 jpm 97
	private PersonneListe auteursInitialListe = null;
1284 gduche 98
	private PersonneListe auteursAjoutes = null;
99
	private PersonneListe auteursSupprimes = null;
219 aurelien 100
 
1329 cyprien 101
	private ContentPanel auteursFieldset = null;
102
	private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
775 jpm 103
	private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
104
	private ListStore<Personne> auteursStorePartage = null;
227 aurelien 105
 
775 jpm 106
	private FieldSet generalitesFieldset = null;
786 jpm 107
	private TextField<String> titreChp = null;
108
	private TextField<String> collectionChp = null;
109
	private TextField<String> uriChp = null;
219 aurelien 110
 
775 jpm 111
	private FieldSet editionFieldset = null;
1329 cyprien 112
	private ChampComboBoxRechercheTempsReelPaginable editeurCombobox = null;
786 jpm 113
	private TextField<String> datePublicationChp = null;
114
	private TextField<String> tomeChp = null;
115
	private TextField<String> fasciculeChp = null;
116
	private TextField<String> pagesChp = null;
219 aurelien 117
 
1284 gduche 118
	private LayoutContainer zoneHaut, zoneBas;
119
 
120
	private ToolBar barreOutils = null;
121
	private EditorGrid<Personne> grille;
122
	private ComboBox<Personne> personnesSaisiesComboBox = null;
123
	private Button personnesBoutonSupprimer = null;
124
	private Button personnesBoutonModifier = null;
125
	private PersonneListe listePersonne = new PersonneListe();
126
 
127
	private FenetreForm fenetreFormulaire = null;
1322 gduche 128
	private Sequenceur sequenceur;
1284 gduche 129
 
781 jpm 130
	public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
782 jpm 131
		initialiserPublicationForm(mediateurCourrant, publicationId);
132
	}
133
 
134
	public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
822 jpm 135
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
782 jpm 136
		initialiserPublicationForm(mediateurCourrant, publicationId);
137
	}
138
 
139
	private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
1322 gduche 140
		sequenceur = new Sequenceur();
799 jpm 141
		publication = new Publication();
822 jpm 142
		publication.setId(publicationId);
1322 gduche 143
		auteursInitialListe = new PersonneListe();
144
		initialiserAuteurs();	// Crée les listes d'auteurs ajoutés et supprimés
822 jpm 145
 
1322 gduche 146
		String modeDeCreation = (UtilString.isEmpty(publicationId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
775 jpm 147
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
1284 gduche 148
		panneauFormulaire.setLayout(new RowLayout());
149
		panneauFormulaire.setStyleAttribute("padding", "0");
1322 gduche 150
 
1284 gduche 151
		zoneHaut = new LayoutContainer(new FitLayout());
152
		zoneBas = new LayoutContainer(new FlowLayout());
153
		panneauFormulaire.add(zoneHaut, new RowData(1, 0.3));
154
		panneauFormulaire.add(zoneBas, new RowData(1, 0.5));
155
		panneauFormulaire.setScrollMode(Scroll.AUTO);
1095 jpm 156
		genererTitreFormulaire();
157
 
775 jpm 158
		creerZoneAuteurs();
1284 gduche 159
		zoneHaut.add(auteursFieldset);
219 aurelien 160
 
775 jpm 161
		creerZoneGeneralites();
1284 gduche 162
		zoneBas.add(generalitesFieldset);
239 aurelien 163
 
775 jpm 164
		creerZoneEdition();
1284 gduche 165
		zoneBas.add(editionFieldset);
822 jpm 166
 
167
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
1322 gduche 168
			mediateurCourrant.selectionnerPublication(this, publicationId, sequenceur);
169
			mediateurCourrant.selectionnerPublicationAPersonne(this, publicationId, null, PublicationAPersonne.ROLE_AUTEUR, sequenceur);
170
			sequenceur.empilerRafraichissement(this, new Information("chargement_modifier_ok"));
822 jpm 171
		}
781 jpm 172
	}
782 jpm 173
 
1284 gduche 174
	public void actualiserEtatBoutonsBarreOutils() {
175
			// Activation des boutons si la grille contient un élément
176
			if (grille.getStore().getCount() > 0) {
177
				personnesBoutonSupprimer.enable();
178
				personnesBoutonModifier.enable();
179
			}
180
			// Désactivation des boutons si la grille ne contient plus d'élément
181
			if (grille.getStore().getCount() == 0) {
182
				personnesBoutonSupprimer.disable();
183
				personnesBoutonModifier.disable();
184
			}
185
		}
186
 
187
	private ToolBar creerBarreOutilsGrille() {
188
		ToolBar barreOutils = new ToolBar();
189
 
190
		Button ajouterBouton = creerBoutonAjouter();
191
		barreOutils.add(ajouterBouton);
192
 
193
		barreOutils.add(new Text(" ou "));
194
 
195
		personnesSaisiesComboBox = creerComboBoxPersonnesSaisies();
196
		barreOutils.add(personnesSaisiesComboBox);
197
 
198
		barreOutils.add(new SeparatorToolItem());
199
 
200
		personnesBoutonModifier = creerBoutonModifier();
201
		barreOutils.add(personnesBoutonModifier);
202
 
203
		barreOutils.add(new SeparatorToolItem());
204
 
205
		personnesBoutonSupprimer = creerBoutonSupprimer();
206
		barreOutils.add(personnesBoutonSupprimer);
207
 
208
		barreOutils.add(new SeparatorToolItem());
209
 
210
		Button rafraichirBouton = creerBoutonRafraichir();
211
		barreOutils.add(rafraichirBouton);
212
 
213
		return barreOutils;
214
	}
215
 
216
	private Button creerBoutonAjouter() {
217
		Button bouton = new Button(i18nC.ajouter());
218
		bouton.setIcon(Images.ICONES.vcardAjouter());
219
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
220
			public void componentSelected(ButtonEvent ce) {
221
				fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
222
				fenetreFormulaire.show();
223
			}
224
		});
225
		return bouton;
226
	}
227
 
228
	private Button creerBoutonModifier() {
229
		Button bouton = new Button(i18nC.modifier());
230
		bouton.setIcon(Images.ICONES.vcardModifier());
231
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
232
			public void componentSelected(ButtonEvent ce) {
233
				Personne personneSaisieSelectionnee = grille.getSelectionModel().getSelectedItem();
234
 
235
				if (personneSaisieSelectionnee == null) {
236
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
237
				} else {
238
					fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
239
					fenetreFormulaire.show();
240
				}
241
			}
242
		});
243
		return bouton;
244
	}
245
 
246
	private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
247
		String personneId = null;
248
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
249
			Personne personneSaisieSelectionnee = grille.getSelectionModel().getSelectedItem();
250
			personneId = personneSaisieSelectionnee.getId();
251
		}
252
 
253
		final FenetreForm fenetre = new FenetreForm("");
254
		final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
255
		fenetre.add(formulaire);
256
		return fenetre;
257
	}
258
 
259
	private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
260
		PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
261
		FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
262
		fenetre.setHeading(panneauFormulaire.getHeading());
263
		panneauFormulaire.setHeaderVisible(false);
264
		panneauFormulaire.setTopComponent(null);
265
 
266
		// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
267
		panneauFormulaire.getBottomComponent().hide();
268
		SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
269
		final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
270
		fenetre.setBottomComponent(barreValidation);
271
 
272
		return formulairePersonne;
273
	}
274
 
275
	private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
276
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
277
			public void componentSelected(ButtonEvent ce) {
278
				String code = ((Button) ce.getComponent()).getData("code");
279
				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
280
					if (formulaire.soumettreFormulaire()) {
281
						fenetre.hide();
282
					}
283
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
284
					formulaire.soumettreFormulaire();
285
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
286
					fenetre.hide();
287
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
288
					fenetreFormulaire.hide();
289
					fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode);
290
					fenetreFormulaire.show();
291
				}
292
			}
293
		};
294
 
295
		return ecouteur;
296
	}
297
 
298
	private Button creerBoutonSupprimer() {
299
		Button bouton = new Button(i18nC.supprimer());
300
		bouton.setIcon(Images.ICONES.vcardSupprimer());
301
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
302
			public void componentSelected(ButtonEvent ce) {
303
				Personne personneSaisieSelectionnee = grille.getSelectionModel().getSelectedItem();
304
				if (personneSaisieSelectionnee == null) {
305
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
306
				} else {
307
					supprimerDansGrille(personneSaisieSelectionnee);
308
				}
309
			}
310
		});
311
		return bouton;
312
	}
313
 
314
	private Button creerBoutonRafraichir() {
315
		Button bouton = new Button(i18nC.rafraichir());
316
		bouton.setIcon(Images.ICONES.rafraichir());
317
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
318
			public void componentSelected(ButtonEvent ce) {
319
				actualiserGrille();
320
			}
321
		});
322
		return bouton;
323
	}
324
 
325
	private void actualiserGrille() {
326
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
327
			// FIXME : c'est la merde
328
			//mediateur.selectionner(this, null, personneSelectionnee.getId(), "%");
329
		} else {
330
			grille.getStore().removeAll();
331
			layout();
332
		}
333
	}
334
 
335
	private ComboBox<Personne> creerComboBoxPersonnesSaisies() {
336
		ListStore<Personne> personnesSaisiesStore = new ListStore<Personne>();
337
 
338
		ComboBox<Personne> comboBox = new ComboBox<Personne>();
339
		comboBox.setWidth(400);
340
		comboBox.setEmptyText(i18nC.chercherPersonneSaisi());
341
		comboBox.setTriggerAction(TriggerAction.ALL);
342
		comboBox.setEditable(true);
343
		comboBox.setDisplayField("fmt_nom_complet");
344
		comboBox.setStore(personnesSaisiesStore);
345
		comboBox.addKeyListener(new KeyListener() {
346
			public void componentKeyUp(ComponentEvent ce) {
347
				if (personnesSaisiesComboBox.getRawValue() != null && personnesSaisiesComboBox.getRawValue().length() > 0) {
348
					if (!ce.isNavKeyPress()) {
349
						obtenirPersonnesSaisies(personnesSaisiesComboBox.getRawValue());
350
					}
351
				}
352
			}
353
		});
354
		comboBox.addListener(Events.Select, new Listener<BaseEvent>() {
355
			public void handleEvent(BaseEvent be) {
356
				if (personnesSaisiesComboBox.getValue() instanceof Personne) {
357
					// N'ajouter l'auteur que s'il n'est pas déjà présent dans la grille et dans les valeurs initiales
358
					Personne personneSaisieSelectionne = personnesSaisiesComboBox.getValue();
359
					if (grille.getStore().findModel(personneSaisieSelectionne) != null)	{
360
						Info.display("Information", "La personne est déjà présente dans la liste d'auteurs");
361
					} else {
362
						if (!auteursInitialListe.containsValue(personneSaisieSelectionne))	{
363
							auteursAjoutes.put(personneSaisieSelectionne.getId(), personneSaisieSelectionne);
364
						}
365
						ajouterDansGrille(personneSaisieSelectionne);
366
						personnesSaisiesComboBox.setValue(null);
367
					}
368
				}
369
			}
370
		});
371
		return comboBox;
372
	}
373
 
374
	private void obtenirPersonnesSaisies(String nom) {
1367 cyprien 375
		mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%", null);
1284 gduche 376
	}
377
 
378
	private void ajouterDansGrille(Personne personne) {
379
		ajouterDansGrille(personne, 0);
380
	}
381
 
382
	private void ajouterDansGrille(Personne personne, int index) {
383
		if (personne != null) {
384
			if (!grille.getStore().contains(personne))	{
385
				//1) si elle ne fait pas partie des initiaux, ajouter à la liste à ajouter
386
				if (!auteursInitialListe.containsValue(personne))	{
387
					auteursAjoutes.put(personne.getId(), personne);
388
				}
389
 
390
				// L'enlever de la liste à supprimer
391
				if (auteursSupprimes.containsValue(personne))	{
392
					auteursSupprimes.remove(personne);
393
				}
394
				//2) Ajouter a la grille
395
				grille.getStore().insert(personne, index);
396
				grille.getSelectionModel().select(index, false);
397
			} else {
398
				InfoLogger.display("Information", "La personne choisie existe déjà dans la liste.");
399
			}
400
		}
401
	}
402
 
403
	/**
404
	 * Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees
405
	 */
406
	private void mettreAJourGrille()	{
407
 
408
		grille.getStore().removeAll();
409
		grille.getStore().add(listePersonne.toList());
410
	}
411
 
412
	private void supprimerDansGrille(Personne personne) {
413
		if (personne != null) {
414
			//1) Ajouter a la liste des personne à supprimer uniquement si est présente dans la liste initiale
415
			if (auteursInitialListe.containsValue(personne)) {
416
				auteursSupprimes.put(personne.getId(), personne);
417
			}
418
 
419
			if (auteursAjoutes.containsValue(personne))	{
420
				auteursAjoutes.remove(personne);
421
			}
422
 
423
			//2) Supprimer la personne de la liste
424
			grille.getStore().remove(personne);
425
		} else {
426
			Info.display("Information", "Vous devez sélectionner une personne");
427
		}
428
	}
429
 
430
	private EditorGrid<Personne> creerGrille() {
431
 
432
		ListStore<Personne> storeGrille = new ListStore<Personne>();
433
		storeGrille.addListener(Store.Add, new Listener<StoreEvent<Personne>>() {
434
			public void handleEvent(StoreEvent<Personne> ce) {
435
				actualiserEtatBoutonsBarreOutils();
436
			}
437
		});
438
 
439
		storeGrille.addListener(Store.Remove, new Listener<StoreEvent<Personne>>() {
440
			public void handleEvent(StoreEvent<Personne> ce) {
441
				actualiserEtatBoutonsBarreOutils();
442
			}
443
		});
444
 
445
		storeGrille.addListener(Store.Update, new Listener<StoreEvent<Personne>>() {
446
			public void handleEvent(StoreEvent<Personne> ce) {
447
				if (ce.getRecord().isModified("_role_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
448
					ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
449
				}
450
			}
451
		});
452
 
453
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
454
		colonnes.add(new ColumnConfig("fmt_nom_complet", i18nC.personneNomComplet(), 150));
455
		colonnes.add(new ColumnConfig("code_postal", i18nC.personneCodePostal(), 150));
456
		colonnes.add(new ColumnConfig("ville", i18nC.personneVille(), 75));
457
		colonnes.add(new ColumnConfig("truk_courriel", i18nC.personneCourriel(), 75));
458
 
459
		GridSelectionModel<Personne> modeleDeSelection = new GridSelectionModel<Personne>();
460
 
461
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
462
 
463
		EditorGrid<Personne> grillePublications = new EditorGrid<Personne>(storeGrille, modeleDeColonnes);
464
		grillePublications.setHeight("100%");
465
		grillePublications.setBorders(true);
466
		grillePublications.setSelectionModel(modeleDeSelection);
467
		grillePublications.getView().setForceFit(true);
468
		grillePublications.setAutoExpandColumn("fmt_nom_complet");
469
		grillePublications.setStripeRows(true);
470
		grillePublications.setTrackMouseOver(true);
471
 
472
		return grillePublications;
473
	}
474
 
1095 jpm 475
	private void genererTitreFormulaire() {
989 jpm 476
		String titre = i18nC.publicationTitreFormAjout();
822 jpm 477
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
1095 jpm 478
			 titre = i18nC.publicationTitreFormModif();
479
			 if (publication != null) {
1322 gduche 480
				 titre += " - "+i18nC.id()+": "+publication.getId()+" - "+publication.getTitre();
1095 jpm 481
			 }
822 jpm 482
		}
1095 jpm 483
		panneauFormulaire.setHeading(titre);
822 jpm 484
	}
1284 gduche 485
 
822 jpm 486
 
775 jpm 487
	private void creerZoneAuteurs() {
1329 cyprien 488
		auteursFieldset = new ContentPanel();
489
		auteursFieldset.setLayout(new FitLayout());
490
		auteursFieldset.setHeading("Auteurs");
491
 
775 jpm 492
		auteurComboboxListe = new ArrayList<ComboBox<Personne>>(0);
792 jpm 493
		mediateur.clicObtenirListeAuteurs(this);
775 jpm 494
 
822 jpm 495
		creerChampsAuteur();
775 jpm 496
	}
497
 
822 jpm 498
	private void creerChampsAuteur() {
775 jpm 499
		auteursFieldset.removeAll();
1284 gduche 500
		barreOutils = creerBarreOutilsGrille();
1329 cyprien 501
		auteursFieldset.setTopComponent(barreOutils);
1284 gduche 502
		grille = creerGrille();
503
		auteursFieldset.add(grille);
1131 jpm 504
		auteursFieldset.layout();
775 jpm 505
	}
506
 
507
	private ComboBox<Personne> creerComboBoxAuteursSaisis() {
1134 jpm 508
		ListStore<Personne> auteursStore = new ListStore<Personne>();
509
		auteursStore.add(auteursStorePartage.getModels());
510
 
775 jpm 511
		ComboBox<Personne> comboBox = new ComboBox<Personne>();
860 jpm 512
		comboBox.setEmptyText(i18nC.chercherPersonneSaisi());
775 jpm 513
		comboBox.setEditable(true);
1131 jpm 514
		comboBox.setAllowBlank(false);
775 jpm 515
		comboBox.setForceSelection(true);
516
		comboBox.setDisplayField("fmt_nom_complet");
517
		comboBox.setTriggerAction(TriggerAction.ALL);
1134 jpm 518
		comboBox.setStore(auteursStore);
1176 jpm 519
		comboBox.setMessageTarget("tooltip");
981 jpm 520
		comboBox.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 521
		comboBox.addListener(Events.Valid, creerEcouteurChampObligatoire());
775 jpm 522
 
523
		return comboBox;
524
	}
525
 
526
	private void creerZoneGeneralites() {
527
		FormLayout layout = new FormLayout();
528
		layout.setLabelWidth(200);
219 aurelien 529
 
530
		// Fieldset Infos Générales
775 jpm 531
		generalitesFieldset = new FieldSet();
532
		generalitesFieldset.setHeading("Informations générales");
533
		generalitesFieldset.setCollapsible(true);
534
		generalitesFieldset.setLayout(layout);
1329 cyprien 535
 
536
		ModelType modelTypeProjets = new ModelType();
537
		modelTypeProjets.setRoot("projets");
538
		modelTypeProjets.setTotalName("nbElements");
539
		modelTypeProjets.addField("cpr_nom");
540
		modelTypeProjets.addField("cpr_id_projet");
219 aurelien 541
 
1329 cyprien 542
		String displayNameProjets = "cpr_nom";
1367 cyprien 543
		ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(sequenceur);
1329 cyprien 544
 
545
		projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
546
		projetsCombo.setWidth(200, 600);
547
		projetsCombo.getCombo().setTabIndex(tabIndex++);
548
		projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp());
549
		projetsCombo.getCombo().setForceSelection(true);
550
		projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
551
		projetsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
552
 
553
		projetsCombo.getCombo().setValidator(new Validator() {
1032 jpm 554
			public String validate(Field<?> field, String value) {
555
				String retour = null;
556
				if (field.getRawValue().equals("")) {
557
					field.setValue(null);
1329 cyprien 558
				} else if (projetsCombo.getStore().findModel("cpr_nom", field.getRawValue()) == null) {
1032 jpm 559
					String contenuBrut = field.getRawValue();
560
					field.setValue(null);
561
					field.setRawValue(contenuBrut);
562
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
563
				}
564
				return retour;
565
			}
1329 cyprien 566
		});
567
		generalitesFieldset.add(projetsCombo, new FormData(600, 0));
1032 jpm 568
 
786 jpm 569
		titreChp = new TextField<String>();
570
		titreChp.setName("cpu");
571
		titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
981 jpm 572
		titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 573
		titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
792 jpm 574
		generalitesFieldset.add(titreChp, new FormData(450, 0));
219 aurelien 575
 
786 jpm 576
		collectionChp = new TextField<String>();
792 jpm 577
		collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
578
		generalitesFieldset.add(collectionChp, new FormData(450, 0));
219 aurelien 579
 
786 jpm 580
		uriChp = new TextField<String>();
792 jpm 581
		uriChp.setFieldLabel("URL de la publication");
582
		generalitesFieldset.add(uriChp, new FormData(450, 0));
775 jpm 583
	}
584
 
585
	private void creerZoneEdition() {
586
		FormLayout layout = new FormLayout();
587
		layout.setLabelWidth(200);
588
 
219 aurelien 589
		// Fieldset Edition
775 jpm 590
		editionFieldset = new FieldSet();
792 jpm 591
		editionFieldset.setHeading("Édition");
775 jpm 592
		editionFieldset.setCollapsible(true);
593
		editionFieldset.setLayout(layout);
219 aurelien 594
 
1329 cyprien 595
 
596
		/*****************************************************/
597
		/**			Champ 'Editeur de la publication'		**/
598
		/*****************************************************/
599
		ModelType modelTypeStructures = new ModelType();
600
		modelTypeStructures.setRoot("structures");
601
		modelTypeStructures.setTotalName("nbElements");
602
		modelTypeStructures.addField("cs_nom");
603
		modelTypeStructures.addField("cs_id_structure");
219 aurelien 604
 
1329 cyprien 605
		String displayNameStructures = "cs_nom";
1367 cyprien 606
		ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(sequenceur);
1329 cyprien 607
 
608
		editeurCombobox = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
609
		editeurCombobox.setWidth(200, 600);
610
		editeurCombobox.getCombo().setTabIndex(tabIndex++);
611
		editeurCombobox.getCombo().setEmptyText("Sélectionner un éditeur...");
612
		editeurCombobox.getCombo().setFieldLabel("Éditeur de la publication");
613
		editeurCombobox.getCombo().setEditable(true);
614
		editionFieldset.add(editeurCombobox, new FormData(600, 0));
615
 
616
		/*********************************************/
617
		/**			Champ 'Date de publication'		**/
618
		/*********************************************/
786 jpm 619
		datePublicationChp = new TextField<String>();
620
		datePublicationChp.setMaxLength(4);
621
		datePublicationChp.setMinLength(4);
622
		datePublicationChp.setFieldLabel("Année de publication");
981 jpm 623
		datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
980 jpm 624
		datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
792 jpm 625
		editionFieldset.add(datePublicationChp, new FormData(40, 0));
219 aurelien 626
 
1329 cyprien 627
		/*****************************/
628
		/**			Champ ''		**/
629
		/*****************************/
786 jpm 630
		tomeChp = new TextField<String>();
792 jpm 631
		tomeChp.setFieldLabel("Série de la revue ou tome");
632
		editionFieldset.add(tomeChp, new FormData(75, 0));
1329 cyprien 633
 
634
		/*****************************/
635
		/**			Champ ''		**/
636
		/*****************************/
786 jpm 637
		fasciculeChp = new TextField<String>();
792 jpm 638
		fasciculeChp.setFieldLabel("Fascicule de la revue");
639
		editionFieldset.add(fasciculeChp, new FormData(75, 0));
1329 cyprien 640
 
641
		/*****************************/
642
		/**			Champ ''		**/
643
		/*****************************/
786 jpm 644
		pagesChp = new TextField<String>();
645
		pagesChp.setFieldLabel("Pages");
887 aurelien 646
		pagesChp.setToolTip("Fomat : NBRE ou NBRE-NBRE. ('NBRE' correspond à une suite de chiffres arabes ou romains ou à un point d'interrogation '?' dans le cas d'une donnée inconnue)");
792 jpm 647
		editionFieldset.add(pagesChp, new FormData(100, 0));
219 aurelien 648
	}
775 jpm 649
 
705 aurelien 650
	public void rafraichir(Object nouvellesDonnees) {
651
		if (nouvellesDonnees instanceof Publication) {
782 jpm 652
			// Si on a reçu les details d'une publication
1322 gduche 653
			publication = (Publication) nouvellesDonnees;
782 jpm 654
		} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
655
			rafraichirListeAuteurs((PublicationAPersonneListe) nouvellesDonnees);
656
		} else if (nouvellesDonnees instanceof Information) {
657
			rafraichirInformation((Information) nouvellesDonnees);
658
		} else {
659
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
227 aurelien 660
		}
1180 jpm 661
	}
662
 
663
	private void synchronisation() {
664
 
782 jpm 665
	}
901 jpm 666
 
1133 jpm 667
	private void miseAJourAuteursInitialListe() {
901 jpm 668
		Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
669
		while (clesAjoutees.hasNext()) {
1284 gduche 670
			Personne auteurAjoute = auteursAjoutes.get(clesAjoutees.next());
1133 jpm 671
			auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
901 jpm 672
		}
673
 
674
		Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
675
		while (clesSupprimees.hasNext()) {
1284 gduche 676
			Personne auteurSupprime = auteursSupprimes.get(clesSupprimees.next());
1133 jpm 677
			auteursInitialListe.remove(auteurSupprime.getId());
901 jpm 678
		}
679
	}
680
 
782 jpm 681
	private void rafraichirListeAuteurs(PublicationAPersonneListe auteurs) {
1133 jpm 682
		Iterator<String> it = auteurs.keySet().iterator();
683
		while (it.hasNext()) {
684
			Personne auteur = auteurs.get(it.next()).getPersonne();
685
			auteursInitialListe.put(auteur.getId(), auteur);
686
		}
1284 gduche 687
 
688
		grille.getStore().removeAll();
689
		grille.getStore().add(auteursInitialListe.toList());
1322 gduche 690
		layout();
782 jpm 691
	}
692
 
1322 gduche 693
	private void rafraichirInformation(Information info) {
1095 jpm 694
		String type = info.getType();
1322 gduche 695
		if (type.equals("publication_enregistree"))	{
696
			// la publication vien d'etre enregistrée, on soumet les auteurs
1284 gduche 697
			soumettreAuteurs();
1322 gduche 698
		} else if (type.equals("auteurs_enregistres")) {
699
			miseAJourAuteursInitialListe();
700
			initialiserAuteurs();
701
			repandreRafraichissement();
702
			controlerFermeture();
703
		} else if (type.equals("chargement_modifier_ok"))	{
704
			peuplerFormulaire();
705
			genererTitreFormulaire();
1095 jpm 706
		}
707
 
782 jpm 708
		if (info.getType().equals("liste_personne")) {
822 jpm 709
			PersonneListe listePersonneAuteur = (PersonneListe) info.getDonnee(0);
1284 gduche 710
			ListStore store = personnesSaisiesComboBox.getStore();
711
			store.removeAll();
712
			store.add(listePersonneAuteur.toList());
713
 
1095 jpm 714
		} else if (info.getType().equals("modif_publication")) {
1284 gduche 715
			InfoLogger.display("Modification d'une publication", info.toString());
1095 jpm 716
		} else if (info.getType().equals("ajout_publication")) {
1197 jpm 717
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String && ((String) info.getDonnee(0)).matches("[0-9]+")) {
1095 jpm 718
				String publicationId = (String) info.getDonnee(0);
1284 gduche 719
				InfoLogger.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
1095 jpm 720
			} else {
1284 gduche 721
				InfoLogger.display("Ajout d'une publication", info.toString());
1095 jpm 722
			}
1284 gduche 723
		}
782 jpm 724
	}
725
 
901 jpm 726
	private void initialiserAuteurs() {
1284 gduche 727
		auteursAjoutes = new PersonneListe();
728
		auteursSupprimes = new PersonneListe();
901 jpm 729
	}
730
 
782 jpm 731
	private void repandreRafraichissement() {
732
		if (vueExterneARafraichirApresValidation != null) {
786 jpm 733
			String type = "publication_modifiee";
734
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
735
				type = "publication_ajoutee";
736
			}
737
			Information info = new Information(type);
738
			info.setDonnee(0, publication);
782 jpm 739
			vueExterneARafraichirApresValidation.rafraichir(info);
740
		}
741
	}
742
 
786 jpm 743
	public boolean soumettreFormulaire() {
1322 gduche 744
		boolean formulaireValideOk = verifierFormulaire();
822 jpm 745
		if (formulaireValideOk) {
901 jpm 746
			soumettrePublication();
747
		}
1322 gduche 748
 
749
 
901 jpm 750
		return formulaireValideOk;
751
	}
1322 gduche 752
 
901 jpm 753
	private void soumettrePublication() {
754
		Publication publicationCollectee = collecterPublication();
755
		if (publicationCollectee != null) {
1322 gduche 756
 
757
			// Pour l'enregistrement des collections, on utilise le séquenceur
758
			// Il doit attendre le retour de l'enregistrement pour poursuivre
759
			sequenceur = new Sequenceur();
760
			int seqId = sequenceur.lancerRequeteSynchrone(this);
901 jpm 761
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
1322 gduche 762
				mediateur.ajouterPublication(sequenceur, publicationCollectee, seqId);
901 jpm 763
			} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
1322 gduche 764
				mediateur.modifierPublication(sequenceur, publicationCollectee, seqId);
901 jpm 765
			}
1322 gduche 766
			sequenceur.empilerRafraichissement(this, new Information("publication_enregistree"));
901 jpm 767
		}
768
	}
769
 
770
	private void soumettreAuteurs() {
771
 
1322 gduche 772
		//attenteAjoutAuteursOk = false;
773
		//attenteSuppressionAuteursOk = false;
774
 
1284 gduche 775
		//1) Auteurs ajoutés :
776
		// - Créer une PublicationAAuteurListe
777
		PublicationAPersonneListe listeDesAuteurs = new PublicationAPersonneListe();
778
		Iterator<String> itAuteur = auteursAjoutes.keySet().iterator();
779
		while (itAuteur.hasNext())	{
780
			PublicationAPersonne publiAPersonne = new PublicationAPersonne();
781
			String cle = itAuteur.next();
782
			publiAPersonne.setIdPersonne(cle);
783
			publiAPersonne.setIdPublication(publication.getId());
784
			listeDesAuteurs.put(cle, publiAPersonne);
785
		}
786
 
787
		// - envoyer au mediateur SSI personnes à ajouter
788
		if (listeDesAuteurs.size() > 0)	{
1322 gduche 789
			int seqId = sequenceur.lancerRequeteSynchrone(this);
790
			mediateur.ajouterPublicationAPersonne(sequenceur, publication.getId(), listeDesAuteurs, PublicationAPersonne.ROLE_AUTEUR, seqId);
791
			//attenteAjoutAuteursOk = true;
1284 gduche 792
		}
793
 
794
		//2) Auteurs supprimés :
795
		// - Créer une PublicationAPersonneListe
796
		listeDesAuteurs = new PublicationAPersonneListe();
797
		itAuteur = auteursSupprimes.keySet().iterator();
798
		while (itAuteur.hasNext())	{
799
			PublicationAPersonne publiAPersonne = new PublicationAPersonne();
800
			String cle = itAuteur.next();
801
			publiAPersonne.setIdPersonne(cle);
802
			publiAPersonne.setIdPublication(publication.getId());
803
			listeDesAuteurs.put(cle, publiAPersonne);
804
		}
805
 
806
		// - Envoyer au médiateur SSI personnes à supprimer
807
		if (listeDesAuteurs.size() > 0) {
1322 gduche 808
			// Pour une suppression des auteurs, on a pas besoin d'attendre le retour
1284 gduche 809
			mediateur.supprimerPublicationAPersonne(this, listeDesAuteurs);
1322 gduche 810
			//attenteSuppressionAuteursOk = true;
1284 gduche 811
		}
812
 
1322 gduche 813
		sequenceur.empilerRafraichissement(this, new Information("auteurs_enregistres"));
219 aurelien 814
	}
815
 
934 jpm 816
	public boolean verifierFormulaire() {
782 jpm 817
		boolean valide = true;
818
		ArrayList<String> messages = new ArrayList<String>();
819
 
1284 gduche 820
		// Tester si au moins un auteur est présent
821
		if (grille.getStore().getModels().size() == 0) {
822
			messages.add("Veuillez saisir au moins un auteur.");
227 aurelien 823
		}
705 aurelien 824
 
786 jpm 825
		String titre = titreChp.getValue();
782 jpm 826
		if (titre == null || titre.equals("")) {
827
			messages.add("Veuillez saisir le titre de la publication !");
705 aurelien 828
		}
829
 
792 jpm 830
		String uri = uriChp.getValue();
831
		if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
832
			messages.add("L'URL saisie n'est pas valide !");
833
		}
834
 
799 jpm 835
		String datePublication = datePublicationChp.getRawValue();
836
		if (datePublication == null || datePublication.equals("")) {
837
			messages.add("Veuillez saisir une année de parution !");
725 aurelien 838
		} else {
799 jpm 839
			if (!etreDateValide(datePublication)) {
792 jpm 840
				messages.add("Le format de l'année saisie est incorrect !");
725 aurelien 841
			}
705 aurelien 842
		}
717 aurelien 843
 
792 jpm 844
		String pages = pagesChp.getValue();
845
		String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
799 jpm 846
		if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
792 jpm 847
			messages.add("Le format des pages est incorrect !");
848
		}
849
 
782 jpm 850
		if (messages.size() != 0) {
851
			String[] tableauDeMessages = {};
852
			tableauDeMessages = messages.toArray(tableauDeMessages);
799 jpm 853
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
782 jpm 854
			valide = false;
705 aurelien 855
		}
782 jpm 856
		return valide;
775 jpm 857
	}
858
 
822 jpm 859
	private void peuplerFormulaire() {
1032 jpm 860
		setValeurComboProjets();
822 jpm 861
		titreChp.setValue(publication.getTitre());
862
		collectionChp.setValue(publication.getCollection());
863
		uriChp.setValue(publication.getURI());
1032 jpm 864
		datePublicationChp.setValue(reduireDateParAnnee(publication.getDateParution()));
822 jpm 865
		tomeChp.setValue(publication.getIndicationNvt());
866
		fasciculeChp.setValue(publication.getFascicule());
867
		pagesChp.setValue(publication.getPages());
868
 
869
		if (publication.getEditeur().matches("^[0-9]+$")) {
1329 cyprien 870
			editeurCombobox.getCombo().setValue(editeurCombobox.getStore().findModel("cs_id_structure", publication.getEditeur()));
822 jpm 871
		} else {
1329 cyprien 872
			editeurCombobox.getCombo().setRawValue(publication.getEditeur());
822 jpm 873
		}
874
	}
875
 
786 jpm 876
	private Publication collecterPublication() {
1284 gduche 877
 
786 jpm 878
		Publication publicationCollectee = (Publication) publication.cloner(new Publication());
1032 jpm 879
		publicationCollectee.setIdProjet(getValeurComboProjets());
1124 jpm 880
		publicationCollectee.setAuteur(construireIntituleAuteur());
786 jpm 881
 
882
		String titre = titreChp.getValue();
883
		publicationCollectee.setTitre(titre);
884
 
885
		String collection = collectionChp.getValue();
886
		publicationCollectee.setCollection(collection);
887
 
1124 jpm 888
		publicationCollectee.setNomComplet(construireNomComplet());
786 jpm 889
 
890
		String uri = uriChp.getValue();
891
		publicationCollectee.setUri(uri);
892
 
893
		String editeur = "";
1329 cyprien 894
		if (editeurCombobox.getValeur() != null) {
895
			Structure structure = new Structure(editeurCombobox.getValeur());
896
			editeur = structure.getId();
897
			publicationCollectee.setStructureEditeur(structure);
898
		} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
899
			editeur = editeurCombobox.getCombo().getRawValue();
786 jpm 900
		}
901
		publicationCollectee.setEditeur(editeur);
902
 
792 jpm 903
		String anneePublication = datePublicationChp.getRawValue();
904
		String datePublication = anneePublication+"-00-00";
905
		publicationCollectee.setDateParution(datePublication);
786 jpm 906
 
907
		String tome = tomeChp.getValue();
908
		publicationCollectee.setIndicationNvt(tome);
909
 
910
		String fascicule = fasciculeChp.getValue();
911
		publicationCollectee.setFascicule(fascicule);
912
 
913
		String pages = pagesChp.getValue();
914
		publicationCollectee.setPages(pages);
915
 
927 jpm 916
		Publication publicationARetourner = null;
786 jpm 917
		if (!publicationCollectee.comparer(publication)) {
918
			publicationARetourner = publication = publicationCollectee;
919
		}
920
		return publicationARetourner;
921
	}
922
 
1124 jpm 923
	private String construireIntituleEditeur() {
924
		String editeur = "";
1329 cyprien 925
		if (editeurCombobox.getValeur() != null) {
926
			Structure structure = new Structure(editeurCombobox.getValeur());
927
			editeur = structure.getNom();
928
		} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
929
			editeur = editeurCombobox.getCombo().getRawValue();
1124 jpm 930
		}
931
		return editeur;
932
	}
933
 
934
	private String construireIntituleAuteur() {
1284 gduche 935
		String intituleAuteur = "";
936
 
937
		// TODO : ranger par ordre non-alphabétique
938
		grille.getStore().sort("nom", SortDir.ASC);
939
		List<Personne> auteurs = grille.getStore().getModels();
940
 
941
		Iterator<Personne> itAuteurs = auteurs.iterator();
942
		while (itAuteurs.hasNext())	{
943
			Personne personneCourante = itAuteurs.next();
944
			intituleAuteur += personneCourante.getNom().toUpperCase() + " " + personneCourante.getPrenom();
945
			if (itAuteurs.hasNext())	{
946
				intituleAuteur+=", ";
947
			}
948
		}
949
		return intituleAuteur;
1124 jpm 950
	}
951
 
952
	private String construireNomComplet() {
953
		// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
954
		String nomComplet = "";
955
		String auteurs = construireIntituleAuteur();
956
		String annee = datePublicationChp.getRawValue();
957
		String titre = titreChp.getValue();
958
		String editeur = construireIntituleEditeur();
959
 
960
		nomComplet += auteurs+", "+annee+". "+titre+".";
961
 
962
		if (!UtilString.isEmpty(editeur)) {
963
			nomComplet += " Éditeur "+editeur+".";
964
		}
965
 
966
		if (collectionChp.getValue() != null) {
967
			String revue = collectionChp.getValue();
968
			nomComplet += ", "+revue;
969
		}
970
 
971
		if (fasciculeChp.getValue() != null) {
972
			String fascicule = fasciculeChp.getValue();
973
			nomComplet += ", "+fascicule;
974
		}
975
 
976
		if (tomeChp.getValue() != null) {
977
			String tomaison = tomeChp.getValue();
978
			nomComplet += ", "+tomaison;
979
		}
980
 
981
		if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
982
			nomComplet += ".";
983
		}
984
 
985
		if (pagesChp.getValue() != null) {
986
			String pages = pagesChp.getValue();
987
			nomComplet += pages+".";
988
		}
989
 
990
		return nomComplet;
991
	}
992
 
934 jpm 993
	public void reinitialiserFormulaire() {
781 jpm 994
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
786 jpm 995
			mediateur.afficherFormPublication(publication.getId());
775 jpm 996
		} else {
997
			mediateur.afficherFormPublication(null);
219 aurelien 998
		}
999
	}
227 aurelien 1000
 
792 jpm 1001
	private boolean etreDateValide(String anneePublication) {
782 jpm 1002
		boolean valide = true;
792 jpm 1003
		if (!anneePublication.matches("^[0-2][0-9]{3}$")) {
782 jpm 1004
			valide = false;
725 aurelien 1005
		}
782 jpm 1006
		return valide;
725 aurelien 1007
	}
758 aurelien 1008
 
1009
	private String reduireDateParAnnee(String datePar) {
775 jpm 1010
		if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) {
758 aurelien 1011
			return datePar.split("-")[0];
505 jp_milcent 1012
		} else {
758 aurelien 1013
			return "";
227 aurelien 1014
		}
758 aurelien 1015
	}
1032 jpm 1016
 
1017
	private String getValeurComboProjets() {
1018
		String valeur = "";
1329 cyprien 1019
		if (projetsCombo.getValeur() != null) {
1020
			Projet projet = new Projet(projetsCombo.getValeur());
1021
			valeur = projet.getId();
1032 jpm 1022
		}
1023
		return valeur;
1024
	}
1025
	private void setValeurComboProjets() {
1026
		if (projetsCombo.getStore() != null ) {
1027
			if (mode.equals(Formulaire.MODE_MODIFIER) && publication != null) {
1329 cyprien 1028
				projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", publication.getIdProjet()));
1032 jpm 1029
			} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
1329 cyprien 1030
				projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", mediateur.getProjetId()));
1032 jpm 1031
			}
1032
		}
1033
	}
505 jp_milcent 1034
}