Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 934 Rev 948
1
package org.tela_botanica.client.vues.collection;
1
package org.tela_botanica.client.vues.collection;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
-
 
4
import java.util.HashMap;
4
import java.util.Iterator;
5
import java.util.Iterator;
5
import java.util.List;
6
import java.util.List;
6
 
7
 
7
import org.tela_botanica.client.Mediateur;
8
import org.tela_botanica.client.Mediateur;
8
import org.tela_botanica.client.composants.ChampCaseACocher;
9
import org.tela_botanica.client.composants.ChampCaseACocher;
9
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
10
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
10
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
11
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
11
import org.tela_botanica.client.composants.ChampSliderPourcentage;
12
import org.tela_botanica.client.composants.ChampSliderPourcentage;
12
import org.tela_botanica.client.images.Images;
13
import org.tela_botanica.client.images.Images;
13
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import org.tela_botanica.client.modeles.InterneValeur;
15
import org.tela_botanica.client.modeles.InterneValeur;
15
import org.tela_botanica.client.modeles.UniteBase;
16
import org.tela_botanica.client.modeles.UniteBase;
16
import org.tela_botanica.client.modeles.UniteRangement;
17
import org.tela_botanica.client.modeles.UniteRangement;
17
import org.tela_botanica.client.modeles.Valeur;
18
import org.tela_botanica.client.modeles.Valeur;
18
import org.tela_botanica.client.modeles.ValeurListe;
19
import org.tela_botanica.client.modeles.ValeurListe;
-
 
20
import org.tela_botanica.client.modeles.aDonnee;
-
 
21
import org.tela_botanica.client.modeles.collection.Collection;
-
 
22
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
-
 
23
import org.tela_botanica.client.modeles.collection.CollectionBotanique;
-
 
24
import org.tela_botanica.client.util.Debug;
-
 
25
import org.tela_botanica.client.util.Pattern;
-
 
26
import org.tela_botanica.client.util.UtilNombre;
-
 
27
import org.tela_botanica.client.util.UtilString;
19
import org.tela_botanica.client.vues.Formulaire;
28
import org.tela_botanica.client.vues.Formulaire;
20
import org.tela_botanica.client.vues.FormulaireOnglet;
29
import org.tela_botanica.client.vues.FormulaireOnglet;
21
 
30
 
22
import com.extjs.gxt.ui.client.Style.Scroll;
31
import com.extjs.gxt.ui.client.Style.Scroll;
23
import com.extjs.gxt.ui.client.event.ButtonEvent;
32
import com.extjs.gxt.ui.client.event.ButtonEvent;
24
import com.extjs.gxt.ui.client.event.Listener;
33
import com.extjs.gxt.ui.client.event.Listener;
25
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
34
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
26
import com.extjs.gxt.ui.client.event.SelectionListener;
35
import com.extjs.gxt.ui.client.event.SelectionListener;
27
import com.extjs.gxt.ui.client.store.ListStore;
36
import com.extjs.gxt.ui.client.store.ListStore;
28
import com.extjs.gxt.ui.client.widget.ContentPanel;
37
import com.extjs.gxt.ui.client.widget.ContentPanel;
29
import com.extjs.gxt.ui.client.widget.Info;
38
import com.extjs.gxt.ui.client.widget.Info;
30
import com.extjs.gxt.ui.client.widget.MessageBox;
39
import com.extjs.gxt.ui.client.widget.MessageBox;
31
import com.extjs.gxt.ui.client.widget.Text;
40
import com.extjs.gxt.ui.client.widget.Text;
32
import com.extjs.gxt.ui.client.widget.button.Button;
41
import com.extjs.gxt.ui.client.widget.button.Button;
33
import com.extjs.gxt.ui.client.widget.form.ComboBox;
42
import com.extjs.gxt.ui.client.widget.form.ComboBox;
34
import com.extjs.gxt.ui.client.widget.form.FieldSet;
43
import com.extjs.gxt.ui.client.widget.form.FieldSet;
35
import com.extjs.gxt.ui.client.widget.form.NumberField;
44
import com.extjs.gxt.ui.client.widget.form.NumberField;
36
import com.extjs.gxt.ui.client.widget.form.TextField;
45
import com.extjs.gxt.ui.client.widget.form.TextField;
37
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
46
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
38
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
47
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
39
import com.extjs.gxt.ui.client.widget.grid.AggregationRowConfig;
48
import com.extjs.gxt.ui.client.widget.grid.AggregationRowConfig;
40
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
49
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
41
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
50
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
-
 
51
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
42
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
52
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
43
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
53
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
44
import com.extjs.gxt.ui.client.widget.grid.Grid;
54
import com.extjs.gxt.ui.client.widget.grid.Grid;
-
 
55
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
45
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
56
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
46
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
57
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
47
import com.extjs.gxt.ui.client.widget.grid.SummaryType;
58
import com.extjs.gxt.ui.client.widget.grid.SummaryType;
48
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
59
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
49
import com.extjs.gxt.ui.client.widget.layout.FormData;
60
import com.extjs.gxt.ui.client.widget.layout.FormData;
50
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
61
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
51
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
62
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
52
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
63
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
53
import com.google.gwt.core.client.GWT;
64
import com.google.gwt.core.client.GWT;
54
import com.google.gwt.i18n.client.NumberFormat;
65
import com.google.gwt.i18n.client.NumberFormat;
55
 
66
 
