Subversion Repositories eFlore/Applications.cel

Rev

Rev 1968 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1968 Rev 1971
1
package org.tela_botanica.client.util;
1
package org.tela_botanica.client.util;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Date;
4
import java.util.Date;
5
import java.util.HashMap;
5
import java.util.HashMap;
6
import java.util.Iterator;
6
import java.util.Iterator;
7
import java.util.List;
7
import java.util.List;
8
import java.util.Map;
8
import java.util.Map;
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;
12
import org.tela_botanica.client.modeles.objets.Configuration;
13
 
13
 
14
import com.google.gwt.user.client.Timer;
14
import com.google.gwt.user.client.Timer;
15
import com.google.gwt.user.client.Window;
15
import com.google.gwt.user.client.Window;
16
import com.google.gwt.user.client.ui.HTML;
16
import com.google.gwt.user.client.ui.HTML;
17
import com.google.gwt.user.client.ui.HorizontalPanel;
17
import com.google.gwt.user.client.ui.HorizontalPanel;
18
import com.gwtext.client.core.EventCallback;
18
import com.gwtext.client.core.EventCallback;
19
import com.gwtext.client.core.EventObject;
19
import com.gwtext.client.core.EventObject;
20
import com.gwtext.client.core.ListenerConfig;
20
import com.gwtext.client.core.ListenerConfig;
21
import com.gwtext.client.data.ArrayReader;
21
import com.gwtext.client.data.ArrayReader;
22
import com.gwtext.client.data.FieldDef;
22
import com.gwtext.client.data.FieldDef;
23
import com.gwtext.client.data.MemoryProxy;
23
import com.gwtext.client.data.MemoryProxy;
24
import com.gwtext.client.data.Record;
24
import com.gwtext.client.data.Record;
25
import com.gwtext.client.data.RecordDef;
25
import com.gwtext.client.data.RecordDef;
26
import com.gwtext.client.data.SimpleStore;
26
import com.gwtext.client.data.SimpleStore;
27
import com.gwtext.client.data.Store;
27
import com.gwtext.client.data.Store;
28
import com.gwtext.client.data.StringFieldDef;
28
import com.gwtext.client.data.StringFieldDef;
29
import com.gwtext.client.widgets.Button;
29
import com.gwtext.client.widgets.Button;
30
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
30
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
31
import com.gwtext.client.widgets.form.ComboBox;
31
import com.gwtext.client.widgets.form.ComboBox;
32
import com.gwtext.client.widgets.form.Field;
32
import com.gwtext.client.widgets.form.Field;
33
import com.gwtext.client.widgets.form.FormPanel;
33
import com.gwtext.client.widgets.form.FormPanel;
34
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
34
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
35
 
35
 
