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