Subversion Repositories eFlore/Archives.cel-v1

Rev

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

/*
 * Copyright 2006 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.tela_botanica.client;

import java.util.Iterator;
import java.util.Vector;

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;

/*
 * Le retour de getUser appelle updateCount qui appelle update pour veiller à une
 * initialisation correcte
 * 
 */

public class InventoryItemList extends Composite implements
                AutoCompleteAsyncTextBoxListener {

        // Barre de navigation

        private class NavBar extends Composite implements ClickListener {

                public final DockPanel bar = new DockPanel();

                public final Button gotoFirst = new Button("<<", this);

                public final Button gotoNext = new Button(">", this);

                public final Button gotoPrev = new Button("<", this);

                public final Button gotoEnd = new Button(">>", this);
                
                 
                public final HTML status = new HTML();
                

                public NavBar() {
                        
                        
                        initWidget(bar);
                        bar.setStyleName("navbar");
                        status.setStyleName("status");
                        
                        HorizontalPanel buttons = new HorizontalPanel();
                        
                        buttons.add(status);
                        buttons.setCellHorizontalAlignment(status,
                                        HasHorizontalAlignment.ALIGN_RIGHT);
                        buttons.setCellVerticalAlignment(status,
                                        HasVerticalAlignment.ALIGN_MIDDLE);
                        buttons.setCellWidth(status, "100%");


                        buttons.add(gotoFirst);
                        buttons.add(gotoPrev);
                        buttons.add(gotoNext);
                        buttons.add(gotoEnd);
                        bar.add(buttons, DockPanel.EAST);
                        bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
                        
                        
                        bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT);

                        bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
                        
                        
                }
                
                  

                public void onClick(Widget sender) {
                        if (sender == gotoNext) {
                                // Move forward a page.
                                startIndex += VISIBLE_TAXON_COUNT;
                                if (startIndex >= count)
                                        startIndex -= VISIBLE_TAXON_COUNT;
                        } else {
                                if (sender == gotoPrev) {
                                        // Move back a page.
                                        startIndex -= VISIBLE_TAXON_COUNT;
                                        if (startIndex < 0)
                                                startIndex = 0;
                                } else {
                                        if (sender == gotoEnd) {
                                                gotoEnd();
                                        } else {
                                                if (sender == gotoFirst) {
                                                        startIndex = 0;
                                                }
                                        }
                                }
                        }
                        update();
                }

        }

        private void setStatusText(String text) {
                navBar.status.setText(text);
        }

        private static final int VISIBLE_TAXON_COUNT = 15;

        private Grid header = new Grid(1, 3);

        private FlexTable table = new FlexTable();

        private VerticalPanel panel = new VerticalPanel();

        private int startIndex = 0;

        private String serviceBaseUrl = null;

        private int count = 65000;

        private String user;

        private NavBar navBar=null;
        
        private Mediator mediator = null;

        private int  selectedRow = -1;
        
        private String location = "all";
        private String date = "all";
        private String search = "all";
        private String station = "all";

        private boolean add=false;
        
        public InventoryItemList(Mediator med) {

                mediator=med;
                
            mediator.registerInventoryItemList(this);
                
                user=mediator.getUser();
            serviceBaseUrl = mediator.getServiceBaseUrl();
        
                navBar = new NavBar();
                

                // Information complementaire : un tableau associe au retour de
                // l'assistant de saisie

                // Mise en forme du header

                header.setCellSpacing(0);
                header.setCellPadding(2);
                header.setWidth("100%");

                header.setStyleName("inventoryItem-ListHeader");

                header.setWidget(0, 2, navBar);

                // Mise en forme de la table.

                table.setCellSpacing(0);
                table.setBorderWidth(0);
                table.setCellPadding(2);
                table.setWidth("100%");
                

                // Mise en forme barre navigation

                navBar.setWidth("100%");

                table.setStyleName("inventoryItem-List");

                //panel.add(navBar);
                panel.add(header);
                panel.add(table);

                
                 // Hook up events.
            table.addTableListener(new TableListener () {
                
                          public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
                                   
                                  if (table.getWidget(row, 0)!=null) {
                                      selectRow(row);
                                      // Numero d'ordre
                                      mediator.onInventoryItemSelected(table.getText(row, 5));
                                  }
                          }

            });
            
                
                //updateCount();
                // update()

                
                initWidget(panel);


        }
        
        
         
          private void selectRow(int row) {
                  
                    styleRow(selectedRow, false);
                    styleRow(row, true);

                    selectedRow = row;
                    
                  }
                  
                  
                  private void styleRow(int row, boolean selected) {
                            if (row != -1) {
                              if (selected)
                                table.getRowFormatter().addStyleName(row, "inventoryItem-SelectedRow");
                              else
                                if (row < table.getRowCount()) { 
                                        table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
                                }
                            }
                          }


        

        /**
         * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
         * la recherche d'informations complémentaires (famille, numero
         * nomenclaturaux etc) et met a jour l'inventaire (addelement())
         * 
         * @return void
         */
        public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
                          String str, String value) {
        

        mediator.onAddInventoryItem();
                
        }
        

        // Action sur modification d'un element 
        
        
        public void updateElement() {
        
        
        if (mediator.inventoryItemIsValid()) {
        
                final InventoryItem inventoryItem=mediator.getInventoryItem();
        
                setStatusDisabled();
                
                                if (inventoryItem.getNomenclaturalNumber() !=null) {
                
                                        HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
                                                        new ResponseTextHandler() {
                
                                                                public void onCompletion(String strcomplete) {
                
                                                                        JSONValue jsonValue = JSONParser.parse(strcomplete);
                                                                        JSONArray jsonArray;
                
                                                                        if ((jsonArray = jsonValue.isArray()) != null) {
                                                                                // Nom retenu, Num Nomen nom retenu, Num Taxon,
                                                                                // Famille
                                                                                updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
                                                                                                ((JSONString) jsonArray.get(0))
                                                                                                                .stringValue(),
                                                                                                ((JSONString) jsonArray.get(1))
                                                                                                                .stringValue(),
                                                                                                ((JSONString) jsonArray.get(2))
                                                                                                                .stringValue(),
                                                                                                ((JSONString) jsonArray.get(3))
                                                                                                                .stringValue(),
                                                                                                                inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
                                                                        }
                                                                }
                
                                                        });
                                }
                                // Saisie libre
                                else {
                                        updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
                                }
                        
                }
        else {
                return;
        }
        }

        
        
        // Action sur ajout d'un element 
        
        
        public void addelement() {
        
        
        if (mediator.inventoryItemIsValid()) {
        
                final InventoryItem inventoryItem=mediator.getInventoryItem();
        
                setStatusDisabled();
                
                                // On met a jour rapidement l'affichage puis on lance la requete  ....
                                
                /*              int row = table.insertRow(table.getRowCount());
                                // Case a cocher
                                table.setWidget(row, 0, new CheckBox());
                                // Nom saisi
                                table.setText(row, 1, nameText);
                                
                                table.getFlexCellFormatter().setWidth(row, 0, "2%");
                                table.getFlexCellFormatter()
                                                .setWidth(row, 1, "31%");*/
                                
                                // Recherche complement d'information
                
                                if (inventoryItem.getNomenclaturalNumber() !=null) {
                
                                        HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
                                                        new ResponseTextHandler() {
                
                                                                public void onCompletion(String strcomplete) {
                
                                                                        JSONValue jsonValue = JSONParser.parse(strcomplete);
                                                                        JSONArray jsonArray;
                
                                                                        if ((jsonArray = jsonValue.isArray()) != null) {
                                                                                // Nom retenu, Num Nomen nom retenu, Num Taxon,
                                                                                // Famille
                                                                                addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
                                                                                                ((JSONString) jsonArray.get(0))
                                                                                                                .stringValue(),
                                                                                                ((JSONString) jsonArray.get(1))
                                                                                                                .stringValue(),
                                                                                                ((JSONString) jsonArray.get(2))
                                                                                                                .stringValue(),
                                                                                                ((JSONString) jsonArray.get(3))
                                                                                                                .stringValue(),
                                                                                                                inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
                                                                        }
                                                                }
                
                                                        });
                                }
                                // Saisie libre
                                else {
                                        addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
                                }
                        
                }
        else {
                return;
        }
        }

        /**
         * Ajoute un element à l'inventaire
         * 
         * @param nom_sel :
         *            nom selectionne
         * @param num_nom_sel :
         *            numero nomenclatural nom selectionne
         * @param nom_ret :
         *            nom retenu
         * @param num_nom_ret :
         *            numero nomenclaturel nom retenu
         * @param num_taxon :
         *            numero taxonomique
         * @param famille :
         *            famille
         */

        private void addElement(String nom_sel, String num_nom_sel, String nom_ret,
                        String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {


                count++;
                HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
                                + user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
                                + "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
                                + "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
                                + "&station="+ complementLocation + "&commentaire="+ comment,

                new ResponseTextHandler() {

                        public void onCompletion(String str) {
                                        location=loc;
                                        if (location.compareTo("")==0) {
                                                location="000null";
                                        }
                                        add=true;
                                        mediator.onInventoryUpdated(location);
                                        updateCount();
                        }
                });
        }

        

        /**
         * Modifie un element de l'inventaire
         * 
         * @param ordre : numero d'ordre
         * @param nom_sel :
         *            nom selectionne
         * @param num_nom_sel :
         *            numero nomenclatural nom selectionne
         * @param nom_ret :
         *            nom retenu
         * @param num_nom_ret :
         *            numero nomenclaturel nom retenu
         * @param num_taxon :
         *            numero taxonomique
         * @param famille :
         *            famille
         */

        private void updateElement(String ordre, String nom_sel, String num_nom_sel, String nom_ret,
                        String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {


                HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user + "/" +ordre + "/",
                                 "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
                                + "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
                                + "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
                                + "&station="+ complementLocation + "&commentaire="+ comment,

                new ResponseTextHandler() {

                        public void onCompletion(String str) {
                                add=false;
                                mediator.onInventoryUpdated(location);
                                update();
                        }
                });
        }

        /**
         * Transmission de releve à Tela
         * 
         */

        
        
        public void transmitElement() {
        
                setStatusDisabled();
                Vector parseChecked = new Vector();

                // TODO : optimiser
                // Lifo ...
                for (int i = table.getRowCount() - 1; i >= 0; i--) {
                         if (table.getWidget(i, 0)!=null) {
                                 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
                                         // Numero ordre
                                         parseChecked.add(table.getText(i, 5));
                                 }
                         }
                }
                StringBuffer ids=new StringBuffer();
                for (Iterator it = parseChecked.iterator(); it.hasNext();) {
                        ids.append((String)it.next());
                        if (it.hasNext()) ids.append(",");
                }
                
                if (ids.length()>0) {
                
                        HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
                                                        + "/" + ids.toString(), "transmission=1",
                                                        
                                                        new ResponseTextHandler() {
                                                                public void onCompletion(String str) {
                                                                                        update();
                                                                }
                                                        });
                }
        
                setStatusEnabled();

                
        }
        
        
        /**
         * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
         * 
         */

        public void deleteElement() {

                setStatusDisabled();
                Vector parseChecked = new Vector();

                // TODO : optimiser
                // Lifo ...
                for (int i = table.getRowCount() - 1; i >= 0; i--) {
                         if (table.getWidget(i, 0)!=null) {
                                 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
                                         // Numero ordre
                                         parseChecked.add(table.getText(i, 5));
                                         count--;
                                 }
                         }
                }
                StringBuffer ids=new StringBuffer();
                for (Iterator it = parseChecked.iterator(); it.hasNext();) {
                        ids.append((String)it.next());
                        if (it.hasNext()) ids.append(",");
                }
                if (ids.length()>0) {
                        
                        HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
                                                        + "/" + ids.toString(), "action=DELETE",
                                                        
                                                        new ResponseTextHandler() {
                                                                public void onCompletion(String str) {
                                                                                        mediator.onInventoryUpdated("all");
                                                                                        updateCount();
                                                                }
                                                        });
                }
        
                setStatusEnabled();
        }
        
        /**
         * Selection de l'ensemble des elements affichés
         * 
         */

        public void selectAll() {

                // TODO : optimiser ...
                for (int i = table.getRowCount() - 1; i >= 0; i--) {
                         if (table.getWidget(i, 0)!=null)
                         ((CheckBox) table.getWidget(i, 0)).setChecked(true); 
                }
        }

        public void deselectAll() {
        
                // TODO : optimiser ...
                for (int i = table.getRowCount() - 1; i >= 0; i--) {
                         if (table.getWidget(i, 0)!=null)
                        ((CheckBox) table.getWidget(i, 0)).setChecked(false); 
                }
        }



        /**
         * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
         * 
         */
        public void updateCount () {
                
                setStatusDisabled();
                
                String adate="all";
                if (date.compareTo("all")!=0) {
                        adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
                }

                HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate  + "/" + search +  "/" + station, 
                                new ResponseTextHandler() {

                                        public void onCompletion(String str) {

                                                JSONValue jsonValue = JSONParser.parse(str);
                                                JSONNumber jsonNumber;
                                                if ((jsonNumber = jsonValue.isNumber()) != null) {
                                                        count = (int) jsonNumber.getValue();
                                                        /*
                                                        if (count==0) {
                                                                location="all";
                                                        }
                                                        */
                                                        if (location.compareTo("")==0)
                                                                location="000null";
                                                //      mediator.onInventoryItemUpdate(location);
                                                        gotoEnd(); // Derniere page
                                                        update();
                                                }
                                        }
                                });

        }
        
        
        private String subLeft(String text, int length) {
                return (text.length() < length) ? text : text.substring(0, length)+ " ...";
        } 

        /**
         * Mise a jour de l'affichage, à partir des données d'inventaire deja
         * saisies. La valeur de this.startIndex permet de determiner quelles
         * données seront affichées
         * 
         *  @param deep : force une mise a jour totale
         */

        public void update() {

        
//              table.setBorderWidth(1);
                setStatusDisabled();

                String adate="all";
                if (date.compareTo("all")!=0) {
                        adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
                }
                
                
                String com;
                if (location.compareTo("all")==0) {
                        com="Toutes communes";
                }
                else {
                        if (location.compareTo("000null")==0) {
                                com="Communes non renseign&eacute;es";
                        }
                        else {
                        com="Commune de "+location;
                        }
                }

                
                String dat;
                
                if (date.compareTo("all")==0) {
                        dat=", toutes p&eacute;riodes";
                }
                else {
                        if (date.compareTo("00/00/0000")==0) {
                                dat=", p&eacute;riodes non renseign&eacute;es";
                        }
                        else {
                                dat=", le "+ date;
                        }
                }
        
                
                String stat;
                
                if (station.compareTo("all")==0) {
                        stat=", toutes stations";
                }
                else {
                        if (station.compareTo("000null")==0) {
                                stat=", stations non renseign&eacute;es";
                        }
                        else {
                                stat=", station "+ station;
                        }
                }
        
                
                header.setHTML(0, 0, com +  dat + stat );
                
                HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/"
                                + startIndex + "/" + VISIBLE_TAXON_COUNT,

                new ResponseTextHandler() {

                        public void onCompletion(String str) {

                                JSONValue jsonValue = JSONParser.parse(str);
                                JSONArray jsonArray;
                                JSONArray jsonArrayNested;
                                
                                StringBuffer left=new StringBuffer();
                                StringBuffer center=new StringBuffer();
                                StringBuffer right=new StringBuffer();
                                
                                

                                
                                int row=0;
                                int i=0;
                                if ((jsonArray = jsonValue.isArray()) != null) {
                                        int arraySize = jsonArray.size();
                                        for (i = 0; i < arraySize; ++i) {
                                                if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
                                                        if (i>=table.getRowCount()) {
                                                                 row = table.insertRow(table.getRowCount());
                                                        }
                                                        else {
                                                                row = i;
                                                        }

                                                        left=new StringBuffer();
                                                        center=new StringBuffer();
                                                        right=new StringBuffer();
                                                        
                                                        // Case a cocher
                                                        table.setWidget(row, 0, new CheckBox());
                                                        
                                                        
                                                        // Observation transmise
                                                        
                                                        
                                                        String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue();
                                                        
                                                        if (atransmit.compareTo("1")==0) {
                                                                table.setWidget(row,1,new Image("tela.gif"));
                                                        }
                                                        else {
                                                                table.setWidget(row,1,new HTML("&nbsp;"));
                                                        }
                                                        
                                                        left.append("<b>"+((JSONString) jsonArrayNested .get(0)).stringValue()+"</b>");
                                                        
                                                        // Nom retenu
                                                        String aname=((JSONString) jsonArrayNested .get(2)).stringValue();
                                                        
                                                        if (aname.compareTo("null")==0) {
                                                        }
                                                        else {
                                                                center.append(aname+", ");
                                                        }
                                                        
                                                        // Num nomenclatural
                                                        String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
                                                        
                                                        if (ann.compareTo("0")!=0) {
                                                                center.append(""+ann+"-");
                                                        }
                                                        else {
                                                                center.append("0-");
                                                        }

                                                        
                                                        // Num Taxonomique
                                                        
                                                        String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
                                                        
                                                        if (ant.compareTo("0")!=0) {
                                                                center.append(ant+", ");
                                                        }
                                                        else {
                                                                center.append("0, ");
                                                        }

                                                        // Famille
                                                        String afamily=((JSONString) jsonArrayNested .get(5)).stringValue();
                                                        
                                                        if (afamily.compareTo("null")==0) {
                                                                //
                                                        }
                                                        else {
                                                                center.append(afamily+", ");
                                                        }

                                                        
                                                        String aloc=((JSONString) jsonArrayNested .get(6)).stringValue();
//                                                              Localisation - Lieu
                                                                
                                                                if (aloc.compareTo("000null")==0) {
                                                                        if (center.length()==0) {
                                                                                center.append("Commune absente");
                                                                        }
                                                                        else {
                                                                                center.append("commune absente");
                                                                        }
                                                                }
                                                                else {
                                                                        if (center.length()==0) {
                                                                                center.append("Commune de "+aloc);
                                                                        }
                                                                        else {
                                                                                center.append("commune de "+aloc);
                                                                        }
                                                                                
                                                                }
                                                        
                                                                
                                                                String alieudit=((JSONString) jsonArrayNested .get(9)).stringValue();
                                                        
//                                                              Localisation - Lieu dit
                                                                
                                                                if (alieudit.compareTo("000null")!=0) {
                                                                        center.append(", "+alieudit);
                                                                }
                                                        
                                                                String acomment=((JSONString) jsonArrayNested .get(10)).stringValue();
//                                                              Commentaire
                                                                
                                                                if (acomment.compareTo("null")!=0) {
                                                                        center.append(", "+acomment);
                                                                }

                                                                
                                                                String adate=((JSONString) jsonArrayNested .get(8)).stringValue();
                                                                
//                                                              Date 
                                                                if (adate.compareTo("0000-00-00 00:00:00")!=0) {
                                                                        right.append("<b>"+adate+"</b>"); 
                                                                }
                                                                else {
//                                                                      right.append("<b>00/00/0000</b>"); 
                                                                }
                                                                
                                                        
                                                        table.setHTML(row, 2, subLeft("&nbsp;"+left,40));
                                                        table.setHTML(row, 3, subLeft("&nbsp;"+center,120));
                                                        table.setHTML(row, 4, subLeft("&nbsp;"+right,25));
                                                        
                                                        table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
                                                        
                                                
                                                        table.getCellFormatter().setWidth(row,0,"2%");
                                                        table.getCellFormatter().setWidth(row,1,"2%");
                                                        table.getCellFormatter().setWordWrap(row,2,false);
                                                        table.getCellFormatter().setWidth(row,2,"10%");
                                                        table.getCellFormatter().setWordWrap(row,3,false);
                                                        table.getCellFormatter().setWordWrap(row,4,false);
                                                        table.getCellFormatter().setWidth(row,4,"7%");
                                                        
                                                        
                                                        String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
                                                
                                                        // Numero d'ordre (caché)
                
                                                        
                                                        table.setText(row, 5, aordre);

                                                        if (add){
                                                                if (i ==(arraySize -1)) {
                                                                        selectRow(row);
                                                                        mediator.getEntryPanel().setOrdre(aordre);
                                                                }
                                                                
                                                        }
                                                        else {
                                                                if ((mediator.getEntryPanel().getOrdre()!=null) && (mediator.getEntryPanel().getOrdre().compareTo(aordre)==0)) {
                                                                        selectRow(row);
                                                                }
                                                        }

                                                        table.getCellFormatter().setVisible(row, 5, false);

                                                        
                                                }

                                        }
                                }

                                
                                // Suppression fin ancien affichage
                                for (int j=i;j<VISIBLE_TAXON_COUNT;j++) {
                                                 table.setHTML(j,0,"&nbsp;");
                                                 table.setHTML(j,1,"&nbsp;");
                                                 table.setHTML(j,2,"&nbsp;");
                                                 table.setHTML(j,3,"&nbsp;");
                                                 table.setHTML(j,4,"&nbsp;");
                                                 table.setHTML(j,5,"&nbsp;");
                                                table.getCellFormatter().setVisible(j, 5, false);
                                                table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow");
                                }
                                
                                add=false;

                                setStatusEnabled();
                                
                                
                        }
                });
                

        }


        /**
         * Affichage message d'attente et désactivation navigation
         * 
         * @param
         * @return void
         */

        private void setStatusDisabled() {

                navBar.gotoFirst.setEnabled(false);
                navBar.gotoPrev.setEnabled(false);
                navBar.gotoNext.setEnabled(false);
                navBar.gotoEnd.setEnabled(false);

                setStatusText("Patientez ...");
        }

        /**
         * Affichage numero de page et gestion de la navigation
         * 
         */

        private void setStatusEnabled() {

                // Il y a forcemment un disabled avant d'arriver ici

                if (count > 0) {

                        if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
                                                                                                                // premiere page
                                navBar.gotoPrev.setEnabled(true);
                                navBar.gotoFirst.setEnabled(true);
                                if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
                                                                                                                                        // derniere
                                                                                                                                        // page
                                        navBar.gotoNext.setEnabled(true);
                                        navBar.gotoEnd.setEnabled(true);
                                        setStatusText((startIndex + 1) + " - "
                                                        + (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
                                } else { // Derniere page
                                        setStatusText((startIndex + 1) + " - " + count + " sur " + count );
                                }
                        } else { // Premiere page
                                if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
                                        navBar.gotoNext.setEnabled(true);
                                        navBar.gotoEnd.setEnabled(true);
                                        setStatusText((startIndex + 1) + " - "
                                                        + (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
                                } else {
                                        setStatusText((startIndex + 1) + " - " + count + " sur " + count);
                                }
                        }
                }

                else { // Pas d'inventaire, pas de navigation
                        setStatusText("0 - 0 sur 0");
                }
        }

        /*
         * Positionnement index de parcours (this.startIndex) pour affichage de la
         * dernière page
         * 
         * @param
         * @return void
         */

        private void gotoEnd() {

                if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
                        startIndex = count - (count % VISIBLE_TAXON_COUNT);
                } else {
                        startIndex = count - VISIBLE_TAXON_COUNT;
                }

        }

        /*
         * Recherche en cours
         * 
         */
        
        public void setSearch(String search) {
                this.search = search;
        }


        
        /*
         * Localite en cours 
         * 
         */
        
        public void setLocation(String location) {
                this.location = location;
        }



        public void setDate(String date) {
                this.date = date;
        }


        public void setUser(String user) {
                this.user = user;
        }
        

        public void setStation(String station) {
                this.station = station;
        }


        
        
        


}