36
@SuppressWarnings("unchecked")
36
@SuppressWarnings("unchecked")
37
public abstract class FormulaireSaisieChampEtendu extends FormPanel implements Rafraichissable {
37
public abstract class FormulaireSaisieChampEtendu extends FormPanel implements Rafraichissable {
38
	
38
	
39
	private final int KEY_ALT = 18;
39
	private final int KEY_ALT = 18;
40
	private final int KEY_BACKSPACE = 8;
40
	private final int KEY_BACKSPACE = 8;
41
	private final int KEY_CTRL = 17;
41
	private final int KEY_CTRL = 17;
42
	private final int KEY_DELETE = 46;
42
	private final int KEY_DELETE = 46;
43
	private final int KEY_DOWN = 40;
43
	private final int KEY_DOWN = 40;
44
	private final int KEY_END = 35;
44
	private final int KEY_END = 35;
45
	private final int KEY_ENTER = 13;
45
	private final int KEY_ENTER = 13;
46
	private final int KEY_ESCAPE = 27;
46
	private final int KEY_ESCAPE = 27;
47
	private final int KEY_HOME = 36;
47
	private final int KEY_HOME = 36;
48
	private final int KEY_LEFT = 37;
48
	private final int KEY_LEFT = 37;
49
	private final int KEY_PAGEDOWN = 34;
49
	private final int KEY_PAGEDOWN = 34;
50
	private final int KEY_PAGEUP = 33;
50
	private final int KEY_PAGEUP = 33;
51
	private final int KEY_RIGHT = 39;
51
	private final int KEY_RIGHT = 39;
52
	private final int KEY_SHIFT = 16;
52
	private final int KEY_SHIFT = 16;
53
	private final int KEY_TAB = 9;
53
	private final int KEY_TAB = 9;
54
	private final int KEY_UP = 38;
54
	private final int KEY_UP = 38;
55
	
55
	
56
	final ComboBox nChamp;
56
	final ComboBox nChamp;
57
	final String resultTplRefPerso = "<div class=\"search-item-ref\">{label}</div>"; 
57
	final String resultTplRefPerso = "<div class=\"search-item-ref\">{label}</div>"; 
58
	Button ajouterChampsEtenduEtFermer;
58
	Button ajouterChampsEtenduEtFermer;
59
	Button ajouterChampsEtendu;
59
	Button ajouterChampsEtendu;
60
	Button annulerAjouterChampEtendu;
60
	Button annulerAjouterChampEtendu;
61
	String idChamp = null;
61
	String idChamp = null;
62
	
62
	
63
	final ComboBox groupesChampsEtendus;
63
	final ComboBox groupesChampsEtendus;
64
	
64
	
65
	private Timer timer = null;
65
	private Timer timer = null;
66
	
66
	
67
	private Map<String, String> cacheClesValeur;
67
	private Map<String, String> cacheClesValeur;
68
	private Record rdSelectionne = null;
68
	private Record rdSelectionne = null;
69
    private Record groupeSelectionne = null;
69
    private Record groupeSelectionne = null;
70
	private String valeurBrute = "";
70
	private String valeurBrute = "";
71
	
71
	
72
	public FormulaireSaisieChampEtendu() {	
72
	public FormulaireSaisieChampEtendu() {	
73
		super();
73
		super();
74
		setPaddings(3);
74
		setPaddings(3);
75
		setBodyBorder(false);
75
		setBodyBorder(false);
76
		
76
		
77
		HTML 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 "+
78
				"par exemple les champs du projet sauvage de ma rue ou florilèges, ou bien "+
78
				"par exemple les champs du projet sauvage de ma rue ou florilèges, ou bien "+
79
				"les champs phytosociolgiques ");
79
				"les champs phytosociolgiques ");
80
		indicationSaisieGroupe.addStyleName("aideCreerChampEtendu");
80
		indicationSaisieGroupe.addStyleName("aideCreerChampEtendu");
81
		
81
		
82
		groupesChampsEtendus = new ComboBox();
82
		groupesChampsEtendus = new ComboBox();
83
		groupesChampsEtendus.setLabel("Ajouter un groupe de champs");
83
		groupesChampsEtendus.setLabel("Ajouter un groupe de champs");
84
		groupesChampsEtendus.setStore(getGroupesChampsEtendusStore());
84
		groupesChampsEtendus.setStore(getGroupesChampsEtendusStore());
85
		groupesChampsEtendus.setDisplayField("label") ;
85
		groupesChampsEtendus.setDisplayField("label") ;
86
		groupesChampsEtendus.setValueField("valeur");
86
		groupesChampsEtendus.setValueField("valeur");
87
		groupesChampsEtendus.setEditable(false);
87
		groupesChampsEtendus.setEditable(false);
88
		groupesChampsEtendus.setHideTrigger(false);
88
		groupesChampsEtendus.setHideTrigger(false);
89
		groupesChampsEtendus.setForceSelection(true);
89
		groupesChampsEtendus.setForceSelection(true);
90
		groupesChampsEtendus.setCls("champ-separation");
90
		groupesChampsEtendus.setCls("champ-separation");
91
		groupesChampsEtendus.setValue("");
91
		groupesChampsEtendus.setValue("");
92
		
92
		
93
		if(groupesChampsEtendusSontDefinis()) {
93
		if(groupesChampsEtendusSontDefinis()) {
94
			add(indicationSaisieGroupe);
94
			add(indicationSaisieGroupe);
95
			add(groupesChampsEtendus);
95
			add(groupesChampsEtendus);
96
		}
96
		}
97
		
97
		
98
		HTML indicationSaisie = new HTML("Saisissez un nom de champ ou choisisez un nom proposé par l'autocomplétion "+
98
		HTML indicationSaisie = new HTML("Saisissez un nom de champ ou choisisez un nom proposé par l'autocomplétion "+
99
				"Si vous choissisez un nom de champ existant vous pourrez profiter d'une autocomplétion "+
99
				"Si vous choissisez un nom de champ existant vous pourrez profiter d'une autocomplétion "+
100
				"sur les valeur déjà saisies pour ce champ par les autres utilisateurs");
100
				"sur les valeur déjà saisies pour ce champ par les autres utilisateurs");
101
		indicationSaisie.addStyleName("aideCreerChampEtendu");
101
		indicationSaisie.addStyleName("aideCreerChampEtendu");
102
		add(indicationSaisie);
102
		add(indicationSaisie);
103
		
103
		
104
		HorizontalPanel hp = new HorizontalPanel();
104
		HorizontalPanel hp = new HorizontalPanel();
105
		hp.setBorderWidth(0);
105
		hp.setBorderWidth(0);
106
				
106
				
107
		nChamp = new ComboBox("Nom du champ", "nom_champ_etendu");
107
		nChamp = new ComboBox("Nom du champ", "nom_champ_etendu");
108
		add(nChamp);
108
		add(nChamp);
109
		
109
		
110
		ajouterChampsEtenduEtFermer = new Button("Ajouter et fermer");
110
		ajouterChampsEtenduEtFermer = new Button("Ajouter et fermer");
111
		ajouterChampsEtenduEtFermer.setTooltip("Ajouter un champ étendu ou un groupe de champs et fermer la fenêtre");
111
		ajouterChampsEtenduEtFermer.setTooltip("Ajouter un champ étendu ou un groupe de champs et fermer la fenêtre");
112
		ajouterChampsEtendu = new Button("Ajouter");
112
		ajouterChampsEtendu = new Button("Ajouter");
113
		ajouterChampsEtendu.setTooltip("Ajouter un champ étendu ou un groupe de champ");
113
		ajouterChampsEtendu.setTooltip("Ajouter un champ étendu ou un groupe de champ");
114
		annulerAjouterChampEtendu = new Button("Annuler");
114
		annulerAjouterChampEtendu = new Button("Annuler");
115
		annulerAjouterChampEtendu.setTooltip("Fermer la fenêtre sans ajouter de champ");
115
		annulerAjouterChampEtendu.setTooltip("Fermer la fenêtre sans ajouter de champ");
116
		
116
		
117
		hp.add(ajouterChampsEtenduEtFermer);
117
		hp.add(ajouterChampsEtenduEtFermer);
118
		hp.add(ajouterChampsEtendu);
118
		hp.add(ajouterChampsEtendu);
119
		hp.add(annulerAjouterChampEtendu);	
119
		hp.add(annulerAjouterChampEtendu);	
120
		add(hp);
120
		add(hp);
121
		
121
				
122
		nChamp.setMode(ComboBox.REMOTE);
-
 
123
		nChamp.setTpl(resultTplRefPerso);
122
		nChamp.setTpl(resultTplRefPerso);
-
 
123
		nChamp.setMode(ComboBox.REMOTE);
124
		nChamp.setItemSelector("div.search-item-ref");
124
		nChamp.setItemSelector("div.search-item-ref");
125
		nChamp.setTypeAhead(false);  
125
		nChamp.setTypeAhead(false);  
126
		nChamp.setLoadingText("Recherche...");  
126
		nChamp.setLoadingText("Recherche...");  
127
		nChamp.setHideTrigger(true);
127
		nChamp.setHideTrigger(true);
-
 
128
		nChamp.setValidateOnBlur(false);
128
		nChamp.setWidth("250px");	
129
		nChamp.setWidth("250px");	
129
		nChamp.setValue("");
-
 
130
		nChamp.focus();
130
		nChamp.focus();
131
		
131
		
132
		ajouterListeners();
132
		ajouterListeners();
133
	}
133
	}
