Subversion Repositories eFlore/Applications.coel

Rev

Rev 853 | Rev 861 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 853 Rev 857
Line 7... Line 7...
7
import org.tela_botanica.client.modeles.Valeur;
7
import org.tela_botanica.client.modeles.Valeur;
Line 8... Line 8...
8
 
8
 
9
import com.extjs.gxt.ui.client.event.ButtonEvent;
9
import com.extjs.gxt.ui.client.event.ButtonEvent;
10
import com.extjs.gxt.ui.client.event.SelectionListener;
10
import com.extjs.gxt.ui.client.event.SelectionListener;
-
 
11
import com.extjs.gxt.ui.client.store.ListStore;
11
import com.extjs.gxt.ui.client.store.ListStore;
12
import com.extjs.gxt.ui.client.widget.Component;
12
import com.extjs.gxt.ui.client.widget.LayoutContainer;
13
import com.extjs.gxt.ui.client.widget.LayoutContainer;
13
import com.extjs.gxt.ui.client.widget.MessageBox;
14
import com.extjs.gxt.ui.client.widget.MessageBox;
14
import com.extjs.gxt.ui.client.widget.Text;
15
import com.extjs.gxt.ui.client.widget.Text;
15
import com.extjs.gxt.ui.client.widget.button.Button;
16
import com.extjs.gxt.ui.client.widget.button.Button;
-
 
17
import com.extjs.gxt.ui.client.widget.form.ComboBox;
16
import com.extjs.gxt.ui.client.widget.form.ComboBox;
18
import com.extjs.gxt.ui.client.widget.form.Field;
17
import com.extjs.gxt.ui.client.widget.form.HiddenField;
19
import com.extjs.gxt.ui.client.widget.form.HiddenField;
18
import com.extjs.gxt.ui.client.widget.form.LabelField;
20
import com.extjs.gxt.ui.client.widget.form.LabelField;
19
import com.extjs.gxt.ui.client.widget.form.TextField;
21
import com.extjs.gxt.ui.client.widget.form.TextField;
20
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
22
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
Line 35... Line 37...
35
	String valeurVideMsg = null;
37
	String valeurVideMsg = null;
36
	String valeurIdentiqueMsg = null;
38
	String valeurIdentiqueMsg = null;
37
	String valeurNonValideMsg = null;
39
	String valeurNonValideMsg = null;
Line 38... Line 40...
38
	
40
	
39
	String valeurParDefaut = "";
41
	String valeurParDefaut = "";
40
	String validation = null;
42
	String validationMasque = null;
41
	String exempleValidation = null;
43
	String exempleValidation = null;
Line 42... Line 44...
42
	String boutonSupprimerLabel = "";
44
	String boutonSupprimerLabel = "";
43
	
45
	
-
 
46
	LayoutContainer principalLayout = null;
44
	LayoutContainer principalLayout = null;
47
	Field<String> champValeurTxt = null;
45
	TextField<String> champTexte = null;
48
	ComboBox<Valeur> champValeurCombo = null;
46
	HiddenField<String> champRecapitulatif = null;
49
	HiddenField<String> champRecapitulatif = null;
Line 47... Line 50...
47
	HashMap<String, LayoutContainer> valeurs = null;
50
	HashMap<String, LayoutContainer> valeurs = null;
48
	ComboBox<Valeur> types = null;
51
	ComboBox<Valeur> types = null;
49
	
52
	
Line 50... Line 53...
50
	int largeurTotale = 420;
53
	int largeurTotale = 420;
-
 
54
	int largeurBouton = 20;
Line 51... Line 55...
51
	int largeurBouton = 20;
55
	int largeurChamp = 0;
52
	int largeurChamp = 0;
56
 	
53
 	
57
	boolean estMultiType = false;
Line 64... Line 68...
64
	public ChampMultiValeurs(String label, int largeurTotale) {
68
	public ChampMultiValeurs(String label, int largeurTotale) {
65
		initialiserChampMultiValeur(label, largeurTotale);
69
		initialiserChampMultiValeur(label, largeurTotale);
66
	}
70
	}
