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 |
Debug.log("Nbre commentaires supprimées avant:"+commentairesSupprimes.size());
|
- |
|
342 |
commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire);
|
341 |
commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire);
|
343 |
Debug.log("Commentaires supprimées : "+relationCollectionACommentaire.getCommentaire().getId());
|
- |
|
344 |
Debug.log("Nbre commentaires supprimées :"+commentairesSupprimes.size());
|
- |
|
345 |
}
|
342 |
}
|
346 |
|
343 |
|
347 |
// Suppression de l'enregistrement de la grille
|
344 |
// Suppression de l'enregistrement de la grille
|
348 |
grille.getStore().remove(relationCollectionACommentaire);
|
345 |
grille.getStore().remove(relationCollectionACommentaire);
|
349 |
}
|
346 |
}
|
350 |
}
|
347 |
}
|
351 |
|
348 |
|
352 |
private EditorGrid<CollectionACommentaire> creerGrille() {
|
349 |
private EditorGrid<CollectionACommentaire> creerGrille() {
|
353 |
ListStore<CollectionACommentaire> storeGrille = new ListStore<CollectionACommentaire>();
|
350 |
ListStore<CollectionACommentaire> storeGrille = new ListStore<CollectionACommentaire>();
|
354 |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionACommentaire>>() {
|
351 |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionACommentaire>>() {
|
355 |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
|
352 |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
|
356 |
actualiserEtatBoutonsBarreOutils();
|
353 |
actualiserEtatBoutonsBarreOutils();
|
357 |
}
|
354 |
}
|
358 |
});
|
355 |
});
|
359 |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionACommentaire>>() {
|
356 |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionACommentaire>>() {
|
360 |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
|
357 |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
|
361 |
actualiserEtatBoutonsBarreOutils();
|
358 |
actualiserEtatBoutonsBarreOutils();
|
362 |
}
|
359 |
}
|
363 |
});
|
360 |
});
|
364 |
storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionACommentaire>>() {
|
361 |
storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionACommentaire>>() {
|
365 |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
|
362 |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) {
|
366 |
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)) {
|
367 |
Debug.log("id type modifié : "+ce.getModel().get("_type_"));
|
- |
|
368 |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
|
364 |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
|
369 |
}
|
365 |
}
|
370 |
}
|
366 |
}
|
371 |
});
|
367 |
});
|
372 |
|
368 |
|
373 |
RowNumberer pluginLigneNumero = new RowNumberer();
|
369 |
RowNumberer pluginLigneNumero = new RowNumberer();
|
374 |
|
370 |
|
375 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
371 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
376 |
colonnes.add(pluginLigneNumero);
|
372 |
colonnes.add(pluginLigneNumero);
|
377 |
|
373 |
|
378 |
colonnes.add(creerColonneType());
|
374 |
colonnes.add(creerColonneType());
|
379 |
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150));
|
375 |
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150));
|
380 |
colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75));
|
376 |
colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75));
|
381 |
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35));
|
377 |
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35));
|
382 |
colonnes.add(creerColonneAcces());
|
378 |
colonnes.add(creerColonneAcces());
|
383 |
|
379 |
|
384 |
GridSelectionModel<CollectionACommentaire> modeleDeSelection = new GridSelectionModel<CollectionACommentaire>();
|
380 |
GridSelectionModel<CollectionACommentaire> modeleDeSelection = new GridSelectionModel<CollectionACommentaire>();
|
385 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
381 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
386 |
|
382 |
|
387 |
EditorGrid<CollectionACommentaire> grille = new EditorGrid<CollectionACommentaire>(storeGrille, modeleDeColonnes);
|
383 |
EditorGrid<CollectionACommentaire> grille = new EditorGrid<CollectionACommentaire>(storeGrille, modeleDeColonnes);
|
388 |
grille.setHeight("100%");
|
384 |
grille.setHeight("100%");
|
389 |
grille.setBorders(true);
|
385 |
grille.setBorders(true);
|
390 |
grille.setSelectionModel(modeleDeSelection);
|
386 |
grille.setSelectionModel(modeleDeSelection);
|
391 |
grille.addPlugin(pluginLigneNumero);
|
387 |
grille.addPlugin(pluginLigneNumero);
|
392 |
grille.getView().setForceFit(true);
|
388 |
grille.getView().setForceFit(true);
|
393 |
grille.setAutoExpandColumn("_titre_");
|
389 |
grille.setAutoExpandColumn("_titre_");
|
394 |
grille.setStripeRows(true);
|
390 |
grille.setStripeRows(true);
|
395 |
grille.setTrackMouseOver(true);
|
391 |
grille.setTrackMouseOver(true);
|
396 |
|
392 |
|
397 |
return grille;
|
393 |
return grille;
|
398 |
}
|
394 |
}
|
399 |
|
395 |
|
400 |
private ColumnConfig creerColonneType() {
|
396 |
private ColumnConfig creerColonneType() {
|
401 |
typeCombo = new ChampComboBoxMultiSelect<Valeur>();
|
397 |
typeCombo = new ChampComboBoxMultiSelect<Valeur>();
|
402 |
typeCombo.setDisplayField("nom");
|
398 |
typeCombo.setDisplayField("nom");
|
403 |
typeCombo.setValueField("id_valeur");
|
399 |
typeCombo.setValueField("id_valeur");
|
404 |
typeCombo.setStore(new ListStore<Valeur>());
|
400 |
typeCombo.setStore(new ListStore<Valeur>());
|
405 |
typeCombo.setEditable(false);
|
401 |
typeCombo.setEditable(false);
|
406 |
typeCombo.setForceSelection(true);
|
402 |
typeCombo.setForceSelection(true);
|
407 |
|
403 |
|
408 |
CellEditor typeEditeur = new CellEditor(typeCombo) {
|
404 |
CellEditor typeEditeur = new CellEditor(typeCombo) {
|
409 |
@SuppressWarnings("unchecked")
|
405 |
@SuppressWarnings("unchecked")
|
410 |
@Override
|
406 |
@Override
|
411 |
public Object preProcessValue(Object valeur) {
|
407 |
public Object preProcessValue(Object valeur) {
|
412 |
Valeur retour = new Valeur();
|
408 |
Valeur retour = new Valeur();
|
413 |
if (valeur != null ) {
|
409 |
if (valeur != null ) {
|
414 |
if (valeur instanceof String) {
|
410 |
if (valeur instanceof String) {
|
415 |
((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString());
|
411 |
((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString());
|
416 |
}
|
412 |
}
|
417 |
}
|
413 |
}
|
418 |
return retour;
|
414 |
return retour;
|
419 |
}
|
415 |
}
|
420 |
|
416 |
|
421 |
@Override
|
417 |
@Override
|
422 |
public Object postProcessValue(Object valeur) {
|
418 |
public Object postProcessValue(Object valeur) {
|
423 |
String retour = null;
|
419 |
String retour = null;
|
424 |
if (getField().getRawValue() != null ) {
|
420 |
if (getField().getRawValue() != null ) {
|
425 |
retour = getField().getRawValue();
|
421 |
retour = getField().getRawValue();
|
426 |
}
|
422 |
}
|
427 |
Debug.log("Post : "+retour);
|
- |
|
428 |
return retour;
|
423 |
return retour;
|
429 |
}
|
424 |
}
|
430 |
};
|
425 |
};
|
431 |
|
426 |
|
432 |
GridCellRenderer<CollectionACommentaire> typeRendu = new GridCellRenderer<CollectionACommentaire>() {
|
427 |
GridCellRenderer<CollectionACommentaire> typeRendu = new GridCellRenderer<CollectionACommentaire>() {
|
433 |
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) {
|
434 |
String type = model.get("_type_");
|
429 |
String type = model.get("_type_");
|
435 |
Debug.log("Initialisation type origine :"+type);
|
- |
|
436 |
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))) {
|
437 |
type = typeCombo.formaterIdentifiantsEnTexte(type);
|
431 |
type = typeCombo.formaterIdentifiantsEnTexte(type);
|
438 |
model.set("_type_", type);
|
432 |
model.set("_type_", type);
|
439 |
Debug.log("Initialisation :"+type);
|
- |
|
440 |
}
|
433 |
}
|
441 |
return type;
|
434 |
return type;
|
442 |
}
|
435 |
}
|
443 |
};
|
436 |
};
|
444 |
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100);
|
437 |
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100);
|
445 |
typeColonne.setEditor(typeEditeur);
|
438 |
typeColonne.setEditor(typeEditeur);
|
446 |
typeColonne.setRenderer(typeRendu);
|
439 |
typeColonne.setRenderer(typeRendu);
|
447 |
return typeColonne;
|
440 |
return typeColonne;
|
448 |
}
|
441 |
}
|
449 |
|
442 |
|
450 |
private ColumnConfig creerColonneAcces() {
|
443 |
private ColumnConfig creerColonneAcces() {
|
451 |
GridCellRenderer<CollectionACommentaire> accesRendu = new GridCellRenderer<CollectionACommentaire>() {
|
444 |
GridCellRenderer<CollectionACommentaire> accesRendu = new GridCellRenderer<CollectionACommentaire>() {
|
452 |
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) {
|
453 |
String acces = (model.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
|
446 |
String acces = (model.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
|
454 |
model.set("_public_", acces);
|
447 |
model.set("_public_", acces);
|
455 |
return acces;
|
448 |
return acces;
|
456 |
}
|
449 |
}
|
457 |
};
|
450 |
};
|
458 |
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30);
|
451 |
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30);
|
459 |
accesColonne.setRenderer(accesRendu);
|
452 |
accesColonne.setRenderer(accesRendu);
|
460 |
return accesColonne;
|
453 |
return accesColonne;
|
461 |
}
|
454 |
}
|
462 |
|
455 |
|
463 |
public void actualiserEtatBoutonsBarreOutils() {
|
456 |
public void actualiserEtatBoutonsBarreOutils() {
|
464 |
// Activation des boutons si la grille contient un élément
|
457 |
// Activation des boutons si la grille contient un élément
|
465 |
if (grille.getStore().getCount() > 0) {
|
458 |
if (grille.getStore().getCount() > 0) {
|
466 |
commentairesBoutonSupprimer.enable();
|
459 |
commentairesBoutonSupprimer.enable();
|
467 |
commentairesBoutonModifier.enable();
|
460 |
commentairesBoutonModifier.enable();
|
468 |
}
|
461 |
}
|
469 |
// 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
|
470 |
if (grille.getStore().getCount() == 0) {
|
463 |
if (grille.getStore().getCount() == 0) {
|
471 |
commentairesBoutonSupprimer.disable();
|
464 |
commentairesBoutonSupprimer.disable();
|
472 |
commentairesBoutonModifier.disable();
|
465 |
commentairesBoutonModifier.disable();
|
473 |
}
|
466 |
}
|
474 |
}
|
467 |
}
|
475 |
|
468 |
|
476 |
public void rafraichir(Object nouvellesDonnees) {
|
469 |
public void rafraichir(Object nouvellesDonnees) {
|
477 |
if (nouvellesDonnees instanceof ValeurListe) {
|
470 |
if (nouvellesDonnees instanceof ValeurListe) {
|
478 |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
|
471 |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
|
479 |
rafraichirValeurListe(listeValeurs);
|
472 |
rafraichirValeurListe(listeValeurs);
|
480 |
} else if (nouvellesDonnees instanceof Information) {
|
473 |
} else if (nouvellesDonnees instanceof Information) {
|
481 |
Information info = (Information) nouvellesDonnees;
|
474 |
Information info = (Information) nouvellesDonnees;
|
482 |
rafraichirInformation(info);
|
475 |
rafraichirInformation(info);
|
483 |
} else if (nouvellesDonnees instanceof CommentaireListe) {
|
476 |
} else if (nouvellesDonnees instanceof CommentaireListe) {
|
484 |
CommentaireListe listeCommentaires = (CommentaireListe) nouvellesDonnees;
|
477 |
CommentaireListe listeCommentaires = (CommentaireListe) nouvellesDonnees;
|
485 |
rafraichirCommentairesListe(listeCommentaires);
|
478 |
rafraichirCommentairesListe(listeCommentaires);
|
486 |
} else {
|
479 |
} else {
|
487 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
480 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
488 |
}
|
481 |
}
|
489 |
|
482 |
|
490 |
if (chargementTypesOk && chargementCommentairesOk) {
|
483 |
if (chargementTypesOk && chargementCommentairesOk) {
|
491 |
peupler();
|
484 |
peupler();
|
492 |
initialiserChargement();
|
485 |
initialiserChargement();
|
493 |
}
|
486 |
}
|
494 |
}
|
487 |
}
|
495 |
|
488 |
|
496 |
private void rafraichirValeurListe(ValeurListe listeValeurs) {
|
489 |
private void rafraichirValeurListe(ValeurListe listeValeurs) {
|
497 |
if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) {
|
490 |
if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) {
|
498 |
List<Valeur> liste = listeValeurs.toList();
|
491 |
List<Valeur> liste = listeValeurs.toList();
|
499 |
if (liste.size() > 0) {
|
492 |
if (liste.size() > 0) {
|
500 |
ListStore<Valeur> store = typeCombo.getStore();
|
493 |
ListStore<Valeur> store = typeCombo.getStore();
|
501 |
store.removeAll();
|
494 |
store.removeAll();
|
502 |
store.add(liste);
|
495 |
store.add(liste);
|
503 |
store.sort("nom", SortDir.ASC);
|
496 |
store.sort("nom", SortDir.ASC);
|
504 |
typeCombo.setStore(store);
|
497 |
typeCombo.setStore(store);
|
505 |
}
|
498 |
}
|
506 |
chargementTypesOk = true;
|
499 |
chargementTypesOk = true;
|
507 |
} else {
|
500 |
} else {
|
508 |
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);
|
509 |
}
|
502 |
}
|
510 |
}
|
503 |
}
|
511 |
|
504 |
|
512 |
public void rafraichirInformation(Information info) {
|
505 |
public void rafraichirInformation(Information info) {
|
513 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
506 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
514 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
507 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
515 |
}
|
508 |
}
|
516 |
String type = info.getType();
|
509 |
String type = info.getType();
|
517 |
if (info.getType().equals("liste_collection_a_commentaire")) {
|
510 |
if (info.getType().equals("liste_collection_a_commentaire")) {
|
518 |
if (info.getDonnee(0) != null) {
|
511 |
if (info.getDonnee(0) != null) {
|
519 |
initialiser();
|
512 |
initialiser();
|
520 |
collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0));
|
513 |
collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0));
|
521 |
chargementCommentairesOk = true;
|
514 |
chargementCommentairesOk = true;
|
522 |
}
|
515 |
}
|
523 |
} else if (info.getType().equals("ajout_collection")) {
|
516 |
} else if (info.getType().equals("ajout_collection")) {
|
524 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
517 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
525 |
String collectionId = (String) info.getDonnee(0);
|
518 |
String collectionId = (String) info.getDonnee(0);
|
526 |
|
519 |
|
527 |
// 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
|
528 |
// 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
|
529 |
mediateur.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes);
|
522 |
mediateur.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes);
|
530 |
}
|
523 |
}
|
531 |
} else if (type.equals("commentaire_modifiee")) {
|
524 |
} else if (type.equals("commentaire_modifiee")) {
|
532 |
if (info.getDonnee(0) != null) {
|
525 |
if (info.getDonnee(0) != null) {
|
533 |
Commentaire commentaire = (Commentaire) info.getDonnee(0);
|
526 |
Commentaire commentaire = (Commentaire) info.getDonnee(0);
|
534 |
CollectionACommentaire commentaireDansGrille = grille.getStore().findModel("id_commentaire", commentaire.getId());
|
527 |
CollectionACommentaire commentaireDansGrille = grille.getStore().findModel("id_commentaire", commentaire.getId());
|
535 |
int index = grille.getStore().indexOf(commentaireDansGrille);
|
528 |
int index = grille.getStore().indexOf(commentaireDansGrille);
|
536 |
grille.getStore().remove(commentaireDansGrille);
|
529 |
grille.getStore().remove(commentaireDansGrille);
|
537 |
String typeCommentaire = (String) commentaireDansGrille.get("_type_");
|
530 |
String typeCommentaire = (String) commentaireDansGrille.get("_type_");
|
538 |
ajouterDansGrille(commentaire, typeCommentaire, index);
|
531 |
ajouterDansGrille(commentaire, typeCommentaire, index);
|
539 |
}
|
532 |
}
|
540 |
} else if (type.equals("commentaire_ajoutee")) {
|
533 |
} else if (type.equals("commentaire_ajoutee")) {
|
541 |
if (info.getDonnee(0) != null) {
|
534 |
if (info.getDonnee(0) != null) {
|
542 |
Commentaire commentaire = (Commentaire) info.getDonnee(0);
|
535 |
Commentaire commentaire = (Commentaire) info.getDonnee(0);
|
543 |
ajouterDansGrille(commentaire);
|
536 |
ajouterDansGrille(commentaire);
|
544 |
}
|
537 |
}
|
545 |
} else if (info.getType().equals("modif_collection_a_commentaire")) {
|
538 |
} else if (info.getType().equals("modif_collection_a_commentaire")) {
|
546 |
InfoLogger.display("Modification des notes liées à la collection", info.toString());
|
539 |
InfoLogger.display("Modification des notes liées à la collection", info.toString());
|
547 |
initialiserGestionCommentaires();
|
540 |
initialiserGestionCommentaires();
|
548 |
} else if (info.getType().equals("suppression_collection_a_commentaire")) {
|
541 |
} else if (info.getType().equals("suppression_collection_a_commentaire")) {
|
549 |
InfoLogger.display("Suppression des notes liées à la collection", info.toString());
|
542 |
InfoLogger.display("Suppression des notes liées à la collection", info.toString());
|
550 |
initialiserGestionCommentaires();
|
543 |
initialiserGestionCommentaires();
|
551 |
} else if (info.getType().equals("ajout_collection_a_commentaire")) {
|
544 |
} else if (info.getType().equals("ajout_collection_a_commentaire")) {
|
552 |
InfoLogger.display("Ajout des notes liées à la collection", info.toString());
|
545 |
InfoLogger.display("Ajout des notes liées à la collection", info.toString());
|
553 |
initialiserGestionCommentaires();
|
546 |
initialiserGestionCommentaires();
|
554 |
}
|
547 |
}
|
555 |
}
|
548 |
}
|
556 |
|
549 |
|
557 |
private void rafraichirCommentairesListe(CommentaireListe listeCommentaires) {
|
550 |
private void rafraichirCommentairesListe(CommentaireListe listeCommentaires) {
|
558 |
commentairesSaisisComboBox.getStore().removeAll();
|
551 |
commentairesSaisisComboBox.getStore().removeAll();
|
559 |
commentairesSaisisComboBox.getStore().add(listeCommentaires.toList());
|
552 |
commentairesSaisisComboBox.getStore().add(listeCommentaires.toList());
|
560 |
commentairesSaisisComboBox.expand();
|
553 |
commentairesSaisisComboBox.expand();
|
561 |
}
|
554 |
}
|
562 |
|
555 |
|
563 |
public void peupler() {
|
556 |
public void peupler() {
|
564 |
grille.getStore().removeAll();
|
557 |
grille.getStore().removeAll();
|
565 |
grille.getStore().add(collection.getCommentairesLiees().toList());
|
558 |
grille.getStore().add(collection.getCommentairesLiees().toList());
|
566 |
grille.recalculate();
|
559 |
grille.recalculate();
|
567 |
layout();
|
560 |
layout();
|
568 |
InfoLogger.display(i18nC.chargementCommentaire(), i18nC.ok());
|
561 |
InfoLogger.display(i18nC.chargementCommentaire(), i18nC.ok());
|
569 |
}
|
562 |
}
|
570 |
|
563 |
|
571 |
public void collecter() {
|
564 |
public void collecter() {
|
572 |
if (etreAccede()) {
|
565 |
if (etreAccede()) {
|
573 |
int nbreCommentaire = grille.getStore().getCount();
|
566 |
int nbreCommentaire = grille.getStore().getCount();
|
574 |
for (int i = 0; i < nbreCommentaire; i++) {
|
567 |
for (int i = 0; i < nbreCommentaire; i++) {
|
575 |
CollectionACommentaire relationCollectionACommentaire = grille.getStore().getAt(i);
|
568 |
CollectionACommentaire relationCollectionACommentaire = grille.getStore().getAt(i);
|
576 |
if (relationCollectionACommentaire.get("_etat_") != null) {
|
569 |
if (relationCollectionACommentaire.get("_etat_") != null) {
|
577 |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
570 |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
578 |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
|
571 |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
|
579 |
commentairesModifies.put("id"+idGenere++, relationCollectionACommentaire);
|
572 |
commentairesModifies.put("id"+idGenere++, relationCollectionACommentaire);
|
580 |
Debug.log("Commentaires modifiés : "+relationCollectionACommentaire.getCommentaire().getTitre());
|
- |
|
581 |
}
|
573 |
}
|
582 |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
574 |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
583 |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
|
575 |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type
|
584 |
commentairesAjoutes.put("id"+idGenere++, relationCollectionACommentaire);
|
576 |
commentairesAjoutes.put("id"+idGenere++, relationCollectionACommentaire);
|
585 |
Debug.log("Commentaires ajoutés : "+relationCollectionACommentaire.getCommentaire().getTitre());
|
- |
|
586 |
}
|
577 |
}
|
587 |
// Initialisation de la grille
|
578 |
// Initialisation de la grille
|
588 |
relationCollectionACommentaire.set("_etat_", "");
|
579 |
relationCollectionACommentaire.set("_etat_", "");
|
589 |
}
|
580 |
}
|
590 |
}
|
581 |
}
|
591 |
grille.getStore().commitChanges();
|
582 |
grille.getStore().commitChanges();
|
592 |
}
|
583 |
}
|
593 |
}
|
584 |
}
|
594 |
|
585 |
|
595 |
private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) {
|
586 |
private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) {
|
596 |
String type = relationCollectionACommentaire.get("_type_");
|
587 |
String type = relationCollectionACommentaire.get("_type_");
|
597 |
relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type));
|
588 |
relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type));
|
598 |
}
|
589 |
}
|
599 |
|
590 |
|
600 |
public void soumettre() {
|
591 |
public void soumettre() {
|
601 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
592 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
602 |
if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) {
|
593 |
if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) {
|
603 |
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é.");
|
604 |
} else {
|
595 |
} else {
|
605 |
mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes);
|
596 |
mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes);
|
606 |
mediateur.modifierCollectionACommentaire(this, commentairesModifies);
|
597 |
mediateur.modifierCollectionACommentaire(this, commentairesModifies);
|
607 |
mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes);
|
598 |
mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes);
|
608 |
}
|
599 |
}
|
609 |
}
|
600 |
}
|
610 |
}
|
601 |
}
|
611 |
|
602 |
|
612 |
private void obtenirCommentairesSaisis(String titre) {
|
603 |
private void obtenirCommentairesSaisis(String titre) {
|
613 |
mediateur.selectionnerCommentaireParTitre(this, titre+"%");
|
604 |
mediateur.selectionnerCommentaireParTitre(this, titre+"%");
|
614 |
}
|
605 |
}
|
615 |
|
606 |
|
616 |
private void actualiserGrille() {
|
607 |
private void actualiserGrille() {
|
617 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
608 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
618 |
mediateur.selectionnerCollectionACommentaire(this, collection.getId());
|
609 |
mediateur.selectionnerCollectionACommentaire(this, collection.getId());
|
619 |
} else {
|
610 |
} else {
|
620 |
grille.getStore().removeAll();
|
611 |
grille.getStore().removeAll();
|
621 |
layout();
|
612 |
layout();
|
622 |
}
|
613 |
}
|
623 |
}
|
614 |
}
|
624 |
}
|
615 |
}
|