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