Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1329 Rev 1367
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.List;
4
import java.util.List;
5
 
5
 
6
import org.tela_botanica.client.Mediateur;
6
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.composants.ChampComboBoxMultiSelect;
7
import org.tela_botanica.client.composants.ChampComboBoxMultiSelect;
8
import org.tela_botanica.client.composants.InfoLogger;
8
import org.tela_botanica.client.composants.InfoLogger;
9
import org.tela_botanica.client.images.Images;
9
import org.tela_botanica.client.images.Images;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.modeles.Information;
11
import org.tela_botanica.client.modeles.Information;
12
import org.tela_botanica.client.modeles.Valeur;
12
import org.tela_botanica.client.modeles.Valeur;
13
import org.tela_botanica.client.modeles.ValeurListe;
13
import org.tela_botanica.client.modeles.ValeurListe;
14
import org.tela_botanica.client.modeles.aDonnee;
14
import org.tela_botanica.client.modeles.aDonnee;
15
import org.tela_botanica.client.modeles.collection.Collection;
15
import org.tela_botanica.client.modeles.collection.Collection;
16
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
16
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
17
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe;
17
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe;
18
import org.tela_botanica.client.modeles.commentaire.Commentaire;
18
import org.tela_botanica.client.modeles.commentaire.Commentaire;
19
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
19
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
20
import org.tela_botanica.client.synchronisation.Sequenceur;
20
import org.tela_botanica.client.synchronisation.Sequenceur;
21
import org.tela_botanica.client.util.Debug;
21
import org.tela_botanica.client.util.Debug;
22
import org.tela_botanica.client.vues.FenetreForm;
22
import org.tela_botanica.client.vues.FenetreForm;
23
import org.tela_botanica.client.vues.Formulaire;
23
import org.tela_botanica.client.vues.Formulaire;
24
import org.tela_botanica.client.vues.FormulaireBarreValidation;
24
import org.tela_botanica.client.vues.FormulaireBarreValidation;
25
import org.tela_botanica.client.vues.FormulaireOnglet;
25
import org.tela_botanica.client.vues.FormulaireOnglet;
26
import org.tela_botanica.client.vues.commentaire.CommentaireForm;
26
import org.tela_botanica.client.vues.commentaire.CommentaireForm;
27
 
27
 
28
import com.extjs.gxt.ui.client.Style.SortDir;
28
import com.extjs.gxt.ui.client.Style.SortDir;
29
import com.extjs.gxt.ui.client.event.BaseEvent;
29
import com.extjs.gxt.ui.client.event.BaseEvent;
30
import com.extjs.gxt.ui.client.event.ButtonEvent;
30
import com.extjs.gxt.ui.client.event.ButtonEvent;
31
import com.extjs.gxt.ui.client.event.ComponentEvent;
31
import com.extjs.gxt.ui.client.event.ComponentEvent;
32
import com.extjs.gxt.ui.client.event.Events;
32
import com.extjs.gxt.ui.client.event.Events;
33
import com.extjs.gxt.ui.client.event.KeyListener;
33
import com.extjs.gxt.ui.client.event.KeyListener;
34
import com.extjs.gxt.ui.client.event.Listener;
34
import com.extjs.gxt.ui.client.event.Listener;
35
import com.extjs.gxt.ui.client.event.SelectionListener;
35
import com.extjs.gxt.ui.client.event.SelectionListener;
36
import com.extjs.gxt.ui.client.store.ListStore;
36
import com.extjs.gxt.ui.client.store.ListStore;
37
import com.extjs.gxt.ui.client.store.Store;
37
import com.extjs.gxt.ui.client.store.Store;
38
import com.extjs.gxt.ui.client.store.StoreEvent;
38
import com.extjs.gxt.ui.client.store.StoreEvent;
39
import com.extjs.gxt.ui.client.widget.ContentPanel;
39
import com.extjs.gxt.ui.client.widget.ContentPanel;
40
import com.extjs.gxt.ui.client.widget.Info;
40
import com.extjs.gxt.ui.client.widget.Info;
41
import com.extjs.gxt.ui.client.widget.Text;
41
import com.extjs.gxt.ui.client.widget.Text;
42
import com.extjs.gxt.ui.client.widget.button.Button;
42
import com.extjs.gxt.ui.client.widget.button.Button;
43
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
43
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
44
import com.extjs.gxt.ui.client.widget.form.ComboBox;
44
import com.extjs.gxt.ui.client.widget.form.ComboBox;
45
import com.extjs.gxt.ui.client.widget.form.FormPanel;
45
import com.extjs.gxt.ui.client.widget.form.FormPanel;
46
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
46
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
47
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
47
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
48
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
48
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
49
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
49
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
50
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
50
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
51
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
51
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
52
import com.extjs.gxt.ui.client.widget.grid.Grid;
52
import com.extjs.gxt.ui.client.widget.grid.Grid;
53
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
53
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
54
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
54
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
55
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
55
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
56
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
56
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
57
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
57
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
58
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
58
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
59
import com.google.gwt.core.client.GWT;
59
import com.google.gwt.core.client.GWT;
60
 
60
 
