| 4 |
aperonnet |
1 |
package org.tela_botanica.client.image;
|
|
|
2 |
|
| 5 |
aperonnet |
3 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 4 |
aperonnet |
4 |
import org.tela_botanica.client.vues.GalerieImageVue;
|
|
|
5 |
import org.tela_botanica.client.vues.ListeImageVue;
|
|
|
6 |
import org.tela_botanica.client.vues.ZoomImageVue;
|
|
|
7 |
|
| 5 |
aperonnet |
8 |
import com.google.gwt.user.client.DOM;
|
|
|
9 |
import com.google.gwt.user.client.Element;
|
|
|
10 |
import com.google.gwt.user.client.Event;
|
|
|
11 |
import com.google.gwt.user.client.Window;
|
|
|
12 |
import com.gwtext.client.core.EventObject;
|
| 4 |
aperonnet |
13 |
import com.gwtext.client.core.RegionPosition;
|
| 5 |
aperonnet |
14 |
import com.gwtext.client.data.Record;
|
|
|
15 |
import com.gwtext.client.data.Store;
|
|
|
16 |
import com.gwtext.client.widgets.DataView;
|
| 4 |
aperonnet |
17 |
import com.gwtext.client.widgets.Panel;
|
|
|
18 |
import com.gwtext.client.widgets.TabPanel;
|
|
|
19 |
import com.gwtext.client.widgets.layout.BorderLayout;
|
|
|
20 |
import com.gwtext.client.widgets.layout.BorderLayoutData;
|
|
|
21 |
|
|
|
22 |
public class ImageMediateur {
|
|
|
23 |
|
|
|
24 |
// controleur
|
|
|
25 |
private ImageControleur iControleur = null ;
|
|
|
26 |
|
|
|
27 |
//widgets
|
|
|
28 |
|
|
|
29 |
//Panneau principal des images (onglet "images")
|
|
|
30 |
private final Panel panneauPrincipalImage = new Panel("Images");
|
|
|
31 |
|
|
|
32 |
// Panneau à onglet pour la liste, la galerie et la vue en grand
|
|
|
33 |
private TabPanel ongletsImage = null ;
|
|
|
34 |
|
|
|
35 |
private GalerieImageVue galerieImage = null ;
|
|
|
36 |
private ListeImageVue listeImage = null ;
|
|
|
37 |
private ZoomImageVue zoomImage = null ;
|
|
|
38 |
|
|
|
39 |
// panneau details et mots clés
|
|
|
40 |
private final Panel detailsEtMotsCles = new Panel("Détails et mots clés");
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
public ImageMediateur()
|
|
|
44 |
{
|
|
|
45 |
|
|
|
46 |
final BorderLayoutData regionEst = new BorderLayoutData(
|
|
|
47 |
RegionPosition.EAST);
|
|
|
48 |
regionEst.setSplit(true);
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
iControleur = new ImageControleur(this);
|
|
|
52 |
|
|
|
53 |
panneauPrincipalImage.setLayout(new BorderLayout());
|
|
|
54 |
|
|
|
55 |
ongletsImage = new TabPanel();
|
|
|
56 |
galerieImage = new GalerieImageVue(this) ;
|
|
|
57 |
|
|
|
58 |
Panel panneauListeImage = new Panel("Liste");
|
|
|
59 |
listeImage = new ListeImageVue(this);
|
|
|
60 |
panneauListeImage.add(listeImage);
|
|
|
61 |
|
|
|
62 |
zoomImage = new ZoomImageVue(this);
|
|
|
63 |
|
|
|
64 |
ongletsImage.add(galerieImage);
|
|
|
65 |
ongletsImage.add(zoomImage);
|
|
|
66 |
ongletsImage.add(panneauListeImage);
|
|
|
67 |
|
|
|
68 |
detailsEtMotsCles.setWidth("20%");
|
|
|
69 |
detailsEtMotsCles.setAnimCollapse(true);
|
|
|
70 |
detailsEtMotsCles.setTitleCollapse(true);
|
|
|
71 |
detailsEtMotsCles.setCollapsible(true);
|
|
|
72 |
|
|
|
73 |
panneauPrincipalImage.add(ongletsImage,new BorderLayoutData(RegionPosition.CENTER));
|
|
|
74 |
panneauPrincipalImage.add(detailsEtMotsCles,regionEst);
|
|
|
75 |
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
public ImageControleur getIControleur() {
|
|
|
81 |
return iControleur;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public Panel getPanneauPrincipalImage() {
|
|
|
85 |
return panneauPrincipalImage;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
public TabPanel getOngletsImage() {
|
|
|
89 |
return ongletsImage;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
public GalerieImageVue getGalerieImage() {
|
|
|
93 |
return galerieImage;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
public ListeImageVue getListeImage() {
|
|
|
97 |
return listeImage;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public ZoomImageVue getZoomImage() {
|
|
|
101 |
return zoomImage;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
public Panel getDetailsEtMotsCles() {
|
|
|
105 |
return detailsEtMotsCles;
|
|
|
106 |
}
|
|
|
107 |
|
| 5 |
aperonnet |
108 |
public void synchroniserZoomListeGalerie(Object o, Rafraichissable r)
|
|
|
109 |
{
|
|
|
110 |
if(r != getGalerieImage())
|
|
|
111 |
{
|
|
|
112 |
getGalerieImage().rafraichir(o);
|
|
|
113 |
}
|
|
|
114 |
if(r != getZoomImage())
|
|
|
115 |
{
|
|
|
116 |
getZoomImage().rafraichir(o);
|
|
|
117 |
}
|
|
|
118 |
if(r != getListeImage())
|
|
|
119 |
{
|
|
|
120 |
getListeImage().rafraichir(o);
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
public void ObtenirPhotoGalerie(Rafraichissable r)
|
|
|
126 |
{
|
|
|
127 |
getIControleur().obtenirPhotoGalerie(r) ;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
public void ClicGalerieImage(int index, Element node,
|
|
|
131 |
EventObject e)
|
|
|
132 |
{
|
|
|
133 |
Record rd = getGalerieImage().getDView().getRecord(node) ;
|
|
|
134 |
String imgUrl = rd.getAsString("url_image");
|
|
|
135 |
|
|
|
136 |
getZoomImage().rafraichir(imgUrl);
|
|
|
137 |
|
|
|
138 |
if(DOM.eventGetType(e.getBrowserEvent()) == Event.ONDBLCLICK)
|
|
|
139 |
{
|
|
|
140 |
getOngletsImage().setActiveTab(1);
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
public void DoubleClicZoomImage()
|
|
|
145 |
{
|
|
|
146 |
getOngletsImage().setActiveTab(0);
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
public void ClicBoutonZoomImage(String arg)
|
|
|
150 |
{
|
|
|
151 |
|
|
|
152 |
DataView dv = getGalerieImage().getDView();
|
|
|
153 |
Store st = getGalerieImage().getSt();
|
|
|
154 |
Record nRec = null ;
|
|
|
155 |
|
|
|
156 |
final int selected = st.indexOf(dv.getSelectedRecords()[0]);
|
|
|
157 |
int storeIndex = dv.indexOf(selected);
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
if(arg.equals("prev"))
|
|
|
161 |
{
|
|
|
162 |
// si la photo séléctionnée est la première, on passe à la
|
|
|
163 |
// dernière
|
|
|
164 |
if (selected == 0) {
|
|
|
165 |
storeIndex = st.getCount() - 1 ;
|
|
|
166 |
nRec = st.getAt(storeIndex);
|
|
|
167 |
|
|
|
168 |
}
|
|
|
169 |
else
|
|
|
170 |
{
|
|
|
171 |
storeIndex = storeIndex - 1 ;
|
|
|
172 |
nRec = st.getAt(storeIndex);
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
if(arg.equals("suiv"))
|
|
|
179 |
{
|
|
|
180 |
// si la photo selectionnée est la dernière on passe à la
|
|
|
181 |
// première
|
|
|
182 |
if (selected == st.getCount() - 1) {
|
|
|
183 |
|
|
|
184 |
storeIndex = 0 ;
|
|
|
185 |
nRec = st.getAt(0);
|
|
|
186 |
}
|
|
|
187 |
else
|
|
|
188 |
{
|
|
|
189 |
storeIndex = storeIndex + 1 ;
|
|
|
190 |
nRec = st.getAt(storeIndex);
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
if(nRec != null)
|
|
|
195 |
{
|
|
|
196 |
getZoomImage().rafraichir(nRec.getAsString("url_image"));
|
|
|
197 |
dv.select(storeIndex);
|
|
|
198 |
}
|
|
|
199 |
}
|
|
|
200 |
|
| 4 |
aperonnet |
201 |
|
|
|
202 |
}
|