| Line 8... |
Line 8... |
| 8 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| Line 9... |
Line 9... |
| 9 |
|
9 |
|
| 10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 11 |
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
|
11 |
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
|
| - |
|
12 |
import org.tela_botanica.client.modeles.objets.Configuration;
|
| - |
|
13 |
import org.tela_botanica.client.modeles.objets.ListeChampsEtendus;
|
| Line 12... |
Line 14... |
| 12 |
import org.tela_botanica.client.modeles.objets.Configuration;
|
14 |
import org.tela_botanica.client.modeles.objets.ListeGroupesChampsEtendus;
|
| 13 |
|
15 |
|
| 14 |
import com.google.gwt.user.client.Timer;
|
16 |
import com.google.gwt.user.client.Timer;
|
| 15 |
import com.google.gwt.user.client.Window;
|
17 |
import com.google.gwt.user.client.Window;
|
| Line 25... |
Line 27... |
| 25 |
import com.gwtext.client.data.RecordDef;
|
27 |
import com.gwtext.client.data.RecordDef;
|
| 26 |
import com.gwtext.client.data.SimpleStore;
|
28 |
import com.gwtext.client.data.SimpleStore;
|
| 27 |
import com.gwtext.client.data.Store;
|
29 |
import com.gwtext.client.data.Store;
|
| 28 |
import com.gwtext.client.data.StringFieldDef;
|
30 |
import com.gwtext.client.data.StringFieldDef;
|
| 29 |
import com.gwtext.client.widgets.Button;
|
31 |
import com.gwtext.client.widgets.Button;
|
| - |
|
32 |
import com.gwtext.client.widgets.Panel;
|
| 30 |
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
|
33 |
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
|
| 31 |
import com.gwtext.client.widgets.form.ComboBox;
|
34 |
import com.gwtext.client.widgets.form.ComboBox;
|
| 32 |
import com.gwtext.client.widgets.form.Field;
|
35 |
import com.gwtext.client.widgets.form.Field;
|
| 33 |
import com.gwtext.client.widgets.form.FormPanel;
|
36 |
import com.gwtext.client.widgets.form.FormPanel;
|
| 34 |
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
|
37 |
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
|
| - |
|
38 |
import com.gwtext.client.widgets.layout.FormLayout;
|
| Line 35... |
Line 39... |
| 35 |
|
39 |
|
| 36 |
@SuppressWarnings("unchecked")
|
40 |
@SuppressWarnings("unchecked")
|
| Line 37... |
Line 41... |
| 37 |
public abstract class FormulaireSaisieChampEtendu extends FormPanel implements Rafraichissable {
|
41 |
public abstract class FormulaireSaisieChampEtendu extends FormPanel implements Rafraichissable {
|
| Line 58... |
Line 62... |
| 58 |
Button ajouterChampsEtenduEtFermer;
|
62 |
Button ajouterChampsEtenduEtFermer;
|
| 59 |
Button ajouterChampsEtendu;
|
63 |
Button ajouterChampsEtendu;
|
| 60 |
Button annulerAjouterChampEtendu;
|
64 |
Button annulerAjouterChampEtendu;
|
| 61 |
String idChamp = null;
|
65 |
String idChamp = null;
|
| Line -... |
Line 66... |
| - |
|
66 |
|
| 62 |
|
67 |
Panel conteneurGroupesChampsEtendus;
|
| - |
|
68 |
final ComboBox groupesChampsEtendus;
|
| - |
|
69 |
HTML indicationSaisieGroupe;
|
| - |
|
70 |
|
| Line 63... |
Line 71... |
| 63 |
final ComboBox groupesChampsEtendus;
|
71 |
private static ListeGroupesChampsEtendus cacheGroupes;
|
| Line 64... |
Line 72... |
| 64 |
|
72 |
|
| 65 |
private Timer timer = null;
|
73 |
private Timer timer = null;
|
| 66 |
|
74 |
|
| 67 |
private Map<String, String> cacheClesValeur;
|
75 |
private static Map<String, String> cacheClesValeur;
|
| Line 68... |
Line 76... |
| 68 |
private Record rdSelectionne = null;
|
76 |
private Record rdSelectionne = null;
|
| 69 |
private Record groupeSelectionne = null;
|
77 |
private Record groupeSelectionne = null;
|
| 70 |
private String valeurBrute = "";
|
78 |
private String valeurBrute = "";
|
| 71 |
|
79 |
|
| Line 72... |
Line 80... |
| 72 |
public FormulaireSaisieChampEtendu() {
|
80 |
public FormulaireSaisieChampEtendu() {
|
| 73 |
super();
|
81 |
super();
|
| 74 |
setPaddings(3);
|
82 |
setPaddings(3);
|
| 75 |
setBodyBorder(false);
|
83 |
setBodyBorder(false);
|
| Line 76... |
Line 84... |
| 76 |
|
84 |
|
| - |
|
85 |
indicationSaisieGroupe = new HTML("Vous pouvez ajouter plusieurs champs à la fois correspondant à un groupe "+
|
| 77 |
HTML indicationSaisieGroupe = new HTML("Vous pouvez ajouter plusieurs champs à la fois correspondant à un groupe "+
|
86 |
"par exemple les champs des projet 'sauvages de ma rue' ou 'florilèges', etc... <br />"+
|
| 78 |
"par exemple les champs du projet sauvage de ma rue ou florilèges, ou bien "+
|
- |
|
| 79 |
"les champs phytosociolgiques ");
|
87 |
"De nouveaux groupes seront ajoutés régulièrement en fonction des champs les plus utilisés");
|
| 80 |
indicationSaisieGroupe.addStyleName("aideCreerChampEtendu");
|
88 |
indicationSaisieGroupe.addStyleName("aideCreerChampEtendu");
|
| 81 |
|
89 |
|
| 82 |
groupesChampsEtendus = new ComboBox();
|
90 |
groupesChampsEtendus = new ComboBox();
|
| 83 |
groupesChampsEtendus.setLabel("Ajouter un groupe de champs");
|
91 |
groupesChampsEtendus.setWidth("350px");
|
| 84 |
groupesChampsEtendus.setStore(getGroupesChampsEtendusStore());
|
92 |
groupesChampsEtendus.setLabel("Ajouter un groupe de champs");
|
| 85 |
groupesChampsEtendus.setDisplayField("label") ;
|
93 |
groupesChampsEtendus.setDisplayField("label") ;
|
| Line -... |
Line 94... |
| - |
|
94 |
groupesChampsEtendus.setValueField("valeur");
|
| - |
|
95 |
groupesChampsEtendus.setEditable(false);
|
| 86 |
groupesChampsEtendus.setValueField("valeur");
|
96 |
groupesChampsEtendus.setHideTrigger(false);
|
| - |
|
97 |
groupesChampsEtendus.setForceSelection(true);
|
| - |
|
98 |
groupesChampsEtendus.setCls("champ-separation");
|
| - |
|
99 |
groupesChampsEtendus.setValue("");
|
| - |
|
100 |
|
| 87 |
groupesChampsEtendus.setEditable(false);
|
101 |
conteneurGroupesChampsEtendus = new Panel();
|
| - |
|
102 |
conteneurGroupesChampsEtendus.setBorder(false);
|
| - |
|
103 |
conteneurGroupesChampsEtendus.setPaddings(0);
|
| - |
|
104 |
conteneurGroupesChampsEtendus.setMargins(0);
|
| 88 |
groupesChampsEtendus.setHideTrigger(false);
|
105 |
conteneurGroupesChampsEtendus.setLayout(new FormLayout());
|
| - |
|
106 |
conteneurGroupesChampsEtendus.setWidth("100%");
|
| - |
|
107 |
|
| 89 |
groupesChampsEtendus.setForceSelection(true);
|
108 |
add(conteneurGroupesChampsEtendus);
|
| 90 |
groupesChampsEtendus.setCls("champ-separation");
|
109 |
|
| 91 |
groupesChampsEtendus.setValue("");
|
110 |
if(cacheGroupes == null) {
|
| 92 |
|
111 |
ListeReferentielChampsEtendusDAO lrceDao = new ListeReferentielChampsEtendusDAO(null);
|
| 93 |
if(groupesChampsEtendusSontDefinis()) {
|
112 |
lrceDao.obtenirGroupesChampsEtendus(this);
|
| 94 |
add(indicationSaisieGroupe);
|
113 |
} else {
|
| 95 |
add(groupesChampsEtendus);
|
114 |
this.rafraichir(cacheGroupes, false);
|
| Line 96... |
Line 115... |
| 96 |
}
|
115 |
}
|
| 97 |
|
116 |
|
| Line 124... |
Line 143... |
| 124 |
nChamp.setItemSelector("div.search-item-ref");
|
143 |
nChamp.setItemSelector("div.search-item-ref");
|
| 125 |
nChamp.setTypeAhead(false);
|
144 |
nChamp.setTypeAhead(false);
|
| 126 |
nChamp.setLoadingText("Recherche...");
|
145 |
nChamp.setLoadingText("Recherche...");
|
| 127 |
nChamp.setHideTrigger(true);
|
146 |
nChamp.setHideTrigger(true);
|
| 128 |
nChamp.setValidateOnBlur(false);
|
147 |
nChamp.setValidateOnBlur(false);
|
| 129 |
nChamp.setWidth("250px");
|
148 |
nChamp.setWidth("350px");
|
| 130 |
nChamp.focus();
|
149 |
nChamp.focus();
|
| Line 131... |
Line 150... |
| 131 |
|
150 |
|
| 132 |
ajouterListeners();
|
151 |
ajouterListeners();
|
| Line 273... |
Line 292... |
| 273 |
return retour;
|
292 |
return retour;
|
| 274 |
}
|
293 |
}
|
| Line 275... |
Line 294... |
| 275 |
|
294 |
|
| 276 |
private List<ChampSaisieEtendu> renvoyerListeChampsEtendus(String groupe) {
|
295 |
private List<ChampSaisieEtendu> renvoyerListeChampsEtendus(String groupe) {
|
| 277 |
List<ChampSaisieEtendu> champsDuGroupe = new ArrayList<ChampSaisieEtendu>();
|
296 |
List<ChampSaisieEtendu> champsDuGroupe = new ArrayList<ChampSaisieEtendu>();
|
| 278 |
HashMap<String, String> listeChampsEtendus = Configuration.getGroupesChampsEtendus().get(groupe);
|
297 |
HashMap<String, String> listeChampsEtendus = cacheGroupes.get(groupe);
|
| 279 |
for (Iterator<String> iterator = listeChampsEtendus.keySet().iterator(); iterator.hasNext();) {
|
298 |
for (Iterator<String> iterator = listeChampsEtendus.keySet().iterator(); iterator.hasNext();) {
|
| 280 |
String cle = iterator.next();
|
299 |
String cle = iterator.next();
|
| 281 |
String label = listeChampsEtendus.get(cle);
|
300 |
String label = listeChampsEtendus.get(cle);
|
| 282 |
ChampSaisieEtendu champ = new ChampSaisieEtendu(label, cle);
|
301 |
ChampSaisieEtendu champ = new ChampSaisieEtendu(label, cle);
|
| Line 313... |
Line 332... |
| 313 |
public abstract void surValidation(ChampSaisieEtendu champ);
|
332 |
public abstract void surValidation(ChampSaisieEtendu champ);
|
| 314 |
public abstract void surValidationMultiple(List<ChampSaisieEtendu> champs);
|
333 |
public abstract void surValidationMultiple(List<ChampSaisieEtendu> champs);
|
| 315 |
public abstract void surAnnulation();
|
334 |
public abstract void surAnnulation();
|
| Line 316... |
Line 335... |
| 316 |
|
335 |
|
| 317 |
public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
|
- |
|
| 318 |
int i = 0;
|
- |
|
| 319 |
|
- |
|
| 320 |
HashMap<String, String> clesLabels = (HashMap<String, String>)nouvelleDonnees;
|
- |
|
| 321 |
cacheClesValeur = clesLabels;
|
- |
|
| 322 |
Object[][] refData = new Object[clesLabels.keySet().size()][2];
|
- |
|
| 323 |
|
- |
|
| 324 |
for (Iterator<String> it = clesLabels.keySet().iterator(); it.hasNext();)
|
- |
|
| 325 |
{
|
- |
|
| 326 |
String cle = it.next();
|
- |
|
| 327 |
String label= clesLabels.get(cle);
|
- |
|
| 328 |
refData[i][0]= cle;
|
- |
|
| 329 |
refData[i][1]= label;
|
- |
|
| 330 |
i++;
|
- |
|
| 331 |
}
|
- |
|
| 332 |
|
- |
|
| 333 |
FieldDef defCle = new StringFieldDef("cle");
|
- |
|
| 334 |
FieldDef defLabel = new StringFieldDef("label");
|
- |
|
| 335 |
FieldDef[] defTab = {defCle, defLabel};
|
- |
|
| 336 |
|
- |
|
| Line -... |
Line 336... |
| - |
|
336 |
public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
|
| - |
|
337 |
|
| - |
|
338 |
if(nouvelleDonnees instanceof ListeChampsEtendus) {
|
| - |
|
339 |
int i = 0;
|
| - |
|
340 |
|
| - |
|
341 |
ListeChampsEtendus clesLabels = (ListeChampsEtendus)nouvelleDonnees;
|
| - |
|
342 |
cacheClesValeur = clesLabels;
|
| - |
|
343 |
Object[][] refData = new Object[clesLabels.keySet().size()][2];
|
| - |
|
344 |
|
| - |
|
345 |
for (Iterator<String> it = clesLabels.keySet().iterator(); it.hasNext();)
|
| - |
|
346 |
{
|
| - |
|
347 |
String cle = it.next();
|
| - |
|
348 |
String label= clesLabels.get(cle);
|
| - |
|
349 |
refData[i][0]= cle;
|
| - |
|
350 |
refData[i][1]= label;
|
| - |
|
351 |
i++;
|
| - |
|
352 |
}
|
| - |
|
353 |
|
| - |
|
354 |
FieldDef defCle = new StringFieldDef("cle");
|
| - |
|
355 |
FieldDef defLabel = new StringFieldDef("label");
|
| - |
|
356 |
FieldDef[] defTab = {defCle, defLabel};
|
| - |
|
357 |
|
| 337 |
RecordDef rd = new RecordDef(defTab);
|
358 |
RecordDef rd = new RecordDef(defTab);
|
| 338 |
|
359 |
|
| 339 |
final MemoryProxy dataProxy = new MemoryProxy(refData);
|
360 |
final MemoryProxy dataProxy = new MemoryProxy(refData);
|
| 340 |
final ArrayReader reader = new ArrayReader(rd);
|
361 |
final ArrayReader reader = new ArrayReader(rd);
|
| - |
|
362 |
|
| - |
|
363 |
Store store=new Store(dataProxy,reader);
|
| - |
|
364 |
|
| - |
|
365 |
nChamp.setStore(store);
|
| Line -... |
Line 366... |
| - |
|
366 |
store.load();
|
| - |
|
367 |
}
|
| - |
|
368 |
|
| 341 |
|
369 |
if(nouvelleDonnees instanceof ListeGroupesChampsEtendus) {
|
| - |
|
370 |
cacheGroupes = (ListeGroupesChampsEtendus)nouvelleDonnees;
|
| - |
|
371 |
groupesChampsEtendus.setStore(getGroupesChampsEtendusStore(cacheGroupes));
|
| 342 |
Store store=new Store(dataProxy,reader);
|
372 |
if(cacheGroupes.size() > 0) {
|
| 343 |
|
373 |
conteneurGroupesChampsEtendus.add(indicationSaisieGroupe);
|
| 344 |
nChamp.setStore(store);
|
374 |
conteneurGroupesChampsEtendus.add(groupesChampsEtendus);
|
| 345 |
store.load();
|
- |
|
| 346 |
}
|
- |
|
| 347 |
|
375 |
doLayout();
|
| Line 348... |
Line 376... |
| 348 |
private boolean groupesChampsEtendusSontDefinis() {
|
376 |
}
|
| 349 |
return Configuration.getGroupesChampsEtendus().size() > 0;
|
377 |
}
|
| 350 |
}
|
- |
|
| 351 |
|
- |
|
| 352 |
private Store getGroupesChampsEtendusStore() {
|
378 |
}
|
| Line 353... |
Line 379... |
| 353 |
int i = 1;
|
379 |
|
| 354 |
|
380 |
private Store getGroupesChampsEtendusStore(ListeGroupesChampsEtendus listeGroupesChampsEtendus) {
|
| 355 |
Map<String, HashMap<String, String>> listeGroupesChampsEtendus = Configuration.getGroupesChampsEtendus();
|
381 |
int i = 1;
|