134
 
134
 
135
	private void ajouterListeners() {
135
	private void ajouterListeners() {
136
		ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
136
		ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
137
	    listenerConfigAutocompletion.setDelay(200);
137
	    listenerConfigAutocompletion.setDelay(200);
138
	    listenerConfigAutocompletion.setStopPropagation(false);
138
	    listenerConfigAutocompletion.setStopPropagation(false);
139
	    listenerConfigAutocompletion.setStopEvent(true);
139
	    listenerConfigAutocompletion.setStopEvent(true);
140
		
140
		
141
	    nChamp.addKeyPressListener(new EventCallback() {
141
	    nChamp.addKeyPressListener(new EventCallback() {
142
 
142
 
143
			@Override
143
			@Override
144
			public void execute(EventObject e) {
144
			public void execute(EventObject e) {
145
 
145
 
146
				switch(e.getKey()) {
146
				switch(e.getKey()) {
147
		    	      
147
		    	      
148
					case KEY_ALT:
148
					case KEY_ALT:
149
		    	      case KEY_CTRL:
149
		    	      case KEY_CTRL:
150
		    	      case KEY_END:
150
		    	      case KEY_END:
151
		    	      case KEY_HOME:
151
		    	      case KEY_HOME:
152
		    	      case KEY_LEFT:
152
		    	      case KEY_LEFT:
153
		    	      case KEY_PAGEDOWN:
153
		    	      case KEY_PAGEDOWN:
154
		    	      case KEY_PAGEUP:
154
		    	      case KEY_PAGEUP:
155
		    	      case KEY_RIGHT:
155
		    	      case KEY_RIGHT:
156
		    	      case KEY_SHIFT:
156
		    	      case KEY_SHIFT:
157
		    	      case KEY_TAB:
157
		    	      case KEY_TAB:
158
		    	      case KEY_UP:
158
		    	      case KEY_UP:
159
	    	        break;
159
	    	        break;
160
	    	        
160
	    	        
161
		    	  case KEY_ENTER:
161
		    	  case KEY_ENTER:
162
  	    	    	  if(rdSelectionne != null) {
162
  	    	    	  if(rdSelectionne != null) {
163
  	    	    		  nChamp.setValue(rdSelectionne.getAsString("label"));
163
  	    	    		  nChamp.setValue(rdSelectionne.getAsString("label"));
164
  	    	    		  idChamp = rdSelectionne.getAsString("cle");
164
  	    	    		  idChamp = rdSelectionne.getAsString("cle");
165
  	    	    		  valeurBrute = rdSelectionne.getAsString("label");
165
  	    	    		  valeurBrute = rdSelectionne.getAsString("label");
166
  	    	    	  }
166
  	    	    	  }
167
	              break;
167
	              break;
168
	    	        
168
	    	        
169
		    	    case KEY_DOWN:
169
		    	    case KEY_DOWN:
170
  	    	    	  if(nChamp.getValueAsString().isEmpty() && !nChamp.isExpanded()) {
170
  	    	    	  if(nChamp.getValueAsString().isEmpty() && !nChamp.isExpanded()) {
171
  	    	    		obtenirListeValeurs("*");
171
  	    	    		obtenirListeValeurs("*");
172
  	    	    	  }
172
  	    	    	  }
173
  	    	    	break;
173
  	    	    	break;
174
	    	        
174
	    	        
175
		    	    case KEY_ESCAPE:
175
		    	    case KEY_ESCAPE:
176
		    	    	surAnnulation();
176
		    	    	surAnnulation();
177
		    	    break;
177
		    	    break;
178
		    	    
178
		    	    
179
		    	    default:
179
		    	    default:
180
		    	    	if(timer != null) {
180
		    	    	if(timer != null) {
181
		    	    		timer.cancel();
181
		    	    		timer.cancel();
182
		    	    	}
182
		    	    	}
183
		    	    	timer = new Timer() {
183
		    	    	timer = new Timer() {
184
							
184
							
185
							@Override
185
							@Override
186
							public void run() {
186
							public void run() {
187
			  	    	      	obtenirListeValeurs();
187
			  	    	      	obtenirListeValeurs();
188
							}
188
							}
189
						};
189
						};
190
						timer.schedule(300);
190
						timer.schedule(300);
191
						valeurBrute = nChamp.getValueAsString();
191
						valeurBrute = nChamp.getValueAsString();
192
						nChamp.setValue(valeurBrute);
192
						nChamp.setValue(valeurBrute);
193
				}
193
				}
194
			}
194
			}
195
	    },listenerConfigAutocompletion);
195
	    },listenerConfigAutocompletion);
196
		
196
		
197
		// Listener completion 
197
		// Listener completion 
198
	    nChamp.addListener(new ComboBoxListenerAdapter() {  
198
	    nChamp.addListener(new ComboBoxListenerAdapter() {  
199
            @Override
199
            @Override
200
			public void onSelect(ComboBox comboBox, Record record, int index) {  
200
			public void onSelect(ComboBox comboBox, Record record, int index) {  
201
            	rdSelectionne = record;
201
            	rdSelectionne = record;
202
            }
202
            }
203
            
203
            
204
            @Override
204
            @Override
205
			public void onBlur(Field field) {  
205
			public void onBlur(Field field) {  
206
            	nChamp.setRawValue(valeurBrute);
206
            	nChamp.setRawValue(valeurBrute);
207
            	nChamp.collapse();
207
            	nChamp.collapse();
208
            }
208
            }
209
	     });
209
	     });
210
	    
210
	    
211
	    groupesChampsEtendus.addListener(new ComboBoxListenerAdapter() {  
211
	    groupesChampsEtendus.addListener(new ComboBoxListenerAdapter() {  
212
			@Override
212
			@Override
213
			public void onSelect(ComboBox comboBox, Record record, int index) {  
213
			public void onSelect(ComboBox comboBox, Record record, int index) {  
214
            	groupeSelectionne = record;
214
            	groupeSelectionne = record;
215
            }
215
            }
216
	     });
216
	     });
217
	    
217
	    
218
	    ajouterChampsEtenduEtFermer.addListener(new ButtonListenerAdapter() {			
218
	    ajouterChampsEtenduEtFermer.addListener(new ButtonListenerAdapter() {			
219
			@Override
219
			@Override
220
			public void onClick(Button button, EventObject e) {
220
			public void onClick(Button button, EventObject e) {
221
				if(doitAjouterGroupe()) {
221
				if(doitAjouterGroupe()) {
222
					surValidationMultiple(renvoyerListeChampsEtendus(groupeSelectionne.getAsString("valeur")));
222
					surValidationMultiple(renvoyerListeChampsEtendus(groupeSelectionne.getAsString("valeur")));
223
				} else {
223
				} else {
224
					if(champEtenduEstValide()) {
224
					if(champEtenduEstValide()) {
225
						surValidation(validerEtRenvoyerChampEtendu());
225
						surValidation(validerEtRenvoyerChampEtendu());
226
					} else {
226
					} else {
227
						Window.alert("Le nom du champ étendu ne peut pas être vide");
227
						Window.alert("Le nom du champ étendu ne peut pas être vide");
228
					}
228
					}
229
				}
229
				}
230
			}
230
			}
231
		});
231
		});
232
	    
232
	    
233
	    ajouterChampsEtendu.addListener(new ButtonListenerAdapter() {			
233
	    ajouterChampsEtendu.addListener(new ButtonListenerAdapter() {			
234
			@Override
234
			@Override
235
			public void onClick(Button button, EventObject e) {
235
			public void onClick(Button button, EventObject e) {
236
				if(champEtenduEstValide()) {
236
				if(champEtenduEstValide()) {
237
					surAjout(validerEtRenvoyerChampEtendu());
237
					surAjout(validerEtRenvoyerChampEtendu());
238
					raz();
238
					raz();
239
				} else {
239
				} else {
240
					Window.alert("Le nom du champ étendu ne peut pas être vide");
240
					Window.alert("Le nom du champ étendu ne peut pas être vide");
241
				}
241
				}
242
			}
242
			}
243
		});
243
		});
244
	    
244
	    
245
	    annulerAjouterChampEtendu.addListener(new ButtonListenerAdapter() {			
245
	    annulerAjouterChampEtendu.addListener(new ButtonListenerAdapter() {			
246
			@Override
246
			@Override
247
			public void onClick(Button button, EventObject e) {
247
			public void onClick(Button button, EventObject e) {
248
				surAnnulation();
248
				surAnnulation();
249
			}
249
			}
250
		});
250
		});
251
	}
251
	}