61
public class CollectionFormCommentaire extends FormulaireOnglet implements Rafraichissable {
61
public class CollectionFormCommentaire extends FormulaireOnglet implements Rafraichissable {
62
	
62
	
63
	public static final String ID = "commentaire";
63
	public static final String ID = "commentaire";
64
	private Collection collection = null;
64
	private Collection collection = null;
65
	private static int idGenere = 1;
65
	private static int idGenere = 1;
66
	
66
	
67
	private ContentPanel panneauPrincipal = null;
67
	private ContentPanel panneauPrincipal = null;
68
	private ToolBar barreOutils = null;
68
	private ToolBar barreOutils = null;
69
	private EditorGrid<CollectionACommentaire> grille;
69
	private EditorGrid<CollectionACommentaire> grille;
70
	private ChampComboBoxMultiSelect<Valeur> typeCombo = null;
70
	private ChampComboBoxMultiSelect<Valeur> typeCombo = null;
71
	
71
	
72
	private CollectionACommentaireListe commentairesAjoutes = null;
72
	private CollectionACommentaireListe commentairesAjoutes = null;
73
	private CollectionACommentaireListe commentairesModifies = null;
73
	private CollectionACommentaireListe commentairesModifies = null;
74
	private CollectionACommentaireListe commentairesSupprimes = null;
74
	private CollectionACommentaireListe commentairesSupprimes = null;
75
	private ComboBox<Commentaire> commentairesSaisisComboBox = null;
75
	private ComboBox<Commentaire> commentairesSaisisComboBox = null;
76
	private Button commentairesBoutonSupprimer = null;
76
	private Button commentairesBoutonSupprimer = null;
77
	private Button commentairesBoutonModifier = null;
77
	private Button commentairesBoutonModifier = null;
78
	
78
	
79
	private static boolean chargementTypesOk = false;
79
	private static boolean chargementTypesOk = false;
80
	private static boolean chargementCommentairesOk = false;
80
	private static boolean chargementCommentairesOk = false;
81
	
81
	
82
	private FenetreForm fenetreFormulaire = null;
82
	private FenetreForm fenetreFormulaire = null;
83
	private Sequenceur sequenceur;
83
	private Sequenceur sequenceur;
84
	
84
	
85
	public CollectionFormCommentaire(Formulaire formulaireCourrant) {
85
	public CollectionFormCommentaire(Formulaire formulaireCourrant) {
86
		initialiserOnglet(formulaireCourrant);
86
		initialiserOnglet(formulaireCourrant);
87
		setId(ID);
87
		setId(ID);
88
		setText(Mediateur.i18nC.collectionCommentaire());
88
		setText(Mediateur.i18nC.collectionCommentaire());
89
		setStyleAttribute("padding", "0");
89
		setStyleAttribute("padding", "0");
90
		
90
		
91
		panneauPrincipal = creerPanneauContenantGrille();
91
		panneauPrincipal = creerPanneauContenantGrille();
92
		barreOutils = creerBarreOutilsGrille();
92
		barreOutils = creerBarreOutilsGrille();
93
		panneauPrincipal.setTopComponent(barreOutils);
93
		panneauPrincipal.setTopComponent(barreOutils);
94
		grille = creerGrille();
94
		grille = creerGrille();
95
  		panneauPrincipal.add(grille);
95
  		panneauPrincipal.add(grille);
96
		
96
		
97
		mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection", null);
97
		mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection", null);
98
		add(panneauPrincipal);
98
		add(panneauPrincipal);
99
		
99
		
100
		initialiser();
100
		initialiser();
101
	}
101
	}
102
	
102
	
103
	private void initialiser() {
103
	private void initialiser() {
104
		// Remise à zéro des modification dans la liste des commentaires
104
		// Remise à zéro des modification dans la liste des commentaires
105
		initialiserGestionCommentaires();
105
		initialiserGestionCommentaires();
106
		
106
		
107
		// Actualisation de l'état des boutons de la barre d'outils
107
		// Actualisation de l'état des boutons de la barre d'outils
108
		actualiserEtatBoutonsBarreOutils();
108
		actualiserEtatBoutonsBarreOutils();
109
		
109
		
110
		collection = ((CollectionForm) formulaire).collection;
110
		collection = ((CollectionForm) formulaire).collection;
111
	}
111
	}
112
	
112
	
113
	private void initialiserGestionCommentaires() {
113
	private void initialiserGestionCommentaires() {
114
		idGenere = 1;
114
		idGenere = 1;
115
		commentairesAjoutes = new CollectionACommentaireListe();
115
		commentairesAjoutes = new CollectionACommentaireListe();
116
		commentairesModifies = new CollectionACommentaireListe();
116
		commentairesModifies = new CollectionACommentaireListe();
117
		commentairesSupprimes = new CollectionACommentaireListe();
117
		commentairesSupprimes = new CollectionACommentaireListe();
118
	}
118
	}
119
	
119
	
120
	private void initialiserChargement() {
120
	private void initialiserChargement() {
121
		chargementCommentairesOk = false;
121
		chargementCommentairesOk = false;
122
	}
122
	}
123
	
123
	
124
	private ContentPanel creerPanneauContenantGrille() {
124
	private ContentPanel creerPanneauContenantGrille() {
125
		ContentPanel panneau = new ContentPanel();
125
		ContentPanel panneau = new ContentPanel();
126
		
126
		
127
		panneau.setHeading(i18nC.collectionCommentaireTitre());
127
		panneau.setHeading(i18nC.collectionCommentaireTitre());
128
		panneau.setIcon(Images.ICONES.table());
128
		panneau.setIcon(Images.ICONES.table());
129
		panneau.setLayout(new FitLayout());
129
		panneau.setLayout(new FitLayout());
130
		panneau.setFrame(true);
130
		panneau.setFrame(true);
131
		
131
		
132
		return panneau;
132
		return panneau;
133
	}
133
	}
134
 
134
 
135
	private ToolBar creerBarreOutilsGrille() {
135
	private ToolBar creerBarreOutilsGrille() {
136
		ToolBar barreOutils = new ToolBar();  
136
		ToolBar barreOutils = new ToolBar();  
137
		
137
		
138
		Button ajouterPersonneBouton = creerBoutonAjouter();
138
		Button ajouterPersonneBouton = creerBoutonAjouter();
139
		barreOutils.add(ajouterPersonneBouton);
139
		barreOutils.add(ajouterPersonneBouton);
140
		
140
		
141
		barreOutils.add(new Text(" ou "));
141
		barreOutils.add(new Text(" ou "));
142
		
142
		
143
		commentairesSaisisComboBox = creerComboBoxCommentairesSaisies();
143
		commentairesSaisisComboBox = creerComboBoxCommentairesSaisies();
144
		barreOutils.add(commentairesSaisisComboBox);
144
		barreOutils.add(commentairesSaisisComboBox);
145
		
145
		
146
		barreOutils.add(new SeparatorToolItem());
146
		barreOutils.add(new SeparatorToolItem());
147
		
147
		
148
		commentairesBoutonModifier = creerBoutonModifier();
148
		commentairesBoutonModifier = creerBoutonModifier();
149
		barreOutils.add(commentairesBoutonModifier);
149
		barreOutils.add(commentairesBoutonModifier);
150
		
150
		
151
		barreOutils.add(new SeparatorToolItem());
151
		barreOutils.add(new SeparatorToolItem());
152
		
152
		
153
		commentairesBoutonSupprimer = creerBoutonSupprimer();
153
		commentairesBoutonSupprimer = creerBoutonSupprimer();
154
		barreOutils.add(commentairesBoutonSupprimer);		
154
		barreOutils.add(commentairesBoutonSupprimer);		
155
		
155
		
156
		barreOutils.add(new SeparatorToolItem());
156
		barreOutils.add(new SeparatorToolItem());
157
		
157
		
158
		Button rafraichirPersonneBouton = creerBoutonRafraichir();
158
		Button rafraichirPersonneBouton = creerBoutonRafraichir();
159
		barreOutils.add(rafraichirPersonneBouton);
159
		barreOutils.add(rafraichirPersonneBouton);
160
				
160
				
161
		return barreOutils;
161
		return barreOutils;
162
	}
162
	}
163
 
163
 
164
	private Button creerBoutonAjouter() {
164
	private Button creerBoutonAjouter() {
165
		Button bouton = new Button(i18nC.ajouter());
165
		Button bouton = new Button(i18nC.ajouter());
166
		bouton.setIcon(Images.ICONES.vcardAjouter());
166
		bouton.setIcon(Images.ICONES.vcardAjouter());
167
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
167
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
168
 
168
 
169
			@Override  
169
			@Override  
170
			public void componentSelected(ButtonEvent ce) {  
170
			public void componentSelected(ButtonEvent ce) {  
171
				fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_AJOUTER);
171
				fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_AJOUTER);
172
				fenetreFormulaire.show();
172
				fenetreFormulaire.show();
173
			}  
173
			}  
174
		});
