| 912 | jpm | 1 | package org.tela_botanica.client.vues.accueil;
 | 
        
           |  |  | 2 |   | 
        
           | 1165 | jpm | 3 | import org.tela_botanica.client.Mediateur;
 | 
        
           | 912 | jpm | 4 | import org.tela_botanica.client.RegistreId;
 | 
        
           |  |  | 5 | import org.tela_botanica.client.configuration.Configuration;
 | 
        
           |  |  | 6 | import org.tela_botanica.client.modeles.InterneValeur;
 | 
        
           |  |  | 7 | import org.tela_botanica.client.vues.Formulaire;
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 | import com.extjs.gxt.ui.client.Registry;
 | 
        
           |  |  | 10 | import com.extjs.gxt.ui.client.event.IconButtonEvent;
 | 
        
           |  |  | 11 | import com.extjs.gxt.ui.client.event.SelectionListener;
 | 
        
           |  |  | 12 | import com.extjs.gxt.ui.client.event.WindowEvent;
 | 
        
           |  |  | 13 | import com.extjs.gxt.ui.client.event.WindowListener;
 | 
        
           |  |  | 14 | import com.extjs.gxt.ui.client.store.ListStore;
 | 
        
           |  |  | 15 | import com.extjs.gxt.ui.client.widget.ContentPanel;
 | 
        
           |  |  | 16 | import com.extjs.gxt.ui.client.widget.Dialog;
 | 
        
           |  |  | 17 | import com.extjs.gxt.ui.client.widget.HtmlContainer;
 | 
        
           |  |  | 18 | import com.extjs.gxt.ui.client.widget.form.ComboBox;
 | 
        
           |  |  | 19 | import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
 | 
        
           |  |  | 20 | import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
 | 
        
           |  |  | 21 | import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 | 
        
           |  |  | 22 |   | 
        
           | 913 | jpm | 23 | public class AppletteStatistique extends Applette {
 | 
        
           | 912 | jpm | 24 |   | 
        
           |  |  | 25 | 	private String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
 | 
        
           | 913 | jpm | 26 |   | 
        
           | 912 | jpm | 27 |   | 
        
           | 1165 | jpm | 28 | 	public AppletteStatistique(Mediateur mediateurCourrant) {
 | 
        
           |  |  | 29 | 		initialiserAppletteStatistique(mediateurCourrant, null);
 | 
        
           | 912 | jpm | 30 | 	}
 | 
        
           |  |  | 31 |   | 
        
           | 1165 | jpm | 32 | 	public AppletteStatistique(Mediateur mediateurCourrant, String contenu) {
 | 
        
           |  |  | 33 | 		initialiserAppletteStatistique(mediateurCourrant, contenu);
 | 
        
           | 912 | jpm | 34 | 	}
 | 
        
           |  |  | 35 |   | 
        
           | 1165 | jpm | 36 | 	private void initialiserAppletteStatistique(Mediateur mediateurCourrant, String contenu) {
 | 
        
           | 913 | jpm | 37 | 		String titre = "Statistiques des collections";
 | 
        
           | 1165 | jpm | 38 | 		initialiserApplette(mediateurCourrant, titre);
 | 
        
           | 912 | jpm | 39 |   | 
        
           | 913 | jpm | 40 | 		SelectionListener<IconButtonEvent> configurationListener = new SelectionListener<IconButtonEvent>() {
 | 
        
           | 912 | jpm | 41 | 			@Override
 | 
        
           |  |  | 42 | 			public void componentSelected(IconButtonEvent ce) {
 | 
        
           |  |  | 43 | 				ContentPanel panneau = new ContentPanel();
 | 
        
           |  |  | 44 | 				panneau.setHeaderVisible(false);
 | 
        
           |  |  | 45 | 				panneau.setLayout(Formulaire.creerFormLayout(350, LabelAlign.TOP));
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | 				ListStore<InterneValeur> appletteStore = new ListStore<InterneValeur>();
 | 
        
           |  |  | 48 | 				appletteStore.add(new InterneValeur("NombreDonnees", "Nombre de données"));
 | 
        
           | 1173 | jpm | 49 | 				appletteStore.add(new InterneValeur("MesDonnees", "Ma participation"));
 | 
        
           | 912 | jpm | 50 | 				appletteStore.add(new InterneValeur("TypeDepot", "Types de dépôt des collections"));
 | 
        
           |  |  | 51 | 				appletteStore.add(new InterneValeur("NombreCollectionParStructure", "Nombre de collections par institution"));
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 | 				final ComboBox<InterneValeur> applettesCombo = new ComboBox<InterneValeur>();
 | 
        
           |  |  | 54 | 				applettesCombo.setFieldLabel("Veuillez sélectionner le type d'applette");
 | 
        
           |  |  | 55 | 				applettesCombo.setForceSelection(true);
 | 
        
           |  |  | 56 | 				applettesCombo.setTriggerAction(TriggerAction.ALL);
 | 
        
           |  |  | 57 | 				applettesCombo.setDisplayField("nom");
 | 
        
           |  |  | 58 | 				applettesCombo.setStore(appletteStore);
 | 
        
           |  |  | 59 | 				applettesCombo.setEditable(false);
 | 
        
           |  |  | 60 | 				applettesCombo.setWidth(300);
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 | 				panneau.add(applettesCombo);
 | 
        
           |  |  | 63 |   | 
        
           |  |  | 64 | 				final Dialog configurationFenetre = new Dialog();
 | 
        
           | 1680 | raphael | 65 | 				configurationFenetre.setHeadingHtml("Configuration de l'applette");
 | 
        
           | 912 | jpm | 66 | 				configurationFenetre.setButtons(Dialog.OK);
 | 
        
           |  |  | 67 | 				configurationFenetre.setSize(350, 150);
 | 
        
           |  |  | 68 | 				configurationFenetre.setPlain(true);
 | 
        
           |  |  | 69 | 				configurationFenetre.setModal(true);
 | 
        
           |  |  | 70 | 				configurationFenetre.setBlinkModal(true);
 | 
        
           |  |  | 71 | 				configurationFenetre.setLayout(new FitLayout());
 | 
        
           |  |  | 72 | 				configurationFenetre.setHideOnButtonClick(true);
 | 
        
           |  |  | 73 | 				configurationFenetre.addWindowListener(new WindowListener(){
 | 
        
           |  |  | 74 | 					public void windowHide(WindowEvent we) {
 | 
        
           |  |  | 75 | 						String abreviation = applettesCombo.getValue().getAbr();
 | 
        
           |  |  | 76 | 						attribuerContenu(abreviation);
 | 
        
           |  |  | 77 | 					}
 | 
        
           |  |  | 78 | 				});
 | 
        
           |  |  | 79 | 				configurationFenetre.add(panneau);
 | 
        
           |  |  | 80 | 				configurationFenetre.show();
 | 
        
           |  |  | 81 | 			}
 | 
        
           | 913 | jpm | 82 | 		};
 | 
        
           |  |  | 83 | 		ajouterConfigurationListener(configurationListener);
 | 
        
           | 912 | jpm | 84 |   | 
        
           | 913 | jpm | 85 | 		attribuerContenu(contenu);
 | 
        
           | 912 | jpm | 86 | 	}
 | 
        
           | 913 | jpm | 87 |   | 
        
           | 912 | jpm | 88 | 	private void attribuerContenu(String abreviation) {
 | 
        
           |  |  | 89 | 		if (abreviation == null) {
 | 
        
           |  |  | 90 | 			abreviation = "NombreDonnees";
 | 
        
           |  |  | 91 | 		}
 | 
        
           |  |  | 92 | 		setData("contenu", abreviation);
 | 
        
           |  |  | 93 | 		String url = baseUrl+"CoelStatistique/"+abreviation;
 | 
        
           |  |  | 94 |   | 
        
           | 1165 | jpm | 95 | 		if (abreviation.equals("MesDonnees")) {
 | 
        
           |  |  | 96 | 			url += "/"+mediateur.getUtilisateurId();
 | 
        
           |  |  | 97 | 		}
 | 
        
           |  |  | 98 |   | 
        
           | 912 | jpm | 99 | 		HtmlContainer conteneurHtml = new HtmlContainer();
 | 
        
           |  |  | 100 | 		conteneurHtml.setUrl(url);
 | 
        
           |  |  | 101 | 		conteneurHtml.recalculate();
 | 
        
           |  |  | 102 |   | 
        
           |  |  | 103 | 		removeAll();
 | 
        
           |  |  | 104 | 		add(conteneurHtml);
 | 
        
           |  |  | 105 | 		layout();
 | 
        
           |  |  | 106 | 	}
 | 
        
           |  |  | 107 | }
 |