Subversion Repositories eFlore/Applications.del

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 benjamin 1
package org.tela_botanica.del.client.vues.rechercheobservations;
9 benjamin 2
 
3
import java.util.ArrayList;
4
import java.util.List;
5
 
32 gduche 6
import org.tela_botanica.del.client.modeles.Observation;
7
 
9 benjamin 8
import com.google.gwt.user.client.ui.Composite;
9
import com.google.gwt.user.client.ui.FlexTable;
10
import com.google.gwt.user.client.ui.FlowPanel;
11
import com.google.gwt.user.client.ui.HTML;
12
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
13
import com.google.gwt.user.client.ui.HorizontalPanel;
14
import com.google.gwt.user.client.ui.Panel;
15
import com.google.gwt.user.client.ui.TextBox;
16
import com.google.gwt.user.client.ui.VerticalPanel;
17
 
14 benjamin 18
public class ObservationRechercheVue extends Composite {
9 benjamin 19
 
20
	private final VerticalPanel mainPanel = new VerticalPanel();
26 gduche 21
	private final Panel panneauChargement = new FlowPanel();
9 benjamin 22
	private final Panel taxaPanel = new FlowPanel();
23
	private final FlexTable imageTable = new FlexTable();
26 gduche 24
	private final Panel panneauPagination = new HorizontalPanel();
25
	private final List<Panel> panneauxImages = new ArrayList<Panel>();
26
	private final HTML labelChargement = new HTML("<img src='img/wait.gif' />Contact du serveur du CEL...");
27
	private final HTML labelChercher = new HTML("<img src='img/search_icon.gif' />Search &nbsp;&nbsp;      taxon:");
9 benjamin 28
	private int nbCol = 5;
29
	private final int nbImagesPerPage = 10;
30
	private int numImage = 0;
31
	private final TextBox textBox = new TextBox();
32
 
26 gduche 33
	// Constructeur
14 benjamin 34
	protected ObservationRechercheVue() {
9 benjamin 35
 
36
		textBox.setText("apifera");
37
		textBox.setFocus(true);
38
 
39
		mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
40
		mainPanel.setSize("100%", "100%");
41
 
42
		Panel textBoxPanel = new HorizontalPanel();
26 gduche 43
		textBoxPanel.add(labelChercher);
9 benjamin 44
		textBoxPanel.add(textBox);
45
 
46
		Panel searchPanel = new VerticalPanel();
47
		searchPanel.add(new HTML("Rechercher une image"));
48
		searchPanel.add(textBoxPanel);
26 gduche 49
		searchPanel.add(new HTML("Entrez un nom de genre ou d'esp&egrave;ce, un nom de commune, un num&eacute;ro de departement, l'email d'un utilisateur ou un mot-clef"));
9 benjamin 50
 
26 gduche 51
		panneauChargement.add(labelChargement);
52
		panneauChargement.setVisible(false);
53
 
54
		mainPanel.add(panneauChargement);
55
 
9 benjamin 56
		taxaPanel.add(imageTable);
57
 
58
		mainPanel.add(searchPanel);
26 gduche 59
		mainPanel.add(panneauPagination);
9 benjamin 60
		mainPanel.add(taxaPanel);
61
 
62
		initWidget(mainPanel);
63
	}
64
 
26 gduche 65
	/**
66
	 * Nettoie et remet à zéro les composants du panneau qui doivent l'être
67
	 * */
68
	protected void nettoyer() {
69
		panneauPagination.clear();
70
		setNumImage(0);
71
		imageTable.clear();
72
		panneauxImages.clear();
73
	}
74
 
86 benjamin 75
	protected void creerPanneauxObservation(List<Observation> observations) {
32 gduche 76
 
77
		for (int i = 0; i < observations.size(); i++) {
78
			Panel imagePanel = new VerticalPanel();
79
			panneauxImages.add(imagePanel);
80
		}
81
 
9 benjamin 82
	}
83
 
26 gduche 84
	protected void afficherPanneauxImage(int first, int last) {
9 benjamin 85
		imageTable.clear();
86
 
87
		int positionImage = 0;
88
		for (int numImage = first; numImage < last; numImage++) {
89
			try {
26 gduche 90
				Panel panel = panneauxImages.get(numImage);
91
				imageTable.setWidget((positionImage) / nbCol, (positionImage) % nbCol, panel);
9 benjamin 92
			} catch (Exception e) {
93
				break;
94
			}
95
 
96
			positionImage++;
97
		}
98
	}
99
 
26 gduche 100
	public void setNumImage(int numImage) {
101
		this.numImage = numImage;
102
	}
103
 
104
	protected void startChargement() {
105
		panneauChargement.setVisible(true);
106
	}
107
 
108
	protected void stopChargement() {
28 benjamin 109
		panneauChargement.setVisible(false);
26 gduche 110
	}
111
 
9 benjamin 112
	public FlexTable getImageTable() {
113
		return imageTable;
114
	}
115
 
116
	public int getNumImage() {
117
		return numImage;
118
	}
119
 
26 gduche 120
	public Panel getPanneauChargement() {
121
		return panneauChargement;
9 benjamin 122
	}
123
 
26 gduche 124
	public HTML getLabelChercher() {
125
		return labelChercher;
9 benjamin 126
	}
127
 
26 gduche 128
	public Panel getPanneauPagination() {
129
		return panneauPagination;
9 benjamin 130
	}
131
 
132
	public int getNbImagesPerPage() {
133
		return nbImagesPerPage;
134
	}
135
 
26 gduche 136
	public TextBox getTextBox() {
137
		return textBox;
9 benjamin 138
	}
139
 
26 gduche 140
	public Panel getPanel() {
141
		return mainPanel;
9 benjamin 142
	}
143
 
86 benjamin 144
	public List<Panel> getPanneauxImages() {
145
		return panneauxImages;
146
	}
147
 
9 benjamin 148
}