Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 22 | Rev 28 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22 Rev 27
1
 
-
 
2
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
3
 
-
 
4
 
2
 
5
import java.util.Iterator;
3
import java.util.Iterator;
6
 
4
 
7
import org.tela_botanica.client.image.ImageMediateur;
5
import org.tela_botanica.client.image.ImageMediateur;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
6
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.interfaces.VueListable;
7
import org.tela_botanica.client.interfaces.VueListable;
10
import org.tela_botanica.client.modeles.ImageCarnet;
8
import org.tela_botanica.client.modeles.ImageCarnet;
11
import org.tela_botanica.client.modeles.ListeImageCarnet;
9
import org.tela_botanica.client.modeles.ListeImageCarnet;
12
 
-
 
13
 
10
 
14
import com.google.gwt.core.client.JavaScriptObject;
11
import com.google.gwt.core.client.JavaScriptObject;
15
import com.google.gwt.user.client.Window;
12
import com.google.gwt.user.client.Window;
16
import com.gwtext.client.core.EventObject;
13
import com.gwtext.client.core.EventObject;
17
import com.gwtext.client.data.ArrayReader;
14
import com.gwtext.client.data.ArrayReader;
18
import com.gwtext.client.data.FieldDef;
15
import com.gwtext.client.data.FieldDef;
19
import com.gwtext.client.data.IntegerFieldDef;
16
import com.gwtext.client.data.IntegerFieldDef;
20
import com.gwtext.client.data.MemoryProxy;
17
import com.gwtext.client.data.MemoryProxy;
21
import com.gwtext.client.data.Record;
18
import com.gwtext.client.data.Record;
22
import com.gwtext.client.data.RecordDef;
19
import com.gwtext.client.data.RecordDef;
23
import com.gwtext.client.data.Store;
20
import com.gwtext.client.data.Store;
24
import com.gwtext.client.data.StoreMgr;
21
import com.gwtext.client.data.StoreMgr;
25
import com.gwtext.client.data.StringFieldDef;
22
import com.gwtext.client.data.StringFieldDef;
26
import com.gwtext.client.widgets.BoxComponent;
23
import com.gwtext.client.widgets.BoxComponent;
27
import com.gwtext.client.widgets.Component;
24
import com.gwtext.client.widgets.Component;
28
import com.gwtext.client.widgets.Container;
25
import com.gwtext.client.widgets.Container;
29
import com.gwtext.client.widgets.Panel;
26
import com.gwtext.client.widgets.Panel;
30
import com.gwtext.client.widgets.event.ComponentListenerAdapter;
27
import com.gwtext.client.widgets.event.ComponentListenerAdapter;
31
import com.gwtext.client.widgets.event.ContainerListener;
28
import com.gwtext.client.widgets.event.ContainerListener;
32
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
29
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
33
import com.gwtext.client.widgets.event.PanelListener;
30
import com.gwtext.client.widgets.event.PanelListener;
34
import com.gwtext.client.widgets.event.PanelListenerAdapter;
31
import com.gwtext.client.widgets.event.PanelListenerAdapter;
35
import com.gwtext.client.widgets.grid.CellMetadata;
32
import com.gwtext.client.widgets.grid.CellMetadata;
36
import com.gwtext.client.widgets.grid.ColumnConfig;
33
import com.gwtext.client.widgets.grid.ColumnConfig;
37
import com.gwtext.client.widgets.grid.ColumnModel;
34
import com.gwtext.client.widgets.grid.ColumnModel;
38
import com.gwtext.client.widgets.grid.GridPanel;
35
import com.gwtext.client.widgets.grid.GridPanel;
39
import com.gwtext.client.widgets.grid.GridView;
36
import com.gwtext.client.widgets.grid.GridView;
40
import com.gwtext.client.widgets.grid.Renderer;
37
import com.gwtext.client.widgets.grid.Renderer;
41
import com.gwtext.client.widgets.grid.RowSelectionModel;
38
import com.gwtext.client.widgets.grid.RowSelectionModel;
42
import com.gwtext.client.widgets.grid.event.GridCellListener;
39
import com.gwtext.client.widgets.grid.event.GridCellListener;
43
import com.gwtext.client.widgets.grid.event.GridListener;
40
import com.gwtext.client.widgets.grid.event.GridListener;
44
import com.gwtext.client.widgets.grid.event.GridRowListener;
41
import com.gwtext.client.widgets.grid.event.GridRowListener;
45
import com.gwtext.client.widgets.grid.event.RowSelectionListener;
42
import com.gwtext.client.widgets.grid.event.RowSelectionListener;
46
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
43
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
47
import com.gwtext.client.widgets.layout.AnchorLayout;
44
import com.gwtext.client.widgets.layout.AnchorLayout;
48
import com.gwtext.client.widgets.layout.FitLayout;
45
import com.gwtext.client.widgets.layout.FitLayout;
49
import com.gwtextux.client.data.BufferedStore;
46
import com.gwtextux.client.data.BufferedStore;
50
 