252
	
252
	
253
	private void raz() {
253
	private void raz() {
254
		timer = null;
254
		timer = null;
255
		idChamp = null;
255
		idChamp = null;
256
		nChamp.clearValue();
256
		nChamp.clearValue();
257
		nChamp.focus();
257
		nChamp.focus();
258
	}
258
	}
259
	
259
	
260
	private ChampSaisieEtendu validerEtRenvoyerChampEtendu() {		
260
	private ChampSaisieEtendu validerEtRenvoyerChampEtendu() {		
261
		String valeurChamp = nChamp.getValueAsString();
261
		String valeurChamp = nChamp.getValueAsString();
262
		String idNouveauChamp = "";
262
		String idNouveauChamp = "";
263
		if(!estUnChampSelectionne(valeurChamp)) {
263
		if(!estUnChampSelectionne(valeurChamp)) {
264
			Date date = new Date();
264
			Date date = new Date();
265
			// affectation d'un id temporaire qui sera remplacé par l'id auto généré à partir
265
			// affectation d'un id temporaire qui sera remplacé par l'id auto généré à partir
266
			// du label
266
			// du label
267
			idNouveauChamp = "tempid_"+date.getTime();
267
			idNouveauChamp = "tempid_"+date.getTime();
268
		} else {
268
		} else {
269
			idNouveauChamp = idChamp; 
269
			idNouveauChamp = idChamp; 
270
		}
270
		}
271
		ChampSaisieEtendu retour = new ChampSaisieEtendu(valeurChamp, idNouveauChamp);
271
		ChampSaisieEtendu retour = new ChampSaisieEtendu(valeurChamp, idNouveauChamp);
272
		retour.setId(idNouveauChamp);
272
		retour.setId(idNouveauChamp);
273
		return retour;
273
		return retour;
274
	}
274
	}
