Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 22 | Rev 31 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22 Rev 27
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line -...
2
 
-
 
3
 
-
 
4
import java.util.Iterator;
-
 
5
 
2
 
6
import org.tela_botanica.client.image.ImageMediateur;
3
import org.tela_botanica.client.image.ImageMediateur;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.interfaces.VueListable;
-
 
9
import org.tela_botanica.client.modeles.ImageCarnet;
-
 
10
import org.tela_botanica.client.modeles.ListeImageCarnet;
-
 
11
 
-
 
12
 
-
 
13
import com.google.gwt.core.client.JavaScriptObject;
5
import org.tela_botanica.client.interfaces.VueListable;
14
import com.google.gwt.user.client.Element;
-
 
15
import com.google.gwt.user.client.Event;
-
 
16
import com.google.gwt.user.client.Window;
6
import com.google.gwt.user.client.Element;
17
import com.gwtext.client.core.EventObject;
7
import com.gwtext.client.core.EventObject;
18
import com.gwtext.client.core.XTemplate;
-
 
19
import com.gwtext.client.data.ArrayReader;
8
import com.gwtext.client.core.XTemplate;
20
import com.gwtext.client.data.FieldDef;
9
import com.gwtext.client.data.FieldDef;
21
import com.gwtext.client.data.IntegerFieldDef;
-
 
22
import com.gwtext.client.data.MemoryProxy;
10
import com.gwtext.client.data.IntegerFieldDef;
23
import com.gwtext.client.data.Record;
11
import com.gwtext.client.data.Record;
24
import com.gwtext.client.data.RecordDef;
12
import com.gwtext.client.data.RecordDef;
25
import com.gwtext.client.data.Store;
13
import com.gwtext.client.data.Store;
26
import com.gwtext.client.data.StringFieldDef;
14
import com.gwtext.client.data.StringFieldDef;
27
import com.gwtext.client.util.Format;
-
 
28
import com.gwtext.client.widgets.BoxComponent;
15
import com.gwtext.client.util.Format;
29
import com.gwtext.client.widgets.Component;
-
 
30
import com.gwtext.client.widgets.Container;
16
import com.gwtext.client.widgets.Component;
31
import com.gwtext.client.widgets.DataView;
-
 
32
import com.gwtext.client.widgets.Observable;
17
import com.gwtext.client.widgets.DataView;
33
import com.gwtext.client.widgets.Panel;
-
 
34
import com.gwtext.client.widgets.DataView.Data;
-
 
35
import com.gwtext.client.widgets.event.ContainerListener;
18
import com.gwtext.client.widgets.Panel;
36
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
-
 
37
import com.gwtext.client.widgets.event.DataViewListener;
19
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
Line 38... Line 20...
38
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
20
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
39
 
21
 
40
/**
-
 
41
 * Galerie d'images miniatures
22
/**
-
 
23
 * Galerie d'images miniatures
42
 * @author aurelien
24
 * 
43
 *
25
 * @author aurelien
-
 
26
 */
Line 44... Line 27...
44
 */
