910 |
jpm |
1 |
package org.tela_botanica.client.vues;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.Mediateur;
|
|
|
4 |
import org.tela_botanica.client.RegistreId;
|
|
|
5 |
import org.tela_botanica.client.configuration.Configuration;
|
|
|
6 |
import org.tela_botanica.client.i18n.Constantes;
|
|
|
7 |
import org.tela_botanica.client.images.Images;
|
|
|
8 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
9 |
import org.tela_botanica.client.modeles.Information;
|
|
|
10 |
import org.tela_botanica.client.modeles.InterneValeur;
|
|
|
11 |
import org.tela_botanica.client.util.Debug;
|
|
|
12 |
|
|
|
13 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
14 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
|
15 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
16 |
import com.extjs.gxt.ui.client.event.IconButtonEvent;
|
|
|
17 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
18 |
import com.extjs.gxt.ui.client.event.WindowEvent;
|
|
|
19 |
import com.extjs.gxt.ui.client.event.WindowListener;
|
|
|
20 |
import com.extjs.gxt.ui.client.store.ListStore;
|
|
|
21 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
22 |
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
|
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.ToolButton;
|
|
|
27 |
import com.extjs.gxt.ui.client.widget.custom.Portal;
|
|
|
28 |
import com.extjs.gxt.ui.client.widget.custom.Portlet;
|
|
|
29 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
|
|
30 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
|
|
31 |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
|
|
|
32 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
33 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
|
|
34 |
|
|
|
35 |
public class AccueilVue extends LayoutContainer implements Rafraichissable {
|
|
|
36 |
|
|
|
37 |
private Mediateur mediateur = null;
|
|
|
38 |
private Constantes i18nC = null;
|
|
|
39 |
private Portal portail = null;
|
|
|
40 |
|
|
|
41 |
public AccueilVue(Mediateur mediateurCourant) {
|
|
|
42 |
mediateur = mediateurCourant;
|
|
|
43 |
i18nC = Mediateur.i18nC;
|
|
|
44 |
setLayout(new FitLayout());
|
|
|
45 |
|
|
|
46 |
ContentPanel panneauPrincipal = new ContentPanel();
|
|
|
47 |
panneauPrincipal.setLayout(new FitLayout());
|
|
|
48 |
panneauPrincipal.setHeading("Accueil");
|
|
|
49 |
panneauPrincipal.setBorders(false);
|
|
|
50 |
|
|
|
51 |
ToolBar barreOutils = new ToolBar();
|
|
|
52 |
Button ajouter = new Button(i18nC.ajouter());
|
|
|
53 |
ajouter.setIcon(Images.ICONES.ajouter());
|
|
|
54 |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
55 |
public void componentSelected(ButtonEvent be) {
|
|
|
56 |
ajouterPortlet(0);
|
|
|
57 |
}
|
|
|
58 |
});
|
|
|
59 |
barreOutils.add(ajouter);
|
|
|
60 |
|
|
|
61 |
panneauPrincipal.setTopComponent(barreOutils);
|
|
|
62 |
|
|
|
63 |
portail = new Portal(3);
|
|
|
64 |
portail.setBorders(true);
|
|
|
65 |
portail.setStyleAttribute("backgroundColor", "white");
|
|
|
66 |
portail.setShadow(true);
|
|
|
67 |
portail.setColumnWidth(0, .33);
|
|
|
68 |
portail.setColumnWidth(1, .33);
|
|
|
69 |
portail.setColumnWidth(2, .33);
|
|
|
70 |
panneauPrincipal.add(portail);
|
|
|
71 |
ajouterPortlet(0);
|
|
|
72 |
|
|
|
73 |
add(panneauPrincipal);
|
|
|
74 |
mediateur.desactiverChargement();
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
private void ajouterPortlet(int index) {
|
|
|
78 |
Portlet portlet = new Portlet();
|
|
|
79 |
portlet.setHeading("Statistiques des collections");
|
|
|
80 |
configPanel(portlet);
|
|
|
81 |
portlet.setLayout(new FitLayout());
|
|
|
82 |
HtmlContainer conteneurHtml = new HtmlContainer();
|
|
|
83 |
conteneurHtml.setUrl("http://localhost/jrest/CoelStatistique/NombreDonnees");
|
|
|
84 |
portlet.add(conteneurHtml);
|
|
|
85 |
portlet.setHeight(250);
|
|
|
86 |
portail.add(portlet, index);
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
private void configPanel(final ContentPanel panel) {
|
|
|
90 |
panel.setLayout(new FitLayout());
|
|
|
91 |
panel.setCollapsible(true);
|
|
|
92 |
panel.setAnimCollapse(false);
|
|
|
93 |
panel.setScrollMode(Scroll.AUTO);
|
|
|
94 |
panel.getHeader().addTool(new ToolButton("x-tool-gear", new SelectionListener<IconButtonEvent>() {
|
|
|
95 |
@Override
|
|
|
96 |
public void componentSelected(IconButtonEvent ce) {
|
|
|
97 |
ContentPanel panneau = new ContentPanel();
|
|
|
98 |
panneau.setHeaderVisible(false);
|
|
|
99 |
panneau.setLayout(Formulaire.creerFormLayout(350, LabelAlign.TOP));
|
|
|
100 |
|
|
|
101 |
String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
|
|
|
102 |
baseUrl += "CoelStatistique/";
|
|
|
103 |
|
|
|
104 |
ListStore<InterneValeur> appletteStore = new ListStore<InterneValeur>();
|
|
|
105 |
appletteStore.add(new InterneValeur(baseUrl+"NombreDonnees", "Nombre de données"));
|
|
|
106 |
appletteStore.add(new InterneValeur(baseUrl+"Accueil", "Bienvenue"));
|
|
|
107 |
appletteStore.add(new InterneValeur(baseUrl+"TypeDepot", "Types de dépôt des collections"));
|
|
|
108 |
appletteStore.add(new InterneValeur(baseUrl+"NombreCollectionParStructure", "Nombre de collections par institution"));
|
|
|
109 |
|
|
|
110 |
final ComboBox<InterneValeur> applettesCombo = new ComboBox<InterneValeur>();
|
|
|
111 |
applettesCombo.setFieldLabel("Veuillez sélectionner le type d'applette");
|
|
|
112 |
applettesCombo.setForceSelection(true);
|
|
|
113 |
applettesCombo.setTriggerAction(TriggerAction.ALL);
|
|
|
114 |
applettesCombo.setDisplayField("nom");
|
|
|
115 |
applettesCombo.setStore(appletteStore);
|
|
|
116 |
applettesCombo.setEditable(false);
|
|
|
117 |
applettesCombo.setWidth(300);
|
|
|
118 |
|
|
|
119 |
panneau.add(applettesCombo);
|
|
|
120 |
|
|
|
121 |
final Dialog configurationFenetre = new Dialog();
|
|
|
122 |
configurationFenetre.setHeading("Configuration de l'applette");
|
|
|
123 |
configurationFenetre.setButtons(Dialog.OK);
|
|
|
124 |
configurationFenetre.setSize(350, 150);
|
|
|
125 |
configurationFenetre.setPlain(true);
|
|
|
126 |
configurationFenetre.setModal(true);
|
|
|
127 |
configurationFenetre.setBlinkModal(true);
|
|
|
128 |
configurationFenetre.setLayout(new FitLayout());
|
|
|
129 |
configurationFenetre.setHideOnButtonClick(true);
|
|
|
130 |
configurationFenetre.addWindowListener(new WindowListener(){
|
|
|
131 |
public void windowHide(WindowEvent we) {
|
|
|
132 |
String url = applettesCombo.getValue().getAbr();
|
|
|
133 |
HtmlContainer conteneurHtml = new HtmlContainer();
|
|
|
134 |
conteneurHtml.setUrl(url);
|
|
|
135 |
conteneurHtml.recalculate();
|
|
|
136 |
panel.removeAll();
|
|
|
137 |
panel.add(conteneurHtml);
|
|
|
138 |
Debug.log(url);
|
|
|
139 |
panel.layout();
|
|
|
140 |
}
|
|
|
141 |
});
|
|
|
142 |
configurationFenetre.add(panneau);
|
|
|
143 |
configurationFenetre.show();
|
|
|
144 |
}
|
|
|
145 |
}));
|
|
|
146 |
panel.getHeader().addTool(new ToolButton("x-tool-close", new SelectionListener<IconButtonEvent>() {
|
|
|
147 |
@Override
|
|
|
148 |
public void componentSelected(IconButtonEvent ce) {
|
|
|
149 |
panel.removeFromParent();
|
|
|
150 |
}
|
|
|
151 |
}));
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
155 |
if (nouvellesDonnees instanceof Information) {
|
|
|
156 |
Information info = (Information) nouvellesDonnees;
|
|
|
157 |
String type = info.getType();
|
|
|
158 |
if (type.equals("")) {
|
|
|
159 |
|
|
|
160 |
}
|
|
|
161 |
} else {
|
|
|
162 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
|
|
163 |
}
|
|
|
164 |
}
|
|
|
165 |
}
|