912 |
jpm |
1 |
package org.tela_botanica.client.vues.accueil;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.RegistreId;
|
|
|
4 |
import org.tela_botanica.client.configuration.Configuration;
|
|
|
5 |
import org.tela_botanica.client.modeles.InterneValeur;
|
|
|
6 |
import org.tela_botanica.client.util.Debug;
|
|
|
7 |
import org.tela_botanica.client.vues.Formulaire;
|
|
|
8 |
|
|
|
9 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
10 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
|
11 |
import com.extjs.gxt.ui.client.event.Events;
|
|
|
12 |
import com.extjs.gxt.ui.client.event.IconButtonEvent;
|
|
|
13 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
14 |
import com.extjs.gxt.ui.client.event.WindowEvent;
|
|
|
15 |
import com.extjs.gxt.ui.client.event.WindowListener;
|
|
|
16 |
import com.extjs.gxt.ui.client.store.ListStore;
|
|
|
17 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
18 |
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
|
19 |
import com.extjs.gxt.ui.client.widget.HtmlContainer;
|
|
|
20 |
import com.extjs.gxt.ui.client.widget.button.ToolButton;
|
|
|
21 |
import com.extjs.gxt.ui.client.widget.custom.Portlet;
|
|
|
22 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
|
|
23 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
|
|
24 |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
|
|
|
25 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
26 |
|
|
|
27 |
public class AppletteStatistique extends Portlet {
|
|
|
28 |
|
|
|
29 |
private String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
|
|
|
30 |
|
|
|
31 |
public AppletteStatistique() {
|
|
|
32 |
initialiserAppletteStatistique(null);
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public AppletteStatistique(String contenu) {
|
|
|
36 |
initialiserAppletteStatistique(contenu);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
private void initialiserAppletteStatistique(String contenu) {
|
|
|
40 |
setLayout(new FitLayout());
|
|
|
41 |
setHeading("Statistiques des collections");
|
|
|
42 |
setHeight(250);
|
|
|
43 |
setCollapsible(true);
|
|
|
44 |
setAnimCollapse(true);
|
|
|
45 |
setScrollMode(Scroll.AUTO);
|
|
|
46 |
|
|
|
47 |
attribuerContenu(contenu);
|
|
|
48 |
|
|
|
49 |
getHeader().addTool(new ToolButton("x-tool-gear", new SelectionListener<IconButtonEvent>() {
|
|
|
50 |
@Override
|
|
|
51 |
public void componentSelected(IconButtonEvent ce) {
|
|
|
52 |
ContentPanel panneau = new ContentPanel();
|
|
|
53 |
panneau.setHeaderVisible(false);
|
|
|
54 |
panneau.setLayout(Formulaire.creerFormLayout(350, LabelAlign.TOP));
|
|
|
55 |
|
|
|
56 |
ListStore<InterneValeur> appletteStore = new ListStore<InterneValeur>();
|
|
|
57 |
appletteStore.add(new InterneValeur("NombreDonnees", "Nombre de données"));
|
|
|
58 |
appletteStore.add(new InterneValeur("TypeDepot", "Types de dépôt des collections"));
|
|
|
59 |
appletteStore.add(new InterneValeur("NombreCollectionParStructure", "Nombre de collections par institution"));
|
|
|
60 |
|
|
|
61 |
final ComboBox<InterneValeur> applettesCombo = new ComboBox<InterneValeur>();
|
|
|
62 |
applettesCombo.setFieldLabel("Veuillez sélectionner le type d'applette");
|
|
|
63 |
applettesCombo.setForceSelection(true);
|
|
|
64 |
applettesCombo.setTriggerAction(TriggerAction.ALL);
|
|
|
65 |
applettesCombo.setDisplayField("nom");
|
|
|
66 |
applettesCombo.setStore(appletteStore);
|
|
|
67 |
applettesCombo.setEditable(false);
|
|
|
68 |
applettesCombo.setWidth(300);
|
|
|
69 |
|
|
|
70 |
panneau.add(applettesCombo);
|
|
|
71 |
|
|
|
72 |
final Dialog configurationFenetre = new Dialog();
|
|
|
73 |
configurationFenetre.setHeading("Configuration de l'applette");
|
|
|
74 |
configurationFenetre.setButtons(Dialog.OK);
|
|
|
75 |
configurationFenetre.setSize(350, 150);
|
|
|
76 |
configurationFenetre.setPlain(true);
|
|
|
77 |
configurationFenetre.setModal(true);
|
|
|
78 |
configurationFenetre.setBlinkModal(true);
|
|
|
79 |
configurationFenetre.setLayout(new FitLayout());
|
|
|
80 |
configurationFenetre.setHideOnButtonClick(true);
|
|
|
81 |
configurationFenetre.addWindowListener(new WindowListener(){
|
|
|
82 |
public void windowHide(WindowEvent we) {
|
|
|
83 |
String abreviation = applettesCombo.getValue().getAbr();
|
|
|
84 |
attribuerContenu(abreviation);
|
|
|
85 |
}
|
|
|
86 |
});
|
|
|
87 |
configurationFenetre.add(panneau);
|
|
|
88 |
configurationFenetre.show();
|
|
|
89 |
}
|
|
|
90 |
}));
|
|
|
91 |
|
|
|
92 |
getHeader().addTool(new ToolButton("x-tool-pin", new SelectionListener<IconButtonEvent>() {
|
|
|
93 |
@Override
|
|
|
94 |
public void componentSelected(IconButtonEvent ce) {
|
|
|
95 |
if (isPinned()) {
|
|
|
96 |
ce.getComponent().setStylePrimaryName("x-tool-pin");
|
|
|
97 |
setPinned(false);
|
|
|
98 |
} else {
|
|
|
99 |
ce.getComponent().setStylePrimaryName("x-tool-unpin");
|
|
|
100 |
setPinned(true);
|
|
|
101 |
}
|
|
|
102 |
layout();
|
|
|
103 |
}
|
|
|
104 |
}));
|
|
|
105 |
|
|
|
106 |
getHeader().addTool(new ToolButton("x-tool-close", new SelectionListener<IconButtonEvent>() {
|
|
|
107 |
@Override
|
|
|
108 |
public void componentSelected(IconButtonEvent ce) {
|
|
|
109 |
removeFromParent();
|
|
|
110 |
}
|
|
|
111 |
}));
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
private void attribuerContenu(String abreviation) {
|
|
|
116 |
if (abreviation == null) {
|
|
|
117 |
abreviation = "NombreDonnees";
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
setData("contenu", abreviation);
|
|
|
121 |
String url = baseUrl+"CoelStatistique/"+abreviation;
|
|
|
122 |
|
|
|
123 |
HtmlContainer conteneurHtml = new HtmlContainer();
|
|
|
124 |
conteneurHtml.setUrl(url);
|
|
|
125 |
conteneurHtml.recalculate();
|
|
|
126 |
|
|
|
127 |
removeAll();
|
|
|
128 |
add(conteneurHtml);
|
|
|
129 |
layout();
|
|
|
130 |
}
|
|
|
131 |
}
|