56
public class CollectionFormDescription extends FormulaireOnglet implements Rafraichissable {
67
public class CollectionFormDescription extends FormulaireOnglet implements Rafraichissable {
-
 
68
	
-
 
69
	private Collection collection = null;
-
 
70
	private CollectionBotanique collectionBotanique = null;
-
 
71
	private Collection collectionCollectee = null;
-
 
72
	private CollectionBotanique collectionBotaniqueCollectee = null;
57
	
73
	
58
	private ChampComboBoxListeValeurs typesCollectionBotaCombo = null;
74
	private ChampComboBoxListeValeurs typesCollectionBotaCombo = null;
59
	private NumberField nbreEchantillonChp = null;
75
	private NumberField nbreEchantillonChp = null;
60
	private Grid<UniteRangement> uniteRangementGrille = null;
76
	private EditorGrid<UniteRangement> uniteRangementGrille = null;
61
	private ChampComboBoxListeValeurs etatUniteRangementCombo = null;
77
	private ChampComboBoxListeValeurs etatUniteRangementCombo = null;
62
	private Grid<UniteBase> uniteBaseGrille = null;
78
	private EditorGrid<UniteBase> uniteBaseGrille = null;
63
	private ChampCaseACocher typePapierConservationChp = null;
79
	private ChampCaseACocher typePapierConservationChp = null;
64
	private ChampCaseACocher methodeConservationChp = null;
80
	private ChampCaseACocher methodeConservationChp = null;
65
	private ChampSliderPourcentage specimenFixationPourcentChp = null;
81
	private ChampSliderPourcentage specimenFixationPourcentChp = null;
66
	private ChampSliderPourcentage etiquetteFixationPourcentChp = null;
82
	private ChampSliderPourcentage etiquetteFixationPourcentChp = null;
67
	private ChampCaseACocher specimentMethodeFixationChp = null;
83
	private ChampCaseACocher specimentMethodeFixationChp = null;
68
	private ChampCaseACocher etiquetteMethodeFixationSurSupportChp = null;
84
	private ChampCaseACocher etiquetteMethodeFixationSurSupportChp = null;
69
	private ChampCaseACocher etiquetteMethodeFixationSurSpecimenChp = null;
85
	private ChampCaseACocher etiquetteMethodeFixationSurSpecimenChp = null;
70
	private ChampCaseACocher typeEcritureChp = null;
86
	private ChampCaseACocher typeEcritureChp = null;
71
	private ChampComboBoxListeValeurs traitementCombo = null;
87
	private ChampComboBoxListeValeurs traitementCombo = null;
72
	private ChampCaseACocher poisonTraitementChp = null;
88
	private ChampCaseACocher poisonTraitementChp = null;
73
	private ChampCaseACocher insecteTraitementChp = null;
89
	private ChampCaseACocher insecteTraitementChp = null;
74
	private ChampComboBoxListeValeurs etatGeneralCombo = null;
90
	private ChampComboBoxListeValeurs etatGeneralCombo = null;
75
	private ChampComboBoxListeValeurs determinationCombo = null;
91
	private ChampComboBoxListeValeurs determinationCombo = null;
76
	private ChampMultiValeursMultiTypes specimenDegradationChp = null;
92
	private ChampMultiValeursMultiTypes specimenDegradationChp = null;
77
	private ChampMultiValeursMultiTypes presentationDegradationChp = null;
93
	private ChampMultiValeursMultiTypes presentationDegradationChp = null;
-
 
94
	private ComboBox<InterneValeur> precisionCombo;
78
	
95
	
79
	public CollectionFormDescription(Formulaire formulaireCourrant) {
96
	public CollectionFormDescription(Formulaire formulaireCourrant) {
80
		initialiserOnglet(formulaireCourrant);
97
		initialiserOnglet(formulaireCourrant);
81
		setId("description");
98
		setId("description");
82
		setText(Mediateur.i18nC.collectionDescription());
99
		setText(Mediateur.i18nC.collectionDescription());
83
 
100
 
84
		FormLayout formulaireLayout = (FormLayout) this.getLayout();
101
		FormLayout formulaireLayout = (FormLayout) this.getLayout();
85
		formulaireLayout.setLabelAlign(LabelAlign.LEFT);
102
		formulaireLayout.setLabelAlign(LabelAlign.LEFT);
86
		formulaireLayout.setLabelWidth(300);
103
		formulaireLayout.setLabelWidth(300);
87
		
104
		
88
		creerFieldsetPrecision();
105
		creerFieldsetPrecision();
89
		creerUniteRangement();
106
		creerUniteRangement();
90
		creerUniteBase();
107
		creerUniteBase();
91
		creerFieldsetConservation();
108
		creerFieldsetConservation();
92
		creerFieldsetEtiquette();
109
		creerFieldsetEtiquette();
93
		creerFieldsetTraitement();
110
		creerFieldsetTraitement();
94
		creerFieldsetEtat();
111
		creerFieldsetEtat();
95
		
112
		
96
		layout();
113
		layout();
97
	}
114
	}
98
	
115
	
99
	private void creerFieldsetPrecision() {
116
	private void creerFieldsetPrecision() {
100
		FieldSet precisionFieldSet = new FieldSet();
117
		FieldSet precisionFieldSet = new FieldSet();
101
		precisionFieldSet.setHeading("Précision");
118
		precisionFieldSet.setHeading("Précision");
102
		precisionFieldSet.setCollapsible(true);
119
		precisionFieldSet.setCollapsible(true);
103
		precisionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
120
		precisionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
104
		
121
		
105
		typesCollectionBotaCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionBotanique(), "typeCollectionBota");
122
		typesCollectionBotaCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionBotanique(), "typeCollectionBota");
106
		typesCollectionBotaCombo.setTabIndex(tabIndex++);
123
		typesCollectionBotaCombo.setTabIndex(tabIndex++);
107
		precisionFieldSet.add(typesCollectionBotaCombo, new FormData(250, 0));
124
		precisionFieldSet.add(typesCollectionBotaCombo, new FormData(250, 0));
108
		
125
		
109
		nbreEchantillonChp = new NumberField(); 
126
		nbreEchantillonChp = new NumberField(); 
110
		nbreEchantillonChp.setFieldLabel(i18nC.nbreEchantillon());
127
		nbreEchantillonChp.setFieldLabel(i18nC.nbreEchantillon());
111
		nbreEchantillonChp.setToolTip(i18nC.nbreEchantillonInfo());
128
		nbreEchantillonChp.setToolTip(i18nC.nbreEchantillonInfo());
112
		nbreEchantillonChp.setFormat(NumberFormat.getFormat("#"));
129
		nbreEchantillonChp.setFormat(NumberFormat.getFormat("#"));
113
		precisionFieldSet.add(nbreEchantillonChp);
130
		precisionFieldSet.add(nbreEchantillonChp);
114
		
131
		
115
		this.add(precisionFieldSet);
132
		this.add(precisionFieldSet);
116
	}
133
	}
117
	
134
	
118
	private void creerUniteRangement() {
135
	private void creerUniteRangement() {
119
		ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteRangementTitre());
136
		ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteRangementTitre());
120
		
137
		
121
		uniteRangementGrille  = creerGrilleUniteRangement();
138
		uniteRangementGrille  = creerGrilleUniteRangement();
122
		mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteRangement");
139
		mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteRangement");
123
		panneauGrille.add(uniteRangementGrille);
140
		panneauGrille.add(uniteRangementGrille);
124
		
141
		
125
		ToolBar barreOutils = creerBarreOutilsGrilleUniteRangement();
142
		ToolBar barreOutils = creerBarreOutilsGrilleUniteRangement();
126
		panneauGrille.setTopComponent(barreOutils);
143
		panneauGrille.setTopComponent(barreOutils);
127
		
144
		
128
		add(panneauGrille);
145
		add(panneauGrille);
129
	}
146
	}
130
	
147
	
131
	private ContentPanel creerPanneauContenantGrille(String titre) {
148
	private ContentPanel creerPanneauContenantGrille(String titre) {
132
		ContentPanel panneau = new ContentPanel();
149
		ContentPanel panneau = new ContentPanel();
133
		panneau.setHeading(titre);
150
		panneau.setHeading(titre);
134
		panneau.setIcon(Images.ICONES.table());
151
		panneau.setIcon(Images.ICONES.table());
135
		panneau.setLayout(new FitLayout());
152
		panneau.setLayout(new FitLayout());
136
		panneau.setFrame(true);
153
		panneau.setFrame(true);
137
		panneau.setScrollMode(Scroll.AUTO);
154
		panneau.setScrollMode(Scroll.AUTO);
138
		panneau.setCollapsible(true);
155
		panneau.setCollapsible(true);
139
		panneau.setStyleAttribute("margin", "5px 0");
156
		panneau.setStyleAttribute("margin", "5px 0");
140
		
157
		
141
		return panneau;
158
		return panneau;
142
	}
159
	}
143
	
160
	
144
	private Grid<UniteRangement> creerGrilleUniteRangement() {
161
	private EditorGrid<UniteRangement> creerGrilleUniteRangement() {
145
		ListStore<UniteRangement> storeGrille = new ListStore<UniteRangement>();
162
		ListStore<UniteRangement> storeGrille = new ListStore<UniteRangement>();
146
		
163
		
147
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
164
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
148
		colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150));
165
		colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150));
149
		
166
		
150
		NumberField champNombre = new NumberField();
167
		NumberField champNombre = new NumberField();
151
		champNombre.setFormat(NumberFormat.getFormat("#"));
168
		champNombre.setFormat(NumberFormat.getFormat("#"));
152
		CellEditor editeurNombre = new CellEditor(champNombre);
-
 
153
		
169
		
154
		ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50);
170
		ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50);
-
 
171
		nombreColonne.setEditor(new CellEditor(champNombre));
155
		nombreColonne.setEditor(editeurNombre);
172
		nombreColonne.setNumberFormat(NumberFormat.getFormat("#"));
156
		colonnes.add(nombreColonne);
173
		colonnes.add(nombreColonne);
157
		
174
		
158
		ListStore<InterneValeur> precisionStore = new ListStore<InterneValeur>();
