Subversion Repositories eFlore/Applications.del

Rev

Rev 379 | Blame | Last modification | View Log | RSS feed

package org.tela_botanica.del.client.vues.rechercheimages.resultats;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

public class ResultatRechercheImageVue extends Composite implements ResultatRechercheImagePresenteur.Vue {

        @UiField
        Panel panneauChargement;
        private final List<Panel> panneauxImages = new ArrayList<Panel>();
        private final int nbImagesPerPage = 10;
        private int numImage = 0;

        // Annotation can be used to change the name of the associated xml file
        // @UiTemplate("ObservationRechercheVue.ui.xml")
        interface MyUiBinder extends UiBinder<Widget, ResultatRechercheImageVue> {
        }

        private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

        @UiField
        Panel panneauPagination, panneauPaginationHaut;

        @UiField
        HTMLPanel imageTable;

        // Constructeur
        public ResultatRechercheImageVue() {
                initWidget(uiBinder.createAndBindUi(this));
        }

        /**
         * Nettoie et remet à zéro les composants du panneau qui doivent l'être
         * */
        public void nettoyer() {
                setNumImage(0);
                imageTable.clear();
                panneauxImages.clear();
        }

        public void creerPanneauxObservations(int taille) {

                panneauxImages.clear();
                for (int i = 0; i < taille; i++) {
                        Panel imagePanel = new HTMLPanel("");
                        panneauxImages.add(imagePanel);
                }
        }

        public void afficherPanneauxObservation(List<Panel> imagesPanel) {

                imageTable.clear();
                for (int i = 0; i < imagesPanel.size(); i++) {
                        HTMLPanel panneauImage = (HTMLPanel) imagesPanel.get(i);
                        panneauxImages.add(panneauImage);
                        // imageTable.setWidget((i) / nbCol, (i) % nbCol, panneauImage);
                        imageTable.add(panneauImage);
                }

        }

        public void setNumImage(int numImage) {
                this.numImage = numImage;
        }

        public void startChargement() {
                panneauChargement.setHeight((this.getOffsetHeight() - (panneauPagination.getOffsetHeight()*2))+"px");
                panneauChargement.setVisible(true);
        }

        public void stopChargement() {
                panneauChargement.setVisible(false);
        }

        public HTMLPanel getImageTable() {
                return imageTable;
        }

        public int getNumImage() {
                return numImage;
        }

        public Panel getPanneauChargement() {
                return panneauChargement;
        }

        public Panel getPanneauPagination() {
                return panneauPagination;
        }
        
        public Panel getPanneauPaginationHaut() {
                return panneauPaginationHaut;
        }

        public int getNbImagesPerPage() {
                return nbImagesPerPage;
        }

        public List<Panel> getPanneauxImages() {
                return panneauxImages;
        }

}