Rev 26 | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.del.client.vues.rechercheobservations;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
public class ObservationRechercheVue extends Composite {
private final VerticalPanel mainPanel = new VerticalPanel();
private final Panel panneauChargement = new FlowPanel();
private final Panel taxaPanel = new FlowPanel();
private final FlexTable imageTable = new FlexTable();
private final Panel panneauPagination = new HorizontalPanel();
private final List<Panel> panneauxImages = new ArrayList<Panel>();
private final HTML labelChargement = new HTML("<img src='img/wait.gif' />Contact du serveur du CEL...");
private final HTML labelChercher = new HTML("<img src='img/search_icon.gif' />Search taxon:");
private int nbCol = 5;
private final int nbImagesPerPage = 10;
private int numImage = 0;
private final TextBox textBox = new TextBox();
// Constructeur
protected ObservationRechercheVue() {
textBox.setText("apifera");
textBox.setFocus(true);
mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
mainPanel.setSize("100%", "100%");
Panel textBoxPanel = new HorizontalPanel();
textBoxPanel.add(labelChercher);
textBoxPanel.add(textBox);
Panel searchPanel = new VerticalPanel();
searchPanel.add(new HTML("Rechercher une image"));
searchPanel.add(textBoxPanel);
searchPanel.add(new HTML("Entrez un nom de genre ou d'espèce, un nom de commune, un numéro de departement, l'email d'un utilisateur ou un mot-clef"));
panneauChargement.add(labelChargement);
panneauChargement.setVisible(false);
mainPanel.add(panneauChargement);
taxaPanel.add(imageTable);
mainPanel.add(searchPanel);
mainPanel.add(panneauPagination);
mainPanel.add(taxaPanel);
initWidget(mainPanel);
}
/**
* Nettoie et remet à zéro les composants du panneau qui doivent l'être
* */
protected void nettoyer() {
panneauPagination.clear();
setNumImage(0);
imageTable.clear();
panneauxImages.clear();
}
protected void addImagePanel(Panel imagePanel) {
this.panneauxImages.add(imagePanel);
}
protected void afficherPanneauxImage(int first, int last) {
imageTable.clear();
int positionImage = 0;
for (int numImage = first; numImage < last; numImage++) {
try {
Panel panel = panneauxImages.get(numImage);
imageTable.setWidget((positionImage) / nbCol, (positionImage) % nbCol, panel);
} catch (Exception e) {
break;
}
positionImage++;
}
}
public void setNumImage(int numImage) {
this.numImage = numImage;
}
protected void startChargement() {
panneauChargement.setVisible(true);
}
protected void stopChargement() {
panneauChargement.setVisible(false);
}
public FlexTable getImageTable() {
return imageTable;
}
public int getNumImage() {
return numImage;
}
public Panel getPanneauChargement() {
return panneauChargement;
}
public HTML getLabelChercher() {
return labelChercher;
}
public Panel getPanneauPagination() {
return panneauPagination;
}
public int getNbImagesPerPage() {
return nbImagesPerPage;
}
public TextBox getTextBox() {
return textBox;
}
public Panel getPanel() {
return mainPanel;
}
}