175
		ListStore<InterneValeur> precisionStore = new ListStore<InterneValeur>();
159
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, i18nC.precisionApproximatif()));  
176
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, i18nC.precisionApproximatif()));  
160
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, i18nC.precisionExact()));
177
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, i18nC.precisionExact()));
161
		
178
		
162
		final ComboBox<InterneValeur> precisionCombo = new ComboBox<InterneValeur>();
179
		precisionCombo = new ComboBox<InterneValeur>();
163
		precisionCombo.setForceSelection(true);
180
		precisionCombo.setForceSelection(true);
164
		precisionCombo.setTriggerAction(TriggerAction.ALL);
181
		precisionCombo.setTriggerAction(TriggerAction.ALL);
165
		precisionCombo.setDisplayField("nom");
182
		precisionCombo.setDisplayField("nom");
166
		precisionCombo.setStore(precisionStore);
183
		precisionCombo.setStore(precisionStore);
167
		precisionCombo.setEditable(false);
184
		precisionCombo.setEditable(false);
168
		
185
		
169
		CellEditor editeurPrecision = new CellEditor(precisionCombo) {  
186
		CellEditor editeurPrecision = new CellEditor(precisionCombo) {  
170
			@Override  
187
			@Override  
171
			public Object preProcessValue(Object valeur) {  
188
			public Object preProcessValue(Object valeur) {  
172
				InterneValeur retour = null;
189
				InterneValeur retour = null;
173
				if (valeur != null ) {
190
				if (valeur != null ) {
174
					if (precisionCombo.getStore().findModel("nom", valeur.toString()) != null) {
191
					if (precisionCombo.getStore().findModel("nom", valeur.toString()) != null) {
175
						retour = precisionCombo.getStore().findModel("nom", valeur.toString());
192
						retour = precisionCombo.getStore().findModel("nom", valeur.toString());
176
					} else if (precisionCombo.getStore().findModel("abr", valeur.toString()) != null) {
193
					} else if (precisionCombo.getStore().findModel("abr", valeur.toString()) != null) {
177
						retour = precisionCombo.getStore().findModel("abr", valeur.toString());
194
						retour = precisionCombo.getStore().findModel("abr", valeur.toString());
178
					}
195
					}
179
				}
196
				}
180
				return retour;
197
				return retour;
181
			}  
198
			}  
182
 
199
 
183
			@Override  
200
			@Override  
184
			public Object postProcessValue(Object valeur) {  
201
			public Object postProcessValue(Object valeur) {  
185
				String retour = null;
202
				String retour = null;
186
				if (valeur != null ) {
203
				if (valeur != null ) {
187
					if (valeur instanceof InterneValeur) {
204
					if (valeur instanceof InterneValeur) {
188
						InterneValeur valeurInterne = (InterneValeur) valeur;
205
						InterneValeur valeurInterne = (InterneValeur) valeur;
189
						retour = valeurInterne.getNom();
206
						retour = valeurInterne.getNom();
190
					}
207
					}
191
				}
208
				}
192
				return retour;  
209
				return retour;  
193
			}  
210
			}
194
		};
211
		};
195
		
212
		
196
		ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50);
213
		ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50);
197
		precisionColonne.setEditor(editeurPrecision);
214
		precisionColonne.setEditor(editeurPrecision);
198
		colonnes.add(precisionColonne);
215
		colonnes.add(precisionColonne);
199
		
216
		
200
		TextField<String> formatChp = new TextField<String>();
217
		TextField<String> formatChp = new TextField<String>();
201
		formatChp.setAllowBlank(false);
218
		formatChp.setAllowBlank(false);
202
 
219
 
203
		ColumnConfig formatColonne =  new ColumnConfig("format", i18nC.collectionUniteFormat(), 100);
220
		ColumnConfig formatColonne =  new ColumnConfig("format", i18nC.collectionUniteFormat(), 100);
204
		formatColonne.setEditor(new CellEditor(formatChp));
221
		formatColonne.setEditor(new CellEditor(formatChp));
205
		colonnes.add(formatColonne);
222
		colonnes.add(formatColonne);
206
		
223
		
207
		GridSelectionModel<UniteRangement> modeleDeSelection = new GridSelectionModel<UniteRangement>();
224
		GridSelectionModel<UniteRangement> modeleDeSelection = new GridSelectionModel<UniteRangement>();
208
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
225
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
-
 
226
		
-
 
227
		AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>();
-
 
228
		total.setHtml("type", "TOTAL");
-
 
229
		total.setSummaryType("nombre", SummaryType.SUM);
-
 
230
		total.setSummaryFormat("nombre", NumberFormat.getFormat("#"));
-
 
231
		modeleDeColonnes.addAggregationRow(total);
209
		
232
		
210
		EditorGrid<UniteRangement> grilleUniteRangement = new EditorGrid<UniteRangement>(storeGrille, modeleDeColonnes);
233
		EditorGrid<UniteRangement> grilleUniteRangement = new EditorGrid<UniteRangement>(storeGrille, modeleDeColonnes);
211
		grilleUniteRangement.setHeight(300);
234
		grilleUniteRangement.setHeight(300);
212
		grilleUniteRangement.setBorders(true);
235
		grilleUniteRangement.setBorders(true);
213
		grilleUniteRangement.setSelectionModel(modeleDeSelection);
236
		grilleUniteRangement.setSelectionModel(modeleDeSelection);
214
		grilleUniteRangement.getView().setForceFit(true);
237
		grilleUniteRangement.getView().setForceFit(true);
215
		grilleUniteRangement.getView().setAutoFill(true);
238
		grilleUniteRangement.getView().setAutoFill(true);
216
		grilleUniteRangement.setAutoExpandColumn("type");
239
		grilleUniteRangement.setAutoExpandColumn("type");
217
		grilleUniteRangement.setStripeRows(true);
240
		grilleUniteRangement.setStripeRows(true);
218
		grilleUniteRangement.setTrackMouseOver(true);
241
		grilleUniteRangement.setTrackMouseOver(true);
219
		
242
		
220
		return grilleUniteRangement;
243
		return grilleUniteRangement;
221
	}
244
	}
-
 
245
	
-
 
246
	private String collecterGrilleUniteRangement() {
-
 
247
		String truk = "";
-
 
248
		int nbreUnite = uniteRangementGrille.getStore().getCount();
-
 
249
		for (int i = 0; i < nbreUnite; i++) {
-
 
250
			UniteRangement unite = uniteRangementGrille.getStore().getAt(i);
-
 
251
			truk += unite.getId()+aDonnee.SEPARATEUR_TYPE_VALEUR;
-
 
252
			truk += UtilNombre.formaterEnEntier(unite.getNombre())+aDonnee.SEPARATEUR_DONNEES;
-
 
253
			String precision = "";
-
 
254
			InterneValeur precisionValeur = precisionCombo.getStore().findModel("nom", unite.getPrecision());
-
 
255
			if (precisionValeur != null) {
-
 
256
				precision = precisionValeur.getAbr();
-
 
257
			}
-
 
258
			truk += precision+aDonnee.SEPARATEUR_DONNEES;
-
 
259
			truk += unite.getFormat();
-
 
260
			truk += (i == (nbreUnite - 1)) ? "" : aDonnee.SEPARATEUR_VALEURS;
-
 
261
		}
-
 
262
		return truk;
-
 
263
	}
-
 
264
	
-
 
265
	private void peuplerGrilleUniteRangement(String valeurTruk) {
-
 
266
		if (!UtilString.isEmpty(valeurTruk)) {
-
 
267
			HashMap<String,UniteRangement> unitesEnregistrees = new HashMap<String,UniteRangement>();
-
 
268
			String[] unites = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS));
-
 
269
			for (int i = 0; i < unites.length; i++) {
-
 
270
				String[] uniteTypeIdDonnees = unites[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR));
