Line 1... |
Line 1... |
1 |
package org.tela_botanica.del.client.vues.rechercheimages;
|
1 |
package org.tela_botanica.del.client.vues.rechercheimages;
|
Line 2... |
Line 2... |
2 |
|
2 |
|
Line 3... |
Line 3... |
3 |
import java.util.List;
|
3 |
import java.util.List;
|
4 |
|
- |
|
5 |
import org.tela_botanica.del.client.cache.CacheClient;
|
4 |
|
6 |
import org.tela_botanica.del.client.modeles.Image;
|
5 |
import org.tela_botanica.del.client.cache.CacheClient;
|
- |
|
6 |
import org.tela_botanica.del.client.modeles.Protocole;
|
7 |
import org.tela_botanica.del.client.modeles.Protocole;
|
7 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
8 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
8 |
import org.tela_botanica.del.client.navigation.evenement.ajoutdetermination.EvenementAjoutDetermination;
|
9 |
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.EvenementChangementProtocole;
|
- |
|
10 |
import org.tela_botanica.del.client.navigation.evenement.rechercheimage.EvenementRechercheImage;
|
9 |
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.EvenementChangementProtocole;
|
11 |
import org.tela_botanica.del.client.services.rest.ImageService;
|
10 |
import org.tela_botanica.del.client.navigation.evenement.rechercheimage.EvenementRechercheImage;
|
Line 12... |
Line 11... |
12 |
import org.tela_botanica.del.client.services.rest.ProtocoleService;
|
11 |
import org.tela_botanica.del.client.services.rest.ProtocoleService;
|
13 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
12 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
Line 23... |
Line 22... |
23 |
import com.google.gwt.event.dom.client.KeyPressEvent;
|
22 |
import com.google.gwt.event.dom.client.KeyPressEvent;
|
24 |
import com.google.gwt.event.dom.client.KeyPressHandler;
|
23 |
import com.google.gwt.event.dom.client.KeyPressHandler;
|
25 |
import com.google.gwt.user.client.ui.HasWidgets;
|
24 |
import com.google.gwt.user.client.ui.HasWidgets;
|
26 |
import com.google.gwt.user.client.ui.IsWidget;
|
25 |
import com.google.gwt.user.client.ui.IsWidget;
|
Line 27... |
Line 26... |
27 |
|
26 |
|
Line 28... |
Line 27... |
28 |
public class RechercheImagePresenteur {
|
27 |
public class MoteurRechercheImage {
|
Line 29... |
Line 28... |
29 |
|
28 |
|
30 |
public interface Vue extends IsWidget {
|
29 |
public interface Vue extends IsWidget {
|
31 |
|
30 |
|
32 |
public abstract void ajouterProtocole(String protocole);
|
31 |
public abstract void ajouterProtocole(String protocole);
|
33 |
public abstract void selectionnerProtocole(int index);
|
32 |
public abstract void selectionnerProtocole(int index);
|
34 |
public abstract HasClickHandlers getBoutonChercher();
|
33 |
public abstract HasClickHandlers getBoutonChercher();
|
- |
|
34 |
public abstract HasKeyPressHandlers getChampEspece();
|
35 |
public abstract HasKeyPressHandlers getChampEspece();
|
35 |
public abstract HasChangeHandlers getListeProtocoles();
|
Line 36... |
Line 36... |
36 |
public abstract HasChangeHandlers getListeProtocoles();
|
36 |
public abstract HasWidgets getZoneResultats();
|
Line 37... |
Line 37... |
37 |
public abstract HasWidgets getZoneResultats();
|
37 |
public abstract String getValeurEspece();
|
38 |
}
|
38 |
}
|
39 |
|
- |
|
40 |
private Vue vue;
|
39 |
|
41 |
|
40 |
private Vue vue;
|
- |
|
41 |
|
- |
|
42 |
// private final ImageService imageService = MockDatasource.getInstance();
|
- |
|
43 |
private final ProtocoleService protocoleService = MockDatasource.getInstance();
|
42 |
private final ImageService imageService = MockDatasource.getInstance();
|
44 |
private List<Protocole> protocoles;
|
43 |
private final ProtocoleService protocoleService = MockDatasource.getInstance();
|
45 |
|
44 |
private String protocoleParDefaut = Protocole.IDENTIFICATION_AUTOMATIQUE;
|
46 |
//TODO : passer ça en cache
|
45 |
private List<Protocole> protocoles;
|
47 |
private String protocoleParDefaut = Protocole.IDENTIFICATION_AUTOMATIQUE;
|
46 |
|
48 |
|
Line 47... |
Line 49... |
47 |
/**
|
49 |
/**
|
48 |
* Constructeur
|
50 |
* Constructeur
|
49 |
* */
|
51 |
* */
|
Line 73... |
Line 75... |
73 |
|
75 |
|
Line 74... |
Line 76... |
74 |
vue.getBoutonChercher().addClickHandler(new ClickHandler() {
|
76 |
vue.getBoutonChercher().addClickHandler(new ClickHandler() {
|
75 |
|
77 |
|
76 |
@Override
|
78 |
@Override
|
77 |
public void onClick(ClickEvent event) {
|
79 |
public void onClick(ClickEvent event) {
|
78 |
chargerImages(0, CacheClient.getInstance().getPaginationPasRechercheImage());
|
80 |
lancerRechercheImage();
|
Line 79... |
Line 81... |
79 |
}
|
81 |
}
|
Line 80... |
Line 82... |
80 |
});
|
82 |
});
|
81 |
|
83 |
|
82 |
vue.getChampEspece().addKeyPressHandler(new KeyPressHandler() {
|
84 |
vue.getChampEspece().addKeyPressHandler(new KeyPressHandler() {
|
83 |
|
85 |
|
84 |
public void onKeyPress(KeyPressEvent event) {
|
86 |
public void onKeyPress(KeyPressEvent event) {
|
85 |
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
|
87 |
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
|
Line 86... |
Line 88... |
86 |
chargerImages(0, CacheClient.getInstance().getPaginationPasRechercheImage());
|
88 |
lancerRechercheImage();
|
Line 97... |
Line 99... |
97 |
EvenementChangementProtocole evenement = new EvenementChangementProtocole(protocoleCourant);
|
99 |
EvenementChangementProtocole evenement = new EvenementChangementProtocole(protocoleCourant);
|
98 |
BusEvenementiel.getInstance().fireEvent(evenement);
|
100 |
BusEvenementiel.getInstance().fireEvent(evenement);
|
99 |
}
|
101 |
}
|
100 |
});
|
102 |
});
|
101 |
}
|
103 |
}
|
102 |
|
104 |
|
103 |
private void chargerImages(int debut, int fin) {
|
105 |
public void lancerRechercheImage() {
|
104 |
List<Image> imagesFromDatabase = imageService.getImages(debut, fin);
|
106 |
CacheClient.getInstance().setEspeceRecherche(vue.getValeurEspece());
|
105 |
EvenementRechercheImage evenementRechercheImage = new EvenementRechercheImage(imagesFromDatabase);
|
- |
|
106 |
BusEvenementiel.getInstance().fireEvent(evenementRechercheImage);
|
107 |
BusEvenementiel.getInstance().fireEvent(new EvenementRechercheImage());
|
107 |
}
|
108 |
}
|
Line 108... |
Line 109... |
108 |
|
109 |
|
109 |
public HasWidgets getZoneResultats() {
|
110 |
public HasWidgets getZoneResultats() {
|
110 |
return vue.getZoneResultats();
|
111 |
return vue.getZoneResultats();
|