Subversion Repositories eFlore/Applications.del

Rev

Rev 14 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 26
Line 15... Line 15...
15
import com.google.gwt.user.client.ui.Panel;
15
import com.google.gwt.user.client.ui.Panel;
16
import com.google.gwt.user.client.ui.VerticalPanel;
16
import com.google.gwt.user.client.ui.VerticalPanel;
Line 17... Line 17...
17
 
17
 
Line 18... Line 18...
18
public class ObservationRecherchePresenteur {
18
public class ObservationRecherchePresenteur {
19
 
-
 
20
	private final MockDatasource observationService = MockDatasource
-
 
21
			.getInstance();
19
 
22
 
-
 
23
	private final ObservationRechercheVue view = new ObservationRechercheVue();
20
	private final MockDatasource observationService = MockDatasource.getInstance();
24
 
-
 
25
	private static ObservationRecherchePresenteur instance;
21
	private final ObservationRechercheVue vue = new ObservationRechercheVue();
Line 26... Line 22...
26
 
22
	private static ObservationRecherchePresenteur instance;
27
	private List<Observation> observations;
23
	private List<Observation> observations;
28
 
24
 
Line 29... Line 25...
29
	public ObservationRecherchePresenteur() {
25
	public ObservationRecherchePresenteur() {
30
		instance = this;
26
		instance = this;
31
	}
27
	}
32
 
28
 
Line 33... Line 29...
33
	public void go(HasWidgets composite) {
29
	public void go(HasWidgets composite) {
34
		composite.add(view);
30
		composite.add(vue);
-
 
31
		gererEvenements();
35
		handleEvents();
32
	}
Line 36... Line 33...
36
	}
33
 
37
 
34
	@SuppressWarnings("deprecation")
-
 
35
	public void gererEvenements() {
38
	@SuppressWarnings("deprecation")
36
 
39
	public void handleEvents() {
37
		vue.getLabelChercher().addClickHandler(new ClickHandler() {
40
		view.getSearchHtml().addClickHandler(new ClickHandler() {
38
 
Line -... Line 39...
-
 
39
			@Override
41
 
40
			public void onClick(ClickEvent event) {
Line 42... Line 41...
42
			@Override
41
				vue.startChargement();
43
			public void onClick(ClickEvent event) {
42
				chargerObservations();
44
				loadObservations();
43
			}
45
			}
44
		});
46
		});
45
 
Line 47... Line 46...
47
 
46
		// TODO : remplacer par KeyUp, KeyDown ... etc.
Line 48... Line 47...
48
		view.getTextBox().addKeyboardListener(new KeyboardKeyListener() {
47
		vue.getTextBox().addKeyboardListener(new KeyboardKeyListener() {
49
 
-
 
50
			@Override
-
 
51
			public void onEnterKeyUp() {
-
 
52
				loadObservations();
-
 
53
			}
-
 
54
		});
-
 
55
 
-
 
Line 56... Line 48...
56
	}
48
 
Line -... Line 49...
-
 
49
			@Override
57
 
50
			public void onEnterKeyUp() {
Line -... Line 51...
-
 
51
				chargerObservations();
-
 
52
			}
-
 
53
		});
-
 
54
 
58
	private void loadObservations() {
55
	}
59
 
56
 
60
		view.getPaginationPanel().clear();
57
	private void chargerObservations() {
61
		view.setNumImage(0);
58
 
62
		view.getImageTable().clear();
59
		observations = observationService.getObservations();
63
		view.getLoadPanel().add(view.getContactingServerHTML());
60
 
Line 64... Line 61...
64
 
61
		// Remise à zéro du panneau d'affichage et des composants
-
 
62
		vue.nettoyer();
65
		// String taxaName = URL.encode(view.getTextBox().getText());
63
 
66
 
64
		// TODO : créer une méthode globale pour l'application ? voir
67
		observations = observationService.getObservations();
65
		// superclasse présenteur ?
68
 
66
 
69
		view.getImagePanels().clear();
67
		// TODO : déplacer dans la vue
Line 70... Line 68...
70
 
68
		List<Panel> imagePanels = new ArrayList<Panel>();
Line 71... Line 69...
71
		List<Panel> imagePanels = new ArrayList<Panel>();
69
		for (int i = 0; i < observations.size(); i++) {
Line 72... Line 70...
72
		for (int i = 0; i < observations.size(); i++) {
70
			Panel imagePanel = new VerticalPanel();
Line 73... Line 71...
73
			Panel imagePanel = new VerticalPanel();
71
			imagePanels.add(imagePanel);
Line 74... Line 72...
74
			imagePanels.add(imagePanel);
72
			vue.addImagePanel(imagePanel);
75
			view.addImagePanel(imagePanel);
73
		}
76
		}
74
 
77
 
75
		vue.afficherPanneauxImage(0, vue.getNbImagesPerPage());
78
		view.showImagePanels(0, view.getNbImagesPerPage());
76
 
79
		Iterator<Panel> panelIterator = imagePanels.iterator();
77
		Iterator<Panel> panelIterator = imagePanels.iterator();
80
		for (Observation observation : observations) {
78
		for (Observation observation : observations) {
81
			Panel imagePanel = panelIterator.next();
79
			Panel imagePanel = panelIterator.next();
Line 82... Line 80...
82
			new ObservationPresenteur(observation).go(imagePanel);
80
			new ObservationPresenteur(observation).go(imagePanel);
83
		}
81
		}
84
 
82
 
Line 85... Line 83...
85
		createPaginationWidget(observations.size());
83
		createPaginationWidget(observations.size());
86
 
84
 
87
		view.getLoadPanel().clear();
85
		vue.stopChargement();
Line 88... Line 86...
88
 
86
 
89
	}
87
	}
90
 
88
 
Line 91... Line 89...
91
	private void createPaginationWidget(int nbImages) {
89
	private void createPaginationWidget(int nbImages) {
92
 
90
 
93
		int nbPages = nbImages / view.getNbImagesPerPage();
91
		int nbPages = nbImages / vue.getNbImagesPerPage();