174
		});
175
		return bouton;
175
		return bouton;
176
	}
176
	}
177
	
177
	
178
	private Button creerBoutonModifier() {
178
	private Button creerBoutonModifier() {
179
		Button bouton = new Button(i18nC.modifier());
179
		Button bouton = new Button(i18nC.modifier());
180
		bouton.setIcon(Images.ICONES.vcardModifier());
180
		bouton.setIcon(Images.ICONES.vcardModifier());
181
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
181
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
182
			@Override  
182
			@Override  
183
			public void componentSelected(ButtonEvent ce) {  
183
			public void componentSelected(ButtonEvent ce) {  
184
				CollectionACommentaire commentaireSaisiSelectionne = grille.getSelectionModel().getSelectedItem();
184
				CollectionACommentaire commentaireSaisiSelectionne = grille.getSelectionModel().getSelectedItem();
185
				if (commentaireSaisiSelectionne == null) {
185
				if (commentaireSaisiSelectionne == null) {
186
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire());
186
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire());
187
				} else {
187
				} else {
188
					fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_MODIFIER);
188
					fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_MODIFIER);
189
					fenetreFormulaire.show();
189
					fenetreFormulaire.show();
190
				}
190
				}
191
			}  
191
			}  
192
		});
192
		});
193
		return bouton;
193
		return bouton;
194
	}
194
	}
195
	
195
	
196
	private FenetreForm creerFenetreModaleAvecFormulaireCommentaire(String mode) {
196
	private FenetreForm creerFenetreModaleAvecFormulaireCommentaire(String mode) {
197
		String commentaireId = null;
197
		String commentaireId = null;
198
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
198
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
199
			CollectionACommentaire commentaierSaisieSelectionnee = grille.getSelectionModel().getSelectedItem();
199
			CollectionACommentaire commentaierSaisieSelectionnee = grille.getSelectionModel().getSelectedItem();
200
			commentaireId = commentaierSaisieSelectionnee.getIdCommentaire();
200
			commentaireId = commentaierSaisieSelectionnee.getIdCommentaire();
201
		}
201
		}
202
		
202
		
203
		final FenetreForm fenetre = new FenetreForm("");
203
		final FenetreForm fenetre = new FenetreForm("");
204
		final CommentaireForm formulaire = creerFormulaireCommentaire(fenetre, commentaireId);
204
		final CommentaireForm formulaire = creerFormulaireCommentaire(fenetre, commentaireId);
205
		fenetre.add(formulaire);
205
		fenetre.add(formulaire);
206
		return fenetre;
206
		return fenetre;
207
	}
207
	}
208
	
208
	
209
	private CommentaireForm creerFormulaireCommentaire(final FenetreForm fenetre, String commentaireId) {
209
	private CommentaireForm creerFormulaireCommentaire(final FenetreForm fenetre, String commentaireId) {
210
		CommentaireForm formulaire = new CommentaireForm(mediateur, commentaireId, this);
210
		CommentaireForm formulaire = new CommentaireForm(mediateur, commentaireId, this);
211
		FormPanel panneauFormulaire = formulaire.getFormulaire();
211
		FormPanel panneauFormulaire = formulaire.getFormulaire();
212
		fenetre.setHeading(panneauFormulaire.getHeading());
212
		fenetre.setHeading(panneauFormulaire.getHeading());
213
		panneauFormulaire.setHeaderVisible(false);
213
		panneauFormulaire.setHeaderVisible(false);
214
		panneauFormulaire.setTopComponent(null);
214
		panneauFormulaire.setTopComponent(null);
215
 
215
 
216
		// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
216
		// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
217
		panneauFormulaire.getBottomComponent().hide();
217
		panneauFormulaire.getBottomComponent().hide();
218
		SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulaireCommentaire(fenetre, formulaire);
218
		SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulaireCommentaire(fenetre, formulaire);
219
		final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
219
		final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
220
		fenetre.setBottomComponent(barreValidation);
220
		fenetre.setBottomComponent(barreValidation);
221
		
221
		
222
		return formulaire;
222
		return formulaire;
223
	}
223
	}
224
	
224
	