27
public class GalerieImageVue extends Panel implements Rafraichissable,
45
public class GalerieImageVue extends Panel implements Rafraichissable, VueListable {
28
		VueListable {
46
 
29
 
47
	// instance du médiateur
30
	// instance du médiateur
Line 48... Line 31...
48
	private ImageMediateur iMediateur = null; 
31
	private ImageMediateur	iMediateur	= null;
49
	private DataView dView = null ;
-
 
50
	private Store st = null ;
32
	private DataView		dView		= null;
51
	
33
	private Store			st			= null;
Line 52... Line 34...
52
	public GalerieImageVue(ImageMediateur im)
34
 
Line 53... Line -...
53
	{
-
 
54
		super("Galerie");
35
	public GalerieImageVue(ImageMediateur im) {
55
		iMediateur = im ;
36
		super("Galerie");
Line 56... Line 37...
56
		
37
		iMediateur = im;
Line 57... Line -...
57
		this.addListener(new ContainerListenerAdapter() {
-
 
58
 
38
 
59
 
39
		this.addListener(new ContainerListenerAdapter() {
Line 60... Line 40...
60
			public void onHide(Component component) {
40
 
Line 61... Line -...
61
				// TODO Auto-generated method stub
-
 
62
				
41
			public void onHide(Component component) {
Line 63... Line -...
63
			}
-
 
64
 
42
				// TODO Auto-generated method stub
65
 
-
 
66
			public void onRender(Component component) {
43
 
67
				// TODO Auto-generated method stub
44
			}
68
				
45
 
Line 69... Line 46...
69
			}
46
			public void onRender(Component component) {
Line 70... Line 47...
70
 
47
				// TODO Auto-generated method stub
Line 71... Line -...
71
 
-
 
72
			public void onShow(Component component) {
48
 
73
				
-
 
Line 74... Line 49...
74
				
49
			}
75
				if(dView == null)
50
 
76
				{
51
			public void onShow(Component component) {
Line 77... Line -...
77
					initialiser();
-
 
78
				}
-
 
79
			}
52
 
80
			
53
				if (dView == null) {
Line 81... Line 54...
81
		});
54
					initialiser();
Line 82... Line 55...
82
		
55
				}
Line 83... Line -...
83
	}
-
 
84
	
56
			}
85
	
57
 
Line 86... Line 58...
86
	public void ajouterListenersDataView()
58
		});
Line 87... Line -...
87
	{
-
 
88
		
59
 
89
		// ajout de listeners pour la gestion de la selection
60
	}
Line 90... Line 61...
90
		// dans la galerie
61
 
91
		dView.addListener(new DataViewListenerAdapter() {
62
	public void ajouterListenersDataView() {
Line 92... Line 63...
92
 
63
 
Line 93... Line -...
93
 
-
 
94
 
64
		// ajout de listeners pour la gestion de la selection
95
			public void onClick(DataView source, int index, Element node,
65
		// dans la galerie
Line 96... Line 66...
96
					EventObject e) {
66
		dView.addListener(new DataViewListenerAdapter() {
97
				
67
 
Line 98... Line 68...
98
				getIMediateur().clicGalerieImage(index, node, e);
68
			public void onClick(DataView source, int index, Element node,
Line 99... Line -...
99
				
-
 
100
			}
69
					EventObject e) {
Line 101... Line 70...
101
 
70
 
102
 
-
 
103
			public void onContainerClick(DataView source, EventObject e) {
71
				getIMediateur().clicGalerieImage(index, node, e);
104
				//TODO: appeler le mediateur
-
 
105
				
72
 
106
			}
-
 
107
 
73
			}
108
 
74
 
109
			public void onContextMenu(DataView source, int index, Element node,
75
			public void onContainerClick(DataView source, EventObject e) {
110
					EventObject e) {
76
				// TODO: appeler le mediateur
Line 111... Line 77...
111
				
77
 
112
				e.stopEvent() ;
78
			}
Line -... Line 79...
-
 
79
 
-
 
80
			public void onContextMenu(DataView source, int index, Element node,
-
 
81
					EventObject e) {
-
 
82
 
-
 
83
				e.stopEvent();
-
 
84
				getIMediateur().montrerContextMenu(e);
-
 
85
 
-
 
86
			}
-
 
87
 
-
 
88
			public void onDblClick(DataView source, int index, Element node,
-
 
89
					EventObject e) {
-
 
90
 
-
 
91
				// TODO: appeler le mediateur
-
 
92
				getIMediateur().clicGalerieImage(index, node, e);
-
 
93
 
-
 
94
			}
-
 
95
 
-
 
96
			public void onSelectionChange(DataView view, Element[] selections) {
-
 
97
 
-
 
98
				if (selections.length <= 0) {
-
 
99
					getIMediateur().aucuneSelection();
-
 
100
				} else {
-
 
101
					getIMediateur().selection();
-
 
102
					getIMediateur().synchroniserSelection("galerie");
Line 113... Line 103...
113
				getIMediateur().montrerContextMenu(e) ;
103
				}
114
				
104
			}
115
			}
-
 
116
 
105
 
117
 
106
		});
118
			public void onDblClick(DataView source, int index, Element node,
107
	}
119
					EventObject e) {
108
 
120
				
109
	public DataView getDView() {
Line 157... Line 146...
157
		template.compile();
146
		template.compile();
Line 158... Line 147...
158
 
147
 
159
		// la dataview affichera les images en accord avec le template
148
		// la dataview affichera les images en accord avec le template
160
		// cree precedemment
149
		// cree precedemment
-
 
150
		dView = new DataView("div.thumb-wrap") {
161
		dView = new DataView("div.thumb-wrap") {
151
 
162
			public void prepareData(Data data) {
152
			public void prepareData(Data data) {
163
				data.setProperty("shortName", Format.ellipsis(data
153
				data.setProperty("shortName", Format.ellipsis(data
164
						.getProperty("num_image"), 15));
154
						.getProperty("num_image"), 15));
165
			}
155
			}
Line 171... Line 161...
171
		dView.setAutoHeight(true);
161
		dView.setAutoHeight(true);
172
		dView.setMultiSelect(true);
162
		dView.setMultiSelect(true);
173
		dView.setOverCls("x-view-over");
163
		dView.setOverCls("x-view-over");
174
		dView.setEmptyText("Aucune image à afficher");
164
		dView.setEmptyText("Aucune image à afficher");
Line 175... Line -...
175
		
-
 
176
		
165
 
177
		// creation du store
166
		// creation du store
178
		FieldDef defNumImage = new IntegerFieldDef("num_image");
167
		FieldDef defNumImage = new IntegerFieldDef("num_image");
179
		FieldDef defDatImage = new StringFieldDef("dat_image");
168
		FieldDef defDatImage = new StringFieldDef("dat_image");
180
		FieldDef defLieImage = new StringFieldDef("lie_image");
169
		FieldDef defLieImage = new StringFieldDef("lie_image");
181
		FieldDef defAppImage = new StringFieldDef("app_image");
170
		FieldDef defAppImage = new StringFieldDef("app_image");
182
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
171
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
183
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
172
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
184
		FieldDef defUrlImage = new StringFieldDef("url_image");
173
		FieldDef defUrlImage = new StringFieldDef("url_image");
-
 
174
		FieldDef[] defTab = { defNumImage, defDatImage, defLieImage,
185
		FieldDef[] defTab = {defNumImage,defDatImage,defLieImage,defAppImage,defUrlImageS,defUrlImageM,defUrlImage};
175
				defAppImage, defUrlImageS, defUrlImageM, defUrlImage };
186
		RecordDef rd = new RecordDef(defTab) ;
176
		RecordDef rd = new RecordDef(defTab);
187
		st = new Store(rd) ;
177
		st = new Store(rd);
Line 188... Line 178...
188
		dView.setStore(st);
178
		dView.setStore(st);
Line 195... Line 185...
195
		this.add(dView);	
185
		this.add(dView);
Line 196... Line 186...
196
		
186
 
197
		getIMediateur().obtenirPhotoGalerie(this);
187
		getIMediateur().obtenirPhotoGalerie(this);
Line -... Line 188...
-
 
188
	}
-
 
189
 
Line 198... Line -...
198
	}
-
 
199
	
-
 
200
	
-
 
201
	
190
	public void rafraichir(Object nouvelleDonnees,
202
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
-
 
203
		
191
			boolean repandreRafraichissement) {
204
		if(nouvelleDonnees instanceof Store)
192
 
205
		{	
193
		if (nouvelleDonnees instanceof Store) {
206
			st = (Store)nouvelleDonnees;
194
			st = (Store) nouvelleDonnees;
207
			st.load() ;
195
			st.load();
Line 208... Line 196...
208
			dView.setStore(st);
196
			dView.setStore(st);
209
			dView.refresh();			
-
 
210
		}
197
			dView.refresh();
211
		
-
 
212
		if(repandreRafraichissement)
-
 
213
		{
-
 
214
			getIMediateur().synchroniserDonneesZoomListeGalerie(nouvelleDonnees, this) ;
-
 
215
		}
-
 
216
	}
-
 
217
 
-
 
218
 
-
 
219
	public ImageMediateur getIMediateur() {
-
 
220
		return iMediateur;
-
 
221
	}
-
 
222
 
-
 
223
 
-
 
224
	public DataView getDView() {
-
 
225
		return dView;
-
 
226
	}
-
 
227
 
-
 
228
 
-
 
229
	public Store getSt() {
-
 
230
		return st;
-
 
231
	}
-
 
232
	
198
		}
233
	public String[] getIdSelectionnees()
-
 
234
	{ 
-
 
235
		Record[] selection = getDView().getSelectedRecords() ;
-
 
236
		int taille = selection.length ;
-
 
237
		String id_selection[] = new String[taille] ;
-
 
238
		
199
 
239
		for (int i = 0; i < selection.length; i++) {
-
 
240
			
-
 
241
			id_selection[i] = selection[i].getAsString("num_image") ;
200
		if (repandreRafraichissement) {
Line 242... Line -...
242
		}
-
 
243
		
201
			getIMediateur().synchroniserDonneesZoomListeGalerie(
Line 244... Line 202...
244
		return id_selection ;
202
					nouvelleDonnees, this);
Line 245... Line 203...
245
	}
203
		}