-
 
271
				String uniteChaineDonnees = uniteTypeIdDonnees[1];
-
 
272
				String[] uniteDonnees = uniteChaineDonnees.split(Pattern.quote(aDonnee.SEPARATEUR_DONNEES));
-
 
273
				
-
 
274
				UniteRangement uniteRangement = new UniteRangement();
-
 
275
				uniteRangement.setId(uniteTypeIdDonnees[0]);
-
 
276
				if (uniteDonnees.length > 0) {
-
 
277
					uniteRangement.setNombre(UtilString.formaterEnDouble(uniteDonnees[0]));
-
 
278
				}
-
 
279
				if (uniteDonnees.length > 1) {
-
 
280
					uniteRangement.setPrecision(uniteDonnees[1]);
-
 
281
				}
-
 
282
				if (uniteDonnees.length > 2) {
-
 
283
					uniteRangement.setFormat(uniteDonnees[2]);
-
 
284
					Debug.log(uniteTypeIdDonnees[0]+"/"+uniteTypeIdDonnees[1]+"/"+uniteDonnees[0]+"-"+uniteDonnees[1]+"-"+uniteDonnees[2]);
-
 
285
				}
-
 
286
				unitesEnregistrees.put(uniteTypeIdDonnees[0], uniteRangement);
-
 
287
			}
-
 
288
			
-
 
289
			ArrayList<UniteRangement> listeUniteMaj = new ArrayList<UniteRangement>();
-
 
290
			int nbreUnite = uniteRangementGrille.getStore().getCount();
-
 
291
			for (int i = 0; i < nbreUnite; i++) {
-
 
292
				UniteRangement uniteDansGrille = uniteRangementGrille.getStore().getAt(i);
-
 
293
				UniteRangement uniteEnregistree = unitesEnregistrees.get(uniteDansGrille.getId());
-
 
294
				if (uniteEnregistree != null) {
-
 
295
					listeUniteMaj.add(uniteEnregistree);
-
 
296
				} else {
-
 
297
					listeUniteMaj.add(uniteDansGrille);
-
 
298
				}
-
 
299
			}
-
 
300
			uniteRangementGrille.getStore().removeAll();
-
 
301
			uniteRangementGrille.getStore().add(listeUniteMaj);
-
 
302
			layout();
-
 
303
		}
-
 
304
	}
222
	
305
	
223
	private ToolBar creerBarreOutilsGrilleUniteRangement() {
306
	private ToolBar creerBarreOutilsGrilleUniteRangement() {
224
		ToolBar barreOutils = new ToolBar();  
307
		ToolBar barreOutils = new ToolBar();  
225
		
308
		
226
		Button ajouterBouton = creerBoutonAjouterUniteRangement();
309
		Button ajouterBouton = creerBoutonAjouterUniteRangement();
227
		barreOutils.add(ajouterBouton);
310
		barreOutils.add(ajouterBouton);
228
		
311
		
229
		barreOutils.add(new SeparatorToolItem());
312
		barreOutils.add(new SeparatorToolItem());
230
		
313
		
231
		Button supprimerBouton = creerBoutonSupprimerUniteRangement();
314
		Button supprimerBouton = creerBoutonSupprimerUniteRangement();
232
		barreOutils.add(supprimerBouton);
315
		barreOutils.add(supprimerBouton);
233
		
316
		
234
		barreOutils.add(new SeparatorToolItem());
317
		barreOutils.add(new SeparatorToolItem());
235
		barreOutils.add(new Text(i18nC.collectionUniteRangementEtatGeneralLabel()));
318
		barreOutils.add(new Text(i18nC.collectionUniteRangementEtatGeneralLabel()));
236
		etatUniteRangementCombo = new ChampComboBoxListeValeurs("", "etat");
319
		etatUniteRangementCombo = new ChampComboBoxListeValeurs("", "etat");
237
		etatUniteRangementCombo.setEmptyText(i18nC.collectionUniteRangementEtatGeneral());
320
		etatUniteRangementCombo.setEmptyText(i18nC.collectionUniteRangementEtatGeneral());
238
		etatUniteRangementCombo.setToolTip(i18nC.collectionUniteRangementEtatGeneralInfo());
321
		etatUniteRangementCombo.setToolTip(i18nC.collectionUniteRangementEtatGeneralInfo());
239
		etatUniteRangementCombo.setTrie("id_valeur");
322
		etatUniteRangementCombo.setTrie("id_valeur");
240
		etatUniteRangementCombo.setWidth(300);
323
		etatUniteRangementCombo.setWidth(300);
241
		barreOutils.add(etatUniteRangementCombo);
324
		barreOutils.add(etatUniteRangementCombo);
242
		
325
		
243
		return barreOutils;
326
		return barreOutils;
244
	}
327
	}
245
	
328
	
246
	private Button creerBoutonAjouterUniteRangement() {
329
	private Button creerBoutonAjouterUniteRangement() {
247
		Button bouton = new Button(i18nC.ajouter());
330
		Button bouton = new Button(i18nC.ajouter());
248
		bouton.setIcon(Images.ICONES.ajouter());
331
		bouton.setIcon(Images.ICONES.ajouter());
249
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
332
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
250
			@Override
333
			@Override
251
			public void componentSelected(ButtonEvent ce) {
334
			public void componentSelected(ButtonEvent ce) {
252
				final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteRangementSaisirType());
335
				final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteRangementSaisirType());
253
					box.addCallback(new Listener<MessageBoxEvent>() {
336
					box.addCallback(new Listener<MessageBoxEvent>() {
254
					public void handleEvent(MessageBoxEvent be) {
337
					public void handleEvent(MessageBoxEvent be) {
255
						final UniteRangement unite = new UniteRangement();
338
						final UniteRangement unite = new UniteRangement();
256
						unite.setType(be.getValue());
339
						unite.setType(be.getValue());
257
						unite.setTypeAutre(true);
340
						unite.setTypeAutre(true);
258
						uniteRangementGrille.getStore().add(unite);
341
						uniteRangementGrille.getStore().add(unite);
259
					}
342
					}
260
				});
343
				});
261
			}
344
			}
262
		});
345
		});
263
		return bouton;
346
		return bouton;
264
	}
347
	}
265
	
348
	
266
	private Button creerBoutonSupprimerUniteRangement() {
349
	private Button creerBoutonSupprimerUniteRangement() {
267
		Button bouton = new Button(i18nC.supprimer());
350
		Button bouton = new Button(i18nC.supprimer());
268
		bouton.setIcon(Images.ICONES.supprimer());
351
		bouton.setIcon(Images.ICONES.supprimer());
269
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
352
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
270
			@Override
353
			@Override
271
			public void componentSelected(ButtonEvent ce) {
354
			public void componentSelected(ButtonEvent ce) {
272
				UniteRangement uniteRangementSelectionnee = uniteRangementGrille.getSelectionModel().getSelectedItem();
355
				UniteRangement uniteRangementSelectionnee = uniteRangementGrille.getSelectionModel().getSelectedItem();
273
				if (uniteRangementSelectionnee == null) {
356
				if (uniteRangementSelectionnee == null) {
274
					Info.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteRangement()));
357
					Info.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteRangement()));
275
				} else if (uniteRangementSelectionnee.getTypeAutre() == false) {
358
				} else if (uniteRangementSelectionnee.getTypeAutre() == false) {
276
					Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteRangementAjoute());
359
					Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteRangementAjoute());
277
				} else {
360
				} else {
278
					uniteRangementGrille.getStore().remove(uniteRangementSelectionnee);
361
					uniteRangementGrille.getStore().remove(uniteRangementSelectionnee);
279
				}
362
				}
280
			}   
363
			}   
281
		});
364
		});
282
		return bouton;
365
		return bouton;
283
	}
366
	}
284
	
