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;
|
|
|
67 |
private DateField datePub = null;
|
|
|
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 |
|
|
|
174 |
datePub = new DateField();
|
|
|
175 |
datePub.setFieldLabel("Date de publication");
|
|
|
176 |
|
|
|
177 |
tomPub = new TextField<String>();
|
|
|
178 |
tomPub.setFieldLabel("Tome");
|
|
|
179 |
|
|
|
180 |
fasciculePub = new TextField<String>();
|
|
|
181 |
fasciculePub.setFieldLabel("Fascicule");
|
|
|
182 |
|
|
|
183 |
pagesPub = new TextField<String>();
|
|
|
184 |
pagesPub.setFieldLabel("Pages");
|
|
|
185 |
|
505 |
jp_milcent |
186 |
fieldSetEdition.add(comboListeEditeurs, new FormData(500, 20));
|
705 |
aurelien |
187 |
fieldSetEdition.add(datePub, new FormData(100, 20));
|
219 |
aurelien |
188 |
fieldSetEdition.add(tomPub);
|
|
|
189 |
fieldSetEdition.add(fasciculePub);
|
505 |
jp_milcent |
190 |
fieldSetEdition.add(pagesPub, new FormData(100, 20));
|
219 |
aurelien |
191 |
|
|
|
192 |
// Ajout des boutons au panneau formulaire
|
705 |
aurelien |
193 |
annulerBtn = new Button("Annuler");
|
505 |
jp_milcent |
194 |
annulerBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
219 |
aurelien |
195 |
@Override
|
505 |
jp_milcent |
196 |
public void componentSelected(ButtonEvent be) {
|
219 |
aurelien |
197 |
mediateur.clicMenu("Publications");
|
|
|
198 |
}
|
|
|
199 |
});
|
|
|
200 |
panel.addButton(annulerBtn);
|
705 |
aurelien |
201 |
|
|
|
202 |
validerBtn = new Button("Valider");
|
505 |
jp_milcent |
203 |
validerBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
219 |
aurelien |
204 |
@Override
|
505 |
jp_milcent |
205 |
public void componentSelected(ButtonEvent be) {
|
219 |
aurelien |
206 |
soumettreFormulaire();
|
|
|
207 |
}
|
|
|
208 |
});
|
705 |
aurelien |
209 |
|
219 |
aurelien |
210 |
panel.addButton(validerBtn);
|
|
|
211 |
|
705 |
aurelien |
212 |
mediateur.clicObtenirListeEditeurs(this);
|
239 |
aurelien |
213 |
mediateur.clicObtenirListeAuteurs(this);
|
219 |
aurelien |
214 |
}
|
|
|
215 |
|
705 |
aurelien |
216 |
public void rafraichir(Object nouvellesDonnees) {
|
227 |
aurelien |
217 |
|
|
|
218 |
// Si on a reçu les details d'une publication
|
705 |
aurelien |
219 |
if (nouvellesDonnees instanceof Publication) {
|
227 |
aurelien |
220 |
mode = "MODIF" ;
|
|
|
221 |
|
705 |
aurelien |
222 |
publi = (Publication) nouvellesDonnees;
|
505 |
jp_milcent |
223 |
genererChampsAuteur(publi.getIdAuteur(), false);
|
705 |
aurelien |
224 |
mediateur.clicObtenirListeAuteurs(this);
|
219 |
aurelien |
225 |
nomArticle.setValue(publi.getTitre());
|
|
|
226 |
intituleCollPub.setValue(publi.getCollection());
|
|
|
227 |
uriPub.setValue(publi.getURI());
|
|
|
228 |
datePub.setRawValue(publi.getDateParution());
|
|
|
229 |
tomPub.setValue(publi.getIndicationNvt());
|
|
|
230 |
fasciculePub.setValue(publi.getFascicule());
|
|
|
231 |
pagesPub.setValue(publi.getPages());
|
|
|
232 |
|
229 |
aurelien |
233 |
idPublication = publi.getId();
|
227 |
aurelien |
234 |
idStructureEdition = publi.getEditeur();
|
229 |
aurelien |
235 |
idProjet = publi.getProjet() ;
|
227 |
aurelien |
236 |
|
219 |
aurelien |
237 |
panel.setHeading("Modification d'une publication");
|
227 |
aurelien |
238 |
}
|
|
|
239 |
|
|
|
240 |
// Si on a reçu une liste des editeurs
|
705 |
aurelien |
241 |
if(nouvellesDonnees instanceof StructureListe) {
|
227 |
aurelien |
242 |
storeEditeurs.removeAll();
|
705 |
aurelien |
243 |
StructureListe listeStructure = (StructureListe) nouvellesDonnees;
|
365 |
jp_milcent |
244 |
storeEditeurs.add((List<Structure>) listeStructure.toList());
|
219 |
aurelien |
245 |
|
505 |
jp_milcent |
246 |
if (mode.equals("MODIF")) {
|
365 |
jp_milcent |
247 |
comboListeEditeurs.setValue((Structure) listeStructure.get(idStructureEdition));
|
227 |
aurelien |
248 |
}
|
|
|
249 |
comboListeEditeurs.expand();
|
219 |
aurelien |
250 |
}
|
239 |
aurelien |
251 |
|
705 |
aurelien |
252 |
if (nouvellesDonnees instanceof Information) {
|
|
|
253 |
Information nouvellesInfos = (Information)nouvellesDonnees;
|
|
|
254 |
|
|
|
255 |
if(nouvellesInfos.getType().equals("liste_personne")) {
|
|
|
256 |
listePersonneAuteur = (PersonneListe)nouvellesInfos.getDonnee(0);
|
|
|
257 |
storeAuteurs.removeAll();
|
|
|
258 |
for (Iterator<String> it = listePersonneAuteur.keySet().iterator(); it.hasNext();) {
|
|
|
259 |
Personne p = listePersonneAuteur.get(it.next());
|
|
|
260 |
storeAuteurs.add(p);
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
if (mode.equals("MODIF")) {
|
|
|
264 |
genererChampsAuteur(publi.getIdAuteur(), false);
|
|
|
265 |
} else {
|
|
|
266 |
listeAuteurs.get(0).expand();
|
|
|
267 |
}
|
|
|
268 |
listeAuteurInitialisee = true;
|
239 |
aurelien |
269 |
}
|
|
|
270 |
|
705 |
aurelien |
271 |
if (nouvellesInfos.getType().equals("publication_valide")) {
|
716 |
aurelien |
272 |
validationPublication = true;
|
|
|
273 |
idPublication = (String)nouvellesInfos.getDonnee(0);
|
|
|
274 |
mediateur.ajouterAuteurPublication(this,idAuteurs,"2360",idPublication);
|
239 |
aurelien |
275 |
}
|
705 |
aurelien |
276 |
|
|
|
277 |
if (nouvellesInfos.getType().equals("auteur_valide")) {
|
|
|
278 |
validationAuteurs = true;
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
if(formValide && validationPublication && validationAuteurs) {
|
|
|
282 |
mediateur.rechargerListePublication();
|
|
|
283 |
}
|
239 |
aurelien |
284 |
}
|
219 |
aurelien |
285 |
}
|
|
|
286 |
|
|
|
287 |
private void soumettreFormulaire() {
|
505 |
jp_milcent |
288 |
String auteur = "";
|
705 |
aurelien |
289 |
String idAuteur = "";
|
505 |
jp_milcent |
290 |
for (int i = 0; i < listeAuteurs.size(); i++) {
|
705 |
aurelien |
291 |
if(listeAuteurs.get(i).getValue() != null) {
|
|
|
292 |
idAuteur += listeAuteurs.get(i).getValue().getId();
|
|
|
293 |
auteur += listeAuteurs.get(i).getValue().getNom()+ " "+listeAuteurs.get(i).getValue().getPrenom();
|
|
|
294 |
if (i != listeAuteurs.size() -1) {
|
|
|
295 |
auteur += "|";
|
|
|
296 |
idAuteur += "|";
|
|
|
297 |
}
|
227 |
aurelien |
298 |
}
|
|
|
299 |
}
|
705 |
aurelien |
300 |
|
|
|
301 |
String erreurs = "";
|
|
|
302 |
|
|
|
303 |
if(idAuteur == null || idAuteur.equals("")) {
|
|
|
304 |
erreurs += "Veuillez entrer au moins un auteur ! ";
|
716 |
aurelien |
305 |
} else {
|
|
|
306 |
idAuteurs = idAuteur;
|
705 |
aurelien |
307 |
}
|
|
|
308 |
|
219 |
aurelien |
309 |
String nomArt = nomArticle.getValue();
|
705 |
aurelien |
310 |
if(nomArt == null || nomArt.equals("")) {
|
|
|
311 |
erreurs += "Veuillez entrer le nom de l'article ! ";
|
|
|
312 |
}
|
|
|
313 |
|
219 |
aurelien |
314 |
String collPub = intituleCollPub.getValue();
|
705 |
aurelien |
315 |
if(collPub == null || collPub.equals("")) {
|
|
|
316 |
erreurs += "Veuillez entrer l'intitulé de la collection ! ";
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
String pub = nomArticle.getValue()+" "+intituleCollPub.getValue();
|
|
|
320 |
|
219 |
aurelien |
321 |
String uri = uriPub.getValue();
|
705 |
aurelien |
322 |
if(uri == null || uri.equals("")) {
|
|
|
323 |
erreurs += "Veuillez entrer l'uri associée à la publication ! ";
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
String editeur = "";
|
|
|
327 |
|
|
|
328 |
if(comboListeEditeurs.getValue() == null) {
|
|
|
329 |
erreurs += "Veuillez sélectionner un éditeur ! ";
|
|
|
330 |
} else {
|
|
|
331 |
editeur = comboListeEditeurs.getValue().getId();
|
|
|
332 |
if(editeur == null || editeur.equals("")) {
|
|
|
333 |
erreurs += "Veuillez sélectionner un éditeur ! ";
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
|
219 |
aurelien |
337 |
String datePar = datePub.getRawValue();
|
705 |
aurelien |
338 |
if(datePar == null || datePar.equals("")) {
|
|
|
339 |
erreurs += "Veuillez entrer une date ! ";
|
|
|
340 |
}
|
219 |
aurelien |
341 |
String tome = tomPub.getValue();
|
705 |
aurelien |
342 |
if(tome == null || tome.equals("")) {
|
|
|
343 |
erreurs += "Veuillez entrer un tome ! ";
|
|
|
344 |
}
|
219 |
aurelien |
345 |
String fascicule = fasciculePub.getValue();
|
705 |
aurelien |
346 |
if(fascicule == null || fascicule.equals("")) {
|
|
|
347 |
erreurs += "Veuillez entrer un fascicule ! ";
|
|
|
348 |
}
|
219 |
aurelien |
349 |
String pages = pagesPub.getValue();
|
705 |
aurelien |
350 |
if(pages == null || pages.equals("")) {
|
|
|
351 |
erreurs += "Veuillez entrer des pages ! ";
|
|
|
352 |
}
|
219 |
aurelien |
353 |
|
705 |
aurelien |
354 |
if(erreurs.length() > 0) {
|
|
|
355 |
MessageBox.alert("Erreur dans la saisie des champs", erreurs, null);
|
|
|
356 |
return;
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
formValide = true;
|
|
|
360 |
this.setEnabled(false);
|
|
|
361 |
mediateur.afficherPopinChargement();
|
|
|
362 |
|
219 |
aurelien |
363 |
if (mode.equals("AJOUT")) {
|
705 |
aurelien |
364 |
Publication publi = new Publication(pub,uri,auteur, idAuteur, collPub,nomArt,editeur,datePar,tome,fascicule,pages);
|
219 |
aurelien |
365 |
mediateur.ajouterPublication(this, publi);
|
|
|
366 |
} else if (mode.equals("MODIF")) {
|
705 |
aurelien |
367 |
Publication publi = new Publication(idPublication,idProjet,pub,uri,auteur,idAuteur, collPub,nomArt,editeur,datePar,tome,fascicule,pages);
|
219 |
aurelien |
368 |
mediateur.modifierPublication(this, publi);
|
|
|
369 |
}
|
|
|
370 |
}
|
227 |
aurelien |
371 |
|
|
|
372 |
private void genererChampsAuteur(String auteursStr, boolean ajouter) {
|
705 |
aurelien |
373 |
String[] auteurs = auteursStr.split("|");
|
|
|
374 |
conteneurChamps = new LayoutContainer();
|
227 |
aurelien |
375 |
|
505 |
jp_milcent |
376 |
if (auteurs.length != 0) {
|
239 |
aurelien |
377 |
listeAuteurs = new ArrayList<ComboBox<Personne>>(auteurs.length);
|
505 |
jp_milcent |
378 |
} else {
|
239 |
aurelien |
379 |
listeAuteurs = new ArrayList<ComboBox<Personne>>(1);
|
227 |
aurelien |
380 |
ajouter = true ;
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
fieldSetAuteurs.removeAll();
|
|
|
384 |
int i = 0;
|
|
|
385 |
|
505 |
jp_milcent |
386 |
for (i = 0; i < auteurs.length; i++) {
|
227 |
aurelien |
387 |
conteneurChamps.add(creerTextFieldEtBouton(auteurs[i]));
|
|
|
388 |
}
|
|
|
389 |
|
505 |
jp_milcent |
390 |
if (ajouter) {
|
227 |
aurelien |
391 |
conteneurChamps.add(creerTextFieldEtBouton(null));
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
Button ajoutAuteurBtn = new Button("Ajouter un auteur");
|
505 |
jp_milcent |
395 |
ajoutAuteurBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
227 |
aurelien |
396 |
|
|
|
397 |
@Override
|
505 |
jp_milcent |
398 |
public void componentSelected(ButtonEvent be) {
|
705 |
aurelien |
399 |
creerTextFieldEtBouton("");
|
|
|
400 |
int nbAuteurs = 1;
|
|
|
401 |
for(Iterator<ComboBox<Personne>> it = listeAuteurs.iterator(); it.hasNext();) {
|
|
|
402 |
if(listeAuteurs.size() > 1) {
|
|
|
403 |
it.next().setFieldLabel("Auteur "+nbAuteurs);
|
|
|
404 |
nbAuteurs++;
|
239 |
aurelien |
405 |
}
|
227 |
aurelien |
406 |
}
|
705 |
aurelien |
407 |
fieldSetAuteurs.layout(true);
|
227 |
aurelien |
408 |
}
|
|
|
409 |
|
|
|
410 |
});
|
|
|
411 |
|
|
|
412 |
fieldSetAuteurs.add(conteneurChamps);
|
|
|
413 |
fieldSetAuteurs.add(ajoutAuteurBtn);
|
705 |
aurelien |
414 |
fieldSetAuteurs.layout(true);
|
227 |
aurelien |
415 |
}
|
|
|
416 |
|
|
|
417 |
public HorizontalPanel creerTextFieldEtBouton(String valeurDefaut) {
|
705 |
aurelien |
418 |
final HorizontalPanel p = new HorizontalPanel();
|
227 |
aurelien |
419 |
|
|
|
420 |
// Création de la disposition : FIELDSET
|
|
|
421 |
FormLayout layoutPanelTF = new FormLayout();
|
|
|
422 |
p.setLayout(layoutPanelTF);
|
|
|
423 |
|
505 |
jp_milcent |
424 |
final ComboBox<Personne> tf = new ComboBox<Personne>();
|
239 |
aurelien |
425 |
tf.setDisplayField("fmt_nom_complet");
|
|
|
426 |
tf.setStore(storeAuteurs);
|
705 |
aurelien |
427 |
tf.setEmptyText("Selectionnez un auteur...");
|
|
|
428 |
String label = "Auteur ";
|
|
|
429 |
tf.setFieldLabel(label);
|
239 |
aurelien |
430 |
if(valeurDefaut != null && !valeurDefaut.equals("") ) {
|
705 |
aurelien |
431 |
Personne auteur = listePersonneAuteur.get(valeurDefaut);
|
239 |
aurelien |
432 |
tf.setValue(auteur);
|
227 |
aurelien |
433 |
}
|
|
|
434 |
listeAuteurs.add(tf);
|
|
|
435 |
|
705 |
aurelien |
436 |
tf.setSize(200, 20);
|
|
|
437 |
LayoutContainer lc = new LayoutContainer();
|
|
|
438 |
lc.setLayout(new FormLayout());
|
|
|
439 |
lc.add(tf);
|
|
|
440 |
|
227 |
aurelien |
441 |
Button supp = new Button("-");
|
505 |
jp_milcent |
442 |
supp.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
227 |
aurelien |
443 |
@Override
|
505 |
jp_milcent |
444 |
public void componentSelected(ButtonEvent be) {
|
705 |
aurelien |
445 |
int nbAuteurs = 1;
|
|
|
446 |
if(listeAuteurs.size() != 1) {
|
|
|
447 |
for(Iterator<ComboBox<Personne>> it = listeAuteurs.iterator(); it.hasNext();) {
|
|
|
448 |
it.next().setFieldLabel("Auteur "+nbAuteurs);
|
|
|
449 |
nbAuteurs++;
|
239 |
aurelien |
450 |
}
|
227 |
aurelien |
451 |
}
|
705 |
aurelien |
452 |
listeAuteurs.remove(tf);
|
|
|
453 |
conteneurChamps.remove(p);
|
|
|
454 |
fieldSetAuteurs.layout(true);
|
227 |
aurelien |
455 |
}
|
|
|
456 |
|
|
|
457 |
});
|
705 |
aurelien |
458 |
p.add(lc);
|
227 |
aurelien |
459 |
p.add(supp);
|
705 |
aurelien |
460 |
conteneurChamps.add(p);
|
|
|
461 |
fieldSetAuteurs.layout(true);
|
227 |
aurelien |
462 |
|
505 |
jp_milcent |
463 |
return p;
|
227 |
aurelien |
464 |
}
|
705 |
aurelien |
465 |
|
|
|
466 |
public void obtenirListeAuteurs() {
|
|
|
467 |
mediateur.clicObtenirListeAuteurs(this);
|
|
|
468 |
}
|
|
|
469 |
|
505 |
jp_milcent |
470 |
}
|