225
	private SelectionListener<ButtonEvent> creerEcouteurValidationFormulaireCommentaire(final FenetreForm fenetre, final CommentaireForm formulaire) {
225
	private SelectionListener<ButtonEvent> creerEcouteurValidationFormulaireCommentaire(final FenetreForm fenetre, final CommentaireForm formulaire) {
226
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
226
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
227
			@Override
227
			@Override
228
			public void componentSelected(ButtonEvent ce) {
228
			public void componentSelected(ButtonEvent ce) {
229
				String code = ((Button) ce.getComponent()).getData("code");
229
				String code = ((Button) ce.getComponent()).getData("code");
230
				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
230
				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
231
					if (formulaire.soumettreFormulaire()) {
231
					if (formulaire.soumettreFormulaire()) {
232
						fenetre.hide();
232
						fenetre.hide();
233
					}
233
					}
234
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
234
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
235
					formulaire.soumettreFormulaire();
235
					formulaire.soumettreFormulaire();
236
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
236
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
237
					fenetre.hide();
237
					fenetre.hide();
238
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
238
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
239
					fenetreFormulaire.hide();
239
					fenetreFormulaire.hide();
240
					fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(formulaire.mode);
240
					fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(formulaire.mode);
241
					fenetreFormulaire.show();
241
					fenetreFormulaire.show();
242
				}
242
				}
243
			}
243
			}
244
		};
244
		};
245
		
245
		
246
		return ecouteur;
246
		return ecouteur;
247
	}
247
	}
248
	
248
	
249
	private Button creerBoutonSupprimer() {
249
	private Button creerBoutonSupprimer() {
250
		Button bouton = new Button(i18nC.supprimer());
250
		Button bouton = new Button(i18nC.supprimer());
251
		bouton.setIcon(Images.ICONES.vcardSupprimer());
251
		bouton.setIcon(Images.ICONES.vcardSupprimer());
252
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
252
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
253
			public void componentSelected(ButtonEvent ce) {
253
			public void componentSelected(ButtonEvent ce) {
254
				CollectionACommentaire commentaireSaisiSelectionnee = grille.getSelectionModel().getSelectedItem();
254
				CollectionACommentaire commentaireSaisiSelectionnee = grille.getSelectionModel().getSelectedItem();
255
				if (commentaireSaisiSelectionnee == null) {
255
				if (commentaireSaisiSelectionnee == null) {
256
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire());
256
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire());
257
				} else {
257
				} else {
258
					supprimerDansGrille(commentaireSaisiSelectionnee);
258
					supprimerDansGrille(commentaireSaisiSelectionnee);
259
				}
259
				}
260
			}   
260
			}   
261
		});
261
		});
262
		return bouton;
262
		return bouton;
263
	}
263
	}
264
	
264
	
265
	private Button creerBoutonRafraichir() {
265
	private Button creerBoutonRafraichir() {
266
		Button bouton = new Button(i18nC.rafraichir());
266
		Button bouton = new Button(i18nC.rafraichir());
267
		bouton.setIcon(Images.ICONES.rafraichir());
267
		bouton.setIcon(Images.ICONES.rafraichir());
268
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
268
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
269
			public void componentSelected(ButtonEvent ce) {
269
			public void componentSelected(ButtonEvent ce) {
270
				actualiserGrille();
270
				actualiserGrille();
271
			}   
271
			}   
272
		});
272
		});
273
		return bouton;
273
		return bouton;
274
	}
274
	}
275
	
275
	
276
	private ComboBox<Commentaire> creerComboBoxCommentairesSaisies() {
276
	private ComboBox<Commentaire> creerComboBoxCommentairesSaisies() {
277
		ListStore<Commentaire> commentairesSaisiesStore = new ListStore<Commentaire>();
277
		ListStore<Commentaire> commentairesSaisiesStore = new ListStore<Commentaire>();
278
		commentairesSaisiesStore.add(new ArrayList<Commentaire>());
278
		commentairesSaisiesStore.add(new ArrayList<Commentaire>());
279
		
279
		
280
		ComboBox<Commentaire> comboBox = new ComboBox<Commentaire>();
280
		ComboBox<Commentaire> comboBox = new ComboBox<Commentaire>();
281
		comboBox.setWidth(200);
281
		comboBox.setWidth(200);
282
		comboBox.setEmptyText(i18nC.chercherCommentaireSaisi());
282
		comboBox.setEmptyText(i18nC.chercherCommentaireSaisi());
283
		comboBox.setTriggerAction(TriggerAction.ALL);  
283
		comboBox.setTriggerAction(TriggerAction.ALL);  
284
		comboBox.setEditable(true);
284
		comboBox.setEditable(true);
285
		comboBox.setDisplayField("titre");
285
		comboBox.setDisplayField("titre");
286
		comboBox.setStore(commentairesSaisiesStore);
286
		comboBox.setStore(commentairesSaisiesStore);
287
		comboBox.addKeyListener(new KeyListener() {
287
		comboBox.addKeyListener(new KeyListener() {
288
			public void componentKeyUp(ComponentEvent ce) {
288
			public void componentKeyUp(ComponentEvent ce) {
289
				if (commentairesSaisisComboBox.getRawValue() != null && commentairesSaisisComboBox.getRawValue().length() > 0) {
289
				if (commentairesSaisisComboBox.getRawValue() != null && commentairesSaisisComboBox.getRawValue().length() > 0) {
290
					if (!ce.isNavKeyPress()) {
290
					if (!ce.isNavKeyPress()) {
291
						obtenirCommentairesSaisis(commentairesSaisisComboBox.getRawValue());
291
						obtenirCommentairesSaisis(commentairesSaisisComboBox.getRawValue());
292
					}
292
					}
293
				}
293
				}
294
			}
294
			}
295
		});
295
		});
296
		comboBox.addListener(Events.Select, new Listener<BaseEvent>() {
296
		comboBox.addListener(Events.Select, new Listener<BaseEvent>() {
297
			public void handleEvent(BaseEvent be) {
297
			public void handleEvent(BaseEvent be) {
298
				if (commentairesSaisisComboBox.getValue() instanceof Commentaire) {
298
				if (commentairesSaisisComboBox.getValue() instanceof Commentaire) {
299
					Commentaire commentaireSaisiSelectionnee = commentairesSaisisComboBox.getValue();
299
					Commentaire commentaireSaisiSelectionnee = commentairesSaisisComboBox.getValue();
300
					ajouterDansGrille(commentaireSaisiSelectionnee);
300
					ajouterDansGrille(commentaireSaisiSelectionnee);
301
					commentairesSaisisComboBox.setValue(null);
301
					commentairesSaisisComboBox.setValue(null);
302
				}
302
				}
303
			}
303
			}
304
		});
304
		});
305
		return comboBox;
305
		return comboBox;
306
	}
306
	}