275
	
275
	
276
	private List<ChampSaisieEtendu> renvoyerListeChampsEtendus(String groupe) {	
276
	private List<ChampSaisieEtendu> renvoyerListeChampsEtendus(String groupe) {	
277
		List<ChampSaisieEtendu> champsDuGroupe = new ArrayList<ChampSaisieEtendu>();
277
		List<ChampSaisieEtendu> champsDuGroupe = new ArrayList<ChampSaisieEtendu>();
278
		HashMap<String, String> listeChampsEtendus = Configuration.getGroupesChampsEtendus().get(groupe);
278
		HashMap<String, String> listeChampsEtendus = Configuration.getGroupesChampsEtendus().get(groupe);
279
		for (Iterator<String> iterator = listeChampsEtendus.keySet().iterator(); iterator.hasNext();) {
279
		for (Iterator<String> iterator = listeChampsEtendus.keySet().iterator(); iterator.hasNext();) {
280
			String cle = iterator.next();
280
			String cle = iterator.next();
281
			String label = listeChampsEtendus.get(cle);
281
			String label = listeChampsEtendus.get(cle);
282
			ChampSaisieEtendu champ = new ChampSaisieEtendu(label, cle);
282
			ChampSaisieEtendu champ = new ChampSaisieEtendu(label, cle);
283
			champsDuGroupe.add(champ);
283
			champsDuGroupe.add(champ);
284
		}
284
		}
285
 
285
 
286
		return champsDuGroupe;
286
		return champsDuGroupe;
287
	}
287
	}