47
 
51
/**
48
/**
52
 * Liste d'image composée de miniatures et d'information sur l'image
49
 * Liste d'image composée de miniatures et d'information sur l'image
-
 
50
 * 
53
 * @author aurelien
51
 * @author aurelien
54
 *
-
 
55
 */
52
 */
56
public class ListeImageVue extends GridPanel implements Rafraichissable, VueListable {
53
public class ListeImageVue extends GridPanel implements Rafraichissable,
57
	
54
		VueListable {
58
	
55
 
59
	
-
 
60
	// instance du médiateur
56
	// instance du médiateur
61
	private ImageMediateur iMediateur = null; 
57
	private ImageMediateur	iMediateur		= null;
62
	
58
 
63
	
-
 
64
	private ColumnConfig numImage ;
59
	private ColumnConfig	numImage;
65
	private ColumnConfig urlImage ;
60
	private ColumnConfig	urlImage;
66
	private ColumnConfig lieImage ;
61
	private ColumnConfig	lieImage;
67
	private ColumnConfig datImage ;
62
	private ColumnConfig	datImage;
68
	private ColumnConfig appImage ;
63
	private ColumnConfig	appImage;
69
	private ColumnModel modeleColonnes ;
64
	private ColumnModel		modeleColonnes;
70
	
65
 
71
	private boolean estInstancie = false ;
66
	private boolean			estInstancie	= false;
72
	
-
 
73
	
-
 
74
	
67
 
75
	// données locales
68
	// données locales
76
	// store qui gère les données de la liste d'images
69
	// store qui gère les données de la liste d'images
77
	private Store st = null ;
70
	private Store			st				= null;
78
	private ColumnConfig cl = null ;
71
	private ColumnConfig	cl				= null;
79
	
-
 
80
	
72
 
81
	public ListeImageVue(ImageMediateur im) {
73
	public ListeImageVue(ImageMediateur im) {
82
		
-
 
83
		super() ;
-
 
84
		
-
 
85
		this.setId("listeImageGrid") ;
-
 
86
		
-
 
87
		this.iMediateur = im ;
-
 
88
		
-
 
89
		numImage = new ColumnConfig("numéro","num_image",100,true);	
-
 
90
		datImage = new ColumnConfig("date","dat_image",120,true);	
-
 
91
		lieImage = new ColumnConfig("lieu","lie_image",120,true);	
-
 
92
		appImage = new ColumnConfig("appareil","app_image",200,true);	
-
 
93
		urlImage = new ColumnConfig("Image","url_image_S",200,true,new Renderer() {
-
 
94
 
-
 
95
			public String render(Object value, CellMetadata cellMetadata,
-
 
96
					Record record, int rowIndex, int colNum, Store store) {
-
 
97
 
-
 
98
				String ImgUrl = record.getAsString("url_image_S");
-
 
99
				String ImgNum = record.getAsString("num_image");
-
 
100
				return "<div class=\"img-list\"> <img src=\""+ImgUrl+"\" title='"+ImgNum+"'> </div>";
-
 
101
			}
-
 
-
 
74
 
-
 
75
		super();
-
 
76
 
-
 
77
		this.setId("listeImageGrid");
-
 
78
 
-
 
79
		this.iMediateur = im;
-
 
80
 
-
 
81
		numImage = new ColumnConfig("numéro", "num_image", 100, true);
-
 
82
		datImage = new ColumnConfig("date", "dat_image", 120, true);
-
 
83
		lieImage = new ColumnConfig("lieu", "lie_image", 120, true);
-
 
84
		appImage = new ColumnConfig("appareil", "app_image", 200, true);
-
 
85
		urlImage = new ColumnConfig("Image", "url_image_S", 200, true,
-
 
86
				new Renderer() {
-
 
87
 
-
 
88
					public String render(Object value,
-
 
89
							CellMetadata cellMetadata, Record record,
-
 
90
							int rowIndex, int colNum, Store store) {
-
 
91
 
-
 
92
						String ImgUrl = record.getAsString("url_image_S");
-
 
93
						String ImgNum = record.getAsString("num_image");
-
 
94
						return "<div class=\"img-list\"> <img src=\"" + ImgUrl
-
 
95
								+ "\" title='" + ImgNum + "'> </div>";
-
 
96
					}
102
 
97
 
103
		});
98
				});
104
		
99
 
105
		ColumnConfig[] cm = {numImage,datImage,lieImage,appImage,urlImage};
100
		ColumnConfig[] cm = { numImage, datImage, lieImage, appImage, urlImage };
106
		modeleColonnes = new ColumnModel(cm);
101
		modeleColonnes = new ColumnModel(cm);
107
		this.setColumnModel(modeleColonnes);
102
		this.setColumnModel(modeleColonnes);
108
		this.setAutoScroll(true);
103
		this.setAutoScroll(true);
109
		this.setAutoWidth(true);
104
		this.setAutoWidth(true);
110
		
-
 
111
		
105
 
112
		// creation du store
106
		// creation du store
113
		FieldDef defNumImage = new IntegerFieldDef("num_image");
107
		FieldDef defNumImage = new IntegerFieldDef("num_image");
114
		FieldDef defDatImage = new StringFieldDef("dat_image");
108
		FieldDef defDatImage = new StringFieldDef("dat_image");
115
		FieldDef defLieImage = new StringFieldDef("lie_image");
109
		FieldDef defLieImage = new StringFieldDef("lie_image");
116
		FieldDef defAppImage = new StringFieldDef("app_image");
110
		FieldDef defAppImage = new StringFieldDef("app_image");
117
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
111
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
118
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
112
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
119
		FieldDef defUrlImage = new StringFieldDef("url_image");
113
		FieldDef defUrlImage = new StringFieldDef("url_image");
120
		FieldDef[] defTab = {defNumImage,defDatImage,defLieImage,defAppImage,defUrlImageS,defUrlImageM,defUrlImage};
114
		FieldDef[] defTab = { defNumImage, defDatImage, defLieImage,
-
 
115
				defAppImage, defUrlImageS, defUrlImageM, defUrlImage };
121
		RecordDef rd = new RecordDef(defTab) ;
116
		RecordDef rd = new RecordDef(defTab);
122
		st = new Store(rd) ;
117
		st = new Store(rd);
123
		this.setStore(st);
118
		this.setStore(st);
124
		this.getView().setAutoFill(true) ;
119
		this.getView().setAutoFill(true);
125
		
120
 
126
		//this.setLoadMask(true) ;
121
		// this.setLoadMask(true) ;
127
		this.setLoadMask("chargement") ;
122
		this.setLoadMask("chargement");
128
		
123
 
129
		ajouterListeners() ;
124
		ajouterListeners();
130
		
-
 
131
		
125
 
132
	}
126
	}
133
	
127
 
134
	public void ajouterListeners()
128
	public void ajouterListeners() {
135
	{	
-
 
136
		this.addListener(new ContainerListenerAdapter() {
129
		this.addListener(new ContainerListenerAdapter() {
137
 
-
 
138
			
130
 
139
			public void onHide(Component component) {
-
 
140
				// TODO Auto-generated method stub
131
			public void onHide(Component component) {
141
				
132
 
142
			}
-
 
143
 
133
			}
144
			
134
 
145
			public void onRender(Component component) {
-
 
146
 
135
			public void onRender(Component component) {
147
				if(!isEstInstancie())
136
 
148
				{
137
				if (!isEstInstancie()) {
149
					setEstInstancie(true) ;
138
					setEstInstancie(true);
150
					getIMediateur().synchroniserSelection("galerie") ;
139
					getIMediateur().synchroniserSelection("galerie");
151
				}
140
				}
152
			}
141
			}
153
 
-
 
154
			
142
 
155
			public void onShow(Component component) {
-
 
156
				
143
			public void onShow(Component component) {
157
				
144
 
158
			}
-
 
159
 
145
			}
160
			
-
 
161
		});
-
 
-
 
146
 
162
		
147
		});
163
		this.addGridRowListener(new GridRowListener() {
148
 
164
 
149
		this.addGridRowListener(new GridRowListener() {
165
 
150
 
166
			public void onRowClick(GridPanel grid, int rowIndex, EventObject e) {
151
			public void onRowClick(GridPanel grid, int rowIndex, EventObject e) {
167
					;
152
 
168
				getIMediateur().clicListeImage(rowIndex) ;	
153
				getIMediateur().clicListeImage(rowIndex);
169
			}
154
			}
170
 
155
 
171
			public void onRowContextMenu(GridPanel grid, int rowIndex,
156
			public void onRowContextMenu(GridPanel grid, int rowIndex,
172
					EventObject e) {
157
					EventObject e) {
173
				
158
 
174
				getIMediateur().montrerContextMenu(e) ;
159
				getIMediateur().montrerContextMenu(e);
175
				
-
 
176
			}
160
			}
177
 
161
 
178
			public void onRowDblClick(GridPanel grid, int rowIndex,
162
			public void onRowDblClick(GridPanel grid, int rowIndex,
179
					EventObject e) {
163
					EventObject e) {
180
				
-
 
181
 
164
 
182
				getIMediateur().doubleClicListeImage(rowIndex) ;
-
 
183
				                                    
-
 
184
				
165
				getIMediateur().doubleClicListeImage(rowIndex);
185
			}
-
 
186
			
166
			}
187
		});
167
		});
188
		
168
 
189
		this.getSelectionModel().addListener(new RowSelectionListenerAdapter() {
169
		this.getSelectionModel().addListener(new RowSelectionListenerAdapter() {
190
 
170
 
191
			public void onSelectionChange(RowSelectionModel sm) {
171
			public void onSelectionChange(RowSelectionModel sm) {
192
				
172
 
193
				if(sm.getCount() <= 0)
173
				if (sm.getCount() <= 0) {
194
				{
-
 
195
					getIMediateur().aucuneSelection() ;
174
					getIMediateur().aucuneSelection();
196
				}
-
 
197
				else
175
				} else {
198
				{
-
 
199
					getIMediateur().selection() ;
176
					getIMediateur().selection();
200
					getIMediateur().synchroniserSelection("liste");
177
					getIMediateur().synchroniserSelection("liste");
201
				}
178
				}
202
				
-
 
203
			}
179
			}
204
			
-
 
205
		});
180
		});
206
	}
181
	}
207
	
182
 
208
	public String[] getIdSelectionnees()
183
	public ColumnConfig getCl() {
209
	{ 		
-
 
210
		Record[] selection = this.getSelectionModel().getSelections() ;
-
 
211
		int taille = selection.length ;
-
 
212
		String id_selection[] = new String[taille] ;
-
 
213
		
-
 
214
		for (int i = 0; i < selection.length; i++) {
-
 
215
			
-
 
216
			id_selection[i] = selection[i].getAsString("num_image") ;
-
 
217
		}
-
 
218
		
-
 
219
		return id_selection ;
184
		return cl;
220
	}
185
	}
-
 
186
 
-
 
187
	public String[] getIdSelectionnees() {
-
 
188
		Record[] selection = this.getSelectionModel().getSelections();
-
 
189
		int taille = selection.length;
221
 
-
 
222
 
-
 
223
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
190
		String id_selection[] = new String[taille];
224
		
-
 
225
		if(nouvelleDonnees instanceof Store)
191
 
226
		{
-
 
227
			
-
 
228
			st = (Store)nouvelleDonnees;
192
		for (int i = 0; i < selection.length; i++) {
229
			st.load();
-
 
230
			this.reconfigure(st, this.getColumnModel());
-
 
231
		}
-
 
232
		
-
 
233
		if(repandreRafraichissement)
-
 
234
		{
193
 
235
			getIMediateur().synchroniserDonneesZoomListeGalerie(nouvelleDonnees, this) ;
-
 
-
 
194
			id_selection[i] = selection[i].getAsString("num_image");
-
 
195
		}
236
		}
196
 
237
	}
197
		return id_selection;
238
 
198
	}
239
 
199
 
240
	public ImageMediateur getIMediateur() {
200
	public ImageMediateur getIMediateur() {
241
		return iMediateur;
201
		return iMediateur;
242
	}
202
	}
-
 
203
 
-
 
204
	public ColumnModel getModeleColonnes() {
-
 
205
		return modeleColonnes;
243
 
206
	}
244
 
207
 
245
	public ColumnConfig getNumImage() {
208
	public ColumnConfig getNumImage() {
246
		return numImage;
209
		return numImage;
247
	}
210
	}
-
 
211
 
-
 
212
	public Store getSt() {
-
 
213
		return st;
248
 
214
	}
249
 
215
 
250
	public ColumnConfig getUrlImage() {
216
	public ColumnConfig getUrlImage() {
251
		return urlImage;
217
		return urlImage;
252
	}
218
	}
-
 
219
 
-
 
220
	/**
253
 
221
	 * @return the estInstancie
254
 
222
	 */
255
	public ColumnModel getModeleColonnes() {
223
	public boolean isEstInstancie() {
256
		return modeleColonnes;
224
		return estInstancie;
-
 
225
	}
-
 
226
 
257
	}
227
	public void rafraichir(Object nouvelleDonnees,
258
 
-
 
259
 
-
 
-
 
228
			boolean repandreRafraichissement) {
-
 
229
 
-
 
230
		if (nouvelleDonnees instanceof Store) {
-
 
231
 
260
	public Store getSt() {
232
			st = (Store) nouvelleDonnees;
-
 
233
			st.load();
261
		return st;
234
			this.reconfigure(st, this.getColumnModel());
-
 
235
		}
262
	}
236
 
-
 
237
		if (repandreRafraichissement) {
263
 
-
 
264
 
238
			getIMediateur().synchroniserDonneesZoomListeGalerie(
265
	public ColumnConfig getCl() {
-
 
266
		return cl;
239
					nouvelleDonnees, this);
267
	}
240
		}
-
 
241
	}
268
 
242
 
269
 
-
 
270
	/**
243
	public void selectionnerEnregistrements(Record[] sel) {
-
 
244
 
271
	 * @return the estInstancie
245
		if (isEstInstancie()) {
272
	 */
246
			getSelectionModel().clearSelections();
273
	public boolean isEstInstancie() {
247
			getSelectionModel().selectRecords(sel);
274
		return estInstancie;
248
		}
275
	}