307
	
307
	
308
	private void ajouterDansGrille(Commentaire commentaire) {
308
	private void ajouterDansGrille(Commentaire commentaire) {
309
		ajouterDansGrille(commentaire, null, 0);
309
		ajouterDansGrille(commentaire, null, 0);
310
	}
310
	}
311
	
311
	
312
	private void ajouterDansGrille(Commentaire commentaire, String type, int index) {
312
	private void ajouterDansGrille(Commentaire commentaire, String type, int index) {
313
		if (commentaire != null) {
313
		if (commentaire != null) {
314
			CollectionACommentaire relationCollectionACommentaire = new CollectionACommentaire();
314
			CollectionACommentaire relationCollectionACommentaire = new CollectionACommentaire();
315
			relationCollectionACommentaire.setCommentaire(commentaire);
315
			relationCollectionACommentaire.setCommentaire(commentaire);
316
			relationCollectionACommentaire.setIdCommentaire(commentaire.getId());
316
			relationCollectionACommentaire.setIdCommentaire(commentaire.getId());
317
			if (type != null) {
317
			if (type != null) {
318
				relationCollectionACommentaire.set("_type_", type);
318
				relationCollectionACommentaire.set("_type_", type);
319
			}
319
			}
320
			// Gestion de l'id de la collection
320
			// Gestion de l'id de la collection
321
			if (mode.equals(Formulaire.MODE_MODIFIER)) {
321
			if (mode.equals(Formulaire.MODE_MODIFIER)) {
322
				relationCollectionACommentaire.setIdCollection(collection.getId());
322
				relationCollectionACommentaire.setIdCollection(collection.getId());
323
			}
323
			}
324
			relationCollectionACommentaire.set("_etat_", aDonnee.ETAT_AJOUTE);
324
			relationCollectionACommentaire.set("_etat_", aDonnee.ETAT_AJOUTE);
325
			corrigerChampsGrille(relationCollectionACommentaire);
325
			corrigerChampsGrille(relationCollectionACommentaire);
326
			
326
			
327
			// Ajout à la grille
327
			// Ajout à la grille
328
			grille.stopEditing();
328
			grille.stopEditing();
329
			grille.getStore().insert(relationCollectionACommentaire, index);
329
			grille.getStore().insert(relationCollectionACommentaire, index);
330
			grille.startEditing(index, 0);
330
			grille.startEditing(index, 0);
331
			grille.getSelectionModel().select(index, false);
331
			grille.getSelectionModel().select(index, false);
332
		}
332
		}
333
	}
333
	}
334
	
334
	
335
	private void supprimerDansGrille(CollectionACommentaire relationCollectionACommentaire) {
335
	private void supprimerDansGrille(CollectionACommentaire relationCollectionACommentaire) {
336
		if (relationCollectionACommentaire != null) {
336
		if (relationCollectionACommentaire != null) {
337
			// Ajout de la personne supprimée à la liste
337
			// Ajout de la personne supprimée à la liste
338
			if ((relationCollectionACommentaire.get("_etat_").equals("") || !relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) 
338
			if ((relationCollectionACommentaire.get("_etat_").equals("") || !relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) 
339
					&& relationCollectionACommentaire.getId() != null 
339
					&& relationCollectionACommentaire.getId() != null 
340
					&& !relationCollectionACommentaire.getId().equals("")) {
340
					&& !relationCollectionACommentaire.getId().equals("")) {
341
				commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire);
341
				commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire);
342
			}
342
			}
343
			
343
			
344
			// Suppression de l'enregistrement de la grille
344
			// Suppression de l'enregistrement de la grille
345
			grille.getStore().remove(relationCollectionACommentaire);			
345
			grille.getStore().remove(relationCollectionACommentaire);			
346
		}
346
		}
347
	}
347
	}
348
 
348
 
349
	private EditorGrid<CollectionACommentaire> creerGrille() {
349
	private EditorGrid<CollectionACommentaire> creerGrille() {
350
		ListStore<CollectionACommentaire> storeGrille = new ListStore<CollectionACommentaire>();
350
		ListStore<CollectionACommentaire> storeGrille = new ListStore<CollectionACommentaire>();
351
		storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionACommentaire>>() {
351
		storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionACommentaire>>() {
352
			public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
352
			public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
353
				actualiserEtatBoutonsBarreOutils();
353
				actualiserEtatBoutonsBarreOutils();
354
			}
354
			}
355
		});
355
		});
356
		storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionACommentaire>>() {
356
		storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionACommentaire>>() {
357
			public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
357
			public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
358
				actualiserEtatBoutonsBarreOutils();
358
				actualiserEtatBoutonsBarreOutils();
359
			}
359
			}
360
		});
360
		});
361
		storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionACommentaire>>() {
361
		storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionACommentaire>>() {
362
			public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
362
			public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
363
				if (ce.getRecord().isModified("_type_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
363
				if (ce.getRecord().isModified("_type_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
364
					ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
364
					ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
365
				}
365
				}
366
			}
366
			}
367
		});
367
		});
368
		
368
		
369
		RowNumberer pluginLigneNumero = new RowNumberer();
369
		RowNumberer pluginLigneNumero = new RowNumberer();
370
		
370
		
371
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
371
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
372
		colonnes.add(pluginLigneNumero);
372
		colonnes.add(pluginLigneNumero);
373
		
373
		
374
		colonnes.add(creerColonneType());
374
		colonnes.add(creerColonneType());
375
		colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150));
375
		colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150));
376
		colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75));
376
		colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75));
377
		colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35));
377
		colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35));