367
	
285
	private void creerUniteBase() {
368
	private void creerUniteBase() {
286
		ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteBaseTitre());
369
		ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteBaseTitre());
287
		
370
		
288
		uniteBaseGrille  = creerGrilleUniteBase();
371
		uniteBaseGrille  = creerGrilleUniteBase();
289
		mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteBase");
372
		mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteBase");
290
		panneauGrille.add(uniteBaseGrille);
373
		panneauGrille.add(uniteBaseGrille);
291
		
374
		
292
		ToolBar barreOutils = creerBarreOutilsGrilleUniteBase();
375
		ToolBar barreOutils = creerBarreOutilsGrilleUniteBase();
293
		panneauGrille.setTopComponent(barreOutils);
376
		panneauGrille.setTopComponent(barreOutils);
294
		
377
		
295
		add(panneauGrille);		
378
		add(panneauGrille);		
296
	}
379
	}
297
		
380
		
298
	private Grid<UniteBase> creerGrilleUniteBase() {
381
	private EditorGrid<UniteBase> creerGrilleUniteBase() {
299
		ListStore<UniteBase> storeGrille = new ListStore<UniteBase>();
382
		ListStore<UniteBase> storeGrille = new ListStore<UniteBase>();
300
		
383
		
301
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
384
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
302
		colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150));
385
		colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150));
303
		
386
		
304
		NumberField champNombre = new NumberField();
387
		NumberField champNombre = new NumberField();
305
		champNombre.setFormat(NumberFormat.getFormat("#"));
388
		champNombre.setFormat(NumberFormat.getFormat("#"));
306
		CellEditor editeurNombre = new CellEditor(champNombre);
389
		CellEditor editeurNombre = new CellEditor(champNombre);
307
		
390
		
308
		ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50);
391
		ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50);
309
		nombreColonne.setEditor(editeurNombre);
392
		nombreColonne.setEditor(editeurNombre);
-
 
393
		nombreColonne.setNumberFormat(NumberFormat.getFormat("#"));
310
		colonnes.add(nombreColonne);
394
		colonnes.add(nombreColonne);
311
		
395
		
312
		ListStore<InterneValeur> precisionStore = new ListStore<InterneValeur>();
396
		ListStore<InterneValeur> precisionStore = new ListStore<InterneValeur>();
313
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, i18nC.precisionApproximatif()));  
397
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, i18nC.precisionApproximatif()));  
314
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, i18nC.precisionExact()));
398
		precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, i18nC.precisionExact()));
315
		
399
		
316
		final ComboBox<InterneValeur> precisionCombo = new ComboBox<InterneValeur>();
400
		final ComboBox<InterneValeur> precisionCombo = new ComboBox<InterneValeur>();
317
		precisionCombo.setForceSelection(true);
401
		precisionCombo.setForceSelection(true);
318
		precisionCombo.setTriggerAction(TriggerAction.ALL);
402
		precisionCombo.setTriggerAction(TriggerAction.ALL);
319
		precisionCombo.setDisplayField("nom");
403
		precisionCombo.setDisplayField("nom");
320
		precisionCombo.setStore(precisionStore);
404
		precisionCombo.setStore(precisionStore);
321
		precisionCombo.setEditable(false);
405
		precisionCombo.setEditable(false);
322
		
406
		
323
		CellEditor editeurPrecision = new CellEditor(precisionCombo) {  
407
		CellEditor editeurPrecision = new CellEditor(precisionCombo) {  
324
			@Override  
408
			@Override  
325
			public Object preProcessValue(Object valeur) {  
409
			public Object preProcessValue(Object valeur) {  
326
				InterneValeur retour = null;
410
				InterneValeur retour = null;
327
				if (valeur != null ) {
411
				if (valeur != null ) {
328
					if (precisionCombo.getStore().findModel("nom", valeur.toString()) != null) {
412
					if (precisionCombo.getStore().findModel("nom", valeur.toString()) != null) {
329
						retour = precisionCombo.getStore().findModel("nom", valeur.toString());
413
						retour = precisionCombo.getStore().findModel("nom", valeur.toString());
330
					} else if (precisionCombo.getStore().findModel("abr", valeur.toString()) != null) {
414
					} else if (precisionCombo.getStore().findModel("abr", valeur.toString()) != null) {
331
						retour = precisionCombo.getStore().findModel("abr", valeur.toString());
415
						retour = precisionCombo.getStore().findModel("abr", valeur.toString());
332
					}
416
					}
333
				}
417
				}
334
				return retour;
418
				return retour;
335
			}  
419
			}  
336
 
420
 
337
			@Override  
421
			@Override  
338
			public Object postProcessValue(Object valeur) {  
422
			public Object postProcessValue(Object valeur) {  
339
				String retour = null;
423
				String retour = null;
340
				if (valeur != null ) {
424
				if (valeur != null ) {
341
					if (valeur instanceof InterneValeur) {
425
					if (valeur instanceof InterneValeur) {
342
						InterneValeur valeurInterne = (InterneValeur) valeur;
426
						InterneValeur valeurInterne = (InterneValeur) valeur;
343
						retour = valeurInterne.getNom();
427
						retour = valeurInterne.getNom();
344
					}
428
					}
345
				}
429
				}
346
				return retour;
430
				return retour;
347
			}  
431
			}  
348
		};
432
		};
349
		
433
		
350
		ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50);
434
		ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50);
351
		precisionColonne.setEditor(editeurPrecision);
435
		precisionColonne.setEditor(editeurPrecision);
352
		colonnes.add(precisionColonne);
436
		colonnes.add(precisionColonne);
353
		
437
		
354
		TextField<String> formatChp = new TextField<String>();
438
		TextField<String> formatChp = new TextField<String>();
355
		formatChp.setAllowBlank(false);
439
		formatChp.setAllowBlank(false);
356
 
440
 
357
		ColumnConfig formatColonne =  new ColumnConfig("format", i18nC.collectionUniteFormat(), 100);
441
		ColumnConfig formatColonne =  new ColumnConfig("format", i18nC.collectionUniteFormat(), 100);
358
		formatColonne.setEditor(new CellEditor(formatChp));
442
		formatColonne.setEditor(new CellEditor(formatChp));
359
		colonnes.add(formatColonne);
443
		colonnes.add(formatColonne);
360
		
444
		
361
		ColumnConfig partNombreColonne = new ColumnConfig("nombre_part", i18nC.collectionUniteNbre(), 50);
445
		ColumnConfig partNombreColonne = new ColumnConfig("nombre_part", i18nC.collectionUniteNbre(), 50);
362
		partNombreColonne.setEditor(editeurNombre);
446
		partNombreColonne.setEditor(editeurNombre);
-
 
447
		partNombreColonne.setNumberFormat(NumberFormat.getFormat("#"));
363
		colonnes.add(partNombreColonne);
448
		colonnes.add(partNombreColonne);
364
		
449
		
365
		ColumnConfig partPrecisionColonne = new ColumnConfig("precision_part", i18nC.collectionUnitePrecision(), 50);
450
		ColumnConfig partPrecisionColonne = new ColumnConfig("precision_part", i18nC.collectionUnitePrecision(), 50);
366
		partPrecisionColonne.setEditor(editeurPrecision);
451
		partPrecisionColonne.setEditor(editeurPrecision);
367
		colonnes.add(partPrecisionColonne);
452
		colonnes.add(partPrecisionColonne);
368
		
453
		
369
		ColumnConfig spNombreColonne = new ColumnConfig("nombre_sp", i18nC.collectionUniteNbre(), 50);
454
		ColumnConfig spNombreColonne = new ColumnConfig("nombre_sp", i18nC.collectionUniteNbre(), 50);
370
		spNombreColonne.setEditor(editeurNombre);
455
		spNombreColonne.setEditor(editeurNombre);
