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() {
|
989 |
jpm |
117 |
String titre = i18nC.publicationTitreFormAjout();
|
822 |
jpm |
118 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
989 |
jpm |
119 |
titre = i18nC.publicationTitreFormModif()+" - "+i18nC.id()+": "+publication.getId();
|
822 |
jpm |
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();
|
989 |
jpm |
130 |
auteursFieldset.setHeading(i18nC.publicationAuteursTitre());
|
775 |
jpm |
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 |
|
989 |
jpm |
146 |
Button ajouterAuteurBouton = new Button(i18nC.publicationAuteurBoutonAjouter());
|
822 |
jpm |
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) {
|
|
|
170 |
auteursSaisisComboBox.setValue(auteursStorePartage.findModel("id_personne", auteur.getId()));
|
901 |
jpm |
171 |
auteursSaisisComboBox.validate();
|
775 |
jpm |
172 |
}
|
|
|
173 |
auteurComboboxListe.add(auteursSaisisComboBox);
|
989 |
jpm |
174 |
auteursSaisisComboBox.setFieldLabel(i18nC.publicationAuteurSingulier()+" "+auteurComboboxListe.size());
|
758 |
aurelien |
175 |
|
822 |
jpm |
176 |
LayoutContainer panneauChampTxtEtBouton = new LayoutContainer();
|
|
|
177 |
panneauChampTxtEtBouton.setLayout(new FormLayout());
|
|
|
178 |
panneauChampTxtEtBouton.add(auteursSaisisComboBox, new FormData(300, 0));
|
|
|
179 |
panneauHorizontal.add(panneauChampTxtEtBouton);
|
219 |
aurelien |
180 |
|
822 |
jpm |
181 |
Button supprimerAuteurBouton = new Button();
|
|
|
182 |
supprimerAuteurBouton.setIcon(Images.ICONES.supprimer());
|
|
|
183 |
supprimerAuteurBouton.setToolTip(i18nC.supprimer());
|
|
|
184 |
supprimerAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
775 |
jpm |
185 |
@Override
|
|
|
186 |
public void componentSelected(ButtonEvent be) {
|
|
|
187 |
auteurComboboxListe.remove(auteursSaisisComboBox);
|
|
|
188 |
conteneurChamps.remove(panneauHorizontal);
|
822 |
jpm |
189 |
|
|
|
190 |
int numeroAuteurs = 1;
|
|
|
191 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
989 |
jpm |
192 |
it.next().setFieldLabel(i18nC.publicationAuteurSingulier()+" "+numeroAuteurs);
|
822 |
jpm |
193 |
numeroAuteurs++;
|
|
|
194 |
}
|
|
|
195 |
|
775 |
jpm |
196 |
auteursFieldset.layout(true);
|
|
|
197 |
}
|
|
|
198 |
});
|
822 |
jpm |
199 |
panneauHorizontal.add(supprimerAuteurBouton);
|
|
|
200 |
|
775 |
jpm |
201 |
conteneurChamps.add(panneauHorizontal);
|
|
|
202 |
auteursFieldset.layout(true);
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
private ComboBox<Personne> creerComboBoxAuteursSaisis() {
|
|
|
206 |
ComboBox<Personne> comboBox = new ComboBox<Personne>();
|
860 |
jpm |
207 |
comboBox.setEmptyText(i18nC.chercherPersonneSaisi());
|
775 |
jpm |
208 |
comboBox.setEditable(true);
|
|
|
209 |
comboBox.setForceSelection(true);
|
|
|
210 |
comboBox.setDisplayField("fmt_nom_complet");
|
|
|
211 |
comboBox.setTriggerAction(TriggerAction.ALL);
|
|
|
212 |
comboBox.setStore(auteursStorePartage);
|
981 |
jpm |
213 |
comboBox.addStyleName(ComposantClass.OBLIGATOIRE);
|
980 |
jpm |
214 |
comboBox.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
775 |
jpm |
215 |
|
|
|
216 |
return comboBox;
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
private void creerZoneGeneralites() {
|
|
|
220 |
FormLayout layout = new FormLayout();
|
|
|
221 |
layout.setLabelWidth(200);
|
219 |
aurelien |
222 |
|
|
|
223 |
// Fieldset Infos Générales
|
775 |
jpm |
224 |
generalitesFieldset = new FieldSet();
|
|
|
225 |
generalitesFieldset.setHeading("Informations générales");
|
|
|
226 |
generalitesFieldset.setCollapsible(true);
|
|
|
227 |
generalitesFieldset.setLayout(layout);
|
219 |
aurelien |
228 |
|
786 |
jpm |
229 |
titreChp = new TextField<String>();
|
|
|
230 |
titreChp.setName("cpu");
|
|
|
231 |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
981 |
jpm |
232 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
980 |
jpm |
233 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
792 |
jpm |
234 |
generalitesFieldset.add(titreChp, new FormData(450, 0));
|
219 |
aurelien |
235 |
|
786 |
jpm |
236 |
collectionChp = new TextField<String>();
|
792 |
jpm |
237 |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
|
|
|
238 |
generalitesFieldset.add(collectionChp, new FormData(450, 0));
|
219 |
aurelien |
239 |
|
786 |
jpm |
240 |
uriChp = new TextField<String>();
|
792 |
jpm |
241 |
uriChp.setFieldLabel("URL de la publication");
|
|
|
242 |
generalitesFieldset.add(uriChp, new FormData(450, 0));
|
775 |
jpm |
243 |
}
|
|
|
244 |
|
|
|
245 |
private void creerZoneEdition() {
|
|
|
246 |
FormLayout layout = new FormLayout();
|
|
|
247 |
layout.setLabelWidth(200);
|
|
|
248 |
|
219 |
aurelien |
249 |
// Fieldset Edition
|
775 |
jpm |
250 |
editionFieldset = new FieldSet();
|
792 |
jpm |
251 |
editionFieldset.setHeading("Édition");
|
775 |
jpm |
252 |
editionFieldset.setCollapsible(true);
|
|
|
253 |
editionFieldset.setLayout(layout);
|
219 |
aurelien |
254 |
|
792 |
jpm |
255 |
ListStore<Structure> editeurStore = new ListStore<Structure>();
|
|
|
256 |
editeurCombobox = new ComboBox<Structure>();
|
|
|
257 |
editeurCombobox.setEmptyText("Sélectionner un éditeur...");
|
|
|
258 |
editeurCombobox.setFieldLabel("Éditeur de la publication");
|
|
|
259 |
editeurCombobox.setDisplayField("nom");
|
|
|
260 |
editeurCombobox.setStore(editeurStore);
|
|
|
261 |
editeurCombobox.setEditable(true);
|
|
|
262 |
editeurCombobox.setTriggerAction(TriggerAction.ALL);
|
|
|
263 |
editionFieldset.add(editeurCombobox, new FormData(450, 0));
|
|
|
264 |
mediateur.clicObtenirListeEditeurs(this);
|
219 |
aurelien |
265 |
|
786 |
jpm |
266 |
datePublicationChp = new TextField<String>();
|
|
|
267 |
datePublicationChp.setMaxLength(4);
|
|
|
268 |
datePublicationChp.setMinLength(4);
|
|
|
269 |
datePublicationChp.setFieldLabel("Année de publication");
|
981 |
jpm |
270 |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
980 |
jpm |
271 |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
792 |
jpm |
272 |
editionFieldset.add(datePublicationChp, new FormData(40, 0));
|
219 |
aurelien |
273 |
|
786 |
jpm |
274 |
tomeChp = new TextField<String>();
|
792 |
jpm |
275 |
tomeChp.setFieldLabel("Série de la revue ou tome");
|
|
|
276 |
editionFieldset.add(tomeChp, new FormData(75, 0));
|
219 |
aurelien |
277 |
|
786 |
jpm |
278 |
fasciculeChp = new TextField<String>();
|
792 |
jpm |
279 |
fasciculeChp.setFieldLabel("Fascicule de la revue");
|
|
|
280 |
editionFieldset.add(fasciculeChp, new FormData(75, 0));
|
219 |
aurelien |
281 |
|
786 |
jpm |
282 |
pagesChp = new TextField<String>();
|
|
|
283 |
pagesChp.setFieldLabel("Pages");
|
887 |
aurelien |
284 |
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 |
285 |
editionFieldset.add(pagesChp, new FormData(100, 0));
|
219 |
aurelien |
286 |
}
|
775 |
jpm |
287 |
|
705 |
aurelien |
288 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
289 |
if (nouvellesDonnees instanceof Publication) {
|
782 |
jpm |
290 |
// Si on a reçu les details d'une publication
|
|
|
291 |
rafraichirPublication((Publication) nouvellesDonnees);
|
|
|
292 |
} else if (nouvellesDonnees instanceof StructureListe) {
|
|
|
293 |
// Si on a reçu une liste des editeurs
|
|
|
294 |
rafraichirListeEditeurs((StructureListe) nouvellesDonnees);
|
|
|
295 |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
|
|
|
296 |
rafraichirListeAuteurs((PublicationAPersonneListe) nouvellesDonnees);
|
|
|
297 |
} else if (nouvellesDonnees instanceof Information) {
|
|
|
298 |
rafraichirInformation((Information) nouvellesDonnees);
|
|
|
299 |
} else {
|
|
|
300 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
227 |
aurelien |
301 |
}
|
|
|
302 |
|
822 |
jpm |
303 |
if (etrePretAAfficherAuteurs()) {
|
901 |
jpm |
304 |
initialiserAffichageAuteurs();
|
822 |
jpm |
305 |
afficherAuteurs();
|
|
|
306 |
}
|
|
|
307 |
|
782 |
jpm |
308 |
if (etreValide()) {
|
822 |
jpm |
309 |
initialiserValidation();
|
782 |
jpm |
310 |
repandreRafraichissement();
|
|
|
311 |
controlerFermetureApresRafraichissement();
|
219 |
aurelien |
312 |
}
|
782 |
jpm |
313 |
}
|
901 |
jpm |
314 |
|
|
|
315 |
private void miseAJourPublicationAPersonneListe() {
|
|
|
316 |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
|
|
|
317 |
while (clesAjoutees.hasNext()) {
|
|
|
318 |
String id = clesAjoutees.next();
|
|
|
319 |
publicationAPersonneListe.put(id, auteursAjoutes.get(id));
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
|
|
|
323 |
while (clesSupprimees.hasNext()) {
|
|
|
324 |
String id = clesSupprimees.next();
|
|
|
325 |
publicationAPersonneListe.remove(id);
|
|
|
326 |
}
|
|
|
327 |
}
|
|
|
328 |
|
786 |
jpm |
329 |
private void rafraichirPublication(Publication publi) {
|
|
|
330 |
publication = publi;
|
822 |
jpm |
331 |
peuplerFormulaire();
|
782 |
jpm |
332 |
}
|
|
|
333 |
|
|
|
334 |
private void rafraichirListeEditeurs(StructureListe editeurs) {
|
792 |
jpm |
335 |
editeurCombobox.getStore().removeAll();
|
|
|
336 |
editeurCombobox.getStore().add((List<Structure>) editeurs.toList());
|
782 |
jpm |
337 |
|
|
|
338 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
792 |
jpm |
339 |
editeurCombobox.setValue((Structure) editeurs.get(idStructureEdition));
|
782 |
jpm |
340 |
}
|
792 |
jpm |
341 |
editeurCombobox.expand();
|
782 |
jpm |
342 |
}
|
|
|
343 |
|
|
|
344 |
private void rafraichirListeAuteurs(PublicationAPersonneListe auteurs) {
|
786 |
jpm |
345 |
publicationAPersonneListe = auteurs;
|
822 |
jpm |
346 |
publicationAPersonneListeChargementOk = true;
|
782 |
jpm |
347 |
}
|
|
|
348 |
|
|
|
349 |
private void rafraichirInformation(Information info) {
|
|
|
350 |
if (info.getType().equals("liste_personne")) {
|
822 |
jpm |
351 |
PersonneListe listePersonneAuteur = (PersonneListe) info.getDonnee(0);
|
|
|
352 |
|
782 |
jpm |
353 |
List<Personne> liste = listePersonneAuteur.toList();
|
|
|
354 |
auteursStorePartage.removeAll();
|
|
|
355 |
auteursStorePartage.add(liste);
|
822 |
jpm |
356 |
|
|
|
357 |
auteurStorePartageChargementOk = true;
|
782 |
jpm |
358 |
} else if (info.getType().equals("publication_valide")) {
|
822 |
jpm |
359 |
publicationValideOk = true;
|
786 |
jpm |
360 |
publication.setId((String) info.getDonnee(0));
|
705 |
aurelien |
361 |
|
782 |
jpm |
362 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
901 |
jpm |
363 |
attenteAjoutAuteursOk = true;
|
|
|
364 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
239 |
aurelien |
365 |
}
|
901 |
jpm |
366 |
} else if (info.getType().equals("ajout_publication_a_personne")) {
|
|
|
367 |
attenteAjoutAuteursOk = false;
|
|
|
368 |
GWT.log("attenteAjoutAuteursOk", null);
|
|
|
369 |
} else if (info.getType().equals("suppression_publication_a_personne")) {
|
|
|
370 |
attenteSuppressionAuteursOk = false;
|
|
|
371 |
GWT.log("attenteSuppressionAuteursOk", null);
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
if (avoirAuteursMiseAJourCorrectement()) {
|
822 |
jpm |
375 |
auteursValideOk = true;
|
901 |
jpm |
376 |
miseAJourPublicationAPersonneListe();
|
|
|
377 |
initialiserAuteurs();
|
782 |
jpm |
378 |
}
|
|
|
379 |
}
|
|
|
380 |
|
901 |
jpm |
381 |
private boolean avoirAuteursMiseAJourCorrectement() {
|
|
|
382 |
boolean ok = false;
|
|
|
383 |
if (attenteAjoutAuteursOk == false && attenteSuppressionAuteursOk == false) {
|
|
|
384 |
ok = true;
|
|
|
385 |
}
|
|
|
386 |
return ok;
|
|
|
387 |
}
|
|
|
388 |
|
822 |
jpm |
389 |
private void afficherAuteurs() {
|
|
|
390 |
Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
|
|
|
391 |
while (itap.hasNext()) {
|
|
|
392 |
creerChampAuteurEtBoutonSupprimer(publicationAPersonneListe.get(itap.next()).getPersonne());
|
|
|
393 |
}
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
private void initialiserAffichageAuteurs() {
|
|
|
397 |
auteurStorePartageChargementOk = false;
|
|
|
398 |
publicationAPersonneListeChargementOk = false;
|
|
|
399 |
}
|
|
|
400 |
|
|
|
401 |
private boolean etrePretAAfficherAuteurs() {
|
|
|
402 |
boolean ok = false;
|
|
|
403 |
if (auteurStorePartageChargementOk && publicationAPersonneListeChargementOk) {
|
|
|
404 |
ok = true;
|
|
|
405 |
}
|
|
|
406 |
return ok;
|
|
|
407 |
}
|
|
|
408 |
|
782 |
jpm |
409 |
private Boolean etreValide() {
|
|
|
410 |
Boolean valide = false;
|
989 |
jpm |
411 |
//Debug.log("formulaire"+formulaireValideOk+" - Publication :"+publicationValideOk+" - Auteurs :"+auteursValideOk, null);
|
822 |
jpm |
412 |
if (formulaireValideOk && publicationValideOk && auteursValideOk) {
|
782 |
jpm |
413 |
valide = true;
|
|
|
414 |
}
|
|
|
415 |
return valide;
|
|
|
416 |
}
|
|
|
417 |
|
822 |
jpm |
418 |
private void initialiserValidation() {
|
|
|
419 |
formulaireValideOk = false;
|
|
|
420 |
publicationValideOk = false;
|
901 |
jpm |
421 |
initialiserAuteurs();
|
822 |
jpm |
422 |
auteursValideOk = false;
|
782 |
jpm |
423 |
}
|
|
|
424 |
|
901 |
jpm |
425 |
private void initialiserAuteurs() {
|
|
|
426 |
attenteAjoutAuteursOk = true;
|
|
|
427 |
auteursAjoutes = new PublicationAPersonneListe();
|
|
|
428 |
attenteSuppressionAuteursOk = true;
|
|
|
429 |
auteursSupprimes = new PublicationAPersonneListe();
|
|
|
430 |
}
|
|
|
431 |
|
782 |
jpm |
432 |
private void repandreRafraichissement() {
|
|
|
433 |
if (vueExterneARafraichirApresValidation != null) {
|
786 |
jpm |
434 |
String type = "publication_modifiee";
|
|
|
435 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
436 |
type = "publication_ajoutee";
|
|
|
437 |
}
|
|
|
438 |
Information info = new Information(type);
|
|
|
439 |
info.setDonnee(0, publication);
|
782 |
jpm |
440 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
|
|
441 |
}
|
|
|
442 |
}
|
|
|
443 |
|
786 |
jpm |
444 |
public boolean soumettreFormulaire() {
|
822 |
jpm |
445 |
formulaireValideOk = verifierFormulaire();
|
|
|
446 |
if (formulaireValideOk) {
|
901 |
jpm |
447 |
soumettrePublication();
|
|
|
448 |
soumettreAuteurs();
|
|
|
449 |
}
|
|
|
450 |
return formulaireValideOk;
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
private void soumettrePublication() {
|
|
|
454 |
Publication publicationCollectee = collecterPublication();
|
|
|
455 |
if (publicationCollectee != null) {
|
|
|
456 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
457 |
mediateur.ajouterPublication(this, publicationCollectee);
|
|
|
458 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
459 |
mediateur.modifierPublication(this, publicationCollectee);
|
|
|
460 |
}
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
private void soumettreAuteurs() {
|
|
|
465 |
attenteAjoutAuteursOk = false;
|
|
|
466 |
attenteSuppressionAuteursOk = false;
|
|
|
467 |
|
|
|
468 |
PersonneListe personnesInitiales = new PersonneListe();
|
|
|
469 |
if (publicationAPersonneListe != null) {
|
|
|
470 |
Iterator<String> itap = publicationAPersonneListe.keySet().iterator();
|
|
|
471 |
while (itap.hasNext()) {
|
|
|
472 |
Personne personne = publicationAPersonneListe.get(itap.next()).getPersonne();
|
|
|
473 |
personnesInitiales.put(personne.getId(), personne);
|
|
|
474 |
}
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
PersonneListe personnesActuelles = new PersonneListe();
|
|
|
478 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
|
|
479 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
|
|
480 |
Personne personne = auteurComboboxListe.get(i).getValue();
|
|
|
481 |
personnesActuelles.put(personne.getId(), personne);
|
|
|
482 |
}
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
// Auteurs ajoutés
|
|
|
486 |
Iterator<String> clesActuelles = personnesActuelles.keySet().iterator();
|
|
|
487 |
while (clesActuelles.hasNext()) {
|
|
|
488 |
String idActuel = clesActuelles.next();
|
|
|
489 |
if (personnesInitiales.size() == 0 || personnesInitiales.get(idActuel) == null) {
|
|
|
490 |
Personne personne = personnesActuelles.get(idActuel);
|
|
|
491 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
|
|
492 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
493 |
publicationAAuteur.setIdPublication(publication.getId());
|
741 |
aurelien |
494 |
}
|
901 |
jpm |
495 |
publicationAAuteur.setPersonne(personne);
|
|
|
496 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
|
|
497 |
auteursAjoutes.put(publicationAAuteur.getId(), publicationAAuteur);
|
|
|
498 |
attenteAjoutAuteursOk = true;
|
239 |
aurelien |
499 |
}
|
|
|
500 |
}
|
901 |
jpm |
501 |
|
|
|
502 |
// Auteurs supprimés
|
|
|
503 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
504 |
Iterator<String> clesInitiales = personnesInitiales.keySet().iterator();
|
|
|
505 |
while (clesInitiales.hasNext()) {
|
|
|
506 |
String idInitial = clesInitiales.next();
|
|
|
507 |
if (personnesActuelles.size() == 0 || personnesActuelles.get(idInitial) == null) {
|
|
|
508 |
Personne personne = personnesInitiales.get(idInitial);
|
|
|
509 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
|
|
510 |
publicationAAuteur.setIdPublication(publication.getId());
|
|
|
511 |
publicationAAuteur.setPersonne(personne);
|
|
|
512 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
|
|
513 |
auteursSupprimes.put(publicationAAuteur.getId(), publicationAAuteur);
|
|
|
514 |
attenteSuppressionAuteursOk = true;
|
|
|
515 |
}
|
|
|
516 |
}
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
// Execution de les mise à jour pour le mode MODIFICATION
|
|
|
520 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
521 |
if (auteursAjoutes != null && auteursAjoutes.size() != 0) {
|
|
|
522 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
|
|
523 |
}
|
|
|
524 |
|
|
|
525 |
if (auteursSupprimes != null && auteursSupprimes.size() != 0) {
|
|
|
526 |
mediateur.supprimerPublicationAPersonne(this, auteursSupprimes);
|
|
|
527 |
}
|
|
|
528 |
}
|
219 |
aurelien |
529 |
}
|
|
|
530 |
|
934 |
jpm |
531 |
public boolean verifierFormulaire() {
|
782 |
jpm |
532 |
boolean valide = true;
|
|
|
533 |
ArrayList<String> messages = new ArrayList<String>();
|
|
|
534 |
|
786 |
jpm |
535 |
boolean auteurErreur = true;
|
775 |
jpm |
536 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
|
|
537 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
786 |
jpm |
538 |
auteurErreur = false;
|
782 |
jpm |
539 |
break;
|
227 |
aurelien |
540 |
}
|
|
|
541 |
}
|
782 |
jpm |
542 |
if (auteurErreur) {
|
|
|
543 |
messages.add("Veuillez saisir au moins un auteur !");
|
705 |
aurelien |
544 |
}
|
|
|
545 |
|
786 |
jpm |
546 |
String titre = titreChp.getValue();
|
782 |
jpm |
547 |
if (titre == null || titre.equals("")) {
|
|
|
548 |
messages.add("Veuillez saisir le titre de la publication !");
|
705 |
aurelien |
549 |
}
|
|
|
550 |
|
792 |
jpm |
551 |
String uri = uriChp.getValue();
|
|
|
552 |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
|
|
|
553 |
messages.add("L'URL saisie n'est pas valide !");
|
|
|
554 |
}
|
|
|
555 |
|
799 |
jpm |
556 |
String datePublication = datePublicationChp.getRawValue();
|
|
|
557 |
if (datePublication == null || datePublication.equals("")) {
|
|
|
558 |
messages.add("Veuillez saisir une année de parution !");
|
725 |
aurelien |
559 |
} else {
|
799 |
jpm |
560 |
if (!etreDateValide(datePublication)) {
|
792 |
jpm |
561 |
messages.add("Le format de l'année saisie est incorrect !");
|
725 |
aurelien |
562 |
}
|
705 |
aurelien |
563 |
}
|
717 |
aurelien |
564 |
|
792 |
jpm |
565 |
String pages = pagesChp.getValue();
|
|
|
566 |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
|
799 |
jpm |
567 |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
|
792 |
jpm |
568 |
messages.add("Le format des pages est incorrect !");
|
|
|
569 |
}
|
|
|
570 |
|
782 |
jpm |
571 |
if (messages.size() != 0) {
|
|
|
572 |
String[] tableauDeMessages = {};
|
|
|
573 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
799 |
jpm |
574 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
|
782 |
jpm |
575 |
valide = false;
|
705 |
aurelien |
576 |
}
|
782 |
jpm |
577 |
return valide;
|
775 |
jpm |
578 |
}
|
|
|
579 |
|
822 |
jpm |
580 |
private void peuplerFormulaire() {
|
|
|
581 |
creerChampsAuteur();
|
|
|
582 |
titreChp.setValue(publication.getTitre());
|
|
|
583 |
collectionChp.setValue(publication.getCollection());
|
|
|
584 |
uriChp.setValue(publication.getURI());
|
|
|
585 |
datePublicationChp.setRawValue(reduireDateParAnnee(publication.getDateParution()));
|
|
|
586 |
tomeChp.setValue(publication.getIndicationNvt());
|
|
|
587 |
fasciculeChp.setValue(publication.getFascicule());
|
|
|
588 |
pagesChp.setValue(publication.getPages());
|
|
|
589 |
|
|
|
590 |
if (publication.getEditeur().matches("^[0-9]+$")) {
|
|
|
591 |
editeurCombobox.setValue(editeurCombobox.getStore().findModel("id_structure", publication.getEditeur()));
|
|
|
592 |
idStructureEdition = publication.getEditeur();
|
|
|
593 |
} else {
|
|
|
594 |
editeurCombobox.setRawValue(publication.getEditeur());
|
|
|
595 |
}
|
|
|
596 |
}
|
|
|
597 |
|
786 |
jpm |
598 |
private Publication collecterPublication() {
|
|
|
599 |
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
|
|
|
600 |
|
822 |
jpm |
601 |
String auteurIntituleFormate = "";
|
|
|
602 |
int auteursNombre = auteurComboboxListe.size();
|
|
|
603 |
for (int i = 0; i < auteursNombre; i++) {
|
786 |
jpm |
604 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
822 |
jpm |
605 |
Personne auteur = auteurComboboxListe.get(i).getValue();
|
|
|
606 |
auteurIntituleFormate += auteur.getNom()+ " "+auteur.getPrenom();
|
|
|
607 |
if (i != (auteursNombre - 1)) {
|
|
|
608 |
auteurIntituleFormate += ", ";
|
786 |
jpm |
609 |
}
|
|
|
610 |
}
|
|
|
611 |
}
|
822 |
jpm |
612 |
publicationCollectee.setAuteur(auteurIntituleFormate);
|
786 |
jpm |
613 |
|
|
|
614 |
String titre = titreChp.getValue();
|
|
|
615 |
publicationCollectee.setTitre(titre);
|
|
|
616 |
|
|
|
617 |
String collection = collectionChp.getValue();
|
|
|
618 |
publicationCollectee.setCollection(collection);
|
|
|
619 |
|
|
|
620 |
String nomComplet = titreChp.getValue()+" "+collectionChp.getValue();
|
|
|
621 |
publicationCollectee.setNomComplet(nomComplet);
|
|
|
622 |
|
|
|
623 |
String uri = uriChp.getValue();
|
|
|
624 |
publicationCollectee.setUri(uri);
|
|
|
625 |
|
|
|
626 |
String editeur = "";
|
792 |
jpm |
627 |
if (editeurCombobox.getValue() != null) {
|
|
|
628 |
editeur = editeurCombobox.getValue().getId();
|
799 |
jpm |
629 |
publicationCollectee.setStructureEditeur(editeurCombobox.getValue());
|
792 |
jpm |
630 |
} else if (editeurCombobox.getRawValue() != "") {
|
|
|
631 |
editeur = editeurCombobox.getRawValue();
|
786 |
jpm |
632 |
}
|
|
|
633 |
publicationCollectee.setEditeur(editeur);
|
|
|
634 |
|
792 |
jpm |
635 |
String anneePublication = datePublicationChp.getRawValue();
|
|
|
636 |
String datePublication = anneePublication+"-00-00";
|
|
|
637 |
publicationCollectee.setDateParution(datePublication);
|
786 |
jpm |
638 |
|
|
|
639 |
String tome = tomeChp.getValue();
|
|
|
640 |
publicationCollectee.setIndicationNvt(tome);
|
|
|
641 |
|
|
|
642 |
String fascicule = fasciculeChp.getValue();
|
|
|
643 |
publicationCollectee.setFascicule(fascicule);
|
|
|
644 |
|
|
|
645 |
String pages = pagesChp.getValue();
|
|
|
646 |
publicationCollectee.setPages(pages);
|
|
|
647 |
|
927 |
jpm |
648 |
Publication publicationARetourner = null;
|
786 |
jpm |
649 |
if (!publicationCollectee.comparer(publication)) {
|
|
|
650 |
publicationARetourner = publication = publicationCollectee;
|
|
|
651 |
}
|
|
|
652 |
return publicationARetourner;
|
|
|
653 |
}
|
|
|
654 |
|
934 |
jpm |
655 |
public void reinitialiserFormulaire() {
|
781 |
jpm |
656 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
786 |
jpm |
657 |
mediateur.afficherFormPublication(publication.getId());
|
775 |
jpm |
658 |
} else {
|
|
|
659 |
mediateur.afficherFormPublication(null);
|
219 |
aurelien |
660 |
}
|
|
|
661 |
}
|
227 |
aurelien |
662 |
|
792 |
jpm |
663 |
private boolean etreDateValide(String anneePublication) {
|
782 |
jpm |
664 |
boolean valide = true;
|
792 |
jpm |
665 |
if (!anneePublication.matches("^[0-2][0-9]{3}$")) {
|
782 |
jpm |
666 |
valide = false;
|
725 |
aurelien |
667 |
}
|
782 |
jpm |
668 |
return valide;
|
725 |
aurelien |
669 |
}
|
758 |
aurelien |
670 |
|
|
|
671 |
private String reduireDateParAnnee(String datePar) {
|
775 |
jpm |
672 |
if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) {
|
758 |
aurelien |
673 |
return datePar.split("-")[0];
|
505 |
jp_milcent |
674 |
} else {
|
758 |
aurelien |
675 |
return "";
|
227 |
aurelien |
676 |
}
|
758 |
aurelien |
677 |
}
|
505 |
jp_milcent |
678 |
}
|