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 |
|
1286 |
gduche |
81 |
|
1012 |
jpm |
82 |
add(getTitre(), new RowData(.20, 1));
|
1239 |
cyprien |
83 |
add(barreBoutons, new RowData(.8, 1));
|
|
|
84 |
|
1012 |
jpm |
85 |
}
|
|
|
86 |
|
|
|
87 |
private void initialiserSquelettes() {
|
|
|
88 |
identificationInfoTpl = "<div id='"+ComposantId.DIV_IDENTIFICATION+"'>{0}</div>";
|
|
|
89 |
titreTpl = "<div id='"+ComposantId.DIV_TITRE+"'>{0}</div>";
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
private HtmlContainer getTitre() {
|
536 |
jp_milcent |
93 |
HtmlContainer titreConteneurHtml = new HtmlContainer();
|
1286 |
gduche |
94 |
titreConteneurHtml.setHtml(Format.substitute(titreTpl, Images.ICONES.logoCoel().getHTML()));//Registry.get(RegistreId.APPLI_NOM)));
|
1012 |
jpm |
95 |
return titreConteneurHtml;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
private HtmlContainer getIdentification() {
|
|
|
99 |
HtmlContainer conteneurHtml = new HtmlContainer();
|
60 |
jpm |
100 |
|
1013 |
jpm |
101 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
|
1012 |
jpm |
102 |
return conteneurHtml;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
private SelectionListener<ButtonEvent> getEcouteurDesBoutons() {
|
499 |
jp_milcent |
106 |
SelectionListener<ButtonEvent> boutonEcouteur = new SelectionListener<ButtonEvent>() {
|
|
|
107 |
public void componentSelected(ButtonEvent be) {
|
|
|
108 |
Button btn = (Button) be.getComponent();
|
1012 |
jpm |
109 |
String id = btn.getId();
|
|
|
110 |
String message = "";
|
372 |
jp_milcent |
111 |
|
1012 |
jpm |
112 |
if (id.equals(ComposantId.BTN_AIDE)
|
|
|
113 |
|| id.equals(ComposantId.BTN_FEEDBACK)
|
|
|
114 |
|| id.equals(ComposantId.BTN_APPLIS)) {
|
|
|
115 |
btn.showMenu();
|
|
|
116 |
} else if (id.equals(ComposantId.BTN_CONNEXION)) {
|
|
|
117 |
mediateur.ouvrirIdentification();
|
1013 |
jpm |
118 |
message = i18nM.chargementFenetre(btn.getText());
|
1012 |
jpm |
119 |
} else if (id.equals(ComposantId.BTN_DECONNEXION)) {
|
|
|
120 |
mediateur.deconnecterUtilisateur();
|
|
|
121 |
Utilisateur utilisateurCourant = mediateur.getUtilisateur();
|
1013 |
jpm |
122 |
message = i18nM.deconnexion(utilisateurCourant.getNomComplet());
|
1012 |
jpm |
123 |
} else if (id.equals(ComposantId.BTN_APPLIS)) {
|
61 |
jpm |
124 |
btn.getMenu().show(btn);
|
|
|
125 |
}
|
372 |
jp_milcent |
126 |
|
|
|
127 |
if (!message.equals("")) {
|
1239 |
cyprien |
128 |
InfoLogger.display(i18nC.chargement(), message);
|
372 |
jp_milcent |
129 |
}
|
60 |
jpm |
130 |
}
|
|
|
131 |
};
|
1012 |
jpm |
132 |
return boutonEcouteur;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
private Button getBoutonIdentification() {
|
|
|
136 |
Button bouton = new Button(i18nC.identification(), boutonEcouteur);
|
|
|
137 |
bouton.setId(ComposantId.BTN_CONNEXION);
|
|
|
138 |
return bouton;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
private SplitButton getBoutonAide() {
|
|
|
142 |
MenuItem menuDoc = new MenuItem(i18nC.doc());
|
|
|
143 |
menuDoc.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
144 |
@Override
|
|
|
145 |
public void componentSelected(MenuEvent mEvent) {
|
1013 |
jpm |
146 |
mediateur.ouvrirAide();
|
1012 |
jpm |
147 |
}
|
|
|
148 |
});
|
|
|
149 |
menuDoc.setId(ComposantId.MENU_DOC);
|
|
|
150 |
menuDoc.setIcon(Images.ICONES.aide());
|
60 |
jpm |
151 |
|
357 |
jp_milcent |
152 |
|
1012 |
jpm |
153 |
MenuItem menuApropos = new MenuItem(i18nC.apropos());
|
|
|
154 |
menuApropos.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
155 |
@Override
|
|
|
156 |
public void componentSelected(MenuEvent mEvent) {
|
1013 |
jpm |
157 |
mediateur.ouvrirParametres();
|
1012 |
jpm |
158 |
}
|
|
|
159 |
});
|
|
|
160 |
menuApropos.setId(ComposantId.MENU_APROPOS);
|
|
|
161 |
menuApropos.setIcon(Images.ICONES.engrenages());
|
544 |
jp_milcent |
162 |
|
1012 |
jpm |
163 |
Menu menuAide = new Menu();
|
|
|
164 |
menuAide.add(menuDoc);
|
|
|
165 |
menuAide.add(menuApropos);
|
357 |
jp_milcent |
166 |
|
1012 |
jpm |
167 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.aide());
|
|
|
168 |
boutonAvecMenus.setId(ComposantId.BTN_AIDE);
|
|
|
169 |
boutonAvecMenus.setIcon(Images.ICONES.aide());
|
|
|
170 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
171 |
boutonAvecMenus.setMenu(menuAide);
|
|
|
172 |
return boutonAvecMenus;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
private SplitButton getBoutonAFeedback() {
|
|
|
176 |
MenuItem menuBogue = new MenuItem(i18nC.bogue());
|
989 |
jpm |
177 |
menuBogue.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
178 |
@Override
|
|
|
179 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
180 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
181 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BOGUE);
|
1239 |
cyprien |
182 |
InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getText()));
|
1013 |
jpm |
183 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_BOGUE);
|
989 |
jpm |
184 |
}
|
|
|
185 |
});
|
|
|
186 |
menuBogue.setId(ComposantId.MENU_BOGUE);
|
|
|
187 |
menuBogue.setIcon(Images.ICONES.bogue());
|
1239 |
cyprien |
188 |
|
1012 |
jpm |
189 |
MenuItem menuCommentaire = new MenuItem(i18nC.remarques());
|
989 |
jpm |
190 |
menuCommentaire.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
191 |
@Override
|
|
|
192 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
193 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
194 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE);
|
1239 |
cyprien |
195 |
InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getText()));
|
1013 |
jpm |
196 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_COMMENTAIRE);
|
989 |
jpm |
197 |
}
|
|
|
198 |
});
|
|
|
199 |
menuCommentaire.setId(ComposantId.MENU_COMMENTAIRE);
|
|
|
200 |
menuCommentaire.setIcon(Images.ICONES.commentaire());
|
1239 |
cyprien |
201 |
|
|
|
202 |
MenuItem fenetreJournal = new MenuItem("Journal de l'application");
|
|
|
203 |
fenetreJournal.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
204 |
@Override
|
|
|
205 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
206 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
207 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE);
|
|
|
208 |
//InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getText()));
|
|
|
209 |
mediateur.ouvrirFenetreJournal();
|
|
|
210 |
}
|
|
|
211 |
});
|
1012 |
jpm |
212 |
|
1239 |
cyprien |
213 |
fenetreJournal.setIcon(Images.ICONES.newspaper());
|
|
|
214 |
|
1012 |
jpm |
215 |
Menu menuFeedback = new Menu();
|
|
|
216 |
menuFeedback.add(menuBogue);
|
989 |
jpm |
217 |
menuFeedback.add(menuCommentaire);
|
1239 |
cyprien |
218 |
menuFeedback.add(fenetreJournal);
|
989 |
jpm |
219 |
|
1012 |
jpm |
220 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.feedback());
|
|
|
221 |
boutonAvecMenus.setId(ComposantId.BTN_FEEDBACK);
|
|
|
222 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
223 |
boutonAvecMenus.setMenu(menuFeedback);
|
|
|
224 |
boutonAvecMenus.setIcon(Images.ICONES.flecheDedansDehors());
|
|
|
225 |
return boutonAvecMenus;
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
private SplitButton getBoutonApplications() {
|
1013 |
jpm |
229 |
MenuItem menuCel = new MenuItem(i18nC.cel());
|
499 |
jp_milcent |
230 |
menuCel.addSelectionListener(new SelectionListener<MenuEvent>() {
|
61 |
jpm |
231 |
@Override
|
499 |
jp_milcent |
232 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
233 |
Menu me = (Menu) mEvent.getComponent();
|
61 |
jpm |
234 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL);
|
1239 |
cyprien |
235 |
InfoLogger.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getText()));
|
1013 |
jpm |
236 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_CEL);
|
61 |
jpm |
237 |
}
|
|
|
238 |
});
|
|
|
239 |
menuCel.setId(ComposantId.MENU_CEL);
|
516 |
jp_milcent |
240 |
menuCel.setIcon(Images.ICONES.images());
|
1012 |
jpm |
241 |
|
1013 |
jpm |
242 |
MenuItem menuBel = new MenuItem(i18nC.bel());
|
499 |
jp_milcent |
243 |
menuBel.addSelectionListener(new SelectionListener<MenuEvent>() {
|
61 |
jpm |
244 |
@Override
|
499 |
jp_milcent |
245 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
246 |
Menu me = (Menu) mEvent.getComponent();
|
61 |
jpm |
247 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BEL);
|
1239 |
cyprien |
248 |
InfoLogger.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getText()));
|
1013 |
jpm |
249 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_BEL);
|
61 |
jpm |
250 |
}
|
|
|
251 |
});
|
|
|
252 |
menuBel.setId(ComposantId.MENU_BEL);
|
516 |
jp_milcent |
253 |
menuBel.setIcon(Images.ICONES.livreOuvert());
|
1012 |
jpm |
254 |
|
|
|
255 |
Menu menu = new Menu();
|
|
|
256 |
menu.add(menuCel);
|
61 |
jpm |
257 |
menu.add(menuBel);
|
|
|
258 |
|
1013 |
jpm |
259 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.applicationExterne());
|
1012 |
jpm |
260 |
boutonAvecMenus.setId(ComposantId.BTN_APPLIS);
|
|
|
261 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
262 |
boutonAvecMenus.setMenu(menu);
|
|
|
263 |
boutonAvecMenus.setIcon(Images.ICONES.flecheBascule());
|
61 |
jpm |
264 |
|
1012 |
jpm |
265 |
return boutonAvecMenus;
|
60 |
jpm |
266 |
}
|
1012 |
jpm |
267 |
|
899 |
gduche |
268 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
269 |
if (nouvellesDonnees instanceof Information) {
|
|
|
270 |
Information info = (Information) nouvellesDonnees;
|
156 |
jp_milcent |
271 |
if (info.getType().equals("maj_utilisateur")) {
|
1013 |
jpm |
272 |
Utilisateur utilisateur = mediateur.getUtilisateur();
|
942 |
jpm |
273 |
if (utilisateur.isIdentifie()) {
|
1013 |
jpm |
274 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.bienvenue()+utilisateur.getNomComplet())));
|
|
|
275 |
identificationBouton.setText(i18nC.deconnexion());
|
516 |
jp_milcent |
276 |
identificationBouton.setIcon(Images.ICONES.deconnexion());
|
156 |
jp_milcent |
277 |
identificationBouton.setId(ComposantId.BTN_DECONNEXION);
|
|
|
278 |
} else {
|
1013 |
jpm |
279 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
|
|
|
280 |
identificationBouton.setText(i18nC.identification());
|
516 |
jp_milcent |
281 |
identificationBouton.setIcon(Images.ICONES.connexion());
|
156 |
jp_milcent |
282 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
|
|
283 |
}
|
65 |
jpm |
284 |
}
|
1013 |
jpm |
285 |
} else {
|
|
|
286 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
61 |
jpm |
287 |
}
|
156 |
jp_milcent |
288 |
layout();
|
61 |
jpm |
289 |
}
|
60 |
jpm |
290 |
}
|