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