288
	
288
	
289
	private boolean doitAjouterGroupe() {
289
	private boolean doitAjouterGroupe() {
290
		return groupeSelectionne != null && !groupeSelectionne.getAsString("valeur").equals("");
290
		return groupeSelectionne != null && !groupeSelectionne.getAsString("valeur").equals("");
291
	}
291
	}
292
	
292
	
293
	private boolean champEtenduEstValide() {
293
	private boolean champEtenduEstValide() {
294
		String valeurChamp = nChamp.getValueAsString();
294
		String valeurChamp = nChamp.getValueAsString();
295
		return (valeurChamp != null && !valeurChamp.isEmpty());
295
		return (valeurChamp != null && !valeurChamp.isEmpty());
296
	}
296
	}
297
	
297
	
298
	private boolean estUnChampSelectionne(String valeur) {
298
	private boolean estUnChampSelectionne(String valeur) {
299
		return cacheClesValeur.containsValue(valeur);
299
		return cacheClesValeur.containsValue(valeur);
300
	}
300
	}
301
	
301
	
302
	private void obtenirListeValeurs() {
302
	private void obtenirListeValeurs() {
303
		obtenirListeValeurs(nChamp.getValueAsString());
303
		obtenirListeValeurs(nChamp.getValueAsString());
304
	}
304
	}