-
 
456
		spNombreColonne.setNumberFormat(NumberFormat.getFormat("#"));
371
		colonnes.add(spNombreColonne);
457
		colonnes.add(spNombreColonne);
372
		
458
		
373
		ColumnConfig spPrecisionColonne = new ColumnConfig("precision_sp", i18nC.collectionUnitePrecision(), 50);
459
		ColumnConfig spPrecisionColonne = new ColumnConfig("precision_sp", i18nC.collectionUnitePrecision(), 50);
374
		spPrecisionColonne.setEditor(editeurPrecision);
460
		spPrecisionColonne.setEditor(editeurPrecision);
375
		colonnes.add(spPrecisionColonne);
461
		colonnes.add(spPrecisionColonne);
376
		
462
		
377
		GridSelectionModel<UniteBase> modeleDeSelection = new GridSelectionModel<UniteBase>();
463
		GridSelectionModel<UniteBase> modeleDeSelection = new GridSelectionModel<UniteBase>();
378
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
464
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
379
		modeleDeColonnes.addHeaderGroup(0, 0, new HeaderGroupConfig(i18nC.collectionUniteBase(), 1, 4));
465
		modeleDeColonnes.addHeaderGroup(0, 0, new HeaderGroupConfig(i18nC.collectionUniteBase(), 1, 4));
380
		modeleDeColonnes.addHeaderGroup(0, 4, new HeaderGroupConfig(i18nC.collectionUniteBasePart(), 1, 2));
466
		modeleDeColonnes.addHeaderGroup(0, 4, new HeaderGroupConfig(i18nC.collectionUniteBasePart(), 1, 2));
381
		modeleDeColonnes.addHeaderGroup(0, 6, new HeaderGroupConfig(i18nC.collectionUniteBaseSp(), 1, 2));
467
		modeleDeColonnes.addHeaderGroup(0, 6, new HeaderGroupConfig(i18nC.collectionUniteBaseSp(), 1, 2));
382
		
468
		
383
		AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>();
469
		AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>();
384
		total.setHtml("type", "TOTAL");
470
		total.setHtml("type", "TOTAL");
385
		total.setSummaryType("nombre", SummaryType.SUM);
471
		total.setSummaryType("nombre", SummaryType.SUM);
386
		total.setSummaryFormat("nombre", NumberFormat.getFormat("#"));
472
		total.setSummaryFormat("nombre", NumberFormat.getFormat("#"));
387
		total.setSummaryType("nombre_part", SummaryType.SUM);
473
		total.setSummaryType("nombre_part", SummaryType.SUM);
388
		total.setSummaryFormat("nombre_part", NumberFormat.getFormat("#"));
474
		total.setSummaryFormat("nombre_part", NumberFormat.getFormat("#"));
389
		total.setSummaryType("nombre_sp", SummaryType.SUM);
475
		total.setSummaryType("nombre_sp", SummaryType.SUM);
390
		total.setSummaryFormat("nombre_sp", NumberFormat.getFormat("#"));
476
		total.setSummaryFormat("nombre_sp", NumberFormat.getFormat("#"));
391
		modeleDeColonnes.addAggregationRow(total);
477
		modeleDeColonnes.addAggregationRow(total);
392
		
478
		
393
		EditorGrid<UniteBase> grilleUniteBase = new EditorGrid<UniteBase>(storeGrille, modeleDeColonnes);
479
		EditorGrid<UniteBase> grilleUniteBase = new EditorGrid<UniteBase>(storeGrille, modeleDeColonnes);
394
		grilleUniteBase.setHeight(200);
480
		grilleUniteBase.setHeight(200);
395
		grilleUniteBase.setBorders(true);
481
		grilleUniteBase.setBorders(true);
396
		grilleUniteBase.setSelectionModel(modeleDeSelection);
482
		grilleUniteBase.setSelectionModel(modeleDeSelection);
397
		grilleUniteBase.getView().setForceFit(true);
483
		grilleUniteBase.getView().setForceFit(true);
398
		grilleUniteBase.getView().setAutoFill(true);
484
		grilleUniteBase.getView().setAutoFill(true);
399
		grilleUniteBase.setAutoExpandColumn("type");
485
		grilleUniteBase.setAutoExpandColumn("type");
400
		grilleUniteBase.setStripeRows(true);
486
		grilleUniteBase.setStripeRows(true);
401
		grilleUniteBase.setTrackMouseOver(true);
487
		grilleUniteBase.setTrackMouseOver(true);
402
		
488
		
403
		return grilleUniteBase;
489
		return grilleUniteBase;
404
	}
490
	}
405
	
491
	
406
	private ToolBar creerBarreOutilsGrilleUniteBase() {
492
	private ToolBar creerBarreOutilsGrilleUniteBase() {
407
		ToolBar barreOutils = new ToolBar();  
493
		ToolBar barreOutils = new ToolBar();  
408
		
494
		
409
		Button ajouterBouton = creerBoutonAjouterUniteBase();
495
		Button ajouterBouton = creerBoutonAjouterUniteBase();
410
		barreOutils.add(ajouterBouton);
496
		barreOutils.add(ajouterBouton);
411
		
497
		
412
		barreOutils.add(new SeparatorToolItem());
498
		barreOutils.add(new SeparatorToolItem());
413
		
499
		
414
		Button supprimerBouton = creerBoutonSupprimerUniteBase();
500
		Button supprimerBouton = creerBoutonSupprimerUniteBase();
415
		barreOutils.add(supprimerBouton);		
501
		barreOutils.add(supprimerBouton);		
416
		
502
		
417
		return barreOutils;
503
		return barreOutils;
418
	}
504
	}
419
	
505
	
420
	private Button creerBoutonAjouterUniteBase() {
506
	private Button creerBoutonAjouterUniteBase() {
421
		Button bouton = new Button(i18nC.ajouter());
507
		Button bouton = new Button(i18nC.ajouter());
422
		bouton.setIcon(Images.ICONES.ajouter());
508
		bouton.setIcon(Images.ICONES.ajouter());
423
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
509
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
424
			@Override
510
			@Override
425
			public void componentSelected(ButtonEvent ce) {
511
			public void componentSelected(ButtonEvent ce) {
426
				final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteBaseSaisirType());
512
				final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteBaseSaisirType());
427
					box.addCallback(new Listener<MessageBoxEvent>() {
513
					box.addCallback(new Listener<MessageBoxEvent>() {
428
					public void handleEvent(MessageBoxEvent be) {
514
					public void handleEvent(MessageBoxEvent be) {
429
						final UniteBase unite = new UniteBase();
515
						final UniteBase unite = new UniteBase();
430
						unite.setType(be.getValue());
516
						unite.setType(be.getValue());
431
						unite.setTypeAutre(true);
517
						unite.setTypeAutre(true);
432
						uniteBaseGrille.getStore().add(unite);
518
						uniteBaseGrille.getStore().add(unite);
433
					}
519
					}
434
				});
520
				});
435
			}
521
			}
436
		});
522
		});
437
		return bouton;
523
		return bouton;
438
	}
524
	}
439
	
525
	
440
	private Button creerBoutonSupprimerUniteBase() {
526
	private Button creerBoutonSupprimerUniteBase() {
441
		Button bouton = new Button(i18nC.supprimer());
527
		Button bouton = new Button(i18nC.supprimer());
442
		bouton.setIcon(Images.ICONES.supprimer());
528
		bouton.setIcon(Images.ICONES.supprimer());
443
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
529
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
444
			@Override
530
			@Override
445
			public void componentSelected(ButtonEvent ce) {
531
			public void componentSelected(ButtonEvent ce) {
446
				UniteBase uniteBaseSelectionnee = uniteBaseGrille.getSelectionModel().getSelectedItem();
532
				UniteBase uniteBaseSelectionnee = uniteBaseGrille.getSelectionModel().getSelectedItem();
447
				if (uniteBaseSelectionnee == null) {
533
				if (uniteBaseSelectionnee == null) {
448
					Info.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteBase()));
534
					Info.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteBase()));
449
				} else if (uniteBaseSelectionnee.getTypeAutre() == false) {
535
				} else if (uniteBaseSelectionnee.getTypeAutre() == false) {
450
					Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteBaseAjoute());
536
					Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteBaseAjoute());
