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