305
	
305
	
306
	private void obtenirListeValeurs(String valeur) {
306
	private void obtenirListeValeurs(String valeur) {
307
		ListeReferentielChampsEtendusDAO lrce = new ListeReferentielChampsEtendusDAO(null);
307
		ListeReferentielChampsEtendusDAO lrce = new ListeReferentielChampsEtendusDAO(null);
308
		lrce.obtenirListeNomsChampsEtendus(this, valeur+"*");
308
		lrce.obtenirListeNomsChampsEtendus(this, valeur+"*");
309
	}
309
	}
310
	
310
	
311
	public abstract void surAjout(ChampSaisieEtendu champ);
311
	public abstract void surAjout(ChampSaisieEtendu champ);
312
	public abstract void surAjoutMultiple(List<ChampSaisieEtendu> champs);
312
	public abstract void surAjoutMultiple(List<ChampSaisieEtendu> champs);
313
	public abstract void surValidation(ChampSaisieEtendu champ);
313
	public abstract void surValidation(ChampSaisieEtendu champ);
314
	public abstract void surValidationMultiple(List<ChampSaisieEtendu> champs);
314
	public abstract void surValidationMultiple(List<ChampSaisieEtendu> champs);
315
	public abstract void surAnnulation();
315
	public abstract void surAnnulation();
316
	
316
	
