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