451
				} else {
537
				} else {
452
					uniteBaseGrille.getStore().remove(uniteBaseSelectionnee);
538
					uniteBaseGrille.getStore().remove(uniteBaseSelectionnee);
453
				}
539
				}
454
			}   
540
			}   
455
		});
541
		});
456
		return bouton;
542
		return bouton;
457
	}
543
	}
458
	
544
	
459
	private void creerFieldsetConservation() {
545
	private void creerFieldsetConservation() {
460
		FieldSet conservationFieldSet = new FieldSet();
546
		FieldSet conservationFieldSet = new FieldSet();
461
		conservationFieldSet.setHeading("Conservation");
547
		conservationFieldSet.setHeading("Conservation");
462
		conservationFieldSet.setCollapsible(true);
548
		conservationFieldSet.setCollapsible(true);
463
		conservationFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
549
		conservationFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
464
		
550
		
465
		typePapierConservationChp = new ChampCaseACocher(i18nC.typePapierConservation(), "typePapier", true);
551
		typePapierConservationChp = new ChampCaseACocher(i18nC.typePapierConservation(), "typePapier", true);
466
		conservationFieldSet.add(typePapierConservationChp);
552
		conservationFieldSet.add(typePapierConservationChp);
467
		
553
		
468
		methodeConservationChp = new ChampCaseACocher(i18nC.methodeConservation(), "methodeRangement", true);
554
		methodeConservationChp = new ChampCaseACocher(i18nC.methodeConservation(), "methodeRangement", true);
469
		conservationFieldSet.add(methodeConservationChp);
555
		conservationFieldSet.add(methodeConservationChp);
470
		
556
		
471
		this.add(conservationFieldSet);
557
		this.add(conservationFieldSet);
472
	}
558
	}
473
	
559
	
474
	private void creerFieldsetEtiquette() {
560
	private void creerFieldsetEtiquette() {
475
		FieldSet etiquetteFieldSet = new FieldSet();
561
		FieldSet etiquetteFieldSet = new FieldSet();
476
		etiquetteFieldSet.setHeading("Conservation");
562
		etiquetteFieldSet.setHeading("Conservation");
477
		etiquetteFieldSet.setCollapsible(true);
563
		etiquetteFieldSet.setCollapsible(true);
478
		etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
564
		etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
479
		
565
		
480
		Text fixationPoucentLabel = new Text(i18nC.fixationPourcent());
566
		Text fixationPoucentLabel = new Text(i18nC.fixationPourcent());
481
		etiquetteFieldSet.add(fixationPoucentLabel);
567
		etiquetteFieldSet.add(fixationPoucentLabel);
482
		
568
		
483
		specimenFixationPourcentChp = new ChampSliderPourcentage(i18nC.specimenFixationPourcent());
569
		specimenFixationPourcentChp = new ChampSliderPourcentage(i18nC.specimenFixationPourcent());
484
		etiquetteFieldSet.add(specimenFixationPourcentChp, new FormData(200, 0));
570
		etiquetteFieldSet.add(specimenFixationPourcentChp, new FormData(200, 0));
485
		
571
		
486
		etiquetteFixationPourcentChp = new ChampSliderPourcentage(i18nC.etiquetteFixationPourcent());
572
		etiquetteFixationPourcentChp = new ChampSliderPourcentage(i18nC.etiquetteFixationPourcent());
487
		etiquetteFieldSet.add(etiquetteFixationPourcentChp, new FormData(200, 0));
573
		etiquetteFieldSet.add(etiquetteFixationPourcentChp, new FormData(200, 0));
488
		
574
		
489
		specimentMethodeFixationChp = new ChampCaseACocher(i18nC.specimenMethodeFixation(), "methodeFixation", true);
575
		specimentMethodeFixationChp = new ChampCaseACocher(i18nC.specimenMethodeFixation(), "methodeFixation", true);
490
		etiquetteFieldSet.add(specimentMethodeFixationChp);
576
		etiquetteFieldSet.add(specimentMethodeFixationChp);
491
		
577
		
492
		etiquetteMethodeFixationSurSupportChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSupport(), "methodeFixation", true);
578
		etiquetteMethodeFixationSurSupportChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSupport(), "methodeFixation", true);
493
		etiquetteFieldSet.add(etiquetteMethodeFixationSurSupportChp);
579
		etiquetteFieldSet.add(etiquetteMethodeFixationSurSupportChp);
494
		
580
		
495
		etiquetteMethodeFixationSurSpecimenChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSpecimen(), "methodeFixationSurSpecimen", true);
581
		etiquetteMethodeFixationSurSpecimenChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSpecimen(), "methodeFixationSurSpecimen", true);
496
		etiquetteFieldSet.add(etiquetteMethodeFixationSurSpecimenChp);
582
		etiquetteFieldSet.add(etiquetteMethodeFixationSurSpecimenChp);
497
		
583
		
498
		typeEcritureChp = new ChampCaseACocher(i18nC.typeEcriture(), "typeEcriture", false);
584
		typeEcritureChp = new ChampCaseACocher(i18nC.typeEcriture(), "typeEcriture", false);
499
		etiquetteFieldSet.add(typeEcritureChp);
585
		etiquetteFieldSet.add(typeEcritureChp);
500
		
586
		
501
		this.add(etiquetteFieldSet);
587
		this.add(etiquetteFieldSet);
502
	}
588
	}
503
	
589
	
504
	private void creerFieldsetTraitement() {
590
	private void creerFieldsetTraitement() {
505
		FieldSet traitementFieldSet = new FieldSet();
591
		FieldSet traitementFieldSet = new FieldSet();
506
		traitementFieldSet.setHeading("Traitements");
592
		traitementFieldSet.setHeading("Traitements");
507
		traitementFieldSet.setCollapsible(true);
593
		traitementFieldSet.setCollapsible(true);
508
		traitementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
594
		traitementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
509
		
595
		
510
		traitementCombo  = new ChampComboBoxListeValeurs(i18nC.collectionTraitement(), "onpi");
596
		traitementCombo  = new ChampComboBoxListeValeurs(i18nC.collectionTraitement(), "onpi");
511
		traitementCombo.setTrie("id_valeur");
597
		traitementCombo.setTrie("id_valeur");
512
		traitementFieldSet.add(traitementCombo, new FormData(300, 0));
598
		traitementFieldSet.add(traitementCombo, new FormData(300, 0));
513
		
599
		
514
		poisonTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementPoison(), "poisonTraitement", true);
600
		poisonTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementPoison(), "poisonTraitement", true);
515
		traitementFieldSet.add(poisonTraitementChp);
601
		traitementFieldSet.add(poisonTraitementChp);
516
		
602
		
517
		insecteTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementInsecte(), "insecteTraitement", true);
603
		insecteTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementInsecte(), "insecteTraitement", true);
518
		traitementFieldSet.add(insecteTraitementChp);
604
		traitementFieldSet.add(insecteTraitementChp);
519
 
605
 
520
		this.add(traitementFieldSet);
606
		this.add(traitementFieldSet);
521
	}
607
	}
522
	
608
	