378
		colonnes.add(creerColonneAcces());
378
		colonnes.add(creerColonneAcces());
379
		
379
		
380
		GridSelectionModel<CollectionACommentaire> modeleDeSelection = new GridSelectionModel<CollectionACommentaire>();
380
		GridSelectionModel<CollectionACommentaire> modeleDeSelection = new GridSelectionModel<CollectionACommentaire>();
381
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
381
		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
382
		
382
		
383
		EditorGrid<CollectionACommentaire> grille = new EditorGrid<CollectionACommentaire>(storeGrille, modeleDeColonnes);
383
		EditorGrid<CollectionACommentaire> grille = new EditorGrid<CollectionACommentaire>(storeGrille, modeleDeColonnes);
384
		grille.setHeight("100%");
384
		grille.setHeight("100%");
385
		grille.setBorders(true);
385
		grille.setBorders(true);
386
		grille.setSelectionModel(modeleDeSelection);
386
		grille.setSelectionModel(modeleDeSelection);
387
		grille.addPlugin(pluginLigneNumero);
387
		grille.addPlugin(pluginLigneNumero);
388
		grille.getView().setForceFit(true);
388
		grille.getView().setForceFit(true);
389
		grille.setAutoExpandColumn("_titre_");
389
		grille.setAutoExpandColumn("_titre_");
390
		grille.setStripeRows(true);
390
		grille.setStripeRows(true);
391
		grille.setTrackMouseOver(true);
391
		grille.setTrackMouseOver(true);
392
		
392
		
393
		return grille;
393
		return grille;
394
	}
394
	}
395
	
395
	
396
	private ColumnConfig creerColonneType() {
396
	private ColumnConfig creerColonneType() {
397
		typeCombo = new ChampComboBoxMultiSelect<Valeur>();
397
		typeCombo = new ChampComboBoxMultiSelect<Valeur>();
398
		typeCombo.setDisplayField("nom");
398
		typeCombo.setDisplayField("nom");
399
		typeCombo.setValueField("id_valeur");
399
		typeCombo.setValueField("id_valeur");
400
		typeCombo.setStore(new ListStore<Valeur>());
400
		typeCombo.setStore(new ListStore<Valeur>());
401
		typeCombo.setEditable(false);
401
		typeCombo.setEditable(false);
402
		typeCombo.setForceSelection(true);
402
		typeCombo.setForceSelection(true);
403
		
403
		
404
		CellEditor typeEditeur = new CellEditor(typeCombo) {  
404
		CellEditor typeEditeur = new CellEditor(typeCombo) {  
405
			@SuppressWarnings("unchecked")
405
			@SuppressWarnings("unchecked")
406
			@Override  
406
			@Override  
407
			public Object preProcessValue(Object valeur) {  
407
			public Object preProcessValue(Object valeur) {  
408
				Valeur retour = new Valeur();
408
				Valeur retour = new Valeur();
409
				if (valeur != null ) {
409
				if (valeur != null ) {
410
					if (valeur instanceof String) {
410
					if (valeur instanceof String) {
411
						((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString());
411
						((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString());
412
					}
412
					}
413
				}
413
				}
414
				return retour;
414
				return retour;
415
			}  
415
			}  
416
 
416
 
417
			@Override  
417
			@Override  
418
			public Object postProcessValue(Object valeur) {  
418
			public Object postProcessValue(Object valeur) {  
419
				String retour = null;
419
				String retour = null;
420
				if (getField().getRawValue() != null ) {
420
				if (getField().getRawValue() != null ) {
421
					retour = getField().getRawValue();
421
					retour = getField().getRawValue();
422
				}
422
				}
423
				return retour;  
423
				return retour;  
424
			}  
424
			}  
425
		};
425
		};
426
 
426
 
427
		GridCellRenderer<CollectionACommentaire> typeRendu = new GridCellRenderer<CollectionACommentaire>() {
427
		GridCellRenderer<CollectionACommentaire> typeRendu = new GridCellRenderer<CollectionACommentaire>() {
428
			public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) {
428
			public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) {
429
				String type = model.get("_type_");
429
				String type = model.get("_type_");
430
				if (typeCombo.getStore() != null && type != null && (type.matches("[0-9]+") || type.contains(aDonnee.SEPARATEUR_VALEURS))) {
430
				if (typeCombo.getStore() != null && type != null && (type.matches("[0-9]+") || type.contains(aDonnee.SEPARATEUR_VALEURS))) {
431
					type = typeCombo.formaterIdentifiantsEnTexte(type);
431
					type = typeCombo.formaterIdentifiantsEnTexte(type);
432
					model.set("_type_", type);
432
					model.set("_type_", type);
433
				}
433
				}
434
				return type;
434
				return type;
435
			}
435
			}
436
		};
436
		};
437
		ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100);
437
		ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100);
438
		typeColonne.setEditor(typeEditeur);
438
		typeColonne.setEditor(typeEditeur);
439
		typeColonne.setRenderer(typeRendu);
439
		typeColonne.setRenderer(typeRendu);
440
		return typeColonne;
440
		return typeColonne;
441
	}
441
	}
442
	
442
	
443
	private ColumnConfig creerColonneAcces() {
443
	private ColumnConfig creerColonneAcces() {
444
		GridCellRenderer<CollectionACommentaire> accesRendu = new GridCellRenderer<CollectionACommentaire>() {
444
		GridCellRenderer<CollectionACommentaire> accesRendu = new GridCellRenderer<CollectionACommentaire>() {
445
			public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) {
445
			public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) {
446
				String acces = (model.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
446
				String acces = (model.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
447
				model.set("_public_", acces);
447
				model.set("_public_", acces);
448
				return acces;
448
				return acces;
449
			}
449
			}
450
		};
450
		};
451
		ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30);
451
		ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30);
452
		accesColonne.setRenderer(accesRendu);
452
		accesColonne.setRenderer(accesRendu);
453
		return accesColonne;
453
		return accesColonne;
454
	}
454
	}
455
	
455
	
