| Line 9... |
Line 9... |
| 9 |
import org.tela_botanica.client.modeles.Information;
|
9 |
import org.tela_botanica.client.modeles.Information;
|
| 10 |
import org.tela_botanica.client.modeles.Personne;
|
10 |
import org.tela_botanica.client.modeles.Personne;
|
| 11 |
import org.tela_botanica.client.modeles.PersonneListe;
|
11 |
import org.tela_botanica.client.modeles.PersonneListe;
|
| 12 |
import org.tela_botanica.client.modeles.ValeurListe;
|
12 |
import org.tela_botanica.client.modeles.ValeurListe;
|
| Line -... |
Line 13... |
| - |
|
13 |
|
| 13 |
|
14 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
| 14 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
15 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
| - |
|
16 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
| 15 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
17 |
import com.extjs.gxt.ui.client.event.EventType;
|
| 16 |
import com.extjs.gxt.ui.client.event.Events;
|
- |
|
| 17 |
import com.extjs.gxt.ui.client.event.GridEvent;
|
18 |
import com.extjs.gxt.ui.client.event.Events;
|
| 18 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
19 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
| 19 |
import com.extjs.gxt.ui.client.event.Listener;
|
20 |
import com.extjs.gxt.ui.client.event.Listener;
|
| 20 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
21 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
| 21 |
import com.extjs.gxt.ui.client.store.ListStore;
|
22 |
import com.extjs.gxt.ui.client.store.ListStore;
|
| 22 |
import com.extjs.gxt.ui.client.store.Store;
|
23 |
import com.extjs.gxt.ui.client.store.Store;
|
| 23 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
24 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
| 24 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
25 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
| 25 |
import com.extjs.gxt.ui.client.widget.Info;
|
- |
|
| 26 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
26 |
import com.extjs.gxt.ui.client.widget.Info;
|
| - |
|
27 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
| 27 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
28 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
| 28 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
29 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
| 29 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
30 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
| 30 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
31 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
| 31 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
32 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
| Line 35... |
Line 36... |
| 35 |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
|
36 |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
|
| 36 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
37 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
| 37 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
38 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
| 38 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
39 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
| 39 |
import com.google.gwt.core.client.GWT;
|
40 |
import com.google.gwt.core.client.GWT;
|
| - |
|
41 |
import com.google.gwt.event.dom.client.KeyCodes;
|
| Line 40... |
Line 42... |
| 40 |
|
42 |
|
| Line 41... |
Line 43... |
| 41 |
public class CollectionFormAuteur extends FormulaireOnglet implements Rafraichissable {
|
43 |
public class CollectionFormAuteur extends FormulaireOnglet implements Rafraichissable {
|
| 42 |
|
44 |
|
| Line 48... |
Line 50... |
| 48 |
private PersonneListe auteursAjoutes = null;
|
50 |
private PersonneListe auteursAjoutes = null;
|
| 49 |
private PersonneListe auteursSupprimes = null;
|
51 |
private PersonneListe auteursSupprimes = null;
|
| 50 |
private ComboBox<Personne> auteursSaisisComboBox = null;
|
52 |
private ComboBox<Personne> auteursSaisisComboBox = null;
|
| 51 |
private Button auteursBoutonSupprimer = null;
|
53 |
private Button auteursBoutonSupprimer = null;
|
| 52 |
private Button auteursBoutonModifier = null;
|
54 |
private Button auteursBoutonModifier = null;
|
| - |
|
55 |
private Button ajouterAuteurSaisiBouton = null;
|
| Line 53... |
Line 56... |
| 53 |
|
56 |
|
| 54 |
private static final String ETAT_AJOUTE = "A";
|
57 |
private static final String ETAT_AJOUTE = "A";
|
| Line 55... |
Line 58... |
| 55 |
private static final String ETAT_SUPPRIME = "S";
|
58 |
private static final String ETAT_SUPPRIME = "S";
|
| Line 114... |
Line 117... |
| 114 |
barreOutils.add(new SeparatorToolItem());
|
117 |
barreOutils.add(new SeparatorToolItem());
|
| Line 115... |
Line 118... |
| 115 |
|
118 |
|
| 116 |
auteursSaisisComboBox = creerComboBoxAuteursSaisis();
|
119 |
auteursSaisisComboBox = creerComboBoxAuteursSaisis();
|
| Line 117... |
Line 120... |
| 117 |
barreOutils.add(auteursSaisisComboBox);
|
120 |
barreOutils.add(auteursSaisisComboBox);
|
| 118 |
|
121 |
|
| Line 119... |
Line 122... |
| 119 |
Button ajouterAuteurSaisiBouton = creerBoutonAjouterAuteurSaisi();
|
122 |
ajouterAuteurSaisiBouton = creerBoutonAjouterAuteurSaisi();
|
| 120 |
barreOutils.add(ajouterAuteurSaisiBouton);
|
123 |
barreOutils.add(ajouterAuteurSaisiBouton);
|
| Line 126... |
Line 129... |
| 126 |
Button bouton = new Button(i18nC.ajouter());
|
129 |
Button bouton = new Button(i18nC.ajouter());
|
| 127 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
130 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
| 128 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
131 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
| 129 |
@Override
|
132 |
@Override
|
| 130 |
public void componentSelected(ButtonEvent ce) {
|
133 |
public void componentSelected(ButtonEvent ce) {
|
| 131 |
PersonneForm formulairePersonne = new PersonneForm(Formulaire.MODE_AJOUTER);
|
134 |
FenetreForm fenetre = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
|
| 132 |
formulairePersonne.setHeaderVisible(false);
|
- |
|
| 133 |
formulairePersonne.setTopComponent(null);
|
- |
|
| 134 |
// TODO : gérer la barre d'outil avec des évènements spécifique au contexte de fenêtre modale
|
- |
|
| 135 |
//formulairePersonne.setBottomComponent(null);
|
- |
|
| 136 |
|
- |
|
| 137 |
final FenetreForm fenetre = new FenetreForm(i18nC.personneModeAjout());
|
- |
|
| 138 |
fenetre.add(formulairePersonne);
|
- |
|
| 139 |
fenetre.show();
|
135 |
fenetre.show();
|
| 140 |
}
|
136 |
}
|
| 141 |
});
|
137 |
});
|
| 142 |
return bouton;
|
138 |
return bouton;
|
| 143 |
}
|
139 |
}
|
| Line 147... |
Line 143... |
| 147 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
143 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
| 148 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
144 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
| 149 |
@Override
|
145 |
@Override
|
| 150 |
public void componentSelected(ButtonEvent ce) {
|
146 |
public void componentSelected(ButtonEvent ce) {
|
| 151 |
Personne auteurSaisiSelectionne = grille.getSelectionModel().getSelectedItem();
|
147 |
Personne auteurSaisiSelectionne = grille.getSelectionModel().getSelectedItem();
|
| 152 |
|
- |
|
| 153 |
if (auteurSaisiSelectionne == null) {
|
148 |
if (auteurSaisiSelectionne == null) {
|
| 154 |
Info.display("Info", "Veuillez selectionner un auteur");
|
149 |
Info.display("Info", "Veuillez selectionner un auteur");
|
| 155 |
} else {
|
150 |
} else {
|
| 156 |
PersonneForm formulairePersonne = new PersonneForm(Formulaire.MODE_MODIFIER);
|
151 |
FenetreForm fenetre = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
|
| 157 |
formulairePersonne.setHeaderVisible(false);
|
- |
|
| 158 |
formulairePersonne.setTopComponent(null);
|
- |
|
| 159 |
// TODO : gérer la barre d'outil avec des évènements spécifique au contexte de fenêtre modale
|
- |
|
| 160 |
//formulairePersonne.setBottomComponent(null);
|
- |
|
| 161 |
// TODO : simplifier la gestion de l'ajout des données d'une Personne au form pour la modification... (pas besoin de passer par une liste).
|
- |
|
| 162 |
Information info = new Information("liste_personne");
|
- |
|
| 163 |
PersonneListe personnes = new PersonneListe();
|
- |
|
| 164 |
personnes.put(auteurSaisiSelectionne.getId(), auteurSaisiSelectionne);
|
- |
|
| 165 |
info.setDonnee(0, personnes);
|
- |
|
| 166 |
formulairePersonne.rafraichir(info);
|
- |
|
| 167 |
|
- |
|
| 168 |
final FenetreForm fenetre = new FenetreForm(i18nC.personneModeModifier());
|
- |
|
| 169 |
fenetre.add(formulairePersonne);
|
- |
|
| 170 |
fenetre.show();
|
152 |
fenetre.show();
|
| 171 |
}
|
153 |
}
|
| 172 |
}
|
154 |
}
|
| 173 |
});
|
155 |
});
|
| 174 |
return bouton;
|
156 |
return bouton;
|
| 175 |
}
|
157 |
}
|
| - |
|
158 |
|
| - |
|
159 |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
|
| - |
|
160 |
final FenetreForm fenetre = new FenetreForm("");
|
| - |
|
161 |
final PersonneForm formulaire = creerFormulairePersonne(fenetre);
|
| - |
|
162 |
fenetre.add(formulaire);
|
| - |
|
163 |
return fenetre;
|
| - |
|
164 |
}
|
| - |
|
165 |
|
| - |
|
166 |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre) {
|
| - |
|
167 |
PersonneForm formulaire = new PersonneForm(mode);
|
| - |
|
168 |
fenetre.setHeading(formulaire.getHeading());
|
| - |
|
169 |
formulaire.setHeaderVisible(false);
|
| - |
|
170 |
formulaire.setTopComponent(null);
|
| Line -... |
Line 171... |
| - |
|
171 |
|
| - |
|
172 |
// TODO : gérer la barre d'outil avec des évènements spécifique au contexte de fenêtre modale
|
| - |
|
173 |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulaire);
|
| - |
|
174 |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
|
| - |
|
175 |
formulaire.setBottomComponent(barreValidation);
|
| - |
|
176 |
|
| - |
|
177 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
| - |
|
178 |
// TODO : simplifier la gestion de l'ajout des données d'une Personne au form pour la modification... (pas besoin de passer par une liste).
|
| - |
|
179 |
Information info = new Information("liste_personne");
|
| - |
|
180 |
PersonneListe personnes = new PersonneListe();
|
| - |
|
181 |
Personne auteurSaisiSelectionne = grille.getSelectionModel().getSelectedItem();
|
| - |
|
182 |
personnes.put(auteurSaisiSelectionne.getId(), auteurSaisiSelectionne);
|
| - |
|
183 |
info.setDonnee(0, personnes);
|
| - |
|
184 |
formulaire.rafraichir(info);
|
| - |
|
185 |
}
|
| - |
|
186 |
|
| - |
|
187 |
return formulaire;
|
| - |
|
188 |
}
|
| - |
|
189 |
|
| - |
|
190 |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
|
| - |
|
191 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
| - |
|
192 |
@Override
|
| - |
|
193 |
public void componentSelected(ButtonEvent ce) {
|
| - |
|
194 |
String code = ((Button) ce.getComponent()).getData("code");
|
| - |
|
195 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
| - |
|
196 |
Boolean ok = formulaire.enregistrer();
|
| - |
|
197 |
if (ok == true) {
|
| - |
|
198 |
// Fermer fenêtre et ajouter/modifier l'élément dans la liste
|
| - |
|
199 |
}
|
| - |
|
200 |
fenetre.hide();
|
| - |
|
201 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
| - |
|
202 |
Boolean ok = formulaire.enregistrer();
|
| - |
|
203 |
if (ok == true) {
|
| - |
|
204 |
// Fermer fenêtre et ajouter/modifier l'élément dans la liste
|
| - |
|
205 |
}
|
| - |
|
206 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
| - |
|
207 |
fenetre.hide();
|
| - |
|
208 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
|
| - |
|
209 |
formulaire.reinitialiser();
|
| - |
|
210 |
}
|
| - |
|
211 |
}
|
| - |
|
212 |
};
|
| - |
|
213 |
|
| - |
|
214 |
return ecouteur;
|
| - |
|
215 |
}
|
| 176 |
|
216 |
|
| 177 |
private Button creerBoutonSupprimer() {
|
217 |
private Button creerBoutonSupprimer() {
|
| 178 |
Button bouton = new Button(i18nC.supprimer());
|
218 |
Button bouton = new Button(i18nC.supprimer());
|
| 179 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
219 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
| 180 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
220 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
| Line 214... |
Line 254... |
| 214 |
comboBox.setEditable(true);
|
254 |
comboBox.setEditable(true);
|
| 215 |
comboBox.setDisplayField("fmt_nom_complet");
|
255 |
comboBox.setDisplayField("fmt_nom_complet");
|
| 216 |
comboBox.setStore(personnesSaisiesStore);
|
256 |
comboBox.setStore(personnesSaisiesStore);
|
| 217 |
comboBox.addKeyListener(new KeyListener() {
|
257 |
comboBox.addKeyListener(new KeyListener() {
|
| 218 |
public void componentKeyUp(ComponentEvent ce) {
|
258 |
public void componentKeyUp(ComponentEvent ce) {
|
| - |
|
259 |
if (auteursSaisisComboBox.getRawValue() != null && auteursSaisisComboBox.getRawValue().length() > 0) {
|
| - |
|
260 |
if (!ce.isNavKeyPress()) {
|
| - |
|
261 |
obtenirAuteursSaisis(auteursSaisisComboBox.getRawValue());
|
| - |
|
262 |
}
|
| - |
|
263 |
}
|
| - |
|
264 |
}
|
| - |
|
265 |
});
|
| 219 |
ComboBox<Personne> comboBox = (ComboBox<Personne>) ce.getComponent();
|
266 |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() {
|
| - |
|
267 |
@Override
|
| - |
|
268 |
public void handleEvent(BaseEvent be) {
|
| 220 |
if (!ce.isNavKeyPress() && comboBox.getRawValue() != null && comboBox.getRawValue().length() > 0) {
|
269 |
if (auteursSaisisComboBox.getValue() instanceof Personne) {
|
| 221 |
obtenirAuteursSaisis(comboBox.getRawValue());
|
270 |
ajouterAuteurSaisiBouton.fireEvent(Events.Select);
|
| 222 |
}
|
271 |
}
|
| 223 |
}
|
272 |
}
|
| 224 |
});
|
273 |
});
|
| 225 |
return comboBox;
|
274 |
return comboBox;
|
| 226 |
}
|
275 |
}
|
| Line 230... |
Line 279... |
| 230 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
279 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
| 231 |
@Override
|
280 |
@Override
|
| 232 |
public void componentSelected(ButtonEvent ce) {
|
281 |
public void componentSelected(ButtonEvent ce) {
|
| 233 |
Personne auteurSaisiSelectionne = auteursSaisisComboBox.getValue();
|
282 |
Personne auteurSaisiSelectionne = auteursSaisisComboBox.getValue();
|
| 234 |
ajouterDansGrille(auteurSaisiSelectionne);
|
283 |
ajouterDansGrille(auteurSaisiSelectionne);
|
| - |
|
284 |
auteursSaisisComboBox.setValue(null);
|
| 235 |
}
|
285 |
}
|
| 236 |
});
|
286 |
});
|
| 237 |
return bouton;
|
287 |
return bouton;
|
| 238 |
}
|
288 |
}
|