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