Subversion Repositories eFlore/Applications.coel

Rev

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