Line 1... |
Line 1... |
1 |
package org.tela_botanica.client.composants;
|
1 |
package org.tela_botanica.client.composants;
|
Line 2... |
Line -... |
2 |
|
- |
|
3 |
import org.tela_botanica.client.ComposantClass;
|
2 |
|
4 |
import org.tela_botanica.client.ComposantId;
|
3 |
import org.tela_botanica.client.ComposantId;
|
5 |
import org.tela_botanica.client.RegistreId;
|
4 |
import org.tela_botanica.client.RegistreId;
|
6 |
import org.tela_botanica.client.images.Images;
|
5 |
import org.tela_botanica.client.images.Images;
|
7 |
import org.tela_botanica.client.modeles.Configuration;
|
6 |
import org.tela_botanica.client.modeles.Configuration;
|
8 |
import org.tela_botanica.client.modeles.Information;
|
7 |
import org.tela_botanica.client.modeles.Information;
|
- |
|
8 |
import org.tela_botanica.client.modeles.Menu;
|
9 |
import org.tela_botanica.client.modeles.Menu;
|
9 |
import org.tela_botanica.client.util.Pattern;
|
Line 10... |
Line 10... |
10 |
import org.tela_botanica.client.util.Print;
|
10 |
import org.tela_botanica.client.util.Print;
|
11 |
|
11 |
|
- |
|
12 |
import com.extjs.gxt.ui.client.event.Events;
|
- |
|
13 |
import com.extjs.gxt.ui.client.Registry;
|
- |
|
14 |
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
12 |
import com.extjs.gxt.ui.client.event.Events;
|
15 |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
13 |
import com.extjs.gxt.ui.client.Registry;
|
16 |
import com.extjs.gxt.ui.client.Style.IconAlign;
|
14 |
import com.extjs.gxt.ui.client.Style.LayoutRegion;
|
17 |
import com.extjs.gxt.ui.client.Style.LayoutRegion;
|
15 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
18 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
16 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
19 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
Line 29... |
Line 32... |
29 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
32 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
30 |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
|
33 |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
|
31 |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
|
34 |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
|
32 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
35 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
33 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
36 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
- |
|
37 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
34 |
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
|
38 |
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
|
35 |
import com.google.gwt.core.client.GWT;
|
39 |
import com.google.gwt.core.client.GWT;
|
36 |
import com.google.gwt.http.client.Request;
|
40 |
import com.google.gwt.http.client.Request;
|
37 |
import com.google.gwt.http.client.RequestBuilder;
|
41 |
import com.google.gwt.http.client.RequestBuilder;
|
38 |
import com.google.gwt.http.client.RequestCallback;
|
42 |
import com.google.gwt.http.client.RequestCallback;
|
Line 45... |
Line 49... |
45 |
import com.google.gwt.user.client.Event;
|
49 |
import com.google.gwt.user.client.Event;
|
Line 46... |
Line 50... |
46 |
|
50 |
|
Line 47... |
Line 51... |
47 |
public class AideFenetre extends Dialog {
|
51 |
public class AideFenetre extends Dialog {
|
48 |
|
52 |
|
49 |
private static final String SERVICE_NOM = "CoelAide";
|
53 |
private static final String SERVICE_NOM = "CoelAide";
|
50 |
private static final String PAGE_SOMMAIRE_CODE = "AideCoelSommaire";
|
54 |
private static final String PAGE_SOMMAIRE_CODE = "AideCOELSommaire";
|
51 |
private static final String PAGE_A_OUVRIR_CODE = "AideCoelPresentationGenerale";
|
55 |
private static final String PAGE_A_OUVRIR_CODE = "AideCOELPresentationGenerale";
|
52 |
private static Menu pagePrincipale = null;
|
56 |
private static Menu pagePrincipale = null;
|
53 |
private static Menu menuAOuvrirParDefaut = null;
|
57 |
private static Menu menuAOuvrirParDefaut = null;
|
54 |
private TreePanel<Menu> arbre = null;
|
58 |
private TreePanel<Menu> arbre = null;
|
55 |
private TreeStore<Menu> magazin = null;
|
59 |
private TreeStore<Menu> magazin = null;
|
56 |
private StoreFilterField<Menu> filtre = null;
|
60 |
private StoreFilterField<Menu> filtre = null;
|
57 |
private Menu sommaire = null;
|
61 |
private Menu sommaire = null;
|
58 |
private ContentPanel sommairePanneau = null;
|
62 |
private ContentPanel sommairePanneau = null;
|
59 |
private ContentPanel contenuPanneau = null;
|
63 |
private ContentPanel contenuPanneau = null;
|
- |
|
64 |
private HtmlContainer conteneurDuHtml;
|
Line 60... |
Line 65... |
60 |
private HtmlContainer conteneurDuHtml;
|
65 |
private LayoutContainer entetePanneau;
|
61 |
private LayoutContainer entetePanneau;
|
66 |
private ToolBar sommaireBarreOutils;
|
62 |
|
67 |
|
63 |
public AideFenetre() {
|
68 |
public AideFenetre() {
|
Line 68... |
Line 73... |
68 |
setWidth(675);
|
73 |
setWidth(675);
|
69 |
setHeight(400);
|
74 |
setHeight(400);
|
70 |
setHideOnButtonClick(true);
|
75 |
setHideOnButtonClick(true);
|
71 |
setLayout(new BorderLayout());
|
76 |
setLayout(new BorderLayout());
|
Line -... |
Line 77... |
- |
|
77 |
|
- |
|
78 |
creerPanneauEntete();
|
- |
|
79 |
creerPanneauSommaire();
|
72 |
|
80 |
getSommaireArbreModele();
|
- |
|
81 |
creerPanneauContenu();
|
- |
|
82 |
}
|
- |
|
83 |
|
73 |
// Panneau Nord : entête
|
84 |
private void creerPanneauEntete() {
|
74 |
entetePanneau = new LayoutContainer();
|
85 |
entetePanneau = new LayoutContainer();
|
75 |
entetePanneau.setLayout(new FlowLayout());
|
86 |
entetePanneau.setLayout(new FlowLayout());
|
76 |
BorderLayoutData enteteDisposition = new BorderLayoutData(LayoutRegion.NORTH, 30);
|
87 |
BorderLayoutData enteteDisposition = new BorderLayoutData(LayoutRegion.NORTH, 30);
|
77 |
add(entetePanneau, enteteDisposition);
|
88 |
add(entetePanneau, enteteDisposition);
|
78 |
|
- |
|
Line 79... |
Line -... |
79 |
inititialiserSommaireArbreFiltre();
|
- |
|
80 |
|
89 |
}
|
- |
|
90 |
|
81 |
|
91 |
private void creerPanneauSommaire() {
|
- |
|
92 |
inititialiserSommaireArbreFiltre();
|
82 |
// Panneau Ouest : sommaire
|
93 |
creerSommaire();
|
83 |
creerSommaire();
|
94 |
|
- |
|
95 |
sommairePanneau = new ContentPanel();
|
- |
|
96 |
sommairePanneau.setScrollMode(Scroll.AUTO);
|
- |
|
97 |
sommairePanneau.setHeight("100%");
|
- |
|
98 |
sommairePanneau.setHeaderVisible(false);
|
- |
|
99 |
|
84 |
sommairePanneau = new ContentPanel();
|
100 |
creerBarreOutilSommaire();
|
85 |
sommairePanneau.setScrollMode(Scroll.AUTO);
|
101 |
|
86 |
BorderLayoutData sommaireDisposition = new BorderLayoutData(LayoutRegion.WEST, 230, 175, 350);
|
102 |
BorderLayoutData sommaireDisposition = new BorderLayoutData(LayoutRegion.WEST, 230, 175, 350);
|
87 |
sommaireDisposition.setMargins(new Margins(0, 5, 0, 0));
|
103 |
sommaireDisposition.setMargins(new Margins(0, 5, 0, 0));
|
- |
|
104 |
sommaireDisposition.setSplit(true);
|
- |
|
105 |
sommaireDisposition.setFloatable(true);
|
88 |
sommaireDisposition.setSplit(true);
|
106 |
add(sommairePanneau, sommaireDisposition);
|
- |
|
107 |
}
|
- |
|
108 |
|
- |
|
109 |
private void creerBarreOutilSommaire() {
|
- |
|
110 |
sommaireBarreOutils = new ToolBar();
|
- |
|
111 |
// FIXME : on peut utiliser l'alignement à droite car cela pose un problème de rendu dans le Hosted Mode
|
- |
|
112 |
//sommaireBarreOutils.setAlignment(HorizontalAlignment.RIGHT);
|
- |
|
113 |
creerBoutonPlierDeplier();
|
- |
|
114 |
sommairePanneau.setTopComponent(sommaireBarreOutils);
|
- |
|
115 |
}
|
- |
|
116 |
|
89 |
sommaireDisposition.setFloatable(true);
|
117 |
private void creerBoutonPlierDeplier() {
|
90 |
|
118 |
Button plierDeplierToutBtn = new Button();
|
91 |
Button plierDeplierToutBtn = new Button(null, new SelectionListener<ButtonEvent>() {
|
119 |
plierDeplierToutBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
92 |
public void componentSelected(ButtonEvent be) {
|
- |
|
93 |
Button boutonPlierDeplierTout = (Button) be.getSource();
|
120 |
public void componentSelected(ButtonEvent be) {
|
94 |
// CHECK : vérifier si cela marche
|
121 |
Button boutonPlierDeplierTout = (Button) be.getSource();
|
95 |
if (boutonPlierDeplierTout.getIcon().equals(Images.ICONES.deplierTout())) {
|
122 |
if (boutonPlierDeplierTout.getIcon().equals(Images.ICONES.deplierTout())) {
|
96 |
boutonPlierDeplierTout.setIcon(Images.ICONES.deplierTout());
|
123 |
boutonPlierDeplierTout.setIcon(Images.ICONES.replierTout());
|
97 |
arbre.expandAll();
|
124 |
arbre.expandAll();
|
98 |
} else if (boutonPlierDeplierTout.getIcon().equals(Images.ICONES.replierTout())) {
|
125 |
} else if (boutonPlierDeplierTout.getIcon().equals(Images.ICONES.replierTout())) {
|
99 |
boutonPlierDeplierTout.setIcon(Images.ICONES.replierTout());
|
126 |
boutonPlierDeplierTout.setIcon(Images.ICONES.deplierTout());
|
- |
|
127 |
arbre.collapseAll();
|
100 |
arbre.collapseAll();
|
128 |
}
|
101 |
}
|
129 |
boutonPlierDeplierTout.repaint();
|
102 |
}
|
130 |
}
|
- |
|
131 |
});
|
103 |
});
|
132 |
plierDeplierToutBtn.setIcon(Images.ICONES.deplierTout());
|
104 |
plierDeplierToutBtn.setIcon(Images.ICONES.deplierTout());
|
133 |
plierDeplierToutBtn.setScale(ButtonScale.SMALL);
|
105 |
plierDeplierToutBtn.setToolTip("Étendre le sommaire");
|
134 |
plierDeplierToutBtn.setToolTip("Étendre le sommaire");
|
106 |
sommairePanneau.getHeader().insertTool(plierDeplierToutBtn, 0);
|
- |
|
107 |
|
- |
|
108 |
add(sommairePanneau, sommaireDisposition);
|
- |
|
109 |
|
- |
|
110 |
// Chargement de l'arbre du sommaire et de son filtre
|
135 |
sommaireBarreOutils.add(plierDeplierToutBtn);
|
111 |
getSommaireArbreModele();
|
136 |
}
|
112 |
|
137 |
|
113 |
// Panneau Central : contenu
|
138 |
private void creerPanneauContenu() {
|
- |
|
139 |
contenuPanneau = new ContentPanel();
|
114 |
contenuPanneau = new ContentPanel();
|
140 |
contenuPanneau.setScrollMode(Scroll.AUTO);
|
- |
|
141 |
|
- |
|
142 |
creerBarreOutilContenu();
|
- |
|
143 |
|
- |
|
144 |
BorderLayoutData contenuDisposition = new BorderLayoutData(LayoutRegion.CENTER);
|
- |
|
145 |
add(contenuPanneau, contenuDisposition);
|
- |
|
146 |
}
|
115 |
contenuPanneau.setScrollMode(Scroll.AUTO);
|
147 |
|
116 |
// Barre d'outils
|
148 |
private void creerBarreOutilContenu() {
|
117 |
Button imprimerBtn = new Button(null, new SelectionListener<ButtonEvent>() {
|
149 |
Button imprimerBtn = new Button(null, new SelectionListener<ButtonEvent>() {
|
118 |
public void componentSelected(ButtonEvent be) {
|
150 |
public void componentSelected(ButtonEvent be) {
|
119 |
Print.it(conteneurDuHtml.el().getInnerHtml());
|
151 |
Print.it(conteneurDuHtml.el().getInnerHtml());
|
120 |
}
|
152 |
}
|
121 |
});
|
153 |
});
|
122 |
imprimerBtn.setIcon(Images.ICONES.imprimer());
|
- |
|
123 |
contenuPanneau.getHeader().insertTool(imprimerBtn, 0);
|
- |
|
124 |
BorderLayoutData contenuDisposition = new BorderLayoutData(LayoutRegion.CENTER);
|
154 |
imprimerBtn.setIcon(Images.ICONES.imprimer());
|
125 |
add(contenuPanneau, contenuDisposition);
|
155 |
contenuPanneau.getHeader().insertTool(imprimerBtn, 0);
|
126 |
}
|
156 |
}
|
- |
|
157 |
|
127 |
|
158 |
private void etendreArbre(Menu menuAOuvrir) {
|
- |
|
159 |
if (menuAOuvrir != null) {
|
- |
|
160 |
arbre.setExpanded(menuAOuvrir, true);
|
128 |
private void etendreArbre(Menu menuAOuvrir) {
|
161 |
arbre.getSelectionModel().select(menuAOuvrir, false);
|
Line 129... |
Line 162... |
129 |
arbre.setExpanded(menuAOuvrir, true);
|
162 |
}
|
130 |
}
|
163 |
}
|
131 |
|
- |
|
132 |
private void etendreArbre(String menuCode) {
|
164 |
|
133 |
Menu menuAOuvrir = magazin.findModel("code", menuCode);
|
- |
|
134 |
if (menuAOuvrir != null) {
|
165 |
private void etendreArbre(String menuCode) {
|
Line 135... |
Line 166... |
135 |
arbre.setExpanded(menuAOuvrir, true);
|
166 |
Menu menuAOuvrir = magazin.findModel("code", menuCode);
|
136 |
}
|
167 |
etendreArbre(menuAOuvrir);
|
Line 137... |
Line 168... |
137 |
}
|
168 |
}
|
Line 138... |
Line 169... |
138 |
|
169 |
|
- |
|
170 |
private void creerSommaire() {
|
- |
|
171 |
magazin = new TreeStore<Menu>();
|
- |
|
172 |
|
139 |
private void creerSommaire() {
|
173 |
filtre.bind(magazin);
|
140 |
magazin = new TreeStore<Menu>();
|
174 |
|
141 |
|
175 |
arbre = new TreePanel<Menu>(magazin);
|
142 |
filtre.bind(magazin);
|
176 |
arbre.setAutoLoad(true);
|
143 |
|
- |
|
144 |
arbre = new TreePanel<Menu>(magazin);
|
- |
|
145 |
arbre.getStyle().setLeafIcon(Images.ICONES.aide());
|
177 |
arbre.setHeight("100%");
|
146 |
arbre.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
|
178 |
arbre.setDisplayProperty("nom");
|
147 |
public void handleEvent(TreePanelEvent<Menu> tpe) {
|
- |
|
148 |
TreePanel<Menu> f = tpe.getComponent();
|
179 |
arbre.getStyle().setLeafIcon(Images.ICONES.aide());
|
149 |
if (f.getModel() != null) {
|
180 |
arbre.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
|
150 |
Menu menu = f.getModel();
|
181 |
public void handleEvent(TreePanelEvent<Menu> tpe) {
|
151 |
if (menu.get("code") != null) {
|
182 |
Menu menuSelectionne = arbre.getSelectionModel().getSelectedItem();
|
Line 170... |
Line 201... |
170 |
private void chargerPageAide(String url) {
|
201 |
private void chargerPageAide(String url) {
|
171 |
GWT.log("Charger : "+url, null);
|
202 |
GWT.log("Charger : "+url, null);
|
172 |
conteneurDuHtml = new HtmlContainer() {
|
203 |
conteneurDuHtml = new HtmlContainer() {
|
173 |
public void onBrowserEvent(Event e) {
|
204 |
public void onBrowserEvent(Event e) {
|
174 |
// Nous vérifions que l'évenement est un clic et qu'il a lieu sur un lien
|
205 |
// Nous vérifions que l'évenement est un clic et qu'il a lieu sur un lien
|
175 |
if (e.getTypeInt() == Event.ONCLICK && e.getEventTarget().equals("A")) {
|
206 |
if (e.getTypeInt() == Event.ONCLICK && e.getEventTarget().toString().startsWith("http://")) {
|
176 |
e.preventDefault();
|
207 |
e.preventDefault();
|
177 |
String urlPageAideCible = e.getEventTarget().toString();
|
208 |
String urlPageAideCible = e.getEventTarget().toString();
|
178 |
chargerPageAide(urlPageAideCible);
|
209 |
chargerPageAide(urlPageAideCible);
|
179 |
String codePageAideCible = urlPageAideCible.substring(urlPageAideCible.lastIndexOf("/")+1);
|
210 |
String codePageAideCible = urlPageAideCible.substring(urlPageAideCible.lastIndexOf("/")+1);
|
180 |
etendreArbre(codePageAideCible);
|
211 |
etendreArbre(codePageAideCible);
|
181 |
GWT.log("Clic : "+urlPageAideCible+"::"+codePageAideCible, null);
|
212 |
GWT.log("Clic : "+urlPageAideCible+"::"+codePageAideCible, null);
|
182 |
} else {
|
213 |
} else {
|
183 |
GWT.log("Event :"+e.getType(), null);
|
214 |
GWT.log("Event target:"+e.getEventTarget().toString()+" - type :"+e.getTypeInt()+"="+Event.ONCLICK, null);
|
184 |
}
|
215 |
}
|
185 |
}
|
216 |
}
|
186 |
};
|
217 |
};
|
Line 187... |
Line 218... |
187 |
|
218 |
|
Line 203... |
Line 234... |
203 |
Boolean retour = false;
|
234 |
Boolean retour = false;
|
204 |
// Seul les feuilles sont traitées par le filtre
|
235 |
// Seul les feuilles sont traitées par le filtre
|
205 |
String nomMenu = enregistrement.getNom();
|
236 |
String nomMenu = enregistrement.getNom();
|
206 |
String nomMenuMinuscule = nomMenu.toLowerCase();
|
237 |
String nomMenuMinuscule = nomMenu.toLowerCase();
|
207 |
String nomFiltreMinuscule = filtre.toLowerCase();
|
238 |
String nomFiltreMinuscule = filtre.toLowerCase();
|
- |
|
239 |
String nomFiltreMinusculeProtege = Pattern.quote(nomFiltreMinuscule);
|
208 |
if (nomMenuMinuscule.matches(".*"+nomFiltreMinuscule+".*")) {
|
240 |
if (nomMenuMinuscule.matches(".*"+nomFiltreMinusculeProtege+".*")) {
|
209 |
retour = true;
|
241 |
retour = true;
|
210 |
}
|
242 |
}
|
211 |
return retour;
|
243 |
return retour;
|
212 |
}
|
244 |
}
|
213 |
};
|
245 |
};
|
Line 291... |
Line 323... |
291 |
JSONObject pageCourante = tableau.get(i).isObject() ;
|
323 |
JSONObject pageCourante = tableau.get(i).isObject() ;
|
292 |
if (pageCourante != null) {
|
324 |
if (pageCourante != null) {
|
293 |
Menu menuCourrant = new Menu();
|
325 |
Menu menuCourrant = new Menu();
|
Line 294... |
Line 326... |
294 |
|
326 |
|
295 |
if (pageCourante.get("code") != null) {
|
327 |
if (pageCourante.get("code") != null) {
|
- |
|
328 |
String codeCourant = pageCourante.get("code").isString().stringValue();
|
296 |
menuCourrant.setCode(pageCourante.get("code").isString().stringValue());
|
329 |
menuCourrant.setCode(codeCourant);
|
297 |
}
|
330 |
}
|
298 |
if (pageCourante.get("txt") != null) {
|
331 |
if (pageCourante.get("txt") != null) {
|
299 |
menuCourrant.setNom(pageCourante.get("txt").isString().stringValue());
|
332 |
menuCourrant.setNom(pageCourante.get("txt").isString().stringValue());
|
Line 307... |
Line 340... |
307 |
if (pagePrincipale == null) {
|
340 |
if (pagePrincipale == null) {
|
308 |
pagePrincipale = menuCourrant;
|
341 |
pagePrincipale = menuCourrant;
|
309 |
}
|
342 |
}
|
310 |
}
|
343 |
}
|
311 |
}
|
344 |
}
|
312 |
|
- |
|
313 |
if (pageCourante.get("liste") != null) {
|
345 |
if (pageCourante.get("liste") != null) {
|
314 |
ajouterMenuRecursivement(menuCourrant, pageCourante.get("liste").isArray());
|
346 |
ajouterMenuRecursivement(menuCourrant, pageCourante.get("liste").isArray());
|
315 |
}
|
347 |
}
|
316 |
}
|
348 |
}
|
317 |
}
|
349 |
}
|