317
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {	
317
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {	
318
		int i = 0;
318
		int i = 0;
319
				
319
				
320
		HashMap<String, String> clesLabels = (HashMap<String, String>)nouvelleDonnees;		
320
		HashMap<String, String> clesLabels = (HashMap<String, String>)nouvelleDonnees;		
321
		cacheClesValeur = clesLabels;
321
		cacheClesValeur = clesLabels;
322
		Object[][] refData = new Object[clesLabels.keySet().size()][2];
322
		Object[][] refData = new Object[clesLabels.keySet().size()][2];
323
		
323
		
324
		for (Iterator<String> it = clesLabels.keySet().iterator(); it.hasNext();) 
324
		for (Iterator<String> it = clesLabels.keySet().iterator(); it.hasNext();) 
325
		{
325
		{
326
			String cle = it.next();
326
			String cle = it.next();
327
			String label= clesLabels.get(cle);
327
			String label= clesLabels.get(cle);
328
			refData[i][0]= cle;
328
			refData[i][0]= cle;
329
			refData[i][1]= label;
329
			refData[i][1]= label;
330
			i++;
330
			i++;
331
		}
331
		}
332
		
332
		
333
		FieldDef defCle = new StringFieldDef("cle");
333
		FieldDef defCle = new StringFieldDef("cle");
334
		FieldDef defLabel = new StringFieldDef("label");
334
		FieldDef defLabel = new StringFieldDef("label");
335
		FieldDef[] defTab = {defCle, defLabel};
335
		FieldDef[] defTab = {defCle, defLabel};
336
		
336
		
337
		RecordDef rd = new RecordDef(defTab);
337
		RecordDef rd = new RecordDef(defTab);
338
		
338
		
339
		final MemoryProxy dataProxy = new MemoryProxy(refData);
339
		final MemoryProxy dataProxy = new MemoryProxy(refData);
340
		final ArrayReader reader = new ArrayReader(rd);		
340
		final ArrayReader reader = new ArrayReader(rd);		
341
						
341
						
342
		Store store=new Store(dataProxy,reader);
342
		Store store=new Store(dataProxy,reader);
343
		
343
		
344
		nChamp.setStore(store);
344
		nChamp.setStore(store);
345
		store.load();
345
		store.load();
346
	}
346
	}
347
	
347
	
348
	private boolean groupesChampsEtendusSontDefinis() {
348
	private boolean groupesChampsEtendusSontDefinis() {
349
		return Configuration.getGroupesChampsEtendus().size() > 0;
349
		return Configuration.getGroupesChampsEtendus().size() > 0;
350
	}
350
	}
351
	
351
	
352
	private Store getGroupesChampsEtendusStore() {
352
	private Store getGroupesChampsEtendusStore() {
353
		int i = 1;
353
		int i = 1;
354
				
354
				
355
		Map<String, HashMap<String, String>> listeGroupesChampsEtendus = Configuration.getGroupesChampsEtendus();		
355
		Map<String, HashMap<String, String>> listeGroupesChampsEtendus = Configuration.getGroupesChampsEtendus();		
356
		Object[][] valeurs = new Object[listeGroupesChampsEtendus.size()+1][2];
356
		Object[][] valeurs = new Object[listeGroupesChampsEtendus.size()+1][2];
357
		
357
		
358
		valeurs[0][0] = "...";
358
		valeurs[0][0] = "...";
359
		valeurs[0][1] = "";
359
		valeurs[0][1] = "";
360
		if(listeGroupesChampsEtendus.size() > 0) {
360
		if(listeGroupesChampsEtendus.size() > 0) {
361
			for (Iterator<String> it = listeGroupesChampsEtendus.keySet().iterator(); it.hasNext();) 
361
			for (Iterator<String> it = listeGroupesChampsEtendus.keySet().iterator(); it.hasNext();) 
362
			{
362
			{
363
				String cle = it.next();
363
				String cle = it.next();
364
				valeurs[i][0]= cle;
364
				valeurs[i][0]= cle;
365
				valeurs[i][1]= cle;
365
				valeurs[i][1]= cle;
366
				i++;
366
				i++;
367
			}
367
			}
368
		}					
368
		}					
369
		SimpleStore store = new SimpleStore(new String[] {"label","valeur"},valeurs);
369
		SimpleStore store = new SimpleStore(new String[] {"label","valeur"},valeurs);
370
		store.load();
370
		store.load();
371
		return store;
371
		return store;
372
	}
372
	}
373
}
373
}