219 |
aurelien |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
227 |
aurelien |
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.Iterator;
|
365 |
jp_milcent |
5 |
import java.util.List;
|
227 |
aurelien |
6 |
import java.util.Set;
|
|
|
7 |
|
219 |
aurelien |
8 |
import org.tela_botanica.client.Mediateur;
|
|
|
9 |
import org.tela_botanica.client.RegistreId;
|
|
|
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;
|
239 |
aurelien |
13 |
import org.tela_botanica.client.modeles.Personne;
|
227 |
aurelien |
14 |
import org.tela_botanica.client.modeles.PersonneListe;
|
219 |
aurelien |
15 |
import org.tela_botanica.client.modeles.Publication;
|
749 |
aurelien |
16 |
import org.tela_botanica.client.modeles.PublicationAPersonne;
|
|
|
17 |
import org.tela_botanica.client.modeles.PublicationAPersonneListe;
|
705 |
aurelien |
18 |
import org.tela_botanica.client.modeles.PublicationListe;
|
219 |
aurelien |
19 |
import org.tela_botanica.client.modeles.Structure;
|
227 |
aurelien |
20 |
import org.tela_botanica.client.modeles.StructureListe;
|
219 |
aurelien |
21 |
|
|
|
22 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
23 |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
705 |
aurelien |
24 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
505 |
jp_milcent |
25 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
775 |
jpm |
26 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
705 |
aurelien |
27 |
import com.extjs.gxt.ui.client.event.Events;
|
775 |
jpm |
28 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
705 |
aurelien |
29 |
import com.extjs.gxt.ui.client.event.Listener;
|
219 |
aurelien |
30 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
31 |
import com.extjs.gxt.ui.client.store.ListStore;
|
227 |
aurelien |
32 |
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
219 |
aurelien |
33 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
705 |
aurelien |
34 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
219 |
aurelien |
35 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
36 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
|
|
37 |
import com.extjs.gxt.ui.client.widget.form.DateField;
|
|
|
38 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
|
|
39 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
775 |
jpm |
40 |
import com.extjs.gxt.ui.client.widget.form.Radio;
|
219 |
aurelien |
41 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
|
|
42 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
|
|
43 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
44 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
|
|
45 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
|
|
46 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
705 |
aurelien |
47 |
import com.google.gwt.core.client.GWT;
|
|
|
48 |
import com.google.gwt.user.client.Window;
|
227 |
aurelien |
49 |
import com.google.gwt.user.client.ui.HTML;
|
705 |
aurelien |
50 |
import com.google.gwt.user.client.ui.Label;
|
219 |
aurelien |
51 |
|
775 |
jpm |
52 |
public class PublicationForm extends Formulaire implements Rafraichissable {
|
219 |
aurelien |
53 |
|
775 |
jpm |
54 |
private Publication publi;
|
|
|
55 |
private PublicationAPersonneListe pubAPersonneListeAuteur = null;
|
219 |
aurelien |
56 |
|
|
|
57 |
|
775 |
jpm |
58 |
private FieldSet auteursFieldset = null;
|
|
|
59 |
private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
|
|
|
60 |
private PersonneListe listePersonneAuteur = null;
|
|
|
61 |
private LayoutContainer conteneurChamps;
|
|
|
62 |
private ListStore<Personne> auteursStorePartage = null;
|
227 |
aurelien |
63 |
|
775 |
jpm |
64 |
private FieldSet generalitesFieldset = null;
|
219 |
aurelien |
65 |
private TextField<String> nomArticle = null;
|
|
|
66 |
private TextField<String> intituleCollPub = null;
|
|
|
67 |
private TextField<String> uriPub = null;
|
|
|
68 |
|
775 |
jpm |
69 |
private FieldSet editionFieldset = null;
|
219 |
aurelien |
70 |
private ComboBox<Structure> comboListeEditeurs = null;
|
|
|
71 |
private ListStore<Structure> storeEditeurs = null;
|
725 |
aurelien |
72 |
private TextField<String> datePub = null;
|
219 |
aurelien |
73 |
private TextField<String> tomPub = null;
|
|
|
74 |
private TextField<String> fasciculePub = null;
|
|
|
75 |
private TextField<String> pagesPub = null;
|
|
|
76 |
|
775 |
jpm |
77 |
private String idStructureEdition = "";
|
|
|
78 |
private String idPublication = "";
|
|
|
79 |
private String idProjet = "";
|
|
|
80 |
|
|
|
81 |
private String idAuteurs = "";
|
|
|
82 |
|
705 |
aurelien |
83 |
private boolean formValide = false;
|
|
|
84 |
private boolean validationPublication = false;
|
|
|
85 |
private boolean validationAuteurs = false;
|
|
|
86 |
|
|
|
87 |
protected boolean listeAuteurInitialisee = false;
|
749 |
aurelien |
88 |
protected boolean listeAuteurPublicationInitialisee = false;
|
705 |
aurelien |
89 |
|
781 |
jpm |
90 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
|
|
91 |
String modeDeCreation = Formulaire.MODE_AJOUTER;
|
|
|
92 |
if (publicationId != null) {
|
|
|
93 |
modeDeCreation = Formulaire.MODE_MODIFIER;
|
|
|
94 |
}
|
775 |
jpm |
95 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
|
781 |
jpm |
96 |
chargerOntologie();
|
|
|
97 |
|
775 |
jpm |
98 |
panneauFormulaire.setLayout(new FlowLayout());
|
|
|
99 |
String titre = (modeDeCreation.equals(Formulaire.MODE_AJOUTER) ? "Ajout d'une publication" : "Modification d'une publication");
|
|
|
100 |
panneauFormulaire.setHeading(titre);
|
705 |
aurelien |
101 |
|
775 |
jpm |
102 |
creerZoneAuteurs();
|
|
|
103 |
panneauFormulaire.add(auteursFieldset);
|
219 |
aurelien |
104 |
|
775 |
jpm |
105 |
creerZoneGeneralites();
|
|
|
106 |
panneauFormulaire.add(generalitesFieldset);
|
239 |
aurelien |
107 |
|
775 |
jpm |
108 |
creerZoneEdition();
|
|
|
109 |
panneauFormulaire.add(editionFieldset);
|
|
|
110 |
|
781 |
jpm |
111 |
mediateurCourrant.selectionnerPublication(this, publicationId);
|
|
|
112 |
mediateurCourrant.selectionnerAuteurAPublication(this, publicationId);
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
private void chargerOntologie() {
|
775 |
jpm |
116 |
mediateur.clicObtenirListeEditeurs(this);
|
|
|
117 |
mediateur.clicObtenirListeAuteurs(this);
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
private void creerZoneAuteurs() {
|
|
|
121 |
FormLayout layout = new FormLayout();
|
|
|
122 |
layout.setLabelWidth(200);
|
|
|
123 |
|
|
|
124 |
// Fieldset Auteur
|
|
|
125 |
auteursFieldset = new FieldSet();
|
|
|
126 |
auteursFieldset.setHeading("Auteur(s)");
|
|
|
127 |
auteursFieldset.setCollapsible(true);
|
|
|
128 |
auteursFieldset.setLayout(layout);
|
|
|
129 |
|
|
|
130 |
auteurComboboxListe = new ArrayList<ComboBox<Personne>>(0);
|
|
|
131 |
auteursStorePartage = new ListStore<Personne>();
|
|
|
132 |
|
|
|
133 |
genererChampsAuteur(false);
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
private void genererChampsAuteur(boolean vider) {
|
|
|
137 |
auteursFieldset.removeAll();
|
|
|
138 |
|
|
|
139 |
conteneurChamps = new LayoutContainer();
|
|
|
140 |
|
|
|
141 |
Button ajoutAuteurBtn = new Button("Ajouter un auteur");
|
|
|
142 |
ajoutAuteurBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
219 |
aurelien |
143 |
|
775 |
jpm |
144 |
@Override
|
|
|
145 |
public void componentSelected(ButtonEvent be) {
|
|
|
146 |
creerTextFieldEtBouton(null);
|
|
|
147 |
|
|
|
148 |
int nbAuteurs = 0;
|
|
|
149 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
|
|
150 |
if (auteurComboboxListe.size() > 1) {
|
|
|
151 |
it.next().setFieldLabel("Auteur "+nbAuteurs);
|
|
|
152 |
nbAuteurs++;
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
auteursFieldset.layout(true);
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
});
|
219 |
aurelien |
160 |
|
775 |
jpm |
161 |
auteursFieldset.add(conteneurChamps);
|
|
|
162 |
auteursFieldset.add(ajoutAuteurBtn);
|
|
|
163 |
auteursFieldset.layout(true);
|
219 |
aurelien |
164 |
|
775 |
jpm |
165 |
if (!vider) {
|
|
|
166 |
creerTextFieldEtBouton(null);
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
public void creerTextFieldEtBouton(Personne auteur) {
|
|
|
171 |
final HorizontalPanel panneauHorizontal = new HorizontalPanel();
|
|
|
172 |
panneauHorizontal.setLayout(new FormLayout());
|
219 |
aurelien |
173 |
|
775 |
jpm |
174 |
final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis();
|
|
|
175 |
if (auteur != null) {
|
|
|
176 |
GWT.log(auteur.getId(), null);
|
|
|
177 |
auteursSaisisComboBox.setValue(auteursStorePartage.findModel("id_personne", auteur.getId()));
|
|
|
178 |
}
|
|
|
179 |
auteurComboboxListe.add(auteursSaisisComboBox);
|
758 |
aurelien |
180 |
|
775 |
jpm |
181 |
LayoutContainer lc = new LayoutContainer();
|
|
|
182 |
lc.setLayout(new FormLayout());
|
|
|
183 |
lc.add(auteursSaisisComboBox);
|
219 |
aurelien |
184 |
|
775 |
jpm |
185 |
Button supp = new Button("-");
|
|
|
186 |
supp.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
187 |
@Override
|
|
|
188 |
public void componentSelected(ButtonEvent be) {
|
|
|
189 |
int nbAuteurs = 0;
|
|
|
190 |
if (auteurComboboxListe.size() != 1) {
|
|
|
191 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
|
|
192 |
it.next().setFieldLabel("Auteur "+nbAuteurs);
|
|
|
193 |
nbAuteurs++;
|
|
|
194 |
}
|
|
|
195 |
}
|
|
|
196 |
auteurComboboxListe.remove(auteursSaisisComboBox);
|
|
|
197 |
conteneurChamps.remove(panneauHorizontal);
|
|
|
198 |
auteursFieldset.layout(true);
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
});
|
|
|
202 |
panneauHorizontal.add(lc);
|
|
|
203 |
panneauHorizontal.add(supp);
|
|
|
204 |
conteneurChamps.add(panneauHorizontal);
|
|
|
205 |
auteursFieldset.layout(true);
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
private ComboBox<Personne> creerComboBoxAuteursSaisis() {
|
|
|
209 |
ComboBox<Personne> comboBox = new ComboBox<Personne>();
|
|
|
210 |
comboBox.setSize(200, 20);
|
|
|
211 |
comboBox.setEmptyText(i18nC.chercherAuteurSaisi());
|
|
|
212 |
comboBox.setEditable(true);
|
|
|
213 |
comboBox.setForceSelection(true);
|
|
|
214 |
comboBox.setDisplayField("fmt_nom_complet");
|
|
|
215 |
comboBox.setTriggerAction(TriggerAction.ALL);
|
|
|
216 |
comboBox.setStore(auteursStorePartage);
|
|
|
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 |
|
|
|
231 |
nomArticle = new TextField<String>();
|
|
|
232 |
nomArticle.setName("cpu");
|
|
|
233 |
nomArticle.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
|
|
234 |
|
|
|
235 |
intituleCollPub = new TextField<String>();
|
|
|
236 |
intituleCollPub.setFieldLabel("Intitulé de la collection ou de la revue");
|
|
|
237 |
|
|
|
238 |
uriPub = new TextField<String>();
|
|
|
239 |
uriPub.setFieldLabel("URI de la publication");
|
|
|
240 |
|
775 |
jpm |
241 |
generalitesFieldset.add(nomArticle);
|
|
|
242 |
generalitesFieldset.add(intituleCollPub);
|
|
|
243 |
generalitesFieldset.add(uriPub);
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
private void creerZoneEdition() {
|
|
|
247 |
FormLayout layout = new FormLayout();
|
|
|
248 |
layout.setLabelWidth(200);
|
|
|
249 |
|
219 |
aurelien |
250 |
// Fieldset Edition
|
775 |
jpm |
251 |
editionFieldset = new FieldSet();
|
|
|
252 |
editionFieldset.setHeading("Edition");
|
|
|
253 |
editionFieldset.setCollapsible(true);
|
|
|
254 |
editionFieldset.setLayout(layout);
|
219 |
aurelien |
255 |
|
|
|
256 |
storeEditeurs = new ListStore<Structure>();
|
|
|
257 |
comboListeEditeurs = new ComboBox<Structure>();
|
|
|
258 |
comboListeEditeurs.setEmptyText("Sélectionner un editeur...");
|
|
|
259 |
comboListeEditeurs.setFieldLabel("Editeur de la publication");
|
|
|
260 |
comboListeEditeurs.setDisplayField("nom");
|
|
|
261 |
comboListeEditeurs.setStore(storeEditeurs);
|
|
|
262 |
comboListeEditeurs.setEditable(true);
|
|
|
263 |
comboListeEditeurs.setTypeAhead(true);
|
227 |
aurelien |
264 |
comboListeEditeurs.setTriggerAction(TriggerAction.QUERY);
|
775 |
jpm |
265 |
editionFieldset.add(comboListeEditeurs, new FormData(500, 20));
|
219 |
aurelien |
266 |
|
725 |
aurelien |
267 |
datePub = new TextField<String>();
|
734 |
aurelien |
268 |
datePub.setMaxLength(4);
|
|
|
269 |
datePub.setMinLength(4);
|
|
|
270 |
datePub.setFieldLabel("Année de publication");
|
775 |
jpm |
271 |
editionFieldset.add(datePub, new FormData(40, 20));
|
219 |
aurelien |
272 |
|
|
|
273 |
tomPub = new TextField<String>();
|
|
|
274 |
tomPub.setFieldLabel("Tome");
|
775 |
jpm |
275 |
editionFieldset.add(tomPub, new FormData(75, 20));
|
219 |
aurelien |
276 |
|
|
|
277 |
fasciculePub = new TextField<String>();
|
|
|
278 |
fasciculePub.setFieldLabel("Fascicule");
|
775 |
jpm |
279 |
editionFieldset.add(fasciculePub, new FormData(75, 20));
|
219 |
aurelien |
280 |
|
|
|
281 |
pagesPub = new TextField<String>();
|
|
|
282 |
pagesPub.setFieldLabel("Pages");
|
775 |
jpm |
283 |
editionFieldset.add(pagesPub, new FormData(100, 20));
|
219 |
aurelien |
284 |
}
|
775 |
jpm |
285 |
|
705 |
aurelien |
286 |
public void rafraichir(Object nouvellesDonnees) {
|
227 |
aurelien |
287 |
// Si on a reçu les details d'une publication
|
705 |
aurelien |
288 |
if (nouvellesDonnees instanceof Publication) {
|
775 |
jpm |
289 |
publi = (Publication) nouvellesDonnees;
|
758 |
aurelien |
290 |
|
|
|
291 |
genererChampsAuteur(true);
|
219 |
aurelien |
292 |
nomArticle.setValue(publi.getTitre());
|
|
|
293 |
intituleCollPub.setValue(publi.getCollection());
|
|
|
294 |
uriPub.setValue(publi.getURI());
|
758 |
aurelien |
295 |
datePub.setRawValue(reduireDateParAnnee(publi.getDateParution()));
|
219 |
aurelien |
296 |
tomPub.setValue(publi.getIndicationNvt());
|
|
|
297 |
fasciculePub.setValue(publi.getFascicule());
|
|
|
298 |
pagesPub.setValue(publi.getPages());
|
229 |
aurelien |
299 |
idPublication = publi.getId();
|
227 |
aurelien |
300 |
idStructureEdition = publi.getEditeur();
|
229 |
aurelien |
301 |
idProjet = publi.getProjet() ;
|
227 |
aurelien |
302 |
}
|
|
|
303 |
|
|
|
304 |
// Si on a reçu une liste des editeurs
|
775 |
jpm |
305 |
if (nouvellesDonnees instanceof StructureListe) {
|
227 |
aurelien |
306 |
storeEditeurs.removeAll();
|
705 |
aurelien |
307 |
StructureListe listeStructure = (StructureListe) nouvellesDonnees;
|
365 |
jp_milcent |
308 |
storeEditeurs.add((List<Structure>) listeStructure.toList());
|
219 |
aurelien |
309 |
|
775 |
jpm |
310 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
365 |
jp_milcent |
311 |
comboListeEditeurs.setValue((Structure) listeStructure.get(idStructureEdition));
|
227 |
aurelien |
312 |
}
|
|
|
313 |
comboListeEditeurs.expand();
|
219 |
aurelien |
314 |
}
|
239 |
aurelien |
315 |
|
775 |
jpm |
316 |
if (nouvellesDonnees instanceof PublicationAPersonneListe) {
|
|
|
317 |
pubAPersonneListeAuteur = (PublicationAPersonneListe) nouvellesDonnees;
|
749 |
aurelien |
318 |
|
775 |
jpm |
319 |
if (listeAuteurInitialisee) {
|
749 |
aurelien |
320 |
Iterator<String> itap = pubAPersonneListeAuteur.keySet().iterator();
|
775 |
jpm |
321 |
while (itap.hasNext()) {
|
|
|
322 |
creerTextFieldEtBouton(pubAPersonneListeAuteur.get(itap.next()).getPersonne());
|
749 |
aurelien |
323 |
}
|
758 |
aurelien |
324 |
|
|
|
325 |
int nbAuteurs = 0;
|
775 |
jpm |
326 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
|
|
327 |
if (auteurComboboxListe.size() > 1) {
|
758 |
aurelien |
328 |
it.next().setFieldLabel("Auteur "+nbAuteurs);
|
|
|
329 |
nbAuteurs++;
|
|
|
330 |
}
|
|
|
331 |
}
|
|
|
332 |
listeAuteurPublicationInitialisee = true;
|
749 |
aurelien |
333 |
}
|
|
|
334 |
}
|
|
|
335 |
|
705 |
aurelien |
336 |
if (nouvellesDonnees instanceof Information) {
|
|
|
337 |
Information nouvellesInfos = (Information)nouvellesDonnees;
|
|
|
338 |
|
775 |
jpm |
339 |
if (nouvellesInfos.getType().equals("liste_personne")) {
|
|
|
340 |
listePersonneAuteur = (PersonneListe) nouvellesInfos.getDonnee(0);
|
|
|
341 |
List<Personne> liste = listePersonneAuteur.toList();
|
|
|
342 |
auteursStorePartage.removeAll();
|
|
|
343 |
auteursStorePartage.add(liste);
|
|
|
344 |
GWT.log("ok", null);
|
749 |
aurelien |
345 |
listeAuteurInitialisee = true;
|
239 |
aurelien |
346 |
}
|
|
|
347 |
|
705 |
aurelien |
348 |
if (nouvellesInfos.getType().equals("publication_valide")) {
|
716 |
aurelien |
349 |
validationPublication = true;
|
734 |
aurelien |
350 |
idPublication = ""+nouvellesInfos.getDonnee(0);
|
741 |
aurelien |
351 |
|
775 |
jpm |
352 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
353 |
mediateur.ajouterAuteurPublication(this, idAuteurs, "2360", idPublication);
|
|
|
354 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
355 |
mediateur.modifierAuteurPublication(this, idAuteurs, idPublication);
|
741 |
aurelien |
356 |
}
|
239 |
aurelien |
357 |
}
|
705 |
aurelien |
358 |
|
734 |
aurelien |
359 |
if (nouvellesInfos.getType().equals("auteur_valide")) {
|
705 |
aurelien |
360 |
validationAuteurs = true;
|
734 |
aurelien |
361 |
}
|
775 |
jpm |
362 |
|
|
|
363 |
if (formValide && validationPublication && validationAuteurs && clicBoutonvalidation) {
|
|
|
364 |
clicBoutonvalidation = false;
|
|
|
365 |
panneauFormulaire.setEnabled(false);
|
|
|
366 |
mediateur.clicMenu(MenuApplicationId.PUBLICATION);
|
705 |
aurelien |
367 |
}
|
239 |
aurelien |
368 |
}
|
219 |
aurelien |
369 |
}
|
|
|
370 |
|
781 |
jpm |
371 |
public void soumettreFormulaire(Rafraichissable vueARafraichir) {
|
505 |
jp_milcent |
372 |
String auteur = "";
|
705 |
aurelien |
373 |
String idAuteur = "";
|
775 |
jpm |
374 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
|
|
375 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
|
|
376 |
idAuteur += auteurComboboxListe.get(i).getValue().getId();
|
|
|
377 |
auteur += auteurComboboxListe.get(i).getValue().getNom()+ " "+auteurComboboxListe.get(i).getValue().getPrenom();
|
|
|
378 |
if (i != auteurComboboxListe.size() -1) {
|
705 |
aurelien |
379 |
auteur += "|";
|
734 |
aurelien |
380 |
idAuteur += ",";
|
705 |
aurelien |
381 |
}
|
227 |
aurelien |
382 |
}
|
|
|
383 |
}
|
705 |
aurelien |
384 |
|
|
|
385 |
String erreurs = "";
|
|
|
386 |
|
775 |
jpm |
387 |
if (idAuteur == null || idAuteur.equals("")) {
|
705 |
aurelien |
388 |
erreurs += "Veuillez entrer au moins un auteur ! ";
|
716 |
aurelien |
389 |
} else {
|
|
|
390 |
idAuteurs = idAuteur;
|
705 |
aurelien |
391 |
}
|
|
|
392 |
|
219 |
aurelien |
393 |
String nomArt = nomArticle.getValue();
|
775 |
jpm |
394 |
if (nomArt == null || nomArt.equals("")) {
|
705 |
aurelien |
395 |
erreurs += "Veuillez entrer le nom de l'article ! ";
|
|
|
396 |
}
|
|
|
397 |
|
219 |
aurelien |
398 |
String collPub = intituleCollPub.getValue();
|
705 |
aurelien |
399 |
|
|
|
400 |
String pub = nomArticle.getValue()+" "+intituleCollPub.getValue();
|
|
|
401 |
|
219 |
aurelien |
402 |
String uri = uriPub.getValue();
|
705 |
aurelien |
403 |
|
|
|
404 |
String editeur = "";
|
|
|
405 |
|
775 |
jpm |
406 |
if (comboListeEditeurs.getValue() == null) {
|
717 |
aurelien |
407 |
//erreurs += "Veuillez sélectionner un éditeur ! ";
|
705 |
aurelien |
408 |
} else {
|
|
|
409 |
editeur = comboListeEditeurs.getValue().getId();
|
|
|
410 |
if(editeur == null || editeur.equals("")) {
|
|
|
411 |
erreurs += "Veuillez sélectionner un éditeur ! ";
|
|
|
412 |
}
|
|
|
413 |
}
|
|
|
414 |
|
219 |
aurelien |
415 |
String datePar = datePub.getRawValue();
|
775 |
jpm |
416 |
if (datePar == null || datePar.equals("")) {
|
705 |
aurelien |
417 |
erreurs += "Veuillez entrer une date ! ";
|
725 |
aurelien |
418 |
} else {
|
|
|
419 |
String resDate = analyserDate(datePar);
|
775 |
jpm |
420 |
if (resDate.equals("")) {
|
725 |
aurelien |
421 |
datePar = datePar+"-00-00";
|
|
|
422 |
} else {
|
|
|
423 |
erreurs += resDate;
|
|
|
424 |
}
|
705 |
aurelien |
425 |
}
|
219 |
aurelien |
426 |
String tome = tomPub.getValue();
|
717 |
aurelien |
427 |
|
219 |
aurelien |
428 |
String fascicule = fasciculePub.getValue();
|
717 |
aurelien |
429 |
|
219 |
aurelien |
430 |
String pages = pagesPub.getValue();
|
|
|
431 |
|
775 |
jpm |
432 |
if (erreurs.length() > 0) {
|
705 |
aurelien |
433 |
MessageBox.alert("Erreur dans la saisie des champs", erreurs, null);
|
775 |
jpm |
434 |
} else {
|
|
|
435 |
formValide = true;
|
|
|
436 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
|
|
437 |
Publication publi = new Publication(pub, uri, auteur, collPub, nomArt, editeur, datePar, tome, fascicule, pages);
|
|
|
438 |
mediateur.ajouterPublication(this, publi);
|
|
|
439 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
440 |
Publication publi = new Publication(idPublication, idProjet, pub, uri, auteur, collPub, nomArt, editeur, datePar, tome, fascicule, pages);
|
|
|
441 |
mediateur.modifierPublication(this, publi);
|
|
|
442 |
}
|
705 |
aurelien |
443 |
}
|
775 |
jpm |
444 |
}
|
|
|
445 |
|
|
|
446 |
|
|
|
447 |
protected void reinitialiserFormulaire() {
|
781 |
jpm |
448 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
775 |
jpm |
449 |
mediateur.afficherFormPublication(publi.getId());
|
|
|
450 |
} else {
|
|
|
451 |
mediateur.afficherFormPublication(null);
|
219 |
aurelien |
452 |
}
|
|
|
453 |
}
|
227 |
aurelien |
454 |
|
725 |
aurelien |
455 |
private String analyserDate(String datePar) {
|
775 |
jpm |
456 |
if (datePar.matches("^[0-2][0-9]{3}$")) {
|
725 |
aurelien |
457 |
return "";
|
|
|
458 |
} else {
|
|
|
459 |
return "Format de date incorrect ";
|
|
|
460 |
}
|
|
|
461 |
}
|
758 |
aurelien |
462 |
|
|
|
463 |
private String reduireDateParAnnee(String datePar) {
|
775 |
jpm |
464 |
if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) {
|
758 |
aurelien |
465 |
return datePar.split("-")[0];
|
505 |
jp_milcent |
466 |
} else {
|
758 |
aurelien |
467 |
return "";
|
227 |
aurelien |
468 |
}
|
758 |
aurelien |
469 |
}
|
227 |
aurelien |
470 |
|
775 |
jpm |
471 |
@Override
|
|
|
472 |
protected SelectionListener<ButtonEvent> creerEcouteurValidation() {
|
|
|
473 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
227 |
aurelien |
474 |
@Override
|
775 |
jpm |
475 |
public void componentSelected(ButtonEvent ce) {
|
|
|
476 |
String code = ((Button) ce.getComponent()).getData("code");
|
|
|
477 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
781 |
jpm |
478 |
soumettreFormulaire(renvoyerPublicationForm());
|
775 |
jpm |
479 |
clicBoutonvalidation = true;
|
|
|
480 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
781 |
jpm |
481 |
soumettreFormulaire(renvoyerPublicationForm());
|
775 |
jpm |
482 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
|
|
483 |
mediateur.clicMenu(menuIdCourant);
|
|
|
484 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
|
|
|
485 |
reinitialiserFormulaire();
|
227 |
aurelien |
486 |
}
|
|
|
487 |
}
|
775 |
jpm |
488 |
};
|
227 |
aurelien |
489 |
|
775 |
jpm |
490 |
return ecouteur;
|
227 |
aurelien |
491 |
}
|
781 |
jpm |
492 |
|
|
|
493 |
private PublicationForm renvoyerPublicationForm() {
|
|
|
494 |
return this;
|
|
|
495 |
}
|
505 |
jp_milcent |
496 |
}
|