| 113 |
aurelien |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.interfaces.Filtrable;
|
|
|
4 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
5 |
import org.tela_botanica.client.observation.ObservationMediateur;
|
|
|
6 |
|
|
|
7 |
import com.google.gwt.user.client.Event;
|
|
|
8 |
import com.google.gwt.user.client.ui.ClickListener;
|
|
|
9 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
10 |
import com.gwtext.client.core.Ajax;
|
|
|
11 |
import com.gwtext.client.core.EventObject;
|
|
|
12 |
import com.gwtext.client.core.Ext;
|
|
|
13 |
import com.gwtext.client.core.ExtElement;
|
|
|
14 |
import com.gwtext.client.widgets.Window;
|
|
|
15 |
|
|
|
16 |
public class NuageMotsClesVue extends Window implements Filtrable, Rafraichissable {
|
|
|
17 |
|
|
|
18 |
private ObservationMediateur oMediateur = null ;
|
|
|
19 |
|
|
|
20 |
private Object[][] listeMotsPesee = null;
|
|
|
21 |
|
|
|
22 |
private String motsAChercher = "" ;
|
|
|
23 |
|
|
|
24 |
private int nbMotsClesMax = 1 ;
|
|
|
25 |
|
|
|
26 |
public NuageMotsClesVue(ObservationMediateur om) {
|
|
|
27 |
super("Nuage de mots clés");
|
|
|
28 |
setCls("fenmotcles");
|
|
|
29 |
oMediateur = om ;
|
|
|
30 |
setWidth(200);
|
|
|
31 |
this.setCloseAction(CLOSE);
|
|
|
32 |
oMediateur.obtenirNuageMotsCles(this);
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
public boolean renvoyerEtatFiltre() {
|
|
|
37 |
// TODO Auto-generated method stub
|
|
|
38 |
return false;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
public String renvoyerNomFiltre() {
|
|
|
43 |
// TODO Auto-generated method stub
|
|
|
44 |
return null;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
public String[] renvoyerValeursAFiltrer() {
|
|
|
49 |
// TODO Auto-generated method stub
|
|
|
50 |
return null;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
public void valider() {
|
|
|
55 |
// TODO Auto-generated method stub
|
|
|
56 |
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
public void rafraichir(Object nouvelleDonnees,
|
|
|
61 |
boolean repandreRaffraichissement) {
|
|
|
62 |
|
|
|
63 |
if(nouvelleDonnees instanceof Integer) {
|
|
|
64 |
nbMotsClesMax = (Integer)nouvelleDonnees;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
if(nouvelleDonnees instanceof Object[][]) {
|
|
|
68 |
|
|
|
69 |
listeMotsPesee = (Object[][])nouvelleDonnees ;
|
|
|
70 |
construireNuage();
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
private void construireNuage() {
|
|
|
75 |
|
|
|
76 |
String contenu = "<ul class=\"nuagetag\">" ;
|
|
|
77 |
|
|
|
78 |
for(int i = 0; i<listeMotsPesee.length; i++) {
|
|
|
79 |
|
|
|
80 |
String classeMotCle = "motcletaille"+calculerPoids((Integer)listeMotsPesee[i][1]) ;
|
|
|
81 |
contenu += "<li class=\""+classeMotCle+"\">";
|
|
|
82 |
contenu += (String)listeMotsPesee[i][0];
|
|
|
83 |
contenu += "</li>";
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
contenu += "</ul>" ;
|
|
|
87 |
|
|
|
88 |
HTML contenuHTML = new HTML(contenu) {
|
|
|
89 |
public void onBrowserEvent(Event e) {
|
|
|
90 |
|
|
|
91 |
oMediateur.ajouterMotCleRecherche(e.getTarget().getInnerHTML());
|
|
|
92 |
}
|
|
|
93 |
};
|
|
|
94 |
|
|
|
95 |
contenuHTML.sinkEvents(Event.ONCLICK);
|
|
|
96 |
|
|
|
97 |
this.clear();
|
|
|
98 |
this.add(contenuHTML);
|
|
|
99 |
|
|
|
100 |
doLayout();
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
private int calculerPoids(int poidMot) {
|
|
|
104 |
|
|
|
105 |
int poids = (poidMot*10)/nbMotsClesMax;
|
|
|
106 |
if(poids < 1) {
|
|
|
107 |
return 1;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
return poids;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
* Recherche l'élement actuellement affiché et affiche son message de chargement
|
|
|
115 |
*/
|
|
|
116 |
public void masquerChargement()
|
|
|
117 |
{
|
|
|
118 |
ExtElement masked = Ext.get(getId()) ;
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
if (masked!=null) {
|
|
|
122 |
masked.mask("Chargement") ;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
/**
|
|
|
128 |
* Recherche l'élement actuellement affiché et retire son message de chargement si l'était affiché
|
|
|
129 |
*/
|
|
|
130 |
public void demasquerChargement()
|
|
|
131 |
{
|
|
|
132 |
ExtElement masked = Ext.get(getId()) ;
|
|
|
133 |
|
|
|
134 |
if (masked!=null) {
|
|
|
135 |
masked.unmask() ;
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
}
|