1 |
package org.tela_botanica.client.vues;
|
1 |
package org.tela_botanica.client.vues;
|
2 |
|
2 |
|
3 |
import org.tela_botanica.client.ComposantId;
|
3 |
import org.tela_botanica.client.ComposantId;
|
4 |
import org.tela_botanica.client.Mediateur;
|
4 |
import org.tela_botanica.client.Mediateur;
|
5 |
import org.tela_botanica.client.RegistreId;
|
5 |
import org.tela_botanica.client.RegistreId;
|
6 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
6 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
7 |
import org.tela_botanica.client.modeles.Utilisateur;
|
7 |
import org.tela_botanica.client.modeles.Utilisateur;
|
8 |
|
8 |
|
9 |
import com.extjs.gxt.ui.client.Registry;
|
9 |
import com.extjs.gxt.ui.client.Registry;
|
10 |
import com.extjs.gxt.ui.client.Style;
|
10 |
import com.extjs.gxt.ui.client.Style;
|
11 |
import com.extjs.gxt.ui.client.Style.Orientation;
|
11 |
import com.extjs.gxt.ui.client.Style.Orientation;
|
12 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
12 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
13 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
13 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
14 |
import com.extjs.gxt.ui.client.util.Format;
|
14 |
import com.extjs.gxt.ui.client.util.Format;
|
15 |
import com.extjs.gxt.ui.client.util.Params;
|
15 |
import com.extjs.gxt.ui.client.util.Params;
|
16 |
import com.extjs.gxt.ui.client.widget.HtmlContainer;
|
16 |
import com.extjs.gxt.ui.client.widget.HtmlContainer;
|
17 |
import com.extjs.gxt.ui.client.widget.Info;
|
17 |
import com.extjs.gxt.ui.client.widget.Info;
|
18 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
18 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
19 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
19 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
20 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
20 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
21 |
import com.extjs.gxt.ui.client.widget.button.SplitButton;
|
21 |
import com.extjs.gxt.ui.client.widget.button.SplitButton;
|
22 |
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
22 |
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
23 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
23 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
24 |
import com.extjs.gxt.ui.client.widget.menu.Menu;
|
24 |
import com.extjs.gxt.ui.client.widget.menu.Menu;
|
25 |
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
25 |
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
26 |
|
26 |
|
27 |
public class EntetePanneauVue extends LayoutContainer implements Rafraichissable {
|
27 |
public class EntetePanneauVue extends LayoutContainer implements Rafraichissable {
|
28 |
|
28 |
|
29 |
private ButtonBar barreBoutons = null;
|
29 |
private ButtonBar barreBoutons = null;
|
30 |
private Button identificationBouton = null;
|
30 |
private Button identificationBouton = null;
|
31 |
private String identificationInfoTpl = "<div id='coel-identification'>{0}</div>";
|
31 |
private String identificationInfoTpl = "<div id='coel-identification'>{0}</div>";
|
32 |
private HtmlContainer identificationInfoHtml = null;
|
32 |
private HtmlContainer identificationInfoHtml = null;
|
33 |
|
33 |
|
34 |
public EntetePanneauVue() {
|
34 |
public EntetePanneauVue() {
|
35 |
setLayout(new RowLayout(Orientation.HORIZONTAL));
|
35 |
setLayout(new RowLayout(Orientation.HORIZONTAL));
|
36 |
setId("coel-entete");
|
36 |
setId("coel-entete");
|
37 |
|
37 |
|
38 |
// TODO : ajouter la gestion de l'identification
|
38 |
// TODO : ajouter la gestion de l'identification
|
39 |
HtmlContainer html = new HtmlContainer();
|
39 |
HtmlContainer html = new HtmlContainer();
|
40 |
StringBuffer sb = new StringBuffer();
|
40 |
StringBuffer sb = new StringBuffer();
|
41 |
sb.append(" <div id='coel-titre'>Collections en Ligne Demo</div>");
|
41 |
sb.append(" <div id='coel-titre'>Collections en Ligne Demo</div>");
|
42 |
html.setHtml(sb.toString());
|
42 |
html.setHtml(sb.toString());
|
43 |
html.setEnableState(false);
|
43 |
html.setEnableState(false);
|
44 |
|
44 |
|
45 |
identificationInfoHtml = new HtmlContainer();
|
45 |
identificationInfoHtml = new HtmlContainer();
|
46 |
identificationInfoHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add("Mode anonyme")));
|
46 |
identificationInfoHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add("Mode anonyme")));
|
47 |
identificationInfoHtml.setEnableState(false);
|
47 |
identificationInfoHtml.setEnableState(false);
|
48 |
|
48 |
|
49 |
// Création des écouteurs
|
49 |
// Création des écouteurs
|
50 |
SelectionListener<ComponentEvent> boutonEcouteur = new SelectionListener<ComponentEvent>() {
|
50 |
SelectionListener<ComponentEvent> boutonEcouteur = new SelectionListener<ComponentEvent>() {
|
51 |
public void componentSelected(ComponentEvent ce) {
|
51 |
public void componentSelected(ComponentEvent ce) {
|
52 |
Button btn = (Button) ce.component;
|
52 |
Button btn = (Button) ce.component;
|
53 |
Info.display(btn.getText()+" - "+btn.getId(), "Chargement de la fenêtre '{0}' en cours...", btn.getText());
|
53 |
Info.display(btn.getText()+" - "+btn.getId(), "Chargement de la fenêtre '{0}' en cours...", btn.getText());
|
54 |
if (btn.getId().equals(ComposantId.BTN_AIDE)) {
|
54 |
if (btn.getId().equals(ComposantId.BTN_AIDE)) {
|
55 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirAide();
|
55 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirAide();
|
56 |
} else if (btn.getId().equals(ComposantId.BTN_PARAMETRES)) {
|
56 |
} else if (btn.getId().equals(ComposantId.BTN_PARAMETRES)) {
|
57 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirParametres();
|
57 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirParametres();
|
58 |
} else if (btn.getId().equals(ComposantId.BTN_CONNEXION)) {
|
58 |
} else if (btn.getId().equals(ComposantId.BTN_CONNEXION)) {
|
59 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirIdentification();
|
59 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirIdentification();
|
60 |
} else if (btn.getId().equals(ComposantId.BTN_DECONNEXION)) {
|
60 |
} else if (btn.getId().equals(ComposantId.BTN_DECONNEXION)) {
|
61 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).deconnecterUtilisateur();
|
61 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).deconnecterUtilisateur();
|
62 |
} else if (btn.getId().equals(ComposantId.BTN_APPLIS)) {
|
62 |
} else if (btn.getId().equals(ComposantId.BTN_APPLIS)) {
|
63 |
btn.getMenu().show(btn);
|
63 |
btn.getMenu().show(btn);
|
64 |
}
|
64 |
}
|
65 |
}
|
65 |
}
|
66 |
};
|
66 |
};
|
67 |
|
67 |
|
68 |
barreBoutons = new ButtonBar();
|
68 |
barreBoutons = new ButtonBar();
|
69 |
barreBoutons.setButtonAlign(Style.HorizontalAlignment.RIGHT);
|
69 |
barreBoutons.setButtonAlign(Style.HorizontalAlignment.RIGHT);
|
70 |
Button parametresBouton = new Button("Paramêtres", boutonEcouteur);
|
70 |
Button parametresBouton = new Button("Paramêtres", boutonEcouteur);
|
71 |
parametresBouton.setId(ComposantId.BTN_PARAMETRES);
|
71 |
parametresBouton.setId(ComposantId.BTN_PARAMETRES);
|
72 |
parametresBouton.setIconStyle("icone-param");
|
72 |
parametresBouton.setIconStyle("icone-param");
|
73 |
barreBoutons.add(parametresBouton);
|
73 |
barreBoutons.add(parametresBouton);
|
74 |
Button aideBouton = new Button("Aide", boutonEcouteur);
|
74 |
Button aideBouton = new Button("Aide", boutonEcouteur);
|
75 |
aideBouton.setId(ComposantId.BTN_AIDE);
|
75 |
aideBouton.setId(ComposantId.BTN_AIDE);
|
76 |
aideBouton.setIconStyle("icone-aide");
|
76 |
aideBouton.setIconStyle("icone-aide");
|
77 |
barreBoutons.add(aideBouton);
|
77 |
barreBoutons.add(aideBouton);
|
78 |
identificationBouton = new Button("Identifiez vous...", boutonEcouteur);
|
78 |
identificationBouton = new Button("Identifiez vous...", boutonEcouteur);
|
79 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
79 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
80 |
barreBoutons.add(identificationBouton);
|
80 |
barreBoutons.add(identificationBouton);
|
81 |
|
81 |
|
82 |
SplitButton applisBouton = new SplitButton("Changez d'application...");
|
82 |
SplitButton applisBouton = new SplitButton("Changez d'application...");
|
83 |
applisBouton.setId(ComposantId.BTN_APPLIS);
|
83 |
applisBouton.setId(ComposantId.BTN_APPLIS);
|
84 |
applisBouton.addSelectionListener(boutonEcouteur);
|
84 |
applisBouton.addSelectionListener(boutonEcouteur);
|
85 |
|
85 |
|
86 |
Menu menu = new Menu();
|
86 |
Menu menu = new Menu();
|
87 |
MenuItem menuCel = new MenuItem("Carnet en ligne", new SelectionListener<ComponentEvent>() {
|
87 |
MenuItem menuCel = new MenuItem("Carnet en ligne", new SelectionListener<ComponentEvent>() {
|
88 |
@Override
|
88 |
@Override
|
89 |
public void componentSelected(ComponentEvent ce) {
|
89 |
public void componentSelected(ComponentEvent ce) {
|
90 |
Menu me = (Menu) ce.component;
|
90 |
Menu me = (Menu) ce.component;
|
91 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL);
|
91 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL);
|
92 |
Info.display(mi.getId()+" - "+mi.getText(), "Chargement du menu '{0}' en cours...", mi.getId());
|
92 |
Info.display(mi.getId()+" - "+mi.getText(), "Chargement du menu '{0}' en cours...", mi.getId());
|
93 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirApplis(ComposantId.MENU_CEL);
|
93 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirApplis(ComposantId.MENU_CEL);
|
94 |
}
|
94 |
}
|
95 |
});
|
95 |
});
|
96 |
menuCel.setId(ComposantId.MENU_CEL);
|
96 |
menuCel.setId(ComposantId.MENU_CEL);
|
97 |
menuCel.setIconStyle("icone-cel");
|
97 |
menuCel.setIconStyle("icone-cel");
|
98 |
menu.add(menuCel);
|
98 |
menu.add(menuCel);
|
99 |
MenuItem menuBel = new MenuItem("Biblio en ligne", new SelectionListener<ComponentEvent>() {
|
99 |
MenuItem menuBel = new MenuItem("Biblio en ligne", new SelectionListener<ComponentEvent>() {
|
100 |
@Override
|
100 |
@Override
|
101 |
public void componentSelected(ComponentEvent ce) {
|
101 |
public void componentSelected(ComponentEvent ce) {
|
102 |
Menu me = (Menu) ce.component;
|
102 |
Menu me = (Menu) ce.component;
|
103 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BEL);
|
103 |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BEL);
|
104 |
Info.display(mi.getId()+" - "+mi.getText(), "Chargement du menu '{0}' en cours...", mi.getId());
|
104 |
Info.display(mi.getId()+" - "+mi.getText(), "Chargement du menu '{0}' en cours...", mi.getId());
|
105 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirApplis(ComposantId.MENU_BEL);
|
105 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirApplis(ComposantId.MENU_BEL);
|
106 |
}
|
106 |
}
|
107 |
});
|
107 |
});
|
108 |
menuBel.setId(ComposantId.MENU_BEL);
|
108 |
menuBel.setId(ComposantId.MENU_BEL);
|
109 |
menuBel.setIconStyle("icone-bel");
|
109 |
menuBel.setIconStyle("icone-bel");
|
110 |
menu.add(menuBel);
|
110 |
menu.add(menuBel);
|
111 |
|
111 |
|
112 |
applisBouton.setMenu(menu);
|
112 |
applisBouton.setMenu(menu);
|
113 |
applisBouton.setIconStyle("icone-bascule");
|
113 |
applisBouton.setIconStyle("icone-bascule");
|
114 |
barreBoutons.add(applisBouton);
|
114 |
barreBoutons.add(applisBouton);
|
115 |
|
115 |
|
116 |
add(html, new RowData(.3, 1));
|
116 |
add(html, new RowData(.3, 1));
|
117 |
add(identificationInfoHtml, new RowData(.3, 50));
|
117 |
add(identificationInfoHtml, new RowData(.3, 50));
|
118 |
add(barreBoutons, new RowData(.4, 50));
|
118 |
add(barreBoutons, new RowData(.4, 50));
|
119 |
}
|
119 |
}
|
120 |
|
120 |
|
121 |
public void rafraichir(Object nouvelleDonnees) {
|
121 |
public void rafraichir(Object nouvelleDonnees) {
|
122 |
if (nouvelleDonnees instanceof Utilisateur) {
|
122 |
if (nouvelleDonnees instanceof Utilisateur) {
|
123 |
Utilisateur utilisateur = (Utilisateur) nouvelleDonnees;
|
123 |
Utilisateur utilisateur = (Utilisateur) nouvelleDonnees;
|
124 |
if (utilisateur.isIdentifie() == true) {
|
124 |
if (utilisateur.isIdentifie() == true) {
|
125 |
identificationInfoHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add("Bienvenue : "+utilisateur.getLogin())));
|
125 |
identificationInfoHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add("Bienvenue : "+utilisateur.getNomComplet())));
|
126 |
identificationBouton.setText("Deconnexion");
|
126 |
identificationBouton.setText("Deconnexion");
|
127 |
identificationBouton.setIconStyle("icone-deconnexion");
|
127 |
identificationBouton.setIconStyle("icone-deconnexion");
|
128 |
identificationBouton.setId(ComposantId.BTN_DECONNEXION);
|
128 |
identificationBouton.setId(ComposantId.BTN_DECONNEXION);
|
129 |
} else {
|
129 |
} else {
|
130 |
identificationInfoHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add("Mode anonyme")));
|
130 |
identificationInfoHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add("Mode anonyme")));
|
131 |
identificationBouton.setText("Identifiez vous...");
|
131 |
identificationBouton.setText("Identifiez vous...");
|
132 |
identificationBouton.setIconStyle("icone-connexion");
|
132 |
identificationBouton.setIconStyle("icone-connexion");
|
133 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
133 |
identificationBouton.setId(ComposantId.BTN_CONNEXION);
|
134 |
}
|
134 |
}
|
135 |
}
|
135 |
}
|
136 |
|
136 |
|
137 |
}
|
137 |
}
|
138 |
}
|
138 |
}
|