1789 |
aurelien |
1 |
package org.tela_botanica.client.vues.accueil;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.ComposantId;
|
|
|
4 |
import org.tela_botanica.client.Mediateur;
|
|
|
5 |
import org.tela_botanica.client.RegistreId;
|
|
|
6 |
import org.tela_botanica.client.composants.InfoLogger;
|
|
|
7 |
import org.tela_botanica.client.configuration.Configuration;
|
|
|
8 |
import org.tela_botanica.client.images.Images;
|
|
|
9 |
import org.tela_botanica.client.modeles.Information;
|
|
|
10 |
import org.tela_botanica.client.modeles.Menu;
|
|
|
11 |
import org.tela_botanica.client.util.Pattern;
|
|
|
12 |
import org.tela_botanica.client.util.Print;
|
|
|
13 |
|
|
|
14 |
import com.extjs.gxt.ui.client.event.Events;
|
|
|
15 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
16 |
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
|
|
17 |
import com.extjs.gxt.ui.client.Style.LayoutRegion;
|
|
|
18 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
|
19 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
20 |
import com.extjs.gxt.ui.client.event.Listener;
|
|
|
21 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
22 |
import com.extjs.gxt.ui.client.event.TreePanelEvent;
|
|
|
23 |
import com.extjs.gxt.ui.client.store.Store;
|
|
|
24 |
import com.extjs.gxt.ui.client.store.TreeStore;
|
|
|
25 |
import com.extjs.gxt.ui.client.util.Margins;
|
|
|
26 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
27 |
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
|
28 |
import com.extjs.gxt.ui.client.widget.HtmlContainer;
|
|
|
29 |
import com.extjs.gxt.ui.client.widget.Info;
|
|
|
30 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
|
31 |
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
|
|
|
32 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
33 |
import com.extjs.gxt.ui.client.widget.custom.Portlet;
|
|
|
34 |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
|
|
|
35 |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
|
|
|
36 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
37 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
|
|
38 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
|
|
39 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
|
|
40 |
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
|
|
|
41 |
import com.google.gwt.core.client.GWT;
|
|
|
42 |
import com.google.gwt.http.client.Request;
|
|
|
43 |
import org.tela_botanica.client.http.RequestBuilderWithCredentials;
|
|
|
44 |
import com.google.gwt.http.client.RequestCallback;
|
|
|
45 |
import com.google.gwt.http.client.RequestException;
|
|
|
46 |
import com.google.gwt.http.client.Response;
|
|
|
47 |
import com.google.gwt.json.client.JSONArray;
|
|
|
48 |
import com.google.gwt.json.client.JSONObject;
|
|
|
49 |
import com.google.gwt.json.client.JSONParser;
|
|
|
50 |
import com.google.gwt.json.client.JSONValue;
|
|
|
51 |
import com.google.gwt.regexp.shared.MatchResult;
|
|
|
52 |
import com.google.gwt.regexp.shared.RegExp;
|
|
|
53 |
import com.google.gwt.user.client.Event;
|
|
|
54 |
import com.google.gwt.user.client.Window;
|
|
|
55 |
|
|
|
56 |
public class AccueilTutorielVue extends LayoutContainer {
|
|
|
57 |
|
|
|
58 |
private static final String SERVICE_NOM = "CoelAide";
|
|
|
59 |
private static final String PAGE_A_OUVRIR_CODE = "AideCOELTutoriel";
|
|
|
60 |
|
|
|
61 |
private static Menu pagePrincipale = null;
|
|
|
62 |
private static Menu menuAOuvrirParDefaut = null;
|
|
|
63 |
|
|
|
64 |
private ContentPanel contenuPanneau = null;
|
|
|
65 |
private HtmlContainer conteneurDuHtml;
|
|
|
66 |
private LayoutContainer entetePanneau;
|
|
|
67 |
|
|
|
68 |
public AccueilTutorielVue(Mediateur mediateur) {
|
|
|
69 |
setLayout(new FitLayout());
|
|
|
70 |
creerPanneauContenu();
|
|
|
71 |
chargerPageParDefaut();
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
private void chargerPageParDefaut() {
|
|
|
75 |
String serviceUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
|
|
|
76 |
String defautPageUrl = serviceUrl+SERVICE_NOM+"/"+PAGE_A_OUVRIR_CODE+"/";
|
|
|
77 |
chargerPageAide(defautPageUrl);
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
private void creerPanneauContenu() {
|
|
|
81 |
contenuPanneau = new ContentPanel();
|
|
|
82 |
contenuPanneau.setScrollMode(Scroll.AUTO);
|
|
|
83 |
contenuPanneau.setHeaderVisible(false);
|
|
|
84 |
contenuPanneau.setLayout(new FitLayout());
|
|
|
85 |
add(contenuPanneau);
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
private void chargerPageAide(String url) {
|
|
|
89 |
conteneurDuHtml = new HtmlContainer() {
|
|
|
90 |
public void onBrowserEvent(Event e) {
|
|
|
91 |
// Nous vérifions que l'évenement est un clic et qu'il a lieu sur un lien
|
|
|
92 |
if (e.getTypeInt() == Event.ONCLICK && e.getEventTarget().toString().startsWith("<a href=\"http://")) {
|
|
|
93 |
e.preventDefault();
|
|
|
94 |
String urlPageCliquee = extraireLien(e.getEventTarget().toString());
|
|
|
95 |
if(urlPageCliquee != null) {
|
|
|
96 |
chargerPageAide(urlPageCliquee);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
} else {
|
|
|
100 |
GWT.log("Event target:"+e.getEventTarget().toString()+" - type :"+e.getTypeInt()+"="+Event.ONCLICK, null);
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
};
|
|
|
104 |
|
|
|
105 |
conteneurDuHtml.setId(ComposantId.PANNEAU_TUTORIEL);
|
|
|
106 |
|
|
|
107 |
conteneurDuHtml.sinkEvents(Event.ONCLICK);
|
|
|
108 |
conteneurDuHtml.setUrl(url);
|
|
|
109 |
conteneurDuHtml.recalculate();
|
|
|
110 |
|
|
|
111 |
contenuPanneau.removeAll();
|
|
|
112 |
contenuPanneau.add(conteneurDuHtml);
|
|
|
113 |
contenuPanneau.layout();
|
1794 |
aurelien |
114 |
|
|
|
115 |
conteneurDuHtml.setStyleAttribute("padding-left", "5px");
|
|
|
116 |
conteneurDuHtml.setStyleAttribute("padding-top", "5px");
|
1789 |
aurelien |
117 |
}
|
|
|
118 |
|
|
|
119 |
public String extraireLien(String str) {
|
|
|
120 |
String lien = null;
|
|
|
121 |
RegExp regExp = RegExp.compile("href=\"(.*?)\"");
|
|
|
122 |
MatchResult matcher = regExp.exec(str);
|
|
|
123 |
boolean matchOK = (matcher != null);
|
|
|
124 |
if (matchOK) {
|
|
|
125 |
//TODO plus de vérifications
|
|
|
126 |
lien = matcher.getGroup(1);
|
|
|
127 |
}
|
|
|
128 |
return lien;
|
|
|
129 |
}
|
|
|
130 |
}
|