| 594 | 
           gduche | 
           1 | 
           package org.tela_botanica.client.vues;
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
           | 1599 | 
           aurelien | 
           3 | 
           import java.util.ArrayList;
  | 
        
        
           | 594 | 
           gduche | 
           4 | 
           import java.util.Iterator;
  | 
        
        
            | 
            | 
           5 | 
           import java.util.LinkedList;
  | 
        
        
           | 1599 | 
           aurelien | 
           6 | 
           import java.util.List;
  | 
        
        
           | 594 | 
           gduche | 
           7 | 
              | 
        
        
            | 
            | 
           8 | 
           import org.tela_botanica.client.Mediateur;
  | 
        
        
           | 1125 | 
           jpm | 
           9 | 
           import org.tela_botanica.client.i18n.Constantes;
  | 
        
        
            | 
            | 
           10 | 
           import org.tela_botanica.client.i18n.ErrorMessages;
  | 
        
        
           | 594 | 
           gduche | 
           11 | 
           import org.tela_botanica.client.images.Images;
  | 
        
        
            | 
            | 
           12 | 
           import org.tela_botanica.client.interfaces.ListePaginable;
  | 
        
        
            | 
            | 
           13 | 
           import org.tela_botanica.client.interfaces.Rafraichissable;
  | 
        
        
           | 1369 | 
           cyprien | 
           14 | 
           import org.tela_botanica.client.util.Debug;
  | 
        
        
           | 621 | 
           gduche | 
           15 | 
           import org.tela_botanica.client.util.UtilString;
  | 
        
        
           | 1687 | 
           raphael | 
           16 | 
           import org.tela_botanica.client.composants.ChampFiltreRecherche;
  | 
        
        
           | 594 | 
           gduche | 
           17 | 
              | 
        
        
            | 
            | 
           18 | 
           import com.extjs.gxt.ui.client.event.ButtonEvent;
  | 
        
        
            | 
            | 
           19 | 
           import com.extjs.gxt.ui.client.event.ComponentEvent;
  | 
        
        
            | 
            | 
           20 | 
           import com.extjs.gxt.ui.client.event.KeyListener;
  | 
        
        
            | 
            | 
           21 | 
           import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
  | 
        
        
            | 
            | 
           22 | 
           import com.extjs.gxt.ui.client.event.SelectionChangedListener;
  | 
        
        
            | 
            | 
           23 | 
           import com.extjs.gxt.ui.client.event.SelectionListener;
  | 
        
        
            | 
            | 
           24 | 
           import com.extjs.gxt.ui.client.store.ListStore;
  | 
        
        
           | 1599 | 
           aurelien | 
           25 | 
           import com.extjs.gxt.ui.client.store.StoreEvent;
  | 
        
        
            | 
            | 
           26 | 
           import com.extjs.gxt.ui.client.store.StoreListener;
  | 
        
        
           | 594 | 
           gduche | 
           27 | 
           import com.extjs.gxt.ui.client.widget.Text;
  | 
        
        
            | 
            | 
           28 | 
           import com.extjs.gxt.ui.client.widget.button.Button;
  | 
        
        
           | 1599 | 
           aurelien | 
           29 | 
           import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
  | 
        
        
           | 594 | 
           gduche | 
           30 | 
           import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
  | 
        
        
           | 1599 | 
           aurelien | 
           31 | 
           import com.extjs.gxt.ui.client.widget.form.SimpleComboValue;
  | 
        
        
           | 1683 | 
           raphael | 
           32 | 
           import com.extjs.gxt.ui.client.widget.form.NumberField;
  | 
        
        
           | 594 | 
           gduche | 
           33 | 
           import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
  | 
        
        
            | 
            | 
           34 | 
           import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
  | 
        
        
            | 
            | 
           35 | 
           import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
  | 
        
        
            | 
            | 
           36 | 
           import com.google.gwt.event.dom.client.KeyCodes;
  | 
        
        
            | 
            | 
           37 | 
           import com.google.gwt.i18n.client.Dictionary;
  | 
        
        
           | 1599 | 
           aurelien | 
           38 | 
           import com.google.gwt.user.client.Window;
  | 
        
        
           | 594 | 
           gduche | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
           public class BarrePaginationVue extends ToolBar implements Rafraichissable {
  | 
        
        
            | 
            | 
           41 | 
              | 
        
        
           | 1687 | 
           raphael | 
           42 | 
           	private Mediateur mediateur = null;
  | 
        
        
            | 
            | 
           43 | 
           	private Constantes i18nC = null;
  | 
        
        
            | 
            | 
           44 | 
           	private ErrorMessages i18nM = null;
  | 
        
        
            | 
            | 
           45 | 
           	public int valeur = 0;
  | 
        
        
           | 1125 | 
           jpm | 
           46 | 
              | 
        
        
           | 1687 | 
           raphael | 
           47 | 
           	private ListePaginable listePaginable = null;
  | 
        
        
            | 
            | 
           48 | 
           	private Button prevPage, suivPage, premierePage, dernierePage, rafraichir;
  | 
        
        
           | 594 | 
           gduche | 
           49 | 
              | 
        
        
           | 1687 | 
           raphael | 
           50 | 
           	private int pageCourante, nbElement = 0;
  | 
        
        
            | 
            | 
           51 | 
           	private int taillePage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage"));
  | 
        
        
            | 
            | 
           52 | 
           	private int pageTotale = 1;
  | 
        
        
            | 
            | 
           53 | 
           	private Text page, surTotalPage, afficherNbElem, nbElemParPage, intervalleElements;
  | 
        
        
           | 594 | 
           gduche | 
           54 | 
              | 
        
        
           | 1687 | 
           raphael | 
           55 | 
           	private NumberField champPage = new NumberField();
  | 
        
        
            | 
            | 
           56 | 
           	private SimpleComboBox<Integer> selecteurTaillePage = new SimpleComboBox<Integer>();
  | 
        
        
           | 1040 | 
           gduche | 
           57 | 
              | 
        
        
           | 1687 | 
           raphael | 
           58 | 
           	private LinkedList<Integer> intervallePages = new LinkedList<Integer>();
  | 
        
        
            | 
            | 
           59 | 
           	private ListStore storeIntervalle = new ListStore() ;
  | 
        
        
           | 594 | 
           gduche | 
           60 | 
              | 
        
        
           | 1687 | 
           raphael | 
           61 | 
           	private String labelElement;
  | 
        
        
            | 
            | 
           62 | 
           	private int taillePageDefaut = 50;
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
           	private ChampFiltreRecherche champFiltreRecherche = null;
  | 
        
        
            | 
            | 
           65 | 
              | 
        
        
            | 
            | 
           66 | 
           	public ListePaginable getlistePaginable() {
  | 
        
        
            | 
            | 
           67 | 
           		return listePaginable;
  | 
        
        
            | 
            | 
           68 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           69 | 
              | 
        
        
           | 1687 | 
           raphael | 
           70 | 
           	public void setlistePaginable(ListePaginable listePaginable) {
  | 
        
        
            | 
            | 
           71 | 
           		this.listePaginable = listePaginable;
  | 
        
        
            | 
            | 
           72 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           73 | 
              | 
        
        
           | 1687 | 
           raphael | 
           74 | 
           	/***************************************************************************
  | 
        
        
            | 
            | 
           75 | 
           	 * constructeur sans argument (privé car ne doit pas être utilisé)
  | 
        
        
            | 
            | 
           76 | 
           	 */
  | 
        
        
            | 
            | 
           77 | 
           	@SuppressWarnings("unused")
  | 
        
        
            | 
            | 
           78 | 
           	private BarrePaginationVue() {
  | 
        
        
            | 
            | 
           79 | 
           		super();
  | 
        
        
            | 
            | 
           80 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           81 | 
              | 
        
        
           | 1687 | 
           raphael | 
           82 | 
           	/**
  | 
        
        
            | 
            | 
           83 | 
           	 * constructeur avec paramètres
  | 
        
        
            | 
            | 
           84 | 
           	 *
  | 
        
        
            | 
            | 
           85 | 
           	 * @param im
  | 
        
        
            | 
            | 
           86 | 
           	 *            le médiateur à associer à la barre
  | 
        
        
            | 
            | 
           87 | 
           	 */
  | 
        
        
            | 
            | 
           88 | 
           	public BarrePaginationVue(ListePaginable listePaginableCourante, Mediateur mediateurCourant) {
  | 
        
        
            | 
            | 
           89 | 
           		super();
  | 
        
        
           | 594 | 
           gduche | 
           90 | 
              | 
        
        
           | 1687 | 
           raphael | 
           91 | 
           		listePaginable = listePaginableCourante;
  | 
        
        
            | 
            | 
           92 | 
           		mediateur = mediateurCourant;
  | 
        
        
            | 
            | 
           93 | 
           		i18nC = Mediateur.i18nC;
  | 
        
        
            | 
            | 
           94 | 
           		i18nM = Mediateur.i18nM;
  | 
        
        
           | 594 | 
           gduche | 
           95 | 
              | 
        
        
           | 1687 | 
           raphael | 
           96 | 
           		intervallePages.add(10);
  | 
        
        
            | 
            | 
           97 | 
           		intervallePages.add(20);
  | 
        
        
            | 
            | 
           98 | 
           		intervallePages.add(50);
  | 
        
        
            | 
            | 
           99 | 
           		intervallePages.add(100);
  | 
        
        
            | 
            | 
           100 | 
           		intervallePages.add(200);
  | 
        
        
           | 594 | 
           gduche | 
           101 | 
              | 
        
        
           | 1687 | 
           raphael | 
           102 | 
           		premierePage = new Button();
  | 
        
        
            | 
            | 
           103 | 
           		premierePage.setIcon(Images.ICONES.resultsetFirst());
  | 
        
        
            | 
            | 
           104 | 
           		add(premierePage);
  | 
        
        
           | 594 | 
           gduche | 
           105 | 
              | 
        
        
           | 1687 | 
           raphael | 
           106 | 
           		prevPage = new Button();
  | 
        
        
            | 
            | 
           107 | 
           		prevPage.setIcon(Images.ICONES.resultsetPrevious());
  | 
        
        
            | 
            | 
           108 | 
           		add(prevPage);
  | 
        
        
           | 594 | 
           gduche | 
           109 | 
              | 
        
        
           | 1687 | 
           raphael | 
           110 | 
           		add(new SeparatorToolItem());
  | 
        
        
           | 594 | 
           gduche | 
           111 | 
              | 
        
        
           | 1687 | 
           raphael | 
           112 | 
           		page = new Text(i18nC.page());
  | 
        
        
            | 
            | 
           113 | 
           		page.setStyleAttribute("padding", "0 5px 0 5px");
  | 
        
        
            | 
            | 
           114 | 
           		add(page);
  | 
        
        
           | 594 | 
           gduche | 
           115 | 
              | 
        
        
           | 1687 | 
           raphael | 
           116 | 
           		champPage.setValue(pageCourante+1);
  | 
        
        
            | 
            | 
           117 | 
           		champPage.setAllowDecimals(false);
  | 
        
        
            | 
            | 
           118 | 
           		champPage.setAllowNegative(false);
  | 
        
        
            | 
            | 
           119 | 
           		champPage.setStyleAttribute("text-align","right");
  | 
        
        
            | 
            | 
           120 | 
           		champPage.setWidth(30);
  | 
        
        
            | 
            | 
           121 | 
           		add(champPage);
  | 
        
        
           | 594 | 
           gduche | 
           122 | 
              | 
        
        
           | 1687 | 
           raphael | 
           123 | 
           		surTotalPage = new Text(i18nC.sur() + " " + pageTotale);
  | 
        
        
            | 
            | 
           124 | 
           		surTotalPage.setStyleAttribute("padding-left", "5px");
  | 
        
        
            | 
            | 
           125 | 
           		add(surTotalPage);
  | 
        
        
           | 594 | 
           gduche | 
           126 | 
              | 
        
        
           | 1687 | 
           raphael | 
           127 | 
           		//Séparation
  | 
        
        
            | 
            | 
           128 | 
           		add(new SeparatorToolItem());
  | 
        
        
           | 594 | 
           gduche | 
           129 | 
              | 
        
        
           | 1687 | 
           raphael | 
           130 | 
           		suivPage = new Button();
  | 
        
        
            | 
            | 
           131 | 
           		suivPage.setIcon(Images.ICONES.resultsetNext());
  | 
        
        
            | 
            | 
           132 | 
           		add(suivPage);
  | 
        
        
           | 594 | 
           gduche | 
           133 | 
              | 
        
        
           | 1687 | 
           raphael | 
           134 | 
           		dernierePage = new Button();
  | 
        
        
            | 
            | 
           135 | 
           		dernierePage.setIcon(Images.ICONES.resultsetLast());
  | 
        
        
            | 
            | 
           136 | 
           		add(dernierePage);
  | 
        
        
           | 594 | 
           gduche | 
           137 | 
              | 
        
        
           | 1687 | 
           raphael | 
           138 | 
           		//Séparation
  | 
        
        
            | 
            | 
           139 | 
           		add(new SeparatorToolItem());
  | 
        
        
           | 594 | 
           gduche | 
           140 | 
              | 
        
        
           | 1687 | 
           raphael | 
           141 | 
           		rafraichir = new Button();
  | 
        
        
            | 
            | 
           142 | 
           		rafraichir.setIcon(Images.ICONES.rafraichir());
  | 
        
        
            | 
            | 
           143 | 
           		add(rafraichir);
  | 
        
        
           | 594 | 
           gduche | 
           144 | 
              | 
        
        
           | 1687 | 
           raphael | 
           145 | 
           		//Séparation
  | 
        
        
            | 
            | 
           146 | 
           		add(new SeparatorToolItem());
  | 
        
        
           | 594 | 
           gduche | 
           147 | 
              | 
        
        
           | 1687 | 
           raphael | 
           148 | 
           		afficherNbElem = new Text(i18nC.afficher());
  | 
        
        
            | 
            | 
           149 | 
           		afficherNbElem.setStyleAttribute("padding", "0 5px 0 5px");
  | 
        
        
            | 
            | 
           150 | 
           		add(afficherNbElem);
  | 
        
        
           | 594 | 
           gduche | 
           151 | 
              | 
        
        
           | 1687 | 
           raphael | 
           152 | 
           		// Attention l'appel à setTriggerAction avec ALL est indispensable
  | 
        
        
            | 
            | 
           153 | 
           		// pour éviter un bug lors de la selection de la taille de page par défaut
  | 
        
        
            | 
            | 
           154 | 
           		selecteurTaillePage.setTriggerAction(TriggerAction.ALL);
  | 
        
        
            | 
            | 
           155 | 
           		selecteurTaillePage.setLazyRender(false);
  | 
        
        
            | 
            | 
           156 | 
           		selecteurTaillePage.setWidth("40px");
  | 
        
        
            | 
            | 
           157 | 
           		setIntervallesPages();
  | 
        
        
            | 
            | 
           158 | 
           		add(selecteurTaillePage);
  | 
        
        
           | 594 | 
           gduche | 
           159 | 
              | 
        
        
           | 1687 | 
           raphael | 
           160 | 
           		labelElement = i18nC.elements();
  | 
        
        
           | 594 | 
           gduche | 
           161 | 
              | 
        
        
           | 1687 | 
           raphael | 
           162 | 
           		nbElemParPage = new Text(labelElement+" "+i18nC.parPage());
  | 
        
        
            | 
            | 
           163 | 
           		nbElemParPage.setStyleAttribute("padding-left", "5px");
  | 
        
        
            | 
            | 
           164 | 
           		add(nbElemParPage);
  | 
        
        
           | 594 | 
           gduche | 
           165 | 
              | 
        
        
           | 1687 | 
           raphael | 
           166 | 
           		//Séparation
  | 
        
        
            | 
            | 
           167 | 
           		add(new SeparatorToolItem());
  | 
        
        
           | 1633 | 
           aurelien | 
           168 | 
              | 
        
        
           | 1687 | 
           raphael | 
           169 | 
           		intervalleElements = new Text(i18nM.elementsAffiches(UtilString.ucFirst(labelElement),
  | 
        
        
            | 
            | 
           170 | 
           								     pageCourante * taillePage, (pageCourante + 1) * taillePage, nbElement));
  | 
        
        
            | 
            | 
           171 | 
           		add(intervalleElements);
  | 
        
        
           | 594 | 
           gduche | 
           172 | 
              | 
        
        
           | 1687 | 
           raphael | 
           173 | 
           		// on ajoute les différents listeners
  | 
        
        
            | 
            | 
           174 | 
           		ajouterListeners();
  | 
        
        
            | 
            | 
           175 | 
           	}
  | 
        
        
            | 
            | 
           176 | 
              | 
        
        
            | 
            | 
           177 | 
           	public BarrePaginationVue(ListePaginable listePaginableCourante, Mediateur mediateurCourant, ChampFiltreRecherche champFiltreRechercheCourant) {
  | 
        
        
            | 
            | 
           178 | 
           		this(listePaginableCourante, mediateurCourant);
  | 
        
        
            | 
            | 
           179 | 
           		champFiltreRecherche = champFiltreRechercheCourant;
  | 
        
        
            | 
            | 
           180 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           181 | 
              | 
        
        
           | 1687 | 
           raphael | 
           182 | 
           	/**
  | 
        
        
            | 
            | 
           183 | 
           	 *  Texte nommant les elements pagines (Images, Observation, truc, machin etc...).
  | 
        
        
            | 
            | 
           184 | 
           	 * 	@param label
  | 
        
        
            | 
            | 
           185 | 
           	 */
  | 
        
        
            | 
            | 
           186 | 
           	public void setLabelElement(String label) {
  | 
        
        
            | 
            | 
           187 | 
           		this.labelElement = label;
  | 
        
        
            | 
            | 
           188 | 
           		nbElemParPage.setText(labelElement + " par page ");
  | 
        
        
            | 
            | 
           189 | 
           		intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement),
  | 
        
        
            | 
            | 
           190 | 
           								  pageCourante * taillePage, (pageCourante + 1) * taillePage, nbElement));
  | 
        
        
            | 
            | 
           191 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           192 | 
              | 
        
        
           | 1687 | 
           raphael | 
           193 | 
           	public void setTaillePageParDefaut(int taille) {
  | 
        
        
            | 
            | 
           194 | 
           		this.taillePageDefaut = taille;
  | 
        
        
            | 
            | 
           195 | 
           		selecteurTaillePage.setRawValue(""+taillePageDefaut);
  | 
        
        
            | 
            | 
           196 | 
           	}
  | 
        
        
            | 
            | 
           197 | 
              | 
        
        
            | 
            | 
           198 | 
           	public void setIntervallesPages() {
  | 
        
        
            | 
            | 
           199 | 
           		if (!intervallePages.contains(taillePage))	{
  | 
        
        
            | 
            | 
           200 | 
           			intervallePages.add(taillePage);
  | 
        
        
           | 1683 | 
           raphael | 
           201 | 
           		}
  | 
        
        
           | 594 | 
           gduche | 
           202 | 
              | 
        
        
           | 1687 | 
           raphael | 
           203 | 
           		Iterator<Integer> itIntervallePages = intervallePages.iterator();
  | 
        
        
            | 
            | 
           204 | 
           		while (itIntervallePages.hasNext())	{
  | 
        
        
            | 
            | 
           205 | 
           			Integer intervalle = itIntervallePages.next();
  | 
        
        
            | 
            | 
           206 | 
           			selecteurTaillePage.add(intervalle);
  | 
        
        
            | 
            | 
           207 | 
           		}
  | 
        
        
           | 1683 | 
           raphael | 
           208 | 
              | 
        
        
           | 1687 | 
           raphael | 
           209 | 
           		selecteurTaillePage.setSimpleValue(taillePage);
  | 
        
        
            | 
            | 
           210 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           211 | 
              | 
        
        
           | 1687 | 
           raphael | 
           212 | 
           	/**
  | 
        
        
            | 
            | 
           213 | 
           	 * Change l'état de la barre de pagination a actif ou inactif
  | 
        
        
            | 
            | 
           214 | 
           	 * @param etat actif ou inactif
  | 
        
        
            | 
            | 
           215 | 
           	 */
  | 
        
        
            | 
            | 
           216 | 
           	private void changerEtatBarre(boolean etat) {
  | 
        
        
            | 
            | 
           217 | 
           		premierePage.setEnabled(etat);
  | 
        
        
            | 
            | 
           218 | 
           		prevPage.setEnabled(etat);
  | 
        
        
            | 
            | 
           219 | 
           		suivPage.setEnabled(etat);
  | 
        
        
            | 
            | 
           220 | 
           		dernierePage.setEnabled(etat);
  | 
        
        
            | 
            | 
           221 | 
           		champPage.setEnabled(etat);
  | 
        
        
            | 
            | 
           222 | 
           		selecteurTaillePage.setEnabled(etat);
  | 
        
        
            | 
            | 
           223 | 
           		page.setEnabled(etat);
  | 
        
        
            | 
            | 
           224 | 
           		surTotalPage.setEnabled(etat);
  | 
        
        
            | 
            | 
           225 | 
           		afficherNbElem.setEnabled(etat);
  | 
        
        
            | 
            | 
           226 | 
           		nbElemParPage.setEnabled(etat);
  | 
        
        
            | 
            | 
           227 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           228 | 
              | 
        
        
           | 1687 | 
           raphael | 
           229 | 
           	/**
  | 
        
        
            | 
            | 
           230 | 
           	 * ajoute les différents listeners nécessaires au bon fonctionnement des
  | 
        
        
            | 
            | 
           231 | 
           	 * éléments de la barre de pagination
  | 
        
        
            | 
            | 
           232 | 
           	 */
  | 
        
        
            | 
            | 
           233 | 
           	@SuppressWarnings("unchecked")
  | 
        
        
            | 
            | 
           234 | 
           	private void ajouterListeners() {
  | 
        
        
            | 
            | 
           235 | 
           		premierePage.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           236 | 
           				public void componentSelected(ButtonEvent ce)	{
  | 
        
        
            | 
            | 
           237 | 
           					pageCourante = 0;
  | 
        
        
            | 
            | 
           238 | 
           					rafraichirNumeroPage();
  | 
        
        
            | 
            | 
           239 | 
           					changePage();
  | 
        
        
            | 
            | 
           240 | 
           				}
  | 
        
        
            | 
            | 
           241 | 
           			});
  | 
        
        
           | 594 | 
           gduche | 
           242 | 
              | 
        
        
           | 1687 | 
           raphael | 
           243 | 
           		// boutons suivants et précédents
  | 
        
        
            | 
            | 
           244 | 
           		prevPage.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           245 | 
           				public void componentSelected(ButtonEvent ce) {
  | 
        
        
            | 
            | 
           246 | 
           					// si la page courante n'est pas la première
  | 
        
        
            | 
            | 
           247 | 
           					if (pageCourante > 0) {
  | 
        
        
            | 
            | 
           248 | 
           						// on décrémente la page courante de 1
  | 
        
        
            | 
            | 
           249 | 
           						pageCourante--;
  | 
        
        
            | 
            | 
           250 | 
           						// on rafraichit l'affichage
  | 
        
        
            | 
            | 
           251 | 
           						rafraichirNumeroPage();
  | 
        
        
            | 
            | 
           252 | 
           						changePage();
  | 
        
        
            | 
            | 
           253 | 
           					}
  | 
        
        
            | 
            | 
           254 | 
           				}
  | 
        
        
            | 
            | 
           255 | 
           			});
  | 
        
        
           | 594 | 
           gduche | 
           256 | 
              | 
        
        
           | 1687 | 
           raphael | 
           257 | 
           		suivPage.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           258 | 
           				public void componentSelected(ButtonEvent ce)	{
  | 
        
        
            | 
            | 
           259 | 
           					// si la page courante n'est pas la dernière
  | 
        
        
            | 
            | 
           260 | 
           					if (pageCourante < pageTotale - 1) {
  | 
        
        
            | 
            | 
           261 | 
           						// on incrémente la page courante de 1
  | 
        
        
            | 
            | 
           262 | 
           						pageCourante++;
  | 
        
        
            | 
            | 
           263 | 
           						// on rafraichit l'affichage
  | 
        
        
            | 
            | 
           264 | 
           						rafraichirNumeroPage();
  | 
        
        
            | 
            | 
           265 | 
           						changePage();
  | 
        
        
            | 
            | 
           266 | 
           					}
  | 
        
        
            | 
            | 
           267 | 
           				}
  | 
        
        
            | 
            | 
           268 | 
           			});
  | 
        
        
           | 594 | 
           gduche | 
           269 | 
              | 
        
        
           | 1687 | 
           raphael | 
           270 | 
           		dernierePage.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           271 | 
           				public void componentSelected(ButtonEvent ce)	{
  | 
        
        
            | 
            | 
           272 | 
           					pageCourante = pageTotale;
  | 
        
        
            | 
            | 
           273 | 
           					rafraichirNumeroPage();
  | 
        
        
            | 
            | 
           274 | 
           					changePage();
  | 
        
        
            | 
            | 
           275 | 
           				}
  | 
        
        
            | 
            | 
           276 | 
           			});
  | 
        
        
           | 594 | 
           gduche | 
           277 | 
              | 
        
        
           | 1687 | 
           raphael | 
           278 | 
           		rafraichir.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           279 | 
           				public void componentSelected(ButtonEvent ce)	{
  | 
        
        
            | 
            | 
           280 | 
           					changePage();
  | 
        
        
            | 
            | 
           281 | 
           				}
  | 
        
        
            | 
            | 
           282 | 
           			});
  | 
        
        
           | 594 | 
           gduche | 
           283 | 
              | 
        
        
           | 1687 | 
           raphael | 
           284 | 
           		champPage.addKeyListener(new KeyListener() {
  | 
        
        
            | 
            | 
           285 | 
           				public void componentKeyUp(ComponentEvent ce) 	{
  | 
        
        
            | 
            | 
           286 | 
           					// on teste si la touche entrée a été pressée
  | 
        
        
            | 
            | 
           287 | 
           					if (ce.getKeyCode() == KeyCodes.KEY_ENTER) {
  | 
        
        
            | 
            | 
           288 | 
           						int nouvellePage = champPage.getValue().intValue();
  | 
        
        
           | 594 | 
           gduche | 
           289 | 
              | 
        
        
           | 1687 | 
           raphael | 
           290 | 
           						// on verifie s'il est nécessaire de changer de page
  | 
        
        
            | 
            | 
           291 | 
           						// et si la nouvelle est comprise dans l'intervalle des
  | 
        
        
            | 
            | 
           292 | 
           						// pages existantes (0..pageTotale)
  | 
        
        
            | 
            | 
           293 | 
           						if (nouvellePage != pageCourante + 1 && nouvellePage > 0
  | 
        
        
            | 
            | 
           294 | 
           						    && nouvellePage <= pageTotale) {
  | 
        
        
            | 
            | 
           295 | 
           							// le cas échéant, on charge la nouvelle page et on
  | 
        
        
            | 
            | 
           296 | 
           							// notifie le médiateur
  | 
        
        
            | 
            | 
           297 | 
           							changerPageCourante(nouvellePage - 1);
  | 
        
        
            | 
            | 
           298 | 
           							changePage();
  | 
        
        
           | 1683 | 
           raphael | 
           299 | 
           						} else {
  | 
        
        
           | 1687 | 
           raphael | 
           300 | 
           							// sinon on reaffiche l'ancien numero de page sans rien changer
  | 
        
        
            | 
            | 
           301 | 
           							rafraichirNumeroPage();
  | 
        
        
            | 
            | 
           302 | 
           							champPage.focus();
  | 
        
        
           | 1683 | 
           raphael | 
           303 | 
           						}
  | 
        
        
           | 1687 | 
           raphael | 
           304 | 
           					}
  | 
        
        
           | 1683 | 
           raphael | 
           305 | 
           				}
  | 
        
        
           | 1687 | 
           raphael | 
           306 | 
           			});
  | 
        
        
           | 594 | 
           gduche | 
           307 | 
              | 
        
        
           | 1687 | 
           raphael | 
           308 | 
           		// listener pour la selection dans la combobox
  | 
        
        
            | 
            | 
           309 | 
           		selecteurTaillePage.addSelectionChangedListener(new SelectionChangedListener() {
  | 
        
        
            | 
            | 
           310 | 
           				public void selectionChanged(SelectionChangedEvent e) {
  | 
        
        
            | 
            | 
           311 | 
           					SimpleComboBox comboBox = (SimpleComboBox) e.getSource();
  | 
        
        
            | 
            | 
           312 | 
           					String nouvelleTaillePageString = comboBox.getRawValue();
  | 
        
        
            | 
            | 
           313 | 
           					int nouvelleTaillePage = Integer.parseInt(nouvelleTaillePageString);
  | 
        
        
            | 
            | 
           314 | 
           					changerTaillePage(nouvelleTaillePage);
  | 
        
        
            | 
            | 
           315 | 
           					rafraichirNumeroPage();
  | 
        
        
            | 
            | 
           316 | 
           				}
  | 
        
        
            | 
            | 
           317 | 
           			});
  | 
        
        
            | 
            | 
           318 | 
           	}
  | 
        
        
            | 
            | 
           319 | 
              | 
        
        
            | 
            | 
           320 | 
           	public void changePage() {
  | 
        
        
            | 
            | 
           321 | 
           		// si notre barre de pagination n'a pas été initialisée
  | 
        
        
            | 
            | 
           322 | 
           		// avec un filtre de recherche, contentons-nous de changer de page
  | 
        
        
            | 
            | 
           323 | 
           		// Attention, car tous les webservice ne supporte pas un segment d'URI "null" (500)
  | 
        
        
            | 
            | 
           324 | 
           		if(champFiltreRecherche == null || champFiltreRecherche.getFiltreValue() == null) {
  | 
        
        
            | 
            | 
           325 | 
           			// et on notifie le médiateur de l'évenement
  | 
        
        
            | 
            | 
           326 | 
           			listePaginable.changerNumeroPage(pageCourante);
  | 
        
        
            | 
            | 
           327 | 
           		} else {
  | 
        
        
            | 
            | 
           328 | 
           			// autrement nous pouvons changer de page *tout en conservant* le filtre de recherche,
  | 
        
        
            | 
            | 
           329 | 
           			// charge au modèle de cette liste d'avoir implémenté correctement filtrerParNomEtPage()
  | 
        
        
            | 
            | 
           330 | 
           			listePaginable.filtrerParNomEtPage(champFiltreRecherche.getFiltreValue(), pageCourante);
  | 
        
        
           | 1683 | 
           raphael | 
           331 | 
           		}
  | 
        
        
           | 1687 | 
           raphael | 
           332 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           333 | 
              | 
        
        
           | 1687 | 
           raphael | 
           334 | 
              | 
        
        
            | 
            | 
           335 | 
           	/**
  | 
        
        
            | 
            | 
           336 | 
           	 * Met à jour les affichage sur les numéros de pages et d'intervalle
  | 
        
        
            | 
            | 
           337 | 
           	 * d'éléments à partir des variables de classes
  | 
        
        
            | 
            | 
           338 | 
           	 */
  | 
        
        
            | 
            | 
           339 | 
           	public void rafraichirNumeroPage() {
  | 
        
        
            | 
            | 
           340 | 
           		surTotalPage.setText(" sur " + pageTotale);
  | 
        
        
            | 
            | 
           341 | 
           		if (nbElement == 0) {
  | 
        
        
            | 
            | 
           342 | 
           			champPage.setValue(0);
  | 
        
        
            | 
            | 
           343 | 
           			// on met simplement à jour l'intervalle qui contient toujours le
  | 
        
        
            | 
            | 
           344 | 
           			// même nombre d'éléments
  | 
        
        
            | 
            | 
           345 | 
           			intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), 0,0,0));
  | 
        
        
            | 
            | 
           346 | 
           		} else {
  | 
        
        
            | 
            | 
           347 | 
           			champPage.setValue(pageCourante + 1);
  | 
        
        
            | 
            | 
           348 | 
           			// si la page n'est pas la dernière
  | 
        
        
            | 
            | 
           349 | 
           			if (pageCourante + 1 != pageTotale) {
  | 
        
        
            | 
            | 
           350 | 
           				// sauf pour la dernière page qui contient souvent moins
  | 
        
        
            | 
            | 
           351 | 
           				// d'élements que le nombre d'élements par page
  | 
        
        
            | 
            | 
           352 | 
           				intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage,
  | 
        
        
            | 
            | 
           353 | 
           										  (pageCourante + 1) * taillePage, nbElement));
  | 
        
        
            | 
            | 
           354 | 
           			} else {
  | 
        
        
            | 
            | 
           355 | 
              | 
        
        
            | 
            | 
           356 | 
           				// on met simplement à jour l'intervalle qui contient toujours
  | 
        
        
            | 
            | 
           357 | 
           				// le même nombre d'éléments
  | 
        
        
            | 
            | 
           358 | 
           				intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage,
  | 
        
        
            | 
            | 
           359 | 
           										  nbElement, nbElement));
  | 
        
        
            | 
            | 
           360 | 
           			}
  | 
        
        
           | 655 | 
           gduche | 
           361 | 
           		}
  | 
        
        
           | 1687 | 
           raphael | 
           362 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           363 | 
              | 
        
        
           | 1687 | 
           raphael | 
           364 | 
           	/**
  | 
        
        
            | 
            | 
           365 | 
           	 * Met à jour la page en cours
  | 
        
        
            | 
            | 
           366 | 
           	 *
  | 
        
        
            | 
            | 
           367 | 
           	 * @param nouvellePageCourante
  | 
        
        
            | 
            | 
           368 | 
           	 *            la nouvelle page en cours
  | 
        
        
            | 
            | 
           369 | 
           	 */
  | 
        
        
            | 
            | 
           370 | 
           	public void changerPageCourante(int nouvellePageCourante) {
  | 
        
        
            | 
            | 
           371 | 
           		pageCourante = nouvellePageCourante;
  | 
        
        
            | 
            | 
           372 | 
           	}
  | 
        
        
            | 
            | 
           373 | 
              | 
        
        
            | 
            | 
           374 | 
           	/**
  | 
        
        
            | 
            | 
           375 | 
           	 * Envoie au médiateur une demande pour modifier la taille de la page (qui
  | 
        
        
            | 
            | 
           376 | 
           	 * va à son tour faire les modifications nécessaires)
  | 
        
        
            | 
            | 
           377 | 
           	 *
  | 
        
        
            | 
            | 
           378 | 
           	 * @param nouvelleTaillePage
  | 
        
        
            | 
            | 
           379 | 
           	 *            la nouvelle taille de page (élement appartenant au tableau
  | 
        
        
            | 
            | 
           380 | 
           	 *            renvoyé par getNbPages())
  | 
        
        
            | 
            | 
           381 | 
           	 */
  | 
        
        
            | 
            | 
           382 | 
           	public void changerTaillePage(int nouvelleTaillePage) {
  | 
        
        
            | 
            | 
           383 | 
           		if (nouvelleTaillePage != taillePage)	{
  | 
        
        
            | 
            | 
           384 | 
           			listePaginable.changerTaillePage(nouvelleTaillePage);
  | 
        
        
           | 1683 | 
           raphael | 
           385 | 
           		}
  | 
        
        
           | 1687 | 
           raphael | 
           386 | 
           	}
  | 
        
        
           | 594 | 
           gduche | 
           387 | 
              | 
        
        
           | 1687 | 
           raphael | 
           388 | 
           	/**
  | 
        
        
            | 
            | 
           389 | 
           	 * Selectionne la valeur correspond à celle passée en paramètre dans la
  | 
        
        
            | 
            | 
           390 | 
           	 * combobox (si elle existe)
  | 
        
        
            | 
            | 
           391 | 
           	 *
  | 
        
        
            | 
            | 
           392 | 
           	 * @param nouvelleTaillePage
  | 
        
        
            | 
            | 
           393 | 
           	 *            la nouvelle taille de page
  | 
        
        
            | 
            | 
           394 | 
           	 */
  | 
        
        
            | 
            | 
           395 | 
           	public void selectionnerTaillePage(int nouvelleTaillePage) {
  | 
        
        
            | 
            | 
           396 | 
           		selecteurTaillePage.setRawValue("" + nouvelleTaillePage);
  | 
        
        
            | 
            | 
           397 | 
           	}
  | 
        
        
           | 1860 | 
           aurelien | 
           398 | 
              | 
        
        
            | 
            | 
           399 | 
           	public void allerALaDernierePage() {
  | 
        
        
            | 
            | 
           400 | 
           		changerPageCourante(pageTotale);
  | 
        
        
            | 
            | 
           401 | 
           		changePage();
  | 
        
        
            | 
            | 
           402 | 
           	}
  | 
        
        
           | 1687 | 
           raphael | 
           403 | 
              | 
        
        
            | 
            | 
           404 | 
           	public void rafraichir(Object nouvelleDonnees) {
  | 
        
        
            | 
            | 
           405 | 
           		// si on reçoit un tableau de int
  | 
        
        
            | 
            | 
           406 | 
           		if (nouvelleDonnees instanceof int[]) {
  | 
        
        
            | 
            | 
           407 | 
           			int[] page = (int[]) nouvelleDonnees;
  | 
        
        
            | 
            | 
           408 | 
           			// le premier élement est le nombre de pages totales
  | 
        
        
            | 
            | 
           409 | 
           			pageTotale = page[0];
  | 
        
        
            | 
            | 
           410 | 
           			// le second la page en cours
  | 
        
        
            | 
            | 
           411 | 
           			pageCourante = page[1];
  | 
        
        
            | 
            | 
           412 | 
           			// le troisième la taille de la page
  | 
        
        
            | 
            | 
           413 | 
           			taillePage = page[2];
  | 
        
        
            | 
            | 
           414 | 
           			// et le dernier le nombre total d'éléments
  | 
        
        
            | 
            | 
           415 | 
           			nbElement = page[3];
  | 
        
        
           | 594 | 
           gduche | 
           416 | 
              | 
        
        
           | 1687 | 
           raphael | 
           417 | 
           			// si la page courante dépasse la page totale (cas normalement
  | 
        
        
            | 
            | 
           418 | 
           			// improbable car géré en amont)
  | 
        
        
            | 
            | 
           419 | 
           			// on met le numéro de page à la page courante -1 (car la page
  | 
        
        
            | 
            | 
           420 | 
           			// courante est comptée à partir
  | 
        
        
            | 
            | 
           421 | 
           			// de zéro)
  | 
        
        
            | 
            | 
           422 | 
           			if (pageCourante >= pageTotale && pageCourante != 0) {
  | 
        
        
            | 
            | 
           423 | 
           				pageCourante = pageTotale - 1;
  | 
        
        
            | 
            | 
           424 | 
           				// le cas échéant on en notifie le médiateur
  | 
        
        
            | 
            | 
           425 | 
           				changePage();
  | 
        
        
            | 
            | 
           426 | 
           			}
  | 
        
        
            | 
            | 
           427 | 
           		}
  | 
        
        
           | 594 | 
           gduche | 
           428 | 
              | 
        
        
           | 1687 | 
           raphael | 
           429 | 
           		// enfin on rafraichit les informations affichées à partir des nouvelles
  | 
        
        
            | 
            | 
           430 | 
           		// variables de classes mises à jour
  | 
        
        
            | 
            | 
           431 | 
           		rafraichirNumeroPage();
  | 
        
        
           | 594 | 
           gduche | 
           432 | 
              | 
        
        
           | 1687 | 
           raphael | 
           433 | 
           		layout();
  | 
        
        
            | 
            | 
           434 | 
           	}
  | 
        
        
           | 1683 | 
           raphael | 
           435 | 
           }
  |