Line 67... Line 71...
67
	
71
	
68
	public ChampMultiValeurs(boolean estMultiType, String label, int largeurTotale) {
72
	public ChampMultiValeurs(boolean estMultiType, String label, int largeurTotale) {
-
 
73
		this.estMultiType = estMultiType;
-
 
74
		initialiserChampMultiValeur(label, largeurTotale);
-
 
75
	}
-
 
76
	
-
 
77
	public ChampMultiValeurs(boolean estCombobox, boolean estMultiType, String label, int largeurTotale) {
-
 
78
		this.estMultiType = estMultiType;
69
		this.estMultiType = estMultiType; 
79
		this.estComboBox = estCombobox;
70
		initialiserChampMultiValeur(label, largeurTotale);
80
		initialiserChampMultiValeur(label, largeurTotale);
Line 71... Line 81...
71
	}
81
	}
72
	
82
	
Line 83... Line 93...
83
		}
93
		}
84
		largeurChamp = largeurTotale - largeurBouton;
94
		largeurChamp = largeurTotale - largeurBouton;
85
	}
95
	}
Line 86... Line 96...
86
	
96
	
87
	public void setValidation (String validation, String exempleValidation)	{
97
	public void setValidation (String validation, String exempleValidation)	{
88
		this.validation = validation;
98
		this.validationMasque = validation;
Line 89... Line 99...
89
		this.exempleValidation = exempleValidation;
99
		this.exempleValidation = exempleValidation;
90
		
100
		
Line 91... Line 101...
91
		this.valeurNonValideMsg = Mediateur.i18nM.valeurNonValideMsg(exempleValidation);
101
		this.valeurNonValideMsg = Mediateur.i18nM.valeurNonValideMsg(exempleValidation);
92
	}
102
	}
93
	
103
	
94
	public void setValeurParDefaut(String valeur)	{
104
	public void setValeurParDefaut(String valeur)	{
Line 95... Line 105...
95
		this.valeurParDefaut = valeur;
105
		this.valeurParDefaut = valeur;
96
		champTexte.setValue(valeur);
106
		champValeurTxt.setValue(valeur);
97
	}
107
	}
Line 135... Line 145...
135
			types.setEmptyText("Choisissez:");			
145
			types.setEmptyText("Choisissez:");			
136
			types.setStore(new ListStore<Valeur>());
146
			types.setStore(new ListStore<Valeur>());
137
			colonneLayout.add(types, new ColumnData(150));
147
			colonneLayout.add(types, new ColumnData(150));
138
		}
148
		}
Line -... Line 149...
-
 
149
		
-
 
150
		if (estComboBox) {
-
 
151
			champValeurCombo = new ComboBox<Valeur>();
-
 
152
			champValeurCombo.setDisplayField("nom");
-
 
153
			champValeurCombo.setStore(new ListStore<Valeur>());
-
 
154
			colonneLayout.add(champValeurCombo, new ColumnData(largeurChamp));
139
		
155
		} else {
140
		champTexte = new TextField<String>();
156
			champValeurTxt = new TextField<String>();
141
		colonneLayout.add(champTexte, new ColumnData(largeurChamp));
157
			colonneLayout.add(champValeurTxt, new ColumnData(largeurChamp));
142
 
158
		}
143
		Button ajouterBouton = new Button();
159
		Button ajouterBouton = new Button();
144
		ajouterBouton.setIcon(Images.ICONES.ajouter());
160
		ajouterBouton.setIcon(Images.ICONES.ajouter());
