608 |
aurelien |
1 |
package org.tela_botanica.del.client.composants.fenetreoverlay;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
|
|
4 |
|
|
|
5 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
6 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
7 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
8 |
import com.google.gwt.event.dom.client.HasKeyDownHandlers;
|
|
|
9 |
import com.google.gwt.event.dom.client.KeyCodes;
|
|
|
10 |
import com.google.gwt.event.dom.client.KeyDownEvent;
|
|
|
11 |
import com.google.gwt.event.dom.client.KeyDownHandler;
|
|
|
12 |
import com.google.gwt.user.client.ui.HasVisibility;
|
|
|
13 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
14 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
15 |
import com.google.gwt.user.client.ui.RootPanel;
|
|
|
16 |
|
|
|
17 |
public abstract class FenetreOverlayDefilantePresenteur {
|
|
|
18 |
|
|
|
19 |
public interface Vue extends IsWidget {
|
|
|
20 |
public HasKeyDownHandlers getConteneurGlobal();
|
|
|
21 |
public IsWidget getOverlay();
|
|
|
22 |
public void afficherBoutonsSuivantsPrecedents(boolean afficher);
|
|
|
23 |
public HasClickHandlers getOverlayHasClickHandlers();
|
|
|
24 |
public HasVisibility getOverlayVisibility();
|
|
|
25 |
public IsWidget getOverlayContenu();
|
|
|
26 |
public HasVisibility getOverlayContenuVisibility();
|
|
|
27 |
public HasWidgets getOverlayContenuHasWidgets();
|
|
|
28 |
public HasClickHandlers getBoutonFermer();
|
|
|
29 |
public HasClickHandlers getBoutonSuivant();
|
|
|
30 |
public HasClickHandlers getBoutonPrecedent();
|
|
|
31 |
public void setStyleOverlay(String style);
|
|
|
32 |
public void setStyleOverlayContenu(String style);
|
|
|
33 |
public void setOverlayContenu(IsWidget w);
|
|
|
34 |
public void viderOverlay();
|
|
|
35 |
public void viderOverlayContenu();
|
|
|
36 |
public void surOuvertureFenetre();
|
|
|
37 |
public void surFermetureFenetre();
|
|
|
38 |
public void surSetContenuFenetre();
|
1563 |
aurelien |
39 |
public boolean testerFermetureClicExterieur(ClickEvent event);
|
608 |
aurelien |
40 |
}
|
|
|
41 |
|
|
|
42 |
private Vue vue;
|
|
|
43 |
|
|
|
44 |
private boolean fenetreModaleOuverte = false;
|
|
|
45 |
private int indexElementAffiche = 0;
|
|
|
46 |
|
|
|
47 |
// Constructeur
|
|
|
48 |
public FenetreOverlayDefilantePresenteur(int indexElementAffiche, Vue vue) {
|
|
|
49 |
this.indexElementAffiche = indexElementAffiche;
|
|
|
50 |
this.vue = vue;
|
|
|
51 |
gererEvenements();
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
// Afficheur
|
|
|
55 |
public void go() {
|
|
|
56 |
go(null);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public void go(HasWidgets composite) {
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
// Gestion des évènements
|
|
|
64 |
protected void gererEvenements() {
|
|
|
65 |
|
|
|
66 |
vue.getBoutonFermer().addClickHandler(new ClickHandler() {
|
|
|
67 |
public void onClick(ClickEvent event) {
|
|
|
68 |
fermerFenetreModale();
|
|
|
69 |
}
|
|
|
70 |
});
|
|
|
71 |
|
|
|
72 |
vue.getBoutonPrecedent().addClickHandler(new ClickHandler() {
|
|
|
73 |
public void onClick(ClickEvent event) {
|
|
|
74 |
surClicBoutonPrecedent();
|
|
|
75 |
}
|
|
|
76 |
});
|
|
|
77 |
|
|
|
78 |
vue.getBoutonSuivant().addClickHandler(new ClickHandler() {
|
|
|
79 |
public void onClick(ClickEvent event) {
|
|
|
80 |
surClicBoutonSuivant();
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
|
|
|
84 |
vue.getConteneurGlobal().addKeyDownHandler(new KeyDownHandler() {
|
|
|
85 |
@Override
|
|
|
86 |
public void onKeyDown(KeyDownEvent event) {
|
|
|
87 |
if(event.getNativeKeyCode() == KeyCodes.KEY_LEFT) {
|
|
|
88 |
surClicBoutonPrecedent();
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
if(event.getNativeKeyCode() == KeyCodes.KEY_RIGHT) {
|
|
|
92 |
surClicBoutonSuivant();
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
});
|
|
|
96 |
|
|
|
97 |
vue.getOverlayHasClickHandlers().addClickHandler(new ClickHandler() {
|
|
|
98 |
@Override
|
|
|
99 |
public void onClick(ClickEvent event) {
|
1563 |
aurelien |
100 |
if(vue.testerFermetureClicExterieur(event)) {
|
608 |
aurelien |
101 |
fermerFenetreModale();
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
});
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
public void ouvrirFenetreModaleDefilante(int indexElementAffiche, Presenteur presenteurModal) {
|
|
|
108 |
|
|
|
109 |
vue.setStyleOverlay("overlay");
|
|
|
110 |
vue.setStyleOverlayContenu("overlayContenu");
|
|
|
111 |
vue.getOverlayContenuVisibility().setVisible(true);
|
|
|
112 |
vue.getOverlayVisibility().setVisible(true);
|
|
|
113 |
RootPanel.get().add(vue.asWidget());
|
|
|
114 |
fenetreModaleOuverte = true;
|
|
|
115 |
|
|
|
116 |
setContenuFenetreModale(indexElementAffiche, presenteurModal);
|
|
|
117 |
vue.surOuvertureFenetre();
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
public void setContenuFenetreModale(int indexElementAffiche, Presenteur presenteurModal) {
|
|
|
121 |
this.indexElementAffiche = indexElementAffiche;
|
|
|
122 |
vue.viderOverlayContenu();
|
|
|
123 |
presenteurModal.go(vue.getOverlayContenuHasWidgets());
|
|
|
124 |
vue.surSetContenuFenetre();
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public abstract void surClicBoutonSuivant();
|
|
|
128 |
public abstract void surClicBoutonPrecedent();
|
|
|
129 |
|
|
|
130 |
public boolean fenetreModaleEstOuverte() {
|
|
|
131 |
return fenetreModaleOuverte;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
public void fermerFenetreModale() {
|
|
|
135 |
vue.viderOverlay();
|
|
|
136 |
vue.viderOverlayContenu();
|
|
|
137 |
RootPanel.get().remove(vue.asWidget());
|
|
|
138 |
fenetreModaleOuverte = false;
|
|
|
139 |
vue.surFermetureFenetre();
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
public int getIndexElementAffiche() {
|
|
|
143 |
return indexElementAffiche;
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
public void afficherBoutonsSuivantsPrecedents(boolean afficher) {
|
|
|
147 |
vue.afficherBoutonsSuivantsPrecedents(afficher);
|
|
|
148 |
}
|
|
|
149 |
}
|