Subversion Repositories eFlore/Archives.cel-v2

Rev

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

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