| Line 1... |
Line 1... |
| 1 |
package org.tela_botanica.client.vues;
|
1 |
package org.tela_botanica.client.vues;
|
| Line 2... |
Line -... |
| 2 |
|
- |
|
| 3 |
import java.util.LinkedList;
|
- |
|
| 4 |
import java.util.List;
|
- |
|
| 5 |
|
2 |
|
| - |
|
3 |
import org.tela_botanica.client.Mediateur;
|
| 6 |
import org.tela_botanica.client.Mediateur;
|
4 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
| 7 |
import org.tela_botanica.client.RegistreId;
|
5 |
import org.tela_botanica.client.composants.pagination.ProxyProjets;
|
| 8 |
import org.tela_botanica.client.i18n.Constantes;
|
- |
|
| 9 |
import org.tela_botanica.client.images.Images;
|
6 |
import org.tela_botanica.client.i18n.Constantes;
|
| 10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
7 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 11 |
import org.tela_botanica.client.modeles.projet.Projet;
|
8 |
import org.tela_botanica.client.modeles.projet.Projet;
|
| Line -... |
Line 9... |
| - |
|
9 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
| - |
|
10 |
|
| - |
|
11 |
import com.extjs.gxt.ui.client.data.ModelData;
|
| 12 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
12 |
import com.extjs.gxt.ui.client.data.ModelType;
|
| 13 |
|
13 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
| 14 |
import com.extjs.gxt.ui.client.Registry;
|
14 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
| 15 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
- |
|
| 16 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
15 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
| 17 |
import com.extjs.gxt.ui.client.store.ListStore;
|
16 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
| 18 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
17 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
| 19 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
- |
|
| 20 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
18 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
| 21 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
19 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
| Line 22... |
Line 20... |
| 22 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
20 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
| 23 |
import com.google.gwt.core.client.GWT;
|
21 |
import com.google.gwt.event.dom.client.KeyCodes;
|
| 24 |
|
22 |
|
| 25 |
public class FiltreVue extends ContentPanel implements Rafraichissable {
|
23 |
public class FiltreVue extends ContentPanel implements Rafraichissable {
|
| Line 26... |
Line -... |
| 26 |
private Mediateur mediateur = null;
|
- |
|
| 27 |
private Constantes i18nC = null;
|
24 |
private Mediateur mediateur = null;
|
| Line 28... |
Line 25... |
| 28 |
private ListStore<Projet> projets = null;
|
25 |
private Constantes i18nC = null;
|
| 29 |
|
26 |
private Sequenceur sequenceur = new Sequenceur();
|
| 30 |
private ComboBox<Projet> listeProjets;
|
27 |
|
| Line 31... |
Line 28... |
| 31 |
private ProjetListe projetsCache = null;
|
28 |
private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
|
| 32 |
|
29 |
|
| 33 |
public FiltreVue(Mediateur mediateurCourrant) {
|
30 |
public FiltreVue(Mediateur mediateurCourrant) {
|
| Line 34... |
Line -... |
| 34 |
mediateur = mediateurCourrant;
|
- |
|
| 35 |
i18nC = Mediateur.i18nC;
|
31 |
mediateur = mediateurCourrant;
|
| 36 |
|
- |
|
| 37 |
setHeading(i18nC.titreFiltre());
|
- |
|
| 38 |
setLayout(new FitLayout());
|
32 |
i18nC = Mediateur.i18nC;
|
| 39 |
setLayoutOnChange(true);
|
- |
|
| 40 |
|
- |
|
| 41 |
chargerProjets();
|
- |
|
| 42 |
initialiserListeProjets();
|
33 |
|
| 43 |
}
|
- |
|
| Line 44... |
Line 34... |
| 44 |
|
34 |
setHeading(i18nC.titreFiltre());
|
| 45 |
private void chargerProjets() {
|
35 |
setLayout(new FitLayout());
|
| 46 |
mediateur.selectionnerProjet(this, null, null);
|
36 |
setLayoutOnChange(true);
|
| 47 |
}
|
37 |
|
| 48 |
|
38 |
/*********************************/
|
| - |
|
39 |
/** Champ Projets **/
|
| 49 |
private void initialiserListeProjets() {
|
40 |
/*********************************/
|
| - |
|
41 |
|
| - |
|
42 |
ModelType modelTypeProjets = new ModelType();
|
| - |
|
43 |
modelTypeProjets.setRoot("projets");
|
| 50 |
|
44 |
modelTypeProjets.setTotalName("nbElements");
|
| 51 |
|
45 |
modelTypeProjets.addField("cpr_nom");
|
| 52 |
// Ajout de la sélection des projets
|
46 |
modelTypeProjets.addField("cpr_id_projet");
|
| - |
|
47 |
|
| - |
|
48 |
String displayNameProjets = "cpr_nom";
|
| - |
|
49 |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(sequenceur);
|
| - |
|
50 |
|
| - |
|
51 |
projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
|
| - |
|
52 |
projetsCombo.getCombo().setEmptyText("Tous les projets");
|
| - |
|
53 |
projetsCombo.getCombo().setAllowBlank(true);
|
| - |
|
54 |
projetsCombo.getCombo().setForceSelection(false);
|
| - |
|
55 |
projetsCombo.getCombo().setEditable(true);
|
| - |
|
56 |
projetsCombo.setWidth(215);
|
| - |
|
57 |
projetsCombo.getCombo().setValidator(new Validator() {
|
| - |
|
58 |
public String validate(Field<?> field, String value) {
|
| - |
|
59 |
String retour = null;
|
| - |
|
60 |
if (field.getRawValue().equals("")) {
|
| - |
|
61 |
field.setValue(null);
|
| - |
|
62 |
} else if (projetsCombo.getStore().findModel("cpr_nom", field.getRawValue()) == null) {
|
| 53 |
listeProjets = new ComboBox<Projet>();
|
63 |
String contenuBrut = field.getRawValue();
|
| - |
|
64 |
field.setValue(null);
|
| - |
|
65 |
field.setRawValue(contenuBrut);
|
| Line 54... |
Line 66... |
| 54 |
projets = new ListStore<Projet>();
|
66 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
| 55 |
listeProjets.setStore(projets);
|
67 |
}
|
| 56 |
listeProjets.setEditable(false);
|
- |
|
| 57 |
listeProjets.setDisplayField("nom");
|
68 |
return retour;
|
| - |
|
69 |
}
|
| 58 |
listeProjets.setEmptyText(i18nC.txtListeProjetDefaut());
|
70 |
});
|
| - |
|
71 |
|
| 59 |
listeProjets.setTypeAhead(true);
|
72 |
final Projet tousProjets = new Projet();
|
| - |
|
73 |
tousProjets.set("nom", i18nC.tousProjets());
|
| 60 |
listeProjets.setTriggerAction(TriggerAction.ALL);
|
74 |
|
| 61 |
|
75 |
// Ajout d'un écouteur pour le changement => enregistre la valeur courante du projet dans le registre
|
| 62 |
|
76 |
projetsCombo.getCombo().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
|
| - |
|
77 |
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
|
| - |
|
78 |
if (se.getSelectedItem() != null) {
|
| - |
|
79 |
mediateur.activerChargement(i18nC.chargement());
|
| - |
|
80 |
Projet projet = new Projet (se.getSelectedItem());
|
| - |
|
81 |
mediateur.selectionnerProjetCourant(projet);
|
| - |
|
82 |
}
|
| - |
|
83 |
}
|
| - |
|
84 |
});
|
| - |
|
85 |
|
| - |
|
86 |
projetsCombo.getCombo().addKeyListener(new KeyListener() {
|
| - |
|
87 |
public void componentKeyUp(ComponentEvent ce) {
|
| - |
|
88 |
projetsCombo.getCombo().setRawValue("Tous les projets");
|
| - |
|
89 |
projetsCombo.getCombo().setValue(null);
|
| - |
|
90 |
projetsCombo.getCombo().clearSelections();
|
| - |
|
91 |
if (ce.getKeyCode() == KeyCodes.KEY_ENTER) {
|
| 63 |
// Ajout d'un écouteur pour le changement => enregistre la valeur courante du projet dans le registre
|
92 |
mediateur.selectionnerProjetCourant(tousProjets);
|
| 64 |
listeProjets.addSelectionChangedListener(new SelectionChangedListener<Projet>() {
|
93 |
projetsCombo.getCombo().setValue(tousProjets);
|
| Line 65... |
Line 94... |
| 65 |
|
94 |
projetsCombo.getCombo().setVisible(false);
|
| 66 |
public void selectionChanged(SelectionChangedEvent<Projet> se) {
|
95 |
projetsCombo.getCombo().collapse();
|
| 67 |
mediateur.activerChargement(i18nC.chargement());
|
- |
|
| 68 |
mediateur.selectionnerProjetCourant(se.getSelectedItem());
|
96 |
projetsCombo.getCombo().setVisible(true);
|
| 69 |
}
|
97 |
}
|
| 70 |
});
|
- |
|
| 71 |
|
- |
|
| 72 |
add(listeProjets);
|
98 |
}
|
| 73 |
}
|
99 |
});
|
| 74 |
|
- |
|
| 75 |
private void afficherListeProjets(List projetsRecus) {
|
- |
|
| 76 |
projets.removeAll();
|
100 |
|
| - |
|
101 |
add(projetsCombo);
|
| 77 |
|
102 |
}
|
| Line 78... |
Line 103... |
| 78 |
List<Projet> selection = new LinkedList<Projet>();
|
103 |
|
| 79 |
Projet tousProjets = new Projet();
|
- |
|
| 80 |
tousProjets.set("nom", i18nC.tousProjets());
|
- |
|
| 81 |
projetsRecus.add(0, tousProjets);
|
- |
|
| 82 |
selection.add(tousProjets);
|
- |
|
| 83 |
projets.add(projetsRecus);
|
- |
|
| 84 |
listeProjets.setStore(projets);
|
- |
|
| 85 |
listeProjets.setSelection(selection);
|
- |
|
| 86 |
layout();
|
- |
|
| 87 |
}
|
104 |
public String getProjet() {
|
| 88 |
|
- |
|
| 89 |
public void rafraichir(Object nouvellesDonnees) {
|
- |
|
| 90 |
if (nouvellesDonnees instanceof ProjetListe) {
|
105 |
if (projetsCombo.getValeur() != null) {
|
| 91 |
projetsCache = (ProjetListe) nouvellesDonnees;
|
106 |
Projet projet = new Projet(projetsCombo.getValeur());
|
| 92 |
Registry.register(RegistreId.PROJETS, projetsCache);
|
107 |
return projet.getAbreviation();
|