145
		ajouterBouton.addSelectionListener(
161
		ajouterBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
-
 
162
			public void componentSelected(ButtonEvent ce) {
-
 
163
				String valeurChamp = "";
146
			new SelectionListener<ButtonEvent>() {
164
				if (estComboBox) {
-
 
165
					valeurChamp = champValeurCombo.getValue().getNom();
147
				public void componentSelected(ButtonEvent ce) {
166
				} else {
-
 
167
					valeurChamp = champValeurTxt.getValue();
-
 
168
				}
148
					String valeurChampTxt = (String) champTexte.getValue();
169
				
149
					if ((valeurChampTxt == null) || valeurChampTxt.trim().equals("") || valeurChampTxt.trim().equals(valeurParDefaut))	{
170
				if ((valeurChamp == null) || valeurChamp.trim().equals("") || valeurChamp.trim().equals(valeurParDefaut))	{
150
						MessageBox.alert(titreErreur, valeurVideMsg, null);
171
					MessageBox.alert(titreErreur, valeurVideMsg, null);
151
					} else if (valeurs.get(valeurChampTxt) != null){
172
				} else if (valeurs.get(valeurChamp) != null){
-
 
173
					MessageBox.alert(titreErreur, valeurIdentiqueMsg, null);							
-
 
174
				} else {
-
 
175
					if (validationMasque != null && !valeurChamp.matches(validationMasque)) 	{
152
						MessageBox.alert(titreErreur, valeurIdentiqueMsg, null);							
176
						MessageBox.alert(titreErreur, valeurNonValideMsg, null);
153
					} else {
-
 
154
						if (validation!=null && !valeurChampTxt.matches(validation)) 	{
-
 
155
							MessageBox.alert(titreErreur, valeurNonValideMsg, null);
-
 
156
						} else {
177
					} else {
157
							if (estMultiType)	{
-
 
158
								
178
						if (estMultiType)	{
159
								String type = "";
179
							String type = "";
160
								String id = "";
180
							String id = "";
161
								Valeur valeur = types.getValue();
-
 
162
					
-
 
163
								if (valeur != null)	{
-
 
164
									type = valeur.getNom();
-
 
165
									id = valeur.getId();
-
 
166
								}	else {
-
 
167
									type = types.getRawValue();
-
 
168
									id = type;
-
 
Line 169... Line 181...
169
								}
181
							Valeur valeur = types.getValue();
170
				
-
 
171
								if (type.trim().equals(""))	{
182
				
172
									MessageBox.alert("Erreur de saisie", "Vous devez saisir un type ", null);
183
							if (valeur != null)	{
173
								}	else {
-
 
174
									ajouterValeur(valeurChampTxt, type, id);
-
 
175
								}
-
 
176
								
184
								type = valeur.getNom();
177
								
185
								id = valeur.getId();
-
 
186
							} else {
178
							} else {
187
								type = types.getRawValue();
-
 
188
								id = type;
-
 
189
							}
-
 
190
			
-
 
191
							if (type.trim().equals(""))	{
-
 
192
								MessageBox.alert("Erreur de saisie", "Vous devez saisir un type ", null);
-
 
193
							} else {
-
 
194
								ajouterValeur(valeurChamp, type, id);
-
 
195
							}
179
								ajouterValeur(valeurChampTxt);
196
						} else {
180
							}
197
							ajouterValeur(valeurChamp);
181
						}
198
						}
-
 
199
					}
182
					}
200
				}
183
				}
201
			}
Line 184... Line 202...
184
			});
202
		});
185
		colonneLayout.add(ajouterBouton, new ColumnData(largeurBouton));
203
		colonneLayout.add(ajouterBouton, new ColumnData(largeurBouton));
186
		
204
		
Line 229... Line 247...
229
		reinitialiserChamp();
247
		reinitialiserChamp();
230
		actualiserLayoutGlobal();
248
		actualiserLayoutGlobal();
231
	}
249
	}
Line 232... Line 250...
232
	
250
	
-
 
251
	public void reinitialiserChamp()	{
-
 
252
		if (estComboBox) {
-
 
253
			champValeurCombo.setValue(champValeurCombo.getStore().findModel("id_valeur", valeurParDefaut));
233
	public void reinitialiserChamp()	{
254
		} else {
-
 
255
			champValeurTxt.setValue(valeurParDefaut);
-
 
256
		}
-
 
257
		
-
 
258
		if (estMultiType) {
-
 
259
			types.reset();
234
		champTexte.setValue(valeurParDefaut);	
260
		}
Line 235... Line 261...
235
	}
261
	}
236
	
262
	
237
	public void actualiserLayoutGlobal() {
263
	public void actualiserLayoutGlobal() {