249
	}
276
 
250
 
277
 
251
	/**
278
	/**
252
	 * @param estInstancie
279
	 * @param estInstancie the estInstancie to set
253
	 *            the estInstancie to set
280
	 */
254
	 */
281
	public void setEstInstancie(boolean estInstancie) {
255
	public void setEstInstancie(boolean estInstancie) {
282
		this.estInstancie = estInstancie;
256
		this.estInstancie = estInstancie;
283
	}
257
	}
284
 
-
 
285
 
258
 
-
 
259
	/**
286
	/**
260
	 * @param mediateur
287
	 * @param mediateur the iMediateur to set
261
	 *            the iMediateur to set
288
	 */
262
	 */
289
	public void setIMediateur(ImageMediateur mediateur) {
263
	public void setIMediateur(ImageMediateur mediateur) {
290
		iMediateur = mediateur;
264
		iMediateur = mediateur;
291
	}
265
	}
292
 
-
 
293
	public void selectionnerEnregistrements(Record[] sel) {
-
 
294
		
-
 
295
		if(isEstInstancie())
-
 
296
		{
-
 
297
			getSelectionModel().clearSelections() ;
-
 
298
			getSelectionModel().selectRecords(sel) ;
-
 
299
		}
-
 
300
	}
-
 
301
	
-
 
302
	
-
 
303
 
266
 
304
}
267
}