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