Subversion Repositories eFlore/Applications.del

Rev

Rev 478 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 478 Rev 590
Line 23... Line 23...
23
 
23
 
Line 24... Line 24...
24
public class MoteurRechercheImagePresenteur {
24
public class MoteurRechercheImagePresenteur {
Line 25... Line -...
25
 
-
 
26
	public interface Vue extends IsWidget {
-
 
27
 
-
 
28
		public void ajouterProtocole(String protocole);
-
 
29
 
-
 
30
		public void selectionnerProtocole(int index);
-
 
31
 
25
 
Line 32... Line 26...
32
		public HasChangeHandlers getListeProtocoles();
26
	public interface Vue extends IsWidget {
Line 33... Line -...
33
 
-
 
34
		public HasWidgets getZoneResultats();
-
 
35
 
-
 
36
		public HasWidgets getZoneRecherche();
-
 
37
 
27
 
Line 38... Line 28...
38
		public String getNomProtocolSelectionne();
28
		public HasWidgets getZoneResultats();
Line 39... Line 29...
39
 
29
 
Line 40... Line 30...
40
		public int getIdProtocoleSelectionne();
30
		public HasWidgets getZoneRecherche();
41
 
-
 
Line 42... Line -...
42
		public void ajouterVue(HasWidgets composite);
-
 
43
 
31
 
-
 
32
		public void ajouterVue(HasWidgets composite);
44
	}
33
 
45
 
34
	}
46
	private Vue vue;
35
 
47
 
36
	private Vue vue;
48
	private final ProtocoleService protocoleService = MockDatasource.getInstance();
37
 
49
	private List<Protocole> protocoles;
38
	private final ProtocoleService protocoleService = MockDatasource.getInstance();
50
 
39
 
51
	// TODO : passer ça en cache
40
	private String protocoleParDefaut = Protocole.ESTHETISME;
52
	private String protocoleParDefaut = Protocole.ESTHETISME;
41
	
53
 
-
 
54
	/**
-
 
55
	 * Constructeur
42
	
Line 56... Line 43...
56
	 * */
43
	/**
57
	public MoteurRechercheImagePresenteur(Vue vue) {
44
	 * Constructeur
58
		this.vue = vue;
45
	 * */
59
		if (CacheClient.getInstance().getProtocoleCourant() == null) {
46
	public MoteurRechercheImagePresenteur(Vue vue) {
60
			CacheClient.getInstance().setProtocoleCourant(protocoleService.getProtocole(protocoleParDefaut));
47
		this.vue = vue;
61
		}
-
 
62
		gererEvenements();
-
 
63
		chargerProtocoles();
-
 
64
	}
-
 
65
 
-
 
66
	public void go(HasWidgets composite) {
-
 
67
		vue.ajouterVue(composite);
-
 
68
		chargerMoteurRechercheAvancee();
-
 
69
	}
-
 
70
 
-
 
71
	private void chargerProtocoles() {
-
 
72
		protocoles = protocoleService.getProtocoles();
-
 
73
		for (Protocole protocole : protocoles) {
-
 
74
			vue.ajouterProtocole(protocole.getNom());
-
 
75
		}
-
 
76
		vue.selectionnerProtocole(protocoles.indexOf(CacheClient.getInstance().getProtocoleCourant()));
-
 
77
	}
-
 
78
 
-
 
79
	public void gererEvenements() {
-
 
80
 
-
 
81
		vue.getListeProtocoles().addChangeHandler(new ChangeHandler() {
-
 
82
 
-
 
83
			@Override
-
 
84
			public void onChange(ChangeEvent event) {
-
 
85
				surChangementProtocole();
-
 
86
			}
-
 
87
		});
-
 
88
 
-
 
89
	}
-
 
90
 
-
 
91
	public void surChangementProtocole() {
-
 
92
		Protocole protocoleCourant = null;
-
 
Line 93... Line 48...
93
		for (Protocole protocole : protocoles) {
48
		if (CacheClient.getInstance().getProtocoleCourant() == null) {
94
			if (protocole.getId() == vue.getIdProtocoleSelectionne()) {
49
			CacheClient.getInstance().setProtocoleCourant(protocoleService.getProtocole(protocoleParDefaut));
95
				protocoleCourant = protocole;
50
		}
96
			}
51
	}