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