456
	public void actualiserEtatBoutonsBarreOutils() {
456
	public void actualiserEtatBoutonsBarreOutils() {
457
		// Activation des boutons si la grille contient un élément
457
		// Activation des boutons si la grille contient un élément
458
		if (grille.getStore().getCount() > 0) {  
458
		if (grille.getStore().getCount() > 0) {  
459
			commentairesBoutonSupprimer.enable();
459
			commentairesBoutonSupprimer.enable();
460
			commentairesBoutonModifier.enable();
460
			commentairesBoutonModifier.enable();
461
		}
461
		}
462
		// Désactivation des boutons si la grille ne contient plus d'élément
462
		// Désactivation des boutons si la grille ne contient plus d'élément
463
		if (grille.getStore().getCount() == 0) {  
463
		if (grille.getStore().getCount() == 0) {  
464
			commentairesBoutonSupprimer.disable();
464
			commentairesBoutonSupprimer.disable();
465
			commentairesBoutonModifier.disable();
465
			commentairesBoutonModifier.disable();
466
		}
466
		}
467
	}
467
	}
468
	
468
	
469
	public void rafraichir(Object nouvellesDonnees) {
469
	public void rafraichir(Object nouvellesDonnees) {
470
		if (nouvellesDonnees instanceof ValeurListe) {
470
		if (nouvellesDonnees instanceof ValeurListe) {
471
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
471
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
472
			rafraichirValeurListe(listeValeurs);
472
			rafraichirValeurListe(listeValeurs);
473
		} else if (nouvellesDonnees instanceof Information) {
473
		} else if (nouvellesDonnees instanceof Information) {
474
			Information info = (Information) nouvellesDonnees;
474
			Information info = (Information) nouvellesDonnees;
475
			rafraichirInformation(info);
475
			rafraichirInformation(info);
476
		} else if (nouvellesDonnees instanceof CommentaireListe) {
476
		} else if (nouvellesDonnees instanceof CommentaireListe) {
477
			CommentaireListe listeCommentaires = (CommentaireListe) nouvellesDonnees;
477
			CommentaireListe listeCommentaires = (CommentaireListe) nouvellesDonnees;
478
			rafraichirCommentairesListe(listeCommentaires);
478
			rafraichirCommentairesListe(listeCommentaires);
479
		} else {
479
		} else {
480
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
480
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
481
		}
481
		}
482
		
482
		
483
		if (chargementTypesOk && chargementCommentairesOk) {
483
		if (chargementTypesOk && chargementCommentairesOk) {
484
			peupler();
484
			peupler();
485
			initialiserChargement();
485
			initialiserChargement();
486
		}
486
		}
487
	}
487
	}
488
	
488
	
489
	private void rafraichirValeurListe(ValeurListe listeValeurs) {
489
	private void rafraichirValeurListe(ValeurListe listeValeurs) {
490
		if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) {
490
		if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) {
491
			List<Valeur> liste = listeValeurs.toList();
491
			List<Valeur> liste = listeValeurs.toList();
492
			if (liste.size() > 0) {
492
			if (liste.size() > 0) {
493
				ListStore<Valeur> store = typeCombo.getStore();
493
				ListStore<Valeur> store = typeCombo.getStore();
494
				store.removeAll();
494
				store.removeAll();
495
				store.add(liste);
495
				store.add(liste);
496
				store.sort("nom", SortDir.ASC);
496
				store.sort("nom", SortDir.ASC);
497
				typeCombo.setStore(store);
497
				typeCombo.setStore(store);
498
			}
498
			}
499
			chargementTypesOk = true;
499
			chargementTypesOk = true;
500
		} else {
500
		} else {
501
			GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null);
501
			GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null);
502
		}
502
		}
503
	}
503
	}
504
	
504
	
505
	public void rafraichirInformation(Information info) {
505
	public void rafraichirInformation(Information info) {
506
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
506
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
507
			GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
507
			GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
508
		}
508
		}
509
		String type = info.getType();
509
		String type = info.getType();
510
		if (info.getType().equals("liste_collection_a_commentaire")) {
510
		if (info.getType().equals("liste_collection_a_commentaire")) {
511
			if (info.getDonnee(0) != null) {
511
			if (info.getDonnee(0) != null) {
512
				initialiser();
512
				initialiser();
513
				collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0));
513
				collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0));
514
				chargementCommentairesOk = true;
514
				chargementCommentairesOk = true;
515
			}
515
			}
516
		} else if (info.getType().equals("ajout_collection")) {
516
		} else if (info.getType().equals("ajout_collection")) {
517
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
517
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
518
				String collectionId = (String) info.getDonnee(0);
518
				String collectionId = (String) info.getDonnee(0);
519
				
519
				
520
				// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées
520
				// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées
521
				// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées
521
				// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées
522
				mediateur.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes);
522
				mediateur.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes);
523
			}
523
			}
