| 195 |
david |
1 |
package org.tela_botanica.client.vues.observation;
|
| 185 |
david |
2 |
|
|
|
3 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
4 |
import org.tela_botanica.client.observation.ObservationMediateur;
|
|
|
5 |
|
|
|
6 |
import com.google.gwt.user.client.Event;
|
|
|
7 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
8 |
import com.gwtext.client.core.EventObject;
|
|
|
9 |
import com.gwtext.client.core.Ext;
|
|
|
10 |
import com.gwtext.client.core.ExtElement;
|
|
|
11 |
import com.gwtext.client.widgets.Button;
|
|
|
12 |
import com.gwtext.client.widgets.Panel;
|
|
|
13 |
import com.gwtext.client.widgets.Window;
|
|
|
14 |
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
|
|
|
15 |
import com.gwtext.client.widgets.form.TextArea;
|
|
|
16 |
|
|
|
17 |
public class SaisieMotsClesVue extends Window implements Rafraichissable {
|
|
|
18 |
private ObservationMediateur oMediateur = null ;
|
|
|
19 |
|
|
|
20 |
private Object[][] listeMotsPesee = null;
|
|
|
21 |
|
|
|
22 |
private String motsAAjouter = "" ;
|
|
|
23 |
|
|
|
24 |
private int nbMotsClesMax = 1 ;
|
|
|
25 |
|
|
|
26 |
private TextArea motsClesAjout = null;
|
|
|
27 |
|
|
|
28 |
private Button validerAjout = null ;
|
|
|
29 |
|
|
|
30 |
private Button voirCacherNuage = null;
|
|
|
31 |
|
|
|
32 |
private boolean nuageVisible = false ;
|
|
|
33 |
|
|
|
34 |
private Panel contenuNuage = null ;
|
|
|
35 |
|
|
|
36 |
public SaisieMotsClesVue(ObservationMediateur om) {
|
|
|
37 |
super("Entrez vos mots clés");
|
|
|
38 |
setCls("fenmotcles");
|
|
|
39 |
oMediateur = om ;
|
| 201 |
david |
40 |
//setWidth(300);
|
| 185 |
david |
41 |
motsClesAjout = new TextArea();
|
| 201 |
david |
42 |
//motsClesAjout.setWidth(300);
|
| 185 |
david |
43 |
validerAjout = new Button("Valider");
|
|
|
44 |
voirCacherNuage= new Button("Afficher les mots clés");
|
|
|
45 |
final Rafraichissable r = this ;
|
|
|
46 |
|
|
|
47 |
this.setCloseAction(CLOSE);
|
|
|
48 |
|
|
|
49 |
validerAjout.addListener(new ButtonListenerAdapter() {
|
|
|
50 |
public void onClick(Button button, EventObject e) {
|
|
|
51 |
|
|
|
52 |
motsAAjouter = motsClesAjout.getText();
|
|
|
53 |
//oMediateur.AjouterMotsClesEnMasse(motsAAjouter);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
});
|
|
|
57 |
|
|
|
58 |
voirCacherNuage.addListener(new ButtonListenerAdapter() {
|
|
|
59 |
public void onClick(Button button, EventObject e) {
|
|
|
60 |
|
|
|
61 |
if(nuageVisible) {
|
|
|
62 |
|
|
|
63 |
if(contenuNuage != null) {
|
|
|
64 |
contenuNuage.clear();
|
|
|
65 |
}
|
|
|
66 |
voirCacherNuage.setText("Afficher les mots clés");
|
|
|
67 |
nuageVisible = false;
|
|
|
68 |
}
|
|
|
69 |
else {
|
|
|
70 |
// oMediateur.obtenirNuageMotsCles(r);
|
|
|
71 |
voirCacherNuage.setText("Cacher les mots clés");
|
|
|
72 |
nuageVisible = true;
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
});
|
|
|
77 |
|
|
|
78 |
add(motsClesAjout);
|
|
|
79 |
add(validerAjout);
|
|
|
80 |
add(voirCacherNuage);
|
|
|
81 |
|
|
|
82 |
contenuNuage = new Panel();
|
|
|
83 |
contenuNuage.setBorder(false);
|
|
|
84 |
|
|
|
85 |
add(contenuNuage);
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
public boolean renvoyerEtatFiltre() {
|
|
|
90 |
// TODO Auto-generated method stub
|
|
|
91 |
return false;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
public String renvoyerNomFiltre() {
|
|
|
96 |
// TODO Auto-generated method stub
|
|
|
97 |
return null;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
public String[] renvoyerValeursAFiltrer() {
|
|
|
102 |
// TODO Auto-generated method stub
|
|
|
103 |
return null;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
public void valider() {
|
|
|
108 |
// TODO Auto-generated method stub
|
|
|
109 |
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
public void rafraichir(Object nouvelleDonnees,
|
|
|
114 |
boolean repandreRaffraichissement) {
|
|
|
115 |
|
|
|
116 |
if(nouvelleDonnees instanceof Integer) {
|
|
|
117 |
nbMotsClesMax = (Integer)nouvelleDonnees;
|
|
|
118 |
demasquerChargement();
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
if(nouvelleDonnees instanceof Object[][]) {
|
|
|
122 |
|
|
|
123 |
listeMotsPesee = (Object[][])nouvelleDonnees ;
|
|
|
124 |
construireNuage();
|
|
|
125 |
demasquerChargement();
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
if(nouvelleDonnees instanceof String) {
|
|
|
129 |
|
|
|
130 |
String res = (String)nouvelleDonnees;
|
|
|
131 |
if(res.equals("OK")) {
|
|
|
132 |
masquerChargement();
|
|
|
133 |
oMediateur.obtenirListeObservation();
|
|
|
134 |
//oMediateur.obtenirNuageMotsCles(this);
|
|
|
135 |
}
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
private void construireNuage() {
|
|
|
140 |
|
|
|
141 |
contenuNuage.clear();
|
|
|
142 |
|
|
|
143 |
String contenu = "<ul class=\"nuagetag\">" ;
|
|
|
144 |
|
|
|
145 |
for(int i = 0; i<listeMotsPesee.length; i++) {
|
|
|
146 |
|
|
|
147 |
String classeMotCle = "motcletaille"+calculerPoids((Integer)listeMotsPesee[i][1]) ;
|
|
|
148 |
contenu += "<li class=\""+classeMotCle+"\">";
|
|
|
149 |
contenu += (String)listeMotsPesee[i][0];
|
|
|
150 |
contenu += "</li>";
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
contenu += "</ul>" ;
|
|
|
154 |
|
|
|
155 |
HTML contenuHTML = new HTML(contenu) {
|
|
|
156 |
public void onBrowserEvent(Event e) {
|
|
|
157 |
|
|
|
158 |
motsAAjouter += " "+e.getTarget().getInnerHTML();
|
|
|
159 |
motsClesAjout.setValue(motsAAjouter);
|
|
|
160 |
}
|
|
|
161 |
};
|
|
|
162 |
|
|
|
163 |
contenuHTML.sinkEvents(Event.ONCLICK);
|
|
|
164 |
contenuNuage.add(contenuHTML);
|
|
|
165 |
|
|
|
166 |
contenuNuage.doLayout();
|
|
|
167 |
doLayout();
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
private int calculerPoids(int poidMot) {
|
|
|
171 |
|
|
|
172 |
int poids = (poidMot*10)/nbMotsClesMax;
|
|
|
173 |
if(poids < 1) {
|
|
|
174 |
return 1;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
return poids;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
/**
|
|
|
181 |
* Recherche l'élement actuellement affiché et affiche son message de chargement
|
|
|
182 |
*/
|
|
|
183 |
public void masquerChargement()
|
|
|
184 |
{
|
|
|
185 |
ExtElement masked = Ext.get(getId()) ;
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
if (masked!=null) {
|
|
|
189 |
masked.mask("Chargement") ;
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
/**
|
|
|
195 |
* Recherche l'élement actuellement affiché et retire son message de chargement si l'était affiché
|
|
|
196 |
*/
|
|
|
197 |
public void demasquerChargement()
|
|
|
198 |
{
|
|
|
199 |
ExtElement masked = Ext.get(getId()) ;
|
|
|
200 |
|
|
|
201 |
if (masked!=null) {
|
|
|
202 |
masked.unmask() ;
|
|
|
203 |
}
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
}
|