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