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;
|
822 |
jpm |
9 |
import org.tela_botanica.client.images.Images;
|
219 |
aurelien |
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
705 |
aurelien |
11 |
import org.tela_botanica.client.modeles.Information;
|
775 |
jpm |
12 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
935 |
jpm |
13 |
import org.tela_botanica.client.modeles.personne.Personne;
|
|
|
14 |
import org.tela_botanica.client.modeles.personne.PersonneListe;
|
|
|
15 |
import org.tela_botanica.client.modeles.publication.Publication;
|
|
|
16 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
|
|
17 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
|
|
18 |
import org.tela_botanica.client.modeles.structure.Structure;
|
|
|
19 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
792 |
jpm |
20 |
import org.tela_botanica.client.util.Pattern;
|
782 |
jpm |
21 |
import org.tela_botanica.client.util.UtilArray;
|
884 |
jpm |
22 |
import org.tela_botanica.client.util.UtilString;
|
935 |
jpm |
23 |
import org.tela_botanica.client.vues.Formulaire;
|
219 |
aurelien |
24 |
|
505 |
jp_milcent |
25 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
980 |
jpm |
26 |
import com.extjs.gxt.ui.client.event.Events;
|
219 |
aurelien |
27 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
28 |
import com.extjs.gxt.ui.client.store.ListStore;
|
227 |
aurelien |
29 |
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
219 |
aurelien |
30 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
705 |
aurelien |
31 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
219 |
aurelien |
32 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
33 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
|
|
34 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
|
|
35 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
|
|
36 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
|
|
37 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
|
|
38 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
|
|
39 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
705 |
aurelien |
40 |
import com.google.gwt.core.client.GWT;
|
219 |
aurelien |
41 |
|
877 |
aurelien |
42 |
|
775 |
jpm |
43 |
public class PublicationForm extends Formulaire implements Rafraichissable {
|
219 |
aurelien |
44 |
|
786 |
jpm |
45 |
private Publication publication;
|
|
|
46 |
private PublicationAPersonneListe publicationAPersonneListe = null;
|
901 |
jpm |
47 |
private static boolean publicationAPersonneListeChargementOk = false;
|
|
|
48 |
private PublicationAPersonneListe auteursAjoutes = null;
|
|
|
49 |
private PublicationAPersonneListe auteursSupprimes = null;
|
219 |
aurelien |
50 |
|
775 |
jpm |
51 |
private FieldSet auteursFieldset = null;
|
|
|
52 |
private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
|
|
|
53 |
private LayoutContainer conteneurChamps;
|
|
|
54 |
private ListStore<Personne> auteursStorePartage = null;
|
901 |
jpm |
55 |
private static boolean auteurStorePartageChargementOk = false;
|
227 |
aurelien |
56 |
|
775 |
jpm |
57 |
private FieldSet generalitesFieldset = null;
|
786 |
jpm |
58 |
private TextField<String> titreChp = null;
|
|
|
59 |
private TextField<String> collectionChp = null;
|
|
|
60 |
private TextField<String> uriChp = null;
|
219 |
aurelien |
61 |
|
775 |
jpm |
62 |
private FieldSet editionFieldset = null;
|
792 |
jpm |
63 |
private ComboBox<Structure> editeurCombobox = null;
|
786 |
jpm |
64 |
private TextField<String> datePublicationChp = null;
|
|
|
65 |
private TextField<String> tomeChp = null;
|
|
|
66 |
private TextField<String> fasciculeChp = null;
|
|
|
67 |
private TextField<String> pagesChp = null;
|
219 |
aurelien |
68 |
|
775 |
jpm |
69 |
private String idStructureEdition = "";
|
786 |
jpm |
70 |
|
901 |
jpm |
71 |
private static boolean formulaireValideOk = false;
|
|
|
72 |
private static boolean publicationValideOk = false;
|
|
|
73 |
private static boolean auteursValideOk = false;
|
|
|
74 |
private static boolean attenteAjoutAuteursOk = true;
|
|
|
75 |
private static boolean attenteSuppressionAuteursOk = true;
|
786 |
jpm |
76 |
|
781 |
jpm |
77 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
782 |
jpm |
78 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
|
822 |
jpm |
82 |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
|
782 |
jpm |
83 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
905 |
jpm |
87 |
publicationAPersonneListe = new PublicationAPersonneListe();
|
901 |
jpm |
88 |
initialiserValidation();
|
|
|
89 |
initialiserAffichageAuteurs();
|
|
|
90 |
|
799 |
jpm |
91 |
publication = new Publication();
|
822 |
jpm |
92 |
publication.setId(publicationId);
|
|
|
93 |
|
884 |
jpm |
94 |
String modeDeCreation = (UtilString.isEmpty(publication.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
775 |
jpm |
95 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
|
781 |
jpm |
96 |
|
775 |
jpm |
97 |
panneauFormulaire.setLayout(new FlowLayout());
|
822 |
jpm |
98 |
String titre = genererTitreFormulaire();
|
775 |
jpm |
99 |
panneauFormulaire.setHeading(titre);
|
705 |
aurelien |
100 |
|
775 |
jpm |
101 |
creerZoneAuteurs();
|
|
|
102 |
panneauFormulaire.add(auteursFieldset);
|
219 |
aurelien |
103 |
|
775 |
jpm |
104 |
creerZoneGeneralites();
|
|
|
105 |
panneauFormulaire.add(generalitesFieldset);
|
239 |
aurelien |
106 |
|
775 |
jpm |
107 |
creerZoneEdition();
|
|
|
108 |
panneauFormulaire.add(editionFieldset);
|
822 |
jpm |
109 |
|
|
|
110 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
111 |
mediateurCourrant.selectionnerPublication(this, publicationId);
|
|
|
112 |
mediateurCourrant.selectionnerPublicationAPersonne(this, publicationId, null, PublicationAPersonne.ROLE_AUTEUR);
|
|
|
113 |
}
|
781 |
jpm |
114 |
}
|
782 |
jpm |
115 |
|
822 |
jpm |
116 |
private String genererTitreFormulaire() {
|
|
|
117 |
String titre = "Ajout d'une publication";
|
|
|
118 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
119 |
titre = "Modification d'une publication - "+i18nC.id()+": "+publication.getId();
|
|
|
120 |
}
|
|
|
121 |
return titre;
|
|
|
122 |
}
|
|
|
123 |
|
775 |
jpm |
124 |
private void creerZoneAuteurs() {
|
|
|
125 |
FormLayout layout = new FormLayout();
|
|
|
126 |
layout.setLabelWidth(200);
|
|
|
127 |
|
|
|
128 |
// Fieldset Auteur
|
|
|
129 |
auteursFieldset = new FieldSet();
|
|
|
130 |
auteursFieldset.setHeading("Auteur(s)");
|
|
|
131 |
auteursFieldset.setCollapsible(true);
|
|
|
132 |
auteursFieldset.setLayout(layout);
|
|
|
133 |
|
|
|
134 |
auteurComboboxListe = new ArrayList<ComboBox<Personne>>(0);
|
|
|
135 |
auteursStorePartage = new ListStore<Personne>();
|
792 |
jpm |
136 |
mediateur.clicObtenirListeAuteurs(this);
|
775 |
jpm |
137 |
|
822 |
jpm |
138 |
creerChampsAuteur();
|
775 |
jpm |
139 |
}
|
|
|
140 |
|
822 |
jpm |
141 |
private void creerChampsAuteur() {
|
775 |
jpm |
142 |
auteursFieldset.removeAll();
|
|
|
143 |
|
|
|
144 |
conteneurChamps = new LayoutContainer();
|
|
|
145 |
|
822 |
jpm |
146 |
Button ajouterAuteurBouton = new Button("Ajouter un auteur");
|
|
|
147 |
ajouterAuteurBouton.setIcon(Images.ICONES.ajouter());
|
|
|
148 |
ajouterAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
775 |
jpm |
149 |
@Override
|
|
|
150 |
public void componentSelected(ButtonEvent be) {
|
822 |
jpm |
151 |
creerChampAuteurEtBoutonSupprimer(null);
|
775 |
jpm |
152 |
}
|
|
|
153 |
});
|
219 |
aurelien |
154 |
|
775 |
jpm |
155 |
auteursFieldset.add(conteneurChamps);
|
822 |
jpm |
156 |
auteursFieldset.add(ajouterAuteurBouton);
|
775 |
jpm |
157 |
auteursFieldset.layout(true);
|
219 |
aurelien |
158 |
|
822 |
jpm |
159 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
160 |
creerChampAuteurEtBoutonSupprimer(null);
|
775 |
jpm |
161 |
}
|
|
|
162 |
}
|
|
|
163 |
|
822 |
jpm |
164 |
public void creerChampAuteurEtBoutonSupprimer(Personne auteur) {
|
775 |
jpm |
165 |
final HorizontalPanel panneauHorizontal = new HorizontalPanel();
|
|
|
166 |
panneauHorizontal.setLayout(new FormLayout());
|
219 |
aurelien |
167 |
|
775 |
jpm |
168 |
final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis();
|
|
|
169 |
if (auteur != null) {
|
901 |
jpm |
170 |
GWT.log("Auteur peuplé : "+auteur.getId(), null);
|
775 |
jpm |
171 |
auteursSaisisComboBox.setValue(auteursStorePartage.findModel("id_personne", auteur.getId()));
|
901 |
jpm |
172 |
auteursSaisisComboBox.validate();
|
775 |
jpm |
173 |
}
|
|
|
174 |
auteurComboboxListe.add(auteursSaisisComboBox);
|
822 |
jpm |
175 |
auteursSaisisComboBox.setFieldLabel("Auteur "+auteurComboboxListe.size());
|
901 |
jpm |
176 |
GWT.log("Nbre de combobox auteur dans liste : "+auteurComboboxListe.size(), null);
|
758 |
aurelien |
177 |
|
822 |
jpm |
178 |
LayoutContainer panneauChampTxtEtBouton = new LayoutContainer();
|
|
|
179 |
panneauChampTxtEtBouton.setLayout(new FormLayout());
|
|
|
180 |
panneauChampTxtEtBouton.add(auteursSaisisComboBox, new FormData(300, 0));
|
|
|
181 |
panneauHorizontal.add(panneauChampTxtEtBouton);
|
219 |
aurelien |
182 |
|
822 |
jpm |
183 |
Button supprimerAuteurBouton = new Button();
|
|
|
184 |
supprimerAuteurBouton.setIcon(Images.ICONES.supprimer());
|
|
|
185 |
supprimerAuteurBouton.setToolTip(i18nC.supprimer());
|
|
|
186 |
supprimerAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
775 |
jpm |
187 |
@Override
|
|
|
188 |
public void componentSelected(ButtonEvent be) {
|
|
|
189 |
auteurComboboxListe.remove(auteursSaisisComboBox);
|
|
|
190 |
conteneurChamps.remove(panneauHorizontal);
|
822 |
jpm |
191 |
|
|
|
192 |
int numeroAuteurs = 1;
|
|
|
193 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
|
|
194 |
it.next().setFieldLabel("Auteur "+numeroAuteurs);
|
|
|
195 |
numeroAuteurs++;
|
|
|
196 |
}
|
|
|
197 |
|
775 |
jpm |
198 |
auteursFieldset.layout(true);
|
|
|
199 |
}
|
|
|
200 |
});
|
822 |
jpm |
201 |
panneauHorizontal.add(supprimerAuteurBouton);
|
|
|
202 |
|
775 |
jpm |
203 |
conteneurChamps.add(panneauHorizontal);
|
|
|
204 |
auteursFieldset.layout(true);
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
private ComboBox<Personne> creerComboBoxAuteursSaisis() {
|
|
|
208 |
ComboBox<Personne> comboBox = new ComboBox<Personne>();
|
860 |
jpm |
209 |
comboBox.setEmptyText(i18nC.chercherPersonneSaisi());
|
775 |
jpm |
210 |
comboBox.setEditable(true);
|
|
|
211 |
comboBox.setForceSelection(true);
|
|
|
212 |
comboBox.setDisplayField("fmt_nom_complet");
|
|
|
213 |
comboBox.setTriggerAction(TriggerAction.ALL);
|
|
|
214 |
comboBox.setStore(auteursStorePartage);
|
981 |
jpm |
215 |
comboBox.addStyleName(ComposantClass.OBLIGATOIRE);
|
980 |
jpm |
216 |
comboBox.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
775 |
jpm |
217 |
|
|
|
218 |
return comboBox;
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
private void creerZoneGeneralites() {
|
|
|
222 |
FormLayout layout = new FormLayout();
|
|
|
223 |
layout.setLabelWidth(200);
|
219 |
aurelien |
224 |
|
|
|
225 |
// Fieldset Infos Générales
|
775 |
jpm |
226 |
generalitesFieldset = new FieldSet();
|
|
|
227 |
generalitesFieldset.setHeading("Informations générales");
|
|
|
228 |
generalitesFieldset.setCollapsible(true);
|
|
|
229 |
generalitesFieldset.setLayout(layout);
|
219 |
aurelien |
230 |
|
786 |
jpm |
231 |
titreChp = new TextField<String>();
|
|
|
232 |
titreChp.setName("cpu");
|
|
|
233 |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
981 |
jpm |
234 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
980 |
jpm |
235 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
792 |
jpm |
236 |
generalitesFieldset.add(titreChp, new FormData(450, 0));
|
219 |
aurelien |
237 |
|
786 |
jpm |
238 |
collectionChp = new TextField<String>();
|
792 |
jpm |
239 |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
|
|
|
240 |
generalitesFieldset.add(collectionChp, new FormData(450, 0));
|
219 |
aurelien |
241 |
|
786 |
jpm |
242 |
uriChp = new TextField<String>();
|
792 |
jpm |
243 |
uriChp.setFieldLabel("URL de la publication");
|
|
|
244 |
generalitesFieldset.add(uriChp, new FormData(450, 0));
|
775 |
jpm |
245 |
}
|
|
|
246 |
|
|
|
247 |
private void creerZoneEdition() {
|
|
|
248 |
FormLayout layout = new FormLayout();
|
|
|
249 |
layout.setLabelWidth(200);
|
|
|
250 |
|
219 |
aurelien |
251 |
// Fieldset Edition
|
775 |
jpm |
252 |
editionFieldset = new FieldSet();
|
792 |
jpm |
253 |
editionFieldset.setHeading("Édition");
|
775 |
jpm |
254 |
editionFieldset.setCollapsible(true);
|
|
|
255 |
editionFieldset.setLayout(layout);
|
219 |
aurelien |
256 |
|
792 |
jpm |
257 |
ListStore<Structure> editeurStore = new ListStore<Structure>();
|
|
|
258 |
editeurCombobox = new ComboBox<Structure>();
|
|
|
259 |
editeurCombobox.setEmptyText("Sélectionner un éditeur...");
|
|
|
260 |
editeurCombobox.setFieldLabel("Éditeur de la publication");
|
|
|
261 |
editeurCombobox.setDisplayField("nom");
|
|
|
262 |
editeurCombobox.setStore(editeurStore);
|
|
|
263 |
editeurCombobox.setEditable(true);
|
|
|
264 |
editeurCombobox.setTriggerAction(TriggerAction.ALL);
|
|
|
265 |
editionFieldset.add(editeurCombobox, new FormData(450, 0));
|
|
|
266 |
mediateur.clicObtenirListeEditeurs(this);
|
219 |
aurelien |
267 |
|
786 |
jpm |
268 |
datePublicationChp = new TextField<String>();
|
|
|
269 |
datePublicationChp.setMaxLength(4);
|
|
|
270 |
datePublicationChp.setMinLength(4);
|
|
|
271 |
datePublicationChp.setFieldLabel("Année de publication");
|
981 |
jpm |
272 |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
980 |
jpm |
273 |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
792 |
jpm |
274 |
editionFieldset.add(datePublicationChp, new FormData(40, 0));
|
219 |
aurelien |
275 |
|
786 |
jpm |
276 |
tomeChp = new TextField<String>();
|
792 |
jpm |
277 |
tomeChp.setFieldLabel("Série de la revue ou tome");
|
|
|
278 |
editionFieldset.add(tomeChp, new FormData(75, 0));
|
219 |
aurelien |
279 |
|
786 |
jpm |
280 |
fasciculeChp = new TextField<String>();
|
792 |
jpm |
281 |
fasciculeChp.setFieldLabel("Fascicule de la revue");
|
|
|
282 |
editionFieldset.add(fasciculeChp, new FormData(75, 0));
|
219 |
aurelien |
283 |
|
786 |
jpm |
284 |
pagesChp = new TextField<String>();
|
|
|
285 |
pagesChp.setFieldLabel("Pages");
|
887 |
aurelien |
286 |
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 |
287 |
editionFieldset.add(pagesChp, new FormData(100, 0));
|
219 |
aurelien |
288 |
}
|
775 |
jpm |
289 |
|
705 |
aurelien |
290 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
291 |
if (nouvellesDonnees instanceof Publication) {
|
782 |
jpm |
292 |
// Si on a reçu les details d'une publication
|
|
|
293 |
rafraichirPublication((Publication) nouvellesDonnees);
|
|
|
294 |
} else if (nouvellesDonnees instanceof StructureListe) {
|
|
|
295 |
// Si on a reçu une liste des editeurs
|
|
|
296 |
rafraichirListeEditeurs((StructureListe) nouvellesDonnees);
|
|
|
297 |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
|
|
|
298 |
rafraichirListeAuteurs((PublicationAPersonneListe) nouvellesDonnees);
|
|
|
299 |
} else if (nouvellesDonnees instanceof Information) {
|
|
|
300 |
rafraichirInformation((Information) nouvellesDonnees);
|
|
|
301 |
} else {
|
|
|
302 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
227 |
aurelien |
303 |
}
|
|
|
304 |
|
822 |
jpm |
305 |
if (etrePretAAfficherAuteurs()) {
|
901 |
jpm |
306 |
initialiserAffichageAuteurs();
|
822 |
jpm |
307 |
afficherAuteurs();
|
|
|
308 |
}
|
|
|
309 |
|
782 |
jpm |
310 |
if (etreValide()) {
|
822 |
jpm |
311 |
initialiserValidation();
|
782 |
jpm |
312 |
repandreRafraichissement();
|
|
|
313 |
controlerFermetureApresRafraichissement();
|
219 |
aurelien |
314 |
}
|
782 |
jpm |
315 |
}
|
901 |
jpm |
316 |
|
|
|
317 |
private void miseAJourPublicationAPersonneListe() {
|
|
|
318 |
GWT.log("Mise à jour liste publication à personne", null);
|
|
|
319 |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
|
|
|
320 |
while (clesAjoutees.hasNext()) {
|
|
|
321 |
String id = clesAjoutees.next();
|
|
|
322 |
publicationAPersonneListe.put(id, auteursAjoutes.get(id));
|
|
|
323 |
GWT.log("Auteurs ajouté :"+publicationAPersonneListe.get(id).getPersonne().getNomComplet(), null);
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
|
|
|
327 |
while (clesSupprimees.hasNext()) {
|
|
|
328 |
String id = clesSupprimees.next();
|
|
|
329 |
publicationAPersonneListe.remove(id);
|
|
|
330 |
GWT.log("Personne surpprimé :"+id, null);
|
|
|
331 |
}
|
|
|
332 |
GWT.log("Nbre auteurs après maj :"+publicationAPersonneListe.size(), null);
|
|
|
333 |
}
|
|
|
334 |
|
786 |
jpm |
335 |
private void rafraichirPublication(Publication publi) {
|
|
|
336 |
publication = publi;
|
822 |
jpm |
337 |
peuplerFormulaire();
|
782 |
jpm |
338 |
}
|
|
|
339 |
|
|
|
340 |
private void rafraichirListeEditeurs(StructureListe editeurs) {
|
792 |
jpm |
341 |
editeurCombobox.getStore().removeAll();
|
|
|
342 |
editeurCombobox.getStore().add((List<Structure>) editeurs.toList());
|
782 |
jpm |
343 |
|
|
|
344 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
792 |
jpm |
345 |
editeurCombobox.setValue((Structure) editeurs.get(idStructureEdition));
|
782 |
jpm |
346 |
}
|
792 |
jpm |
347 |
editeurCombobox.expand();
|
782 |
jpm |
348 |
}
|
|
|
349 |
|
|
|
350 |
private void rafraichirListeAuteurs(PublicationAPersonneListe auteurs) {
|
786 |
jpm |
351 |
publicationAPersonneListe = auteurs;
|
822 |
jpm |
352 |
publicationAPersonneListeChargementOk = true;
|
782 |
jpm |
353 |
}
|
|
|
354 |
|
|
|
355 |
private void rafraichirInformation(Information info) {
|
|
|
356 |
if (info.getType().equals("liste_personne")) {
|
822 |
jpm |
357 |
PersonneListe listePersonneAuteur = (PersonneListe) info.getDonnee(0);
|
|
|
358 |
|
782 |
jpm |
359 |
List<Personne> liste = listePersonneAuteur.toList();
|
|
|
360 |
auteursStorePartage.removeAll();
|
|
|
361 |
auteursStorePartage.add(liste);
|
822 |
jpm |
362 |
|
|
|
363 |
auteurStorePartageChargementOk = true;
|
782 |
jpm |
364 |
} else if (info.getType().equals("publication_valide")) {
|
822 |
jpm |
365 |
publicationValideOk = true;
|
786 |
jpm |
366 |
publication.setId((String) info.getDonnee(0));
|
705 |
aurelien |
367 |
|
782 |
jpm |
368 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
901 |
jpm |
369 |
attenteAjoutAuteursOk = true;
|
|
|
370 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
239 |
aurelien |
371 |
}
|
901 |
jpm |
372 |
} else if (info.getType().equals("ajout_publication_a_personne")) {
|
|
|
373 |
attenteAjoutAuteursOk = false;
|
|
|
374 |
GWT.log("attenteAjoutAuteursOk", null);
|
|
|
375 |
} else if (info.getType().equals("suppression_publication_a_personne")) {
|
|
|
376 |
attenteSuppressionAuteursOk = false;
|
|
|
377 |
GWT.log("attenteSuppressionAuteursOk", null);
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
if (avoirAuteursMiseAJourCorrectement()) {
|
822 |
jpm |
381 |
auteursValideOk = true;
|
901 |
jpm |
382 |
miseAJourPublicationAPersonneListe();
|
|
|
383 |
initialiserAuteurs();
|
782 |
jpm |
384 |
}
|
|
|
385 |
}
|
|
|
386 |
|
901 |
jpm |
387 |
private boolean avoirAuteursMiseAJourCorrectement() {
|
|
|
388 |
boolean ok = false;
|
|
|
389 |
if (attenteAjoutAuteursOk == false && attenteSuppressionAuteursOk == false) {
|
|
|
390 |
ok = true;
|
|
|
391 |
}
|
|
|
392 |
return ok;
|
|
|
393 |
}
|
|
|
394 |
|
822 |
jpm |
395 |
private void afficherAuteurs() {
|
|
|
396 |
Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
|
901 |
jpm |
397 |
GWT.log("Auteur"+publicationAPersonneListe.size(), null);
|
822 |
jpm |
398 |
while (itap.hasNext()) {
|
|
|
399 |
creerChampAuteurEtBoutonSupprimer(publicationAPersonneListe.get(itap.next()).getPersonne());
|
|
|
400 |
}
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
private void initialiserAffichageAuteurs() {
|
|
|
404 |
auteurStorePartageChargementOk = false;
|
|
|
405 |
publicationAPersonneListeChargementOk = false;
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
private boolean etrePretAAfficherAuteurs() {
|
|
|
409 |
boolean ok = false;
|
|
|
410 |
if (auteurStorePartageChargementOk && publicationAPersonneListeChargementOk) {
|
|
|
411 |
ok = true;
|
|
|
412 |
}
|
|
|
413 |
return ok;
|
|
|
414 |
}
|
|
|
415 |
|
782 |
jpm |
416 |
private Boolean etreValide() {
|
|
|
417 |
Boolean valide = false;
|
822 |
jpm |
418 |
GWT.log("formulaire"+formulaireValideOk+" - Publication :"+publicationValideOk+" - Auteurs :"+auteursValideOk, null);
|
|
|
419 |
if (formulaireValideOk && publicationValideOk && auteursValideOk) {
|
782 |
jpm |
420 |
valide = true;
|
|
|
421 |
}
|
|
|
422 |
return valide;
|
|
|
423 |
}
|
|
|
424 |
|
822 |
jpm |
425 |
private void initialiserValidation() {
|
|
|
426 |
formulaireValideOk = false;
|
|
|
427 |
publicationValideOk = false;
|
901 |
jpm |
428 |
initialiserAuteurs();
|
822 |
jpm |
429 |
auteursValideOk = false;
|
782 |
jpm |
430 |
}
|
|
|
431 |
|
901 |
jpm |
432 |
private void initialiserAuteurs() {
|
|
|
433 |
attenteAjoutAuteursOk = true;
|
|
|
434 |
auteursAjoutes = new PublicationAPersonneListe();
|
|
|
435 |
attenteSuppressionAuteursOk = true;
|
|
|
436 |
auteursSupprimes = new PublicationAPersonneListe();
|
|
|
437 |
}
|
|
|
438 |
|
782 |
jpm |
439 |
private void repandreRafraichissement() {
|
|
|
440 |
if (vueExterneARafraichirApresValidation != null) {
|
786 |
jpm |
441 |
String type = "publication_modifiee";
|
|
|
442 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
443 |
type = "publication_ajoutee";
|
|
|
444 |
}
|
|
|
445 |
Information info = new Information(type);
|
|
|
446 |
info.setDonnee(0, publication);
|
782 |
jpm |
447 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
|
|
448 |
}
|
|
|
449 |
}
|
|
|
450 |
|
786 |
jpm |
451 |
public boolean soumettreFormulaire() {
|
822 |
jpm |
452 |
formulaireValideOk = verifierFormulaire();
|
|
|
453 |
GWT.log("Form?"+formulaireValideOk, null);
|
|
|
454 |
if (formulaireValideOk) {
|
901 |
jpm |
455 |
soumettrePublication();
|
|
|
456 |
soumettreAuteurs();
|
|
|
457 |
}
|
|
|
458 |
return formulaireValideOk;
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
private void soumettrePublication() {
|
|
|
462 |
Publication publicationCollectee = collecterPublication();
|
|
|
463 |
if (publicationCollectee != null) {
|
|
|
464 |
GWT.log("Info public collectée ? ok", null);
|
|
|
465 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
466 |
mediateur.ajouterPublication(this, publicationCollectee);
|
|
|
467 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
468 |
mediateur.modifierPublication(this, publicationCollectee);
|
|
|
469 |
}
|
|
|
470 |
}
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
private void soumettreAuteurs() {
|
|
|
474 |
attenteAjoutAuteursOk = false;
|
|
|
475 |
attenteSuppressionAuteursOk = false;
|
|
|
476 |
|
|
|
477 |
PersonneListe personnesInitiales = new PersonneListe();
|
|
|
478 |
if (publicationAPersonneListe != null) {
|
|
|
479 |
GWT.log("Nbre auteur initial :"+publicationAPersonneListe.size(), null);
|
|
|
480 |
Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
|
|
|
481 |
while (itap.hasNext()) {
|
|
|
482 |
Personne personne = publicationAPersonneListe.get(itap.next()).getPersonne();
|
|
|
483 |
GWT.log("Auteur initial :"+personne.getNomComplet(), null);
|
|
|
484 |
personnesInitiales.put(personne.getId(), personne);
|
|
|
485 |
}
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
PersonneListe personnesActuelles = new PersonneListe();
|
|
|
489 |
GWT.log("Nbre auteur actuel :"+auteurComboboxListe.size(), null);
|
|
|
490 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
|
|
491 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
|
|
492 |
Personne personne = auteurComboboxListe.get(i).getValue();
|
|
|
493 |
personnesActuelles.put(personne.getId(), personne);
|
|
|
494 |
}
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
// Auteurs ajoutés
|
|
|
498 |
Iterator<String> clesActuelles = personnesActuelles.keySet().iterator();
|
|
|
499 |
while (clesActuelles.hasNext()) {
|
|
|
500 |
String idActuel = clesActuelles.next();
|
|
|
501 |
if (personnesInitiales.size() == 0 || personnesInitiales.get(idActuel) == null) {
|
|
|
502 |
Personne personne = personnesActuelles.get(idActuel);
|
|
|
503 |
GWT.log("Auteur ajouté :"+personne.getNomComplet(), null);
|
|
|
504 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
|
|
505 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
506 |
publicationAAuteur.setIdPublication(publication.getId());
|
741 |
aurelien |
507 |
}
|
901 |
jpm |
508 |
publicationAAuteur.setPersonne(personne);
|
|
|
509 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
|
|
510 |
auteursAjoutes.put(publicationAAuteur.getId(), publicationAAuteur);
|
|
|
511 |
attenteAjoutAuteursOk = true;
|
239 |
aurelien |
512 |
}
|
|
|
513 |
}
|
901 |
jpm |
514 |
|
|
|
515 |
// Auteurs supprimés
|
|
|
516 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
517 |
Iterator<String> clesInitiales = personnesInitiales.keySet().iterator();
|
|
|
518 |
while (clesInitiales.hasNext()) {
|
|
|
519 |
String idInitial = clesInitiales.next();
|
|
|
520 |
if (personnesActuelles.size() == 0 || personnesActuelles.get(idInitial) == null) {
|
|
|
521 |
Personne personne = personnesInitiales.get(idInitial);
|
|
|
522 |
GWT.log("Auteur supprimé :"+personne.getNomComplet(), null);
|
|
|
523 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
|
|
524 |
publicationAAuteur.setIdPublication(publication.getId());
|
|
|
525 |
publicationAAuteur.setPersonne(personne);
|
|
|
526 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
|
|
527 |
auteursSupprimes.put(publicationAAuteur.getId(), publicationAAuteur);
|
|
|
528 |
attenteSuppressionAuteursOk = true;
|
|
|
529 |
}
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
|
|
|
533 |
// Execution de les mise à jour pour le mode MODIFICATION
|
|
|
534 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
535 |
if (auteursAjoutes != null && auteursAjoutes.size() != 0) {
|
|
|
536 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
|
|
537 |
}
|
|
|
538 |
|
|
|
539 |
if (auteursSupprimes != null && auteursSupprimes.size() != 0) {
|
|
|
540 |
mediateur.supprimerPublicationAPersonne(this, auteursSupprimes);
|
|
|
541 |
}
|
|
|
542 |
}
|
219 |
aurelien |
543 |
}
|
|
|
544 |
|
934 |
jpm |
545 |
public boolean verifierFormulaire() {
|
782 |
jpm |
546 |
boolean valide = true;
|
|
|
547 |
ArrayList<String> messages = new ArrayList<String>();
|
|
|
548 |
|
786 |
jpm |
549 |
boolean auteurErreur = true;
|
775 |
jpm |
550 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
|
|
551 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
786 |
jpm |
552 |
auteurErreur = false;
|
782 |
jpm |
553 |
break;
|
227 |
aurelien |
554 |
}
|
|
|
555 |
}
|
782 |
jpm |
556 |
if (auteurErreur) {
|
|
|
557 |
messages.add("Veuillez saisir au moins un auteur !");
|
705 |
aurelien |
558 |
}
|
|
|
559 |
|
786 |
jpm |
560 |
String titre = titreChp.getValue();
|
782 |
jpm |
561 |
if (titre == null || titre.equals("")) {
|
|
|
562 |
messages.add("Veuillez saisir le titre de la publication !");
|
705 |
aurelien |
563 |
}
|
|
|
564 |
|
792 |
jpm |
565 |
String uri = uriChp.getValue();
|
|
|
566 |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
|
|
|
567 |
messages.add("L'URL saisie n'est pas valide !");
|
|
|
568 |
}
|
|
|
569 |
|
799 |
jpm |
570 |
String datePublication = datePublicationChp.getRawValue();
|
|
|
571 |
if (datePublication == null || datePublication.equals("")) {
|
|
|
572 |
messages.add("Veuillez saisir une année de parution !");
|
725 |
aurelien |
573 |
} else {
|
799 |
jpm |
574 |
if (!etreDateValide(datePublication)) {
|
792 |
jpm |
575 |
messages.add("Le format de l'année saisie est incorrect !");
|
725 |
aurelien |
576 |
}
|
705 |
aurelien |
577 |
}
|
717 |
aurelien |
578 |
|
792 |
jpm |
579 |
String pages = pagesChp.getValue();
|
|
|
580 |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
|
799 |
jpm |
581 |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
|
792 |
jpm |
582 |
messages.add("Le format des pages est incorrect !");
|
|
|
583 |
}
|
|
|
584 |
|
782 |
jpm |
585 |
if (messages.size() != 0) {
|
|
|
586 |
String[] tableauDeMessages = {};
|
|
|
587 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
799 |
jpm |
588 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
|
782 |
jpm |
589 |
valide = false;
|
705 |
aurelien |
590 |
}
|
782 |
jpm |
591 |
return valide;
|
775 |
jpm |
592 |
}
|
|
|
593 |
|
822 |
jpm |
594 |
private void peuplerFormulaire() {
|
|
|
595 |
creerChampsAuteur();
|
|
|
596 |
titreChp.setValue(publication.getTitre());
|
|
|
597 |
collectionChp.setValue(publication.getCollection());
|
|
|
598 |
uriChp.setValue(publication.getURI());
|
|
|
599 |
datePublicationChp.setRawValue(reduireDateParAnnee(publication.getDateParution()));
|
|
|
600 |
tomeChp.setValue(publication.getIndicationNvt());
|
|
|
601 |
fasciculeChp.setValue(publication.getFascicule());
|
|
|
602 |
pagesChp.setValue(publication.getPages());
|
|
|
603 |
|
|
|
604 |
if (publication.getEditeur().matches("^[0-9]+$")) {
|
|
|
605 |
editeurCombobox.setValue(editeurCombobox.getStore().findModel("id_structure", publication.getEditeur()));
|
|
|
606 |
idStructureEdition = publication.getEditeur();
|
|
|
607 |
} else {
|
|
|
608 |
editeurCombobox.setRawValue(publication.getEditeur());
|
|
|
609 |
}
|
|
|
610 |
}
|
|
|
611 |
|
786 |
jpm |
612 |
private Publication collecterPublication() {
|
|
|
613 |
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
|
|
|
614 |
|
822 |
jpm |
615 |
String auteurIntituleFormate = "";
|
|
|
616 |
int auteursNombre = auteurComboboxListe.size();
|
|
|
617 |
for (int i = 0; i < auteursNombre; i++) {
|
786 |
jpm |
618 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
822 |
jpm |
619 |
Personne auteur = auteurComboboxListe.get(i).getValue();
|
|
|
620 |
auteurIntituleFormate += auteur.getNom()+ " "+auteur.getPrenom();
|
|
|
621 |
if (i != (auteursNombre - 1)) {
|
|
|
622 |
auteurIntituleFormate += ", ";
|
786 |
jpm |
623 |
}
|
|
|
624 |
}
|
|
|
625 |
}
|
822 |
jpm |
626 |
GWT.log("Auteurs formaté :"+auteurIntituleFormate, null);
|
|
|
627 |
publicationCollectee.setAuteur(auteurIntituleFormate);
|
786 |
jpm |
628 |
|
|
|
629 |
String titre = titreChp.getValue();
|
|
|
630 |
publicationCollectee.setTitre(titre);
|
|
|
631 |
|
|
|
632 |
String collection = collectionChp.getValue();
|
|
|
633 |
publicationCollectee.setCollection(collection);
|
|
|
634 |
|
|
|
635 |
String nomComplet = titreChp.getValue()+" "+collectionChp.getValue();
|
|
|
636 |
publicationCollectee.setNomComplet(nomComplet);
|
|
|
637 |
|
|
|
638 |
String uri = uriChp.getValue();
|
|
|
639 |
publicationCollectee.setUri(uri);
|
|
|
640 |
|
|
|
641 |
String editeur = "";
|
792 |
jpm |
642 |
if (editeurCombobox.getValue() != null) {
|
|
|
643 |
editeur = editeurCombobox.getValue().getId();
|
799 |
jpm |
644 |
publicationCollectee.setStructureEditeur(editeurCombobox.getValue());
|
792 |
jpm |
645 |
} else if (editeurCombobox.getRawValue() != "") {
|
|
|
646 |
editeur = editeurCombobox.getRawValue();
|
786 |
jpm |
647 |
}
|
|
|
648 |
publicationCollectee.setEditeur(editeur);
|
|
|
649 |
|
792 |
jpm |
650 |
String anneePublication = datePublicationChp.getRawValue();
|
|
|
651 |
String datePublication = anneePublication+"-00-00";
|
|
|
652 |
publicationCollectee.setDateParution(datePublication);
|
786 |
jpm |
653 |
|
|
|
654 |
String tome = tomeChp.getValue();
|
|
|
655 |
publicationCollectee.setIndicationNvt(tome);
|
|
|
656 |
|
|
|
657 |
String fascicule = fasciculeChp.getValue();
|
|
|
658 |
publicationCollectee.setFascicule(fascicule);
|
|
|
659 |
|
|
|
660 |
String pages = pagesChp.getValue();
|
|
|
661 |
publicationCollectee.setPages(pages);
|
|
|
662 |
|
927 |
jpm |
663 |
Publication publicationARetourner = null;
|
786 |
jpm |
664 |
if (!publicationCollectee.comparer(publication)) {
|
|
|
665 |
publicationARetourner = publication = publicationCollectee;
|
|
|
666 |
}
|
|
|
667 |
return publicationARetourner;
|
|
|
668 |
}
|
|
|
669 |
|
934 |
jpm |
670 |
public void reinitialiserFormulaire() {
|
781 |
jpm |
671 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
786 |
jpm |
672 |
mediateur.afficherFormPublication(publication.getId());
|
775 |
jpm |
673 |
} else {
|
|
|
674 |
mediateur.afficherFormPublication(null);
|
219 |
aurelien |
675 |
}
|
|
|
676 |
}
|
227 |
aurelien |
677 |
|
792 |
jpm |
678 |
private boolean etreDateValide(String anneePublication) {
|
782 |
jpm |
679 |
boolean valide = true;
|
792 |
jpm |
680 |
if (!anneePublication.matches("^[0-2][0-9]{3}$")) {
|
782 |
jpm |
681 |
valide = false;
|
725 |
aurelien |
682 |
}
|
782 |
jpm |
683 |
return valide;
|
725 |
aurelien |
684 |
}
|
758 |
aurelien |
685 |
|
|
|
686 |
private String reduireDateParAnnee(String datePar) {
|
775 |
jpm |
687 |
if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) {
|
758 |
aurelien |
688 |
return datePar.split("-")[0];
|
505 |
jp_milcent |
689 |
} else {
|
758 |
aurelien |
690 |
return "";
|
227 |
aurelien |
691 |
}
|
758 |
aurelien |
692 |
}
|
505 |
jp_milcent |
693 |
}
|