524
		} else if (type.equals("commentaire_modifiee")) {
524
		} else if (type.equals("commentaire_modifiee")) {
525
			if (info.getDonnee(0) != null) {
525
			if (info.getDonnee(0) != null) {
526
				Commentaire commentaire = (Commentaire) info.getDonnee(0);
526
				Commentaire commentaire = (Commentaire) info.getDonnee(0);
527
				CollectionACommentaire commentaireDansGrille = grille.getStore().findModel("id_commentaire", commentaire.getId());
527
				CollectionACommentaire commentaireDansGrille = grille.getStore().findModel("id_commentaire", commentaire.getId());
528
				int index = grille.getStore().indexOf(commentaireDansGrille);
528
				int index = grille.getStore().indexOf(commentaireDansGrille);
529
				grille.getStore().remove(commentaireDansGrille);
529
				grille.getStore().remove(commentaireDansGrille);
530
				String typeCommentaire = (String) commentaireDansGrille.get("_type_");
530
				String typeCommentaire = (String) commentaireDansGrille.get("_type_");
531
				ajouterDansGrille(commentaire, typeCommentaire, index);
531
				ajouterDansGrille(commentaire, typeCommentaire, index);
532
			}
532
			}
533
		} else if (type.equals("commentaire_ajoutee")) {
533
		} else if (type.equals("commentaire_ajoutee")) {
534
			if (info.getDonnee(0) != null) {
534
			if (info.getDonnee(0) != null) {
535
				Commentaire commentaire = (Commentaire) info.getDonnee(0);
535
				Commentaire commentaire = (Commentaire) info.getDonnee(0);
536
				ajouterDansGrille(commentaire);
536
				ajouterDansGrille(commentaire);
537
			}
537
			}
538
		} else if (info.getType().equals("modif_collection_a_commentaire")) {
538
		} else if (info.getType().equals("modif_collection_a_commentaire")) {
539
			InfoLogger.display("Modification des notes liées à la collection", info.toString());
539
			InfoLogger.display("Modification des notes liées à la collection", info.toString());
540
			initialiserGestionCommentaires();
540
			initialiserGestionCommentaires();
541
		} else if (info.getType().equals("suppression_collection_a_commentaire")) {
541
		} else if (info.getType().equals("suppression_collection_a_commentaire")) {
542
			InfoLogger.display("Suppression des notes liées à la collection", info.toString());
542
			InfoLogger.display("Suppression des notes liées à la collection", info.toString());
543
			initialiserGestionCommentaires();
543
			initialiserGestionCommentaires();
544
		} else if (info.getType().equals("ajout_collection_a_commentaire")) {
544
		} else if (info.getType().equals("ajout_collection_a_commentaire")) {
545
			InfoLogger.display("Ajout des notes liées à la collection", info.toString());
545
			InfoLogger.display("Ajout des notes liées à la collection", info.toString());
546
			initialiserGestionCommentaires();
546
			initialiserGestionCommentaires();
547
		}
547
		}
548
	}
548
	}
549
	
549
	
550
	private void rafraichirCommentairesListe(CommentaireListe listeCommentaires) {
550
	private void rafraichirCommentairesListe(CommentaireListe listeCommentaires) {
551
		commentairesSaisisComboBox.getStore().removeAll();
551
		commentairesSaisisComboBox.getStore().removeAll();
552
		commentairesSaisisComboBox.getStore().add(listeCommentaires.toList());
552
		commentairesSaisisComboBox.getStore().add(listeCommentaires.toList());
553
		commentairesSaisisComboBox.expand();
553
		commentairesSaisisComboBox.expand();
554
	}
554
	}
555
	
555
	
556
	public void peupler() {
556
	public void peupler() {
557
		grille.getStore().removeAll();
557
		grille.getStore().removeAll();
558
		grille.getStore().add(collection.getCommentairesLiees().toList());
558
		grille.getStore().add(collection.getCommentairesLiees().toList());
559
		grille.recalculate();
559
		grille.recalculate();
560
		layout();
560
		layout();
561
		InfoLogger.display(i18nC.chargementCommentaire(), i18nC.ok());
561
		InfoLogger.display(i18nC.chargementCommentaire(), i18nC.ok());
562
	}
562
	}
563
	
563
	
564
	public void collecter() {
564
	public void collecter() {
565
		if (etreAccede()) {
565
		if (etreAccede()) {
566
			int nbreCommentaire = grille.getStore().getCount();
566
			int nbreCommentaire = grille.getStore().getCount();
567
			for (int i = 0; i < nbreCommentaire; i++) {
567
			for (int i = 0; i < nbreCommentaire; i++) {
568
				CollectionACommentaire relationCollectionACommentaire = grille.getStore().getAt(i);
568
				CollectionACommentaire relationCollectionACommentaire = grille.getStore().getAt(i);
569
				if (relationCollectionACommentaire.get("_etat_") != null) {
569
				if (relationCollectionACommentaire.get("_etat_") != null) {
570
					if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
570
					if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
571
						corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
571
						corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
572
						commentairesModifies.put("id"+idGenere++, relationCollectionACommentaire);
572
						commentairesModifies.put("id"+idGenere++, relationCollectionACommentaire);
573
					} 
573
					} 
574
					if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
574
					if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
575
						corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
575
						corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
576
						commentairesAjoutes.put("id"+idGenere++, relationCollectionACommentaire);
576
						commentairesAjoutes.put("id"+idGenere++, relationCollectionACommentaire);
577
					}
577
					}
578
					// Initialisation de la grille
578
					// Initialisation de la grille
579
					relationCollectionACommentaire.set("_etat_", "");
579
					relationCollectionACommentaire.set("_etat_", "");
580
				}
580
				}
581
			}
581
			}
582
			grille.getStore().commitChanges();
582
			grille.getStore().commitChanges();
583
		}
583
		}
584
	}
584
	}
585
	
585
	
586
	private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) {
586
	private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) {
587
		String type = relationCollectionACommentaire.get("_type_");
587
		String type = relationCollectionACommentaire.get("_type_");
588
		relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type));
588
		relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type));
589
	}
589
	}
590
 
590
 
591
	public void soumettre() {
591
	public void soumettre() {
592
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
592
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
593
			if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) {
593
			if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) {
594
				InfoLogger.display("Modification des notes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
594
				InfoLogger.display("Modification des notes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
595
			} else {
595
			} else {
596
				mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes);
596
				mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes);
597
				mediateur.modifierCollectionACommentaire(this, commentairesModifies);
597
				mediateur.modifierCollectionACommentaire(this, commentairesModifies);
598
				mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes);
598
				mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes);
599
			}
599
			}
600
		}
600
		}
601
	}
601
	}
602
	
602
	
603
	private void obtenirCommentairesSaisis(String titre) {
603
	private void obtenirCommentairesSaisis(String titre) {
604
		mediateur.selectionnerCommentaireParTitre(this, titre+"%"); 
604
		mediateur.selectionnerCommentaireParTitre(this, titre+"%", null); 
605
	}
605
	}
606
	
606
	
607
	private void actualiserGrille() {
607
	private void actualiserGrille() {
608
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
608
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
609
			mediateur.selectionnerCollectionACommentaire(this, collection.getId());
609
			mediateur.selectionnerCollectionACommentaire(this, collection.getId(), null);
610
		} else {
610
		} else {
611
			grille.getStore().removeAll();
611
			grille.getStore().removeAll();
612
			layout();
612
			layout();
613
		}
613
		}
614
	}
614
	}
615
}
615
}