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;
|
1239 |
cyprien |
5 |
import org.tela_botanica.client.composants.InfoLogger;
|
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 |
|
|
|
14 |
import com.extjs.gxt.ui.client.Style;
|
|
|
15 |
import com.extjs.gxt.ui.client.Style.Orientation;
|
499 |
jp_milcent |
16 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
17 |
import com.extjs.gxt.ui.client.event.MenuEvent;
|
60 |
jpm |
18 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
66 |
jpm |
19 |
import com.extjs.gxt.ui.client.util.Format;
|
|
|
20 |
import com.extjs.gxt.ui.client.util.Params;
|
60 |
jpm |
21 |
import com.extjs.gxt.ui.client.widget.HtmlContainer;
|
|
|
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 |
|
1239 |
cyprien |
48 |
|
|
|
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));
|
1012 |
jpm |
57 |
initialiserSquelettes();
|
|
|
58 |
boutonEcouteur = getEcouteurDesBoutons();
|
|
|
59 |
conteneurHtml = getIdentification();
|
|
|
60 |
identificationBouton = getBoutonIdentification();
|
|
|
61 |
feedbackBouton = getBoutonAFeedback();
|
|
|
62 |
aideBouton = getBoutonAide();
|
|
|
63 |
applisBouton = getBoutonApplications();
|
|
|
64 |
|
|
|
65 |
barreBoutons = new ButtonBar();
|
|
|
66 |
barreBoutons.setAlignment(Style.HorizontalAlignment.RIGHT);
|
|
|
67 |
barreBoutons.add(conteneurHtml);
|
|
|
68 |
barreBoutons.add(identificationBouton);
|
|
|
69 |
barreBoutons.add(aideBouton);
|
|
|
70 |
barreBoutons.add(feedbackBouton);
|
|
|
71 |
barreBoutons.add(applisBouton);
|
|
|
72 |
|
|
|
73 |
add(getTitre(), new RowData(.20, 1));
|
1239 |
cyprien |
74 |
add(barreBoutons, new RowData(.8, 1));
|
|
|
75 |
|
1012 |
jpm |
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();
|
1286 |
gduche |
85 |
titreConteneurHtml.setHtml(Format.substitute(titreTpl, Images.ICONES.logoCoel().getHTML()));//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();
|
1680 |
raphael |
109 |
message = i18nM.chargementFenetre(btn.getHtml());
|
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("")) {
|
1239 |
cyprien |
119 |
InfoLogger.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() {
|
1239 |
cyprien |
167 |
|
1773 |
mathias |
168 |
MenuItem menuContact = new MenuItem(i18nC.contact());
|
|
|
169 |
menuContact.addSelectionListener(new SelectionListener<MenuEvent>() {
|
989 |
jpm |
170 |
@Override
|
|
|
171 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
172 |
Menu me = (Menu) mEvent.getComponent();
|
1773 |
mathias |
173 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CONTACT);
|
1680 |
raphael |
174 |
InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getHtml()));
|
1773 |
mathias |
175 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_CONTACT);
|
989 |
jpm |
176 |
}
|
|
|
177 |
});
|
1773 |
mathias |
178 |
menuContact.setId(ComposantId.MENU_CONTACT);
|
|
|
179 |
menuContact.setIcon(Images.ICONES.commentaire());
|
1239 |
cyprien |
180 |
|
|
|
181 |
MenuItem fenetreJournal = new MenuItem("Journal de l'application");
|
|
|
182 |
fenetreJournal.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
|
183 |
@Override
|
|
|
184 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
185 |
Menu me = (Menu) mEvent.getComponent();
|
|
|
186 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE);
|
1680 |
raphael |
187 |
//InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getHtml()));
|
1239 |
cyprien |
188 |
mediateur.ouvrirFenetreJournal();
|
|
|
189 |
}
|
|
|
190 |
});
|
1012 |
jpm |
191 |
|
1239 |
cyprien |
192 |
fenetreJournal.setIcon(Images.ICONES.newspaper());
|
|
|
193 |
|
1012 |
jpm |
194 |
Menu menuFeedback = new Menu();
|
1773 |
mathias |
195 |
//menuFeedback.add(menuBogue);
|
|
|
196 |
//menuFeedback.add(menuCommentaire);
|
|
|
197 |
menuFeedback.add(menuContact);
|
1239 |
cyprien |
198 |
menuFeedback.add(fenetreJournal);
|
989 |
jpm |
199 |
|
1012 |
jpm |
200 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.feedback());
|
|
|
201 |
boutonAvecMenus.setId(ComposantId.BTN_FEEDBACK);
|
|
|
202 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
203 |
boutonAvecMenus.setMenu(menuFeedback);
|
|
|
204 |
boutonAvecMenus.setIcon(Images.ICONES.flecheDedansDehors());
|
|
|
205 |
return boutonAvecMenus;
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
private SplitButton getBoutonApplications() {
|
1013 |
jpm |
209 |
MenuItem menuCel = new MenuItem(i18nC.cel());
|
499 |
jp_milcent |
210 |
menuCel.addSelectionListener(new SelectionListener<MenuEvent>() {
|
61 |
jpm |
211 |
@Override
|
499 |
jp_milcent |
212 |
public void componentSelected(MenuEvent mEvent) {
|
|
|
213 |
Menu me = (Menu) mEvent.getComponent();
|
61 |
jpm |
214 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL);
|
1680 |
raphael |
215 |
InfoLogger.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getHtml()));
|
1013 |
jpm |
216 |
mediateur.ouvrirUrlExterne(ComposantId.MENU_CEL);
|
61 |
jpm |
217 |
}
|
|
|
218 |
});
|
|
|
219 |
menuCel.setId(ComposantId.MENU_CEL);
|
516 |
jp_milcent |
220 |
menuCel.setIcon(Images.ICONES.images());
|
1012 |
jpm |
221 |
|
|
|
222 |
Menu menu = new Menu();
|
|
|
223 |
menu.add(menuCel);
|
61 |
jpm |
224 |
|
1013 |
jpm |
225 |
SplitButton boutonAvecMenus = new SplitButton(i18nC.applicationExterne());
|
1012 |
jpm |
226 |
boutonAvecMenus.setId(ComposantId.BTN_APPLIS);
|
|
|
227 |
boutonAvecMenus.addSelectionListener(boutonEcouteur);
|
|
|
228 |
boutonAvecMenus.setMenu(menu);
|
|
|
229 |
boutonAvecMenus.setIcon(Images.ICONES.flecheBascule());
|
61 |
jpm |
230 |
|
1012 |
jpm |
231 |
return boutonAvecMenus;
|
60 |
jpm |
232 |
}
|
1012 |
jpm |
233 |
|
899 |
gduche |
234 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
235 |
if (nouvellesDonnees instanceof Information) {
|
|
|
236 |
Information info = (Information) nouvellesDonnees;
|
156 |
jp_milcent |
237 |
if (info.getType().equals("maj_utilisateur")) {
|
1013 |
jpm |
238 |
Utilisateur utilisateur = mediateur.getUtilisateur();
|
942 |
jpm |
239 |
if (utilisateur.isIdentifie()) {
|
1013 |
jpm |
240 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.bienvenue()+utilisateur.getNomComplet())));
|
|
|
241 |
identificationBouton.setText(i18nC.deconnexion());
|
516 |
jp_milcent |
242 |
identificationBouton.setIcon(Images.ICONES.deconnexion());
|
156 |
jp_milcent |
243 |
identificationBouton.setId(ComposantId.BTN_DECONNEXION);
|
|
|
244 |
} else {
|
1013 |
jpm |
245 |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
|
|
|
246 |
identificationBouton.setText(i18nC.identification());
|
516 |
jp_milcent |
247 |
identificationBouton.setIcon(Images.ICONES.connexion());
|
156 |
jp_milcent |
248 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
|
|
249 |
}
|
65 |
jpm |
250 |
}
|
1013 |
jpm |
251 |
} else {
|
|
|
252 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
61 |
jpm |
253 |
}
|
156 |
jp_milcent |
254 |
layout();
|
61 |
jpm |
255 |
}
|
1654 |
raphael |
256 |
}
|