523
	private void creerFieldsetEtat() {
609
	private void creerFieldsetEtat() {
524
		FieldSet etatFieldSet = new FieldSet();
610
		FieldSet etatFieldSet = new FieldSet();
525
		etatFieldSet.setHeading("État général et dégradation");
611
		etatFieldSet.setHeading("État général et dégradation");
526
		etatFieldSet.setCollapsible(true);
612
		etatFieldSet.setCollapsible(true);
527
		etatFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
613
		etatFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
528
		
614
		
529
		etatGeneralCombo = new ChampComboBoxListeValeurs(i18nC.collectionEtatGeneral(), "etat");
615
		etatGeneralCombo = new ChampComboBoxListeValeurs(i18nC.collectionEtatGeneral(), "etat");
530
		etatGeneralCombo.setToolTip(i18nC.collectionEtatGeneralInfo());
616
		etatGeneralCombo.setToolTip(i18nC.collectionEtatGeneralInfo());
531
		etatGeneralCombo.setTrie("id_valeur");
617
		etatGeneralCombo.setTrie("id_valeur");
532
		etatFieldSet.add(etatGeneralCombo, new FormData(300, 0));
618
		etatFieldSet.add(etatGeneralCombo, new FormData(300, 0));
533
		
619
		
534
		specimenDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationSpecimen(), 150, true);
620
		specimenDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationSpecimen(), 150, true);
535
		specimenDegradationChp.initialiserType("specimenDegradation");
621
		specimenDegradationChp.initialiserType("specimenDegradation");
536
		specimenDegradationChp.initialiserCombobox("niveauImportance");
622
		specimenDegradationChp.initialiserCombobox("niveauImportance");
537
		etatFieldSet.add(specimenDegradationChp);
623
		etatFieldSet.add(specimenDegradationChp);
538
		
624
		
539
		presentationDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationPresentation(), 150, 200, true);
625
		presentationDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationPresentation(), 150, 200, true);
540
		presentationDegradationChp.initialiserType("supportDegradation");
626
		presentationDegradationChp.initialiserType("supportDegradation");
541
		presentationDegradationChp.initialiserCombobox("niveauImportance");
627
		presentationDegradationChp.initialiserCombobox("niveauImportance");
542
		etatFieldSet.add(presentationDegradationChp);
628
		etatFieldSet.add(presentationDegradationChp);
543
		
629
		
544
		determinationCombo = new ChampComboBoxListeValeurs(i18nC.collectionDetermination(), "niveauDetermination");
630
		determinationCombo = new ChampComboBoxListeValeurs(i18nC.collectionDetermination(), "niveauDetermination");
545
		determinationCombo.setTrie("id_valeur");
631
		determinationCombo.setTrie("id_valeur");
546
		etatFieldSet.add(determinationCombo, new FormData(450, 0));
632
		etatFieldSet.add(determinationCombo, new FormData(450, 0));
547
		
633
		
548
		this.add(etatFieldSet);
634
		this.add(etatFieldSet);
549
	}
635
	}
-
 
636
	
-
 
637
	public void peupler() {
-
 
638
		initialiserCollection();
-
 
639
		if (collectionBotanique != null) {
-
 
640
			typesCollectionBotaCombo.peupler(collectionBotanique.getType());
-
 
641
			if (!UtilString.isEmpty(collectionBotanique.getNbreEchantillon())) {
-
 
642
				nbreEchantillonChp.setValue(Integer.parseInt(collectionBotanique.getNbreEchantillon()));
-
 
643
			}
-
 
644
			peuplerGrilleUniteRangement(collectionBotanique.getUniteRangement());
-
 
645
		}
-
 
646
	}
-
 
647
	
-
 
648
	public void collecter() {
-
 
649
		initialiserCollection();
-
 
650
		if (etreAccede()) {
-
 
651
			collectionBotaniqueCollectee.setType(typesCollectionBotaCombo.getValeur());
-
 
652
			collectionBotaniqueCollectee.setNbreEchantillon(Integer.toString(nbreEchantillonChp.getValue().intValue()));
-
 
653
			collectionBotaniqueCollectee.setUniteRangement(collecterGrilleUniteRangement());
-
 
654
			Debug.log(collecterGrilleUniteRangement());
-
 
655
		}
-
 
656
	}
-
 
657
 
-
 
658
	private void initialiserCollection() {
-
 
659
		collection = ((CollectionForm) formulaire).collection;
-
 
660
		if (collection != null) {
-
 
661
			collectionBotanique = collection.getBotanique();
-
 
662
		}
-
 
663
		
-
 
664
		collectionCollectee = ((CollectionForm) formulaire).collectionCollectee;
-
 
665
		if (collectionCollectee != null) {
-
 
666
			collectionBotaniqueCollectee = collectionCollectee.getBotanique();
-
 
667
		}
-
 
668
	}
550
	
669
	
551
	public void rafraichir(Object nouvellesDonnees) {
670
	public void rafraichir(Object nouvellesDonnees) {
552
		if (nouvellesDonnees instanceof ValeurListe) {
671
		if (nouvellesDonnees instanceof ValeurListe) {
553
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
672
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
554
			rafraichirValeurListe(listeValeurs);
673
			rafraichirValeurListe(listeValeurs);
555
		} else {
674
		} else {
556
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
675
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
557
		}
676
		}
558
	}
677
	}
559
	
678
	
560
	private void rafraichirValeurListe(ValeurListe listeValeurs) {
679
	private void rafraichirValeurListe(ValeurListe listeValeurs) {
561
		if (listeValeurs.getId().equals(config.getListeId("typeCollectionBota"))) {
680
		if (listeValeurs.getId().equals(config.getListeId("typeCollectionBota"))) {
562
			Formulaire.rafraichirComboBox(listeValeurs, typesCollectionBotaCombo);
681
			Formulaire.rafraichirComboBox(listeValeurs, typesCollectionBotaCombo);
563
		} else if (listeValeurs.getId().equals(config.getListeId("typeUniteRangement"))) {
682
		} else if (listeValeurs.getId().equals(config.getListeId("typeUniteRangement"))) {
564
			Iterator<String> it = listeValeurs.keySet().iterator();
683
			Iterator<String> it = listeValeurs.keySet().iterator();
565
			while (it.hasNext()) {
684
			while (it.hasNext()) {
566
				Valeur valeur = listeValeurs.get(it.next());
685
				Valeur valeur = listeValeurs.get(it.next());
567
				UniteRangement unite = new UniteRangement();
686
				UniteRangement unite = new UniteRangement();
-
 
687
				unite.setId(valeur.getId());
568
				unite.setType(valeur.getNom());
688
				unite.setType(valeur.getNom());
569
				unite.setTypeAutre(false);
689
				unite.setTypeAutre(false);
570
				uniteRangementGrille.getStore().add(unite);
690
				uniteRangementGrille.getStore().add(unite);
571
			}
691
			}
572
		} else if (listeValeurs.getId().equals(config.getListeId("typeUniteBase"))) {
692
		} else if (listeValeurs.getId().equals(config.getListeId("typeUniteBase"))) {
573
			Iterator<String> it = listeValeurs.keySet().iterator();
693
			Iterator<String> it = listeValeurs.keySet().iterator();
574
			while (it.hasNext()) {
694
			while (it.hasNext()) {
575
				Valeur valeur = listeValeurs.get(it.next());
695
				Valeur valeur = listeValeurs.get(it.next());
576
				UniteBase unite = new UniteBase();
696
				UniteBase unite = new UniteBase();
-
 
697
				unite.setId(valeur.getId());
577
				unite.setType(valeur.getNom());
698
				unite.setType(valeur.getNom());
578
				unite.setTypeAutre(false);
699
				unite.setTypeAutre(false);
579
				uniteBaseGrille.getStore().add(unite);
700
				uniteBaseGrille.getStore().add(unite);
580
			}
701
			}
581
		} else {
702
		} else {
582
			GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null);
703
			GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null);
583
		}
704
		}
584
	}
705
	}
585
}
706
}