178 |
benjamin |
1 |
package org.tela_botanica.del.client.vues.rechercheimages.resultats;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.tela_botanica.del.client.modeles.Image;
|
|
|
7 |
|
|
|
8 |
import com.google.gwt.core.client.GWT;
|
|
|
9 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
10 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
11 |
import com.google.gwt.user.client.ui.Composite;
|
|
|
12 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
13 |
import com.google.gwt.user.client.ui.FlowPanel;
|
|
|
14 |
import com.google.gwt.user.client.ui.Panel;
|
|
|
15 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
16 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
17 |
|
|
|
18 |
public class ResultatRechercheImageVue extends Composite {
|
|
|
19 |
|
|
|
20 |
private final VerticalPanel mainPanel = new VerticalPanel();
|
|
|
21 |
private final Panel panneauChargement = new FlowPanel();
|
|
|
22 |
private final List<Panel> panneauxImages = new ArrayList<Panel>();
|
|
|
23 |
private int nbCol = 5;
|
|
|
24 |
private final int nbImagesPerPage = 10;
|
|
|
25 |
private int numImage = 0;
|
|
|
26 |
|
|
|
27 |
// Annotation can be used to change the name of the associated xml file
|
|
|
28 |
// @UiTemplate("ObservationRechercheVue.ui.xml")
|
|
|
29 |
interface MyUiBinder extends UiBinder<Widget, ResultatRechercheImageVue> {
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
|
|
|
33 |
|
|
|
34 |
@UiField
|
|
|
35 |
Panel panneauPagination;
|
|
|
36 |
|
|
|
37 |
@UiField
|
|
|
38 |
FlexTable imageTable;
|
|
|
39 |
|
|
|
40 |
// Constructeur
|
|
|
41 |
protected ResultatRechercheImageVue() {
|
|
|
42 |
|
|
|
43 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
44 |
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* Nettoie et remet à zéro les composants du panneau qui doivent l'être
|
|
|
49 |
* */
|
|
|
50 |
protected void nettoyer() {
|
|
|
51 |
panneauPagination.clear();
|
|
|
52 |
setNumImage(0);
|
|
|
53 |
imageTable.clear();
|
|
|
54 |
panneauxImages.clear();
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
protected void creerPanneauxObservation(List<Image> images) {
|
|
|
58 |
|
|
|
59 |
for (int i = 0; i < images.size(); i++) {
|
|
|
60 |
Panel imagePanel = new VerticalPanel();
|
|
|
61 |
panneauxImages.add(imagePanel);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
protected void afficherPanneauxImage(int first, int last) {
|
|
|
67 |
imageTable.clear();
|
|
|
68 |
|
|
|
69 |
int positionImage = 0;
|
|
|
70 |
for (int numImage = first; numImage < last; numImage++) {
|
|
|
71 |
try {
|
|
|
72 |
Panel panel = panneauxImages.get(numImage);
|
|
|
73 |
imageTable.setWidget((positionImage) / nbCol, (positionImage) % nbCol, panel);
|
|
|
74 |
} catch (Exception e) {
|
|
|
75 |
break;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
positionImage++;
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
public void setNumImage(int numImage) {
|
|
|
83 |
this.numImage = numImage;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
protected void startChargement() {
|
|
|
87 |
panneauChargement.setVisible(true);
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
protected void stopChargement() {
|
|
|
91 |
panneauChargement.setVisible(false);
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public FlexTable getImageTable() {
|
|
|
95 |
return imageTable;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
public int getNumImage() {
|
|
|
99 |
return numImage;
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
public Panel getPanneauChargement() {
|
|
|
103 |
return panneauChargement;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
public Panel getPanneauPagination() {
|
|
|
107 |
return panneauPagination;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
public int getNbImagesPerPage() {
|
|
|
111 |
return nbImagesPerPage;
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
public Panel getPanel() {
|
|
|
115 |
return mainPanel;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
public List<Panel> getPanneauxImages() {
|
|
|
119 |
return panneauxImages;
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
}
|