60 |
jpm |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
61 |
jpm |
3 |
import org.tela_botanica.client.ComposantId;
|
|
|
4 |
import org.tela_botanica.client.Mediateur;
|
1107 |
jpm |
5 |
import org.tela_botanica.client.RegistreId;
|
1239 |
cyprien |
6 |
import org.tela_botanica.client.composants.InfoLogger;
|
536 |
jp_milcent |
7 |
import org.tela_botanica.client.i18n.Constantes;
|
1013 |
jpm |
8 |
import org.tela_botanica.client.i18n.ErrorMessages;
|
516 |
jp_milcent |
9 |
import org.tela_botanica.client.images.Images;
|
61 |
jpm |
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
156 |
jp_milcent |
11 |
import org.tela_botanica.client.modeles.Information;
|
61 |
jpm |
12 |
import org.tela_botanica.client.modeles.Utilisateur;
|
1013 |
jpm |
13 |
import org.tela_botanica.client.util.Debug;
|
60 |
jpm |
14 |
|
1107 |
jpm |
15 |
import com.extjs.gxt.ui.client.Registry;
|
60 |
jpm |
16 |
import com.extjs.gxt.ui.client.Style;
|
1239 |
cyprien |
17 |
import com.extjs.gxt.ui.client.Style.Direction;
|
60 |
jpm |
18 |
import com.extjs.gxt.ui.client.Style.Orientation;
|
499 |
jp_milcent |
19 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
20 |
import com.extjs.gxt.ui.client.event.MenuEvent;
|
60 |
jpm |
21 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
1239 |
cyprien |
22 |
import com.extjs.gxt.ui.client.fx.FxConfig;
|
66 |
jpm |
23 |
import com.extjs.gxt.ui.client.util.Format;
|
|
|
24 |
import com.extjs.gxt.ui.client.util.Params;
|
1239 |
cyprien |
25 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
60 |
jpm |
26 |
import com.extjs.gxt.ui.client.widget.HtmlContainer;
|
|
|
27 |
import com.extjs.gxt.ui.client.widget.Info;
|
|
|
28 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
|
29 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
30 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
|
|
31 |
import com.extjs.gxt.ui.client.widget.button.SplitButton;
|
|
|
32 |
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
|
|
33 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
|
|
34 |
import com.extjs.gxt.ui.client.widget.menu.Menu;
|
|
|
35 |
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
1286 |
gduche |
36 |
import com.google.gwt.user.client.ui.Image;
|
1239 |
cyprien |
37 |
import com.google.gwt.user.client.ui.ListBox;
|
60 |
jpm |
38 |
|
444 |
jp_milcent |
39 |
public class EnteteVue extends LayoutContainer implements Rafraichissable {
|
371 |
jp_milcent |
40 |
|
|
|
41 |
private Mediateur mediateur = null;
|
536 |
jp_milcent |
42 |
private Constantes i18nC = null;
|
1013 |
jpm |
43 |
private ErrorMessages i18nM = null;
|
1012 |
jpm |
44 |
|
|
|
45 |
private String identificationInfoTpl = null;
|
|
|
46 |
private String titreTpl = null;
|
|
|
47 |
|
|
|
48 |
private HtmlContainer conteneurHtml = null;
|
|
|
49 |
private SelectionListener<ButtonEvent> boutonEcouteur = null;
|
61 |
jpm |
50 |
private ButtonBar barreBoutons = null;
|
|
|
51 |
private Button identificationBouton = null;
|
1012 |
jpm |
52 |
private SplitButton feedbackBouton = null;
|
|
|
53 |
private SplitButton aideBouton = null;
|
|
|
54 |
private SplitButton applisBouton = null;
|
61 |
jpm |
55 |
|
1239 |
cyprien |
56 |
|
|
|
57 |
|
444 |
jp_milcent |
58 |
public EnteteVue(Mediateur mediateurCourant) {
|
371 |
jp_milcent |
59 |
mediateur = mediateurCourant;
|
1012 |
jpm |
60 |
i18nC = Mediateur.i18nC;
|
1013 |
jpm |
61 |
i18nM = Mediateur.i18nM;
|
1012 |
jpm |
62 |
|
|
|
63 |
setId(ComposantId.PANNEAU_ENTETE);
|
60 |
jpm |
64 |
setLayout(new RowLayout(Orientation.HORIZONTAL));
|
1012 |
jpm |
65 |
initialiserSquelettes();
|
|
|
66 |
boutonEcouteur = getEcouteurDesBoutons();
|
|
|
67 |
conteneurHtml = getIdentification();
|
|
|
68 |
identificationBouton = getBoutonIdentification();
|
|
|
69 |
feedbackBouton = getBoutonAFeedback();
|
|
|
70 |
aideBouton = getBoutonAide();
|
|
|
71 |
applisBouton = getBoutonApplications();
|
|
|
72 |
|
|
|
73 |
barreBoutons = new ButtonBar();
|
|
|
74 |
barreBoutons.setAlignment(Style.HorizontalAlignment.RIGHT);
|
|
|
75 |
barreBoutons.add(conteneurHtml);
|
|
|
76 |
barreBoutons.add(identificationBouton);
|
|
|
77 |
barreBoutons.add(aideBouton);
|
|
|
78 |
barreBoutons.add(feedbackBouton);
|
|
|
79 |
barreBoutons.add(applisBouton);
|
|
|
80 |
|
|
|
81 |
add(getTitre(), new RowData(.20, 1));
|
1239 |
cyprien |
82 |
add(barreBoutons, new RowData(.8, 1));
|
|
|
83 |
|
1012 |
jpm |
84 |
}
|
|
|
85 |
|
|
|
86 |
private void initialiserSquelettes() {
|
|
|
87 |
identificationInfoTpl = "<div id='"+ComposantId.DIV_IDENTIFICATION+"'>{0}</div>";
|
|
|
88 |
titreTpl = "<div id='"+ComposantId.DIV_TITRE+"'>{0}</div>";
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
private HtmlContainer getTitre() {
|
536 |
jp_milcent |
92 |
HtmlContainer titreConteneurHtml = new HtmlContainer();
|
1286 |
gduche |
93 |
titreConteneurHtml.setHtml(Format.substitute(titreTpl, Images.ICONES.logoCoel().getHTML()));//Registry.get(RegistreId.APPLI_NOM)));
|
1012 |
jpm |
94 |
return titreConteneurHtml;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
private HtmlContainer getIdentification() {
|
|
|
98 |
HtmlContainer conteneurHtml = new HtmlContainer();
|
60 |
jpm |
99 |
|
1013 |
jpm |
100 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
|
1012 |
jpm |
101 |
return conteneurHtml;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
private SelectionListener<ButtonEvent> getEcouteurDesBoutons() {
|
499 |
jp_milcent |
105 |
SelectionListener<ButtonEvent> boutonEcouteur = new SelectionListener<ButtonEvent>() {
|
|
|
106 |
public void componentSelected(ButtonEvent be) {
|
|
|
107 |
Button btn = (Button) be.getComponent();
|
1012 |
jpm |
108 |
String id = btn.getId();
|
|
|
109 |
String message = "";
|
372 |
jp_milcent |
110 |
|
1012 |
jpm |
111 |
if (id.equals(ComposantId.BTN_AIDE)
|
|
|
112 |
|| id.equals(ComposantId.BTN_FEEDBACK)
|
|
|
113 |
|| id.equals(ComposantId.BTN_APPLIS)) {
|
|
|
114 |
btn.showMenu();
|
|
|
115 |
} else if (id.equals(ComposantId.BTN_CONNEXION)) {
|
|
|
116 |
mediateur.ouvrirIdentification();
|
1680 |
raphael |
117 |
message = i18nM.chargementFenetre(btn.getHtml());
|
1012 |
jpm |
118 |
} else if (id.equals(ComposantId.BTN_DECONNEXION)) {
|
|
|
119 |
mediateur.deconnecterUtilisateur();
|
|
|
120 |
Utilisateur utilisateurCourant = mediateur.getUtilisateur();
|
1013 |
jpm |
121 |
message = i18nM.deconnexion(utilisateurCourant.getNomComplet());
|
1012 |
jpm |
122 |
} else if (id.equals(ComposantId.BTN_APPLIS)) {
|
61 |
jpm |
123 |
btn.getMenu().show(btn);
|
|
|
124 |
}
|
372 |
jp_milcent |
125 |
|
|
|
126 |
if (!message.equals("")) {
|
1239 |
cyprien |
127 |
InfoLogger.display(i18nC.chargement(), message);
|
372 |
jp_milcent |
128 |
}
|
60 |
jpm |
129 |
}
|
|
|
130 |
};
|
1012 |
jpm |
131 |
return boutonEcouteur;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
private Button getBoutonIdentification() {
|
|
|
135 |
Button bouton = new Button(i18nC.identification(), boutonEcouteur);
|
|
|
136 |
bouton.setId(ComposantId.BTN_CONNEXION);
|
|
|
137 |
return bouton;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
private SplitButton getBoutonAide() {
|
|
|
141 |
MenuItem menuDoc = new MenuItem(i18nC.doc());
|
|
|
142 |
menuDoc.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
143 |
@Override
|
|
|
144 |
public void componentSelected(MenuEvent mEvent) {
|
1013 |
jpm |
145 |
mediateur.ouvrirAide();
|
1012 |
jpm |
146 |
}
|
|
|
147 |
});
|
|
|
148 |
menuDoc.setId(ComposantId.MENU_DOC);
|
|
|
149 |
menuDoc.setIcon(Images.ICONES.aide());
|
60 |
jpm |
150 |
|
357 |
jp_milcent |
151 |
|
1012 |
jpm |
152 |
MenuItem menuApropos = new MenuItem(i18nC.apropos());
|
|
|
153 |
menuApropos.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
154 |
@Override
|
|
|
155 |
public void componentSelected(MenuEvent mEvent) {
|
1013 |
jpm |
156 |
mediateur.ouvrirParametres();
|
1012 |
jpm |
157 |
}
|
|
|
158 |
});
|
|
|
159 |
menuApropos.setId(ComposantId.MENU_APROPOS);
|
|
|
160 |
menuApropos.setIcon(Images.ICONES.engrenages());
|
544 |
jp_milcent |
161 |
|
1012 |
jpm |
162 |
Menu menuAide = new Menu();
|
|
|
163 |
menuAide.add(menuDoc);
|
|
|
164 |
menuAide.add(menuApropos);
|
357 |
jp_milcent |
165 |
|
1012 |
jpm |
166 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.aide());
|
|
|
167 |
boutonAvecMenus.setId(ComposantId.BTN_AIDE);
|
|
|
168 |
boutonAvecMenus.setIcon(Images.ICONES.aide());
|
|
|
169 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
170 |
boutonAvecMenus.setMenu(menuAide);
|
|
|
171 |
return boutonAvecMenus;
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
private SplitButton getBoutonAFeedback() {
|
|
|
175 |
MenuItem menuBogue = new MenuItem(i18nC.bogue());
|
989 |
jpm |
176 |
menuBogue.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
177 |
@Override
|
|
|
178 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
179 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
180 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BOGUE);
|
1680 |
raphael |
181 |
InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getHtml()));
|
1013 |
jpm |
182 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_BOGUE);
|
989 |
jpm |
183 |
}
|
|
|
184 |
});
|
|
|
185 |
menuBogue.setId(ComposantId.MENU_BOGUE);
|
|
|
186 |
menuBogue.setIcon(Images.ICONES.bogue());
|
1239 |
cyprien |
187 |
|
1012 |
jpm |
188 |
MenuItem menuCommentaire = new MenuItem(i18nC.remarques());
|
989 |
jpm |
189 |
menuCommentaire.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
190 |
@Override
|
|
|
191 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
192 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
193 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE);
|
1680 |
raphael |
194 |
InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getHtml()));
|
1013 |
jpm |
195 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_COMMENTAIRE);
|
989 |
jpm |
196 |
}
|
|
|
197 |
});
|
|
|
198 |
menuCommentaire.setId(ComposantId.MENU_COMMENTAIRE);
|
|
|
199 |
menuCommentaire.setIcon(Images.ICONES.commentaire());
|
1239 |
cyprien |
200 |
|
|
|
201 |
MenuItem fenetreJournal = new MenuItem("Journal de l'application");
|
|
|
202 |
fenetreJournal.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
203 |
@Override
|
|
|
204 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
205 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
206 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE);
|
1680 |
raphael |
207 |
//InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getHtml()));
|
1239 |
cyprien |
208 |
mediateur.ouvrirFenetreJournal();
|
|
|
209 |
}
|
|
|
210 |
});
|
1012 |
jpm |
211 |
|
1239 |
cyprien |
212 |
fenetreJournal.setIcon(Images.ICONES.newspaper());
|
|
|
213 |
|
1012 |
jpm |
214 |
Menu menuFeedback = new Menu();
|
|
|
215 |
menuFeedback.add(menuBogue);
|
989 |
jpm |
216 |
menuFeedback.add(menuCommentaire);
|
1239 |
cyprien |
217 |
menuFeedback.add(fenetreJournal);
|
989 |
jpm |
218 |
|
1012 |
jpm |
219 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.feedback());
|
|
|
220 |
boutonAvecMenus.setId(ComposantId.BTN_FEEDBACK);
|
|
|
221 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
222 |
boutonAvecMenus.setMenu(menuFeedback);
|
|
|
223 |
boutonAvecMenus.setIcon(Images.ICONES.flecheDedansDehors());
|
|
|
224 |
return boutonAvecMenus;
|
|
|
225 |
}
|
|
|
226 |
|
|
|
227 |
private SplitButton getBoutonApplications() {
|
1013 |
jpm |
228 |
MenuItem menuCel = new MenuItem(i18nC.cel());
|
499 |
jp_milcent |
229 |
menuCel.addSelectionListener(new SelectionListener<MenuEvent>() {
|
61 |
jpm |
230 |
@Override
|
499 |
jp_milcent |
231 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
232 |
Menu me = (Menu) mEvent.getComponent();
|
61 |
jpm |
233 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL);
|
1680 |
raphael |
234 |
InfoLogger.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getHtml()));
|
1013 |
jpm |
235 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_CEL);
|
61 |
jpm |
236 |
}
|
|
|
237 |
});
|
|
|
238 |
menuCel.setId(ComposantId.MENU_CEL);
|
516 |
jp_milcent |
239 |
menuCel.setIcon(Images.ICONES.images());
|
1012 |
jpm |
240 |
|
|
|
241 |
Menu menu = new Menu();
|
|
|
242 |
menu.add(menuCel);
|
61 |
jpm |
243 |
|
1013 |
jpm |
244 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.applicationExterne());
|
1012 |
jpm |
245 |
boutonAvecMenus.setId(ComposantId.BTN_APPLIS);
|
|
|
246 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
247 |
boutonAvecMenus.setMenu(menu);
|
|
|
248 |
boutonAvecMenus.setIcon(Images.ICONES.flecheBascule());
|
61 |
jpm |
249 |
|
1012 |
jpm |
250 |
return boutonAvecMenus;
|
60 |
jpm |
251 |
}
|
1012 |
jpm |
252 |
|
899 |
gduche |
253 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
254 |
if (nouvellesDonnees instanceof Information) {
|
|
|
255 |
Information info = (Information) nouvellesDonnees;
|
156 |
jp_milcent |
256 |
if (info.getType().equals("maj_utilisateur")) {
|
1013 |
jpm |
257 |
Utilisateur utilisateur = mediateur.getUtilisateur();
|
942 |
jpm |
258 |
if (utilisateur.isIdentifie()) {
|
1013 |
jpm |
259 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.bienvenue()+utilisateur.getNomComplet())));
|
|
|
260 |
identificationBouton.setText(i18nC.deconnexion());
|
516 |
jp_milcent |
261 |
identificationBouton.setIcon(Images.ICONES.deconnexion());
|
156 |
jp_milcent |
262 |
identificationBouton.setId(ComposantId.BTN_DECONNEXION);
|
|
|
263 |
} else {
|
1013 |
jpm |
264 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
|
|
|
265 |
identificationBouton.setText(i18nC.identification());
|
516 |
jp_milcent |
266 |
identificationBouton.setIcon(Images.ICONES.connexion());
|
156 |
jp_milcent |
267 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
|
|
268 |
}
|
65 |
jpm |
269 |
}
|
1013 |
jpm |
270 |
} else {
|
|
|
271 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
61 |
jpm |
272 |
}
|
156 |
jp_milcent |
273 |
layout();
|
61 |
jpm |
274 |
}
|
1654 |
raphael |
275 |
}
|