Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 22 | Rev 31 | Go to most recent revision | Show entire file | Ignore 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
 
-
 
22
/**
40
/**
23
 * Galerie d'images miniatures
41
 * 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
48
	private ImageMediateur iMediateur = null; 
31
	private ImageMediateur	iMediateur	= null;
49
	private DataView dView = null ;
32
	private DataView		dView		= null;
50
	private Store st = null ;
-
 
51
	
33
	private Store			st			= null;
52
	public GalerieImageVue(ImageMediateur im)
34
 
53
	{
-
 
54
		super("Galerie");
-
 
Line -... Line 35...
-
 
35
	public GalerieImageVue(ImageMediateur im) {
Line 55... Line 36...
55
		iMediateur = im ;
36
		super("Galerie");
56
		
37
		iMediateur = im;
57
		this.addListener(new ContainerListenerAdapter() {
-
 
58
 
-
 
Line -... Line 38...
-
 
38
 
Line 59... Line 39...
59
 
39
		this.addListener(new ContainerListenerAdapter() {
60
			public void onHide(Component component) {
40
 
61
				// TODO Auto-generated method stub
-
 
62
				
-
 
Line -... Line 41...
-
 
41
			public void onHide(Component component) {
Line 63... Line 42...
63
			}
42
				// TODO Auto-generated method stub
64
 
-
 
65
 
43
 
66
			public void onRender(Component component) {
44
			}
67
				// TODO Auto-generated method stub
-
 
68
				
45
 
69
			}
46
			public void onRender(Component component) {
70
 
47
				// TODO Auto-generated method stub
71
 
48
 
72
			public void onShow(Component component) {
49
			}
73
				
50
 
74
				
51
			public void onShow(Component component) {
75
				if(dView == null)
-
 
76
				{
52
 
77
					initialiser();
53
				if (dView == null) {
78
				}
-
 
79
			}
54
					initialiser();
80
			
55
				}
81
		});
56
			}
82
		
57
 
Line 83... Line -...
83
	}
-
 
84
	
-
 
85
	
58
		});
86
	public void ajouterListenersDataView()
59
 
87
	{
60
	}
88
		
61
 
89
		// ajout de listeners pour la gestion de la selection
-
 
90
		// dans la galerie
-
 
Line -... Line 62...
-
 
62
	public void ajouterListenersDataView() {
Line 91... Line 63...
91
		dView.addListener(new DataViewListenerAdapter() {
63
 
92
 
64
		// ajout de listeners pour la gestion de la selection
93
 
-
 
94
 
-
 
Line -... Line 65...
-
 
65
		// dans la galerie
Line 95... Line 66...
95
			public void onClick(DataView source, int index, Element node,
66
		dView.addListener(new DataViewListenerAdapter() {
96
					EventObject e) {
67
 
97
				
-
 
98
				getIMediateur().clicGalerieImage(index, node, e);
-
 
99
				
-
 
100
			}
-
 
101
 
-
 
Line -... Line 68...
-
 
68
			public void onClick(DataView source, int index, Element node,
-
 
69
					EventObject e) {
-
 
70
 
-
 
71
				getIMediateur().clicGalerieImage(index, node, e);
Line 102... Line 72...
102
 
72
 
103
			public void onContainerClick(DataView source, EventObject e) {
73
			}
104
				//TODO: appeler le mediateur
74
 
105
				
75
			public void onContainerClick(DataView source, EventObject e) {
106
			}
76
				// TODO: appeler le mediateur
107
 
-
 
108
 
-
 
Line -... Line 77...
-
 
77
 
Line 109... Line 78...
109
			public void onContextMenu(DataView source, int index, Element node,
78
			}
110
					EventObject e) {
79
 
111
				
80
			public void onContextMenu(DataView source, int index, Element node,
112
				e.stopEvent() ;
-
 
113
				getIMediateur().montrerContextMenu(e) ;
81
					EventObject e) {
114
				
-
 
115
			}
82
 
116
 
-
 
117
 
83
				e.stopEvent();
118
			public void onDblClick(DataView source, int index, Element node,
84
				getIMediateur().montrerContextMenu(e);
119
					EventObject e) {
85
 
120
				
86
			}
121
				//TODO: appeler le mediateur
87
 
122
				getIMediateur().clicGalerieImage(index, node, e);
88
			public void onDblClick(DataView source, int index, Element node,
123
				
89
					EventObject e) {
124
			}
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");
-
 
103
				}
-
 
104
			}
-
 
105
 
-
 
106
		});
-
 
107
	}
-
 
108
 
-
 
109
	public DataView getDView() {
-
 
110
		return dView;
-
 
111
	}
-
 
112
 
-
 
113
	public String[] getIdSelectionnees() {
-
 
114
		Record[] selection = getDView().getSelectedRecords();
125
 
115
		int taille = selection.length;
126
 
116
		String id_selection[] = new String[taille];
127
			public void onSelectionChange(DataView view, Element[] selections) {
117
 
128
				
-
 
129
				if(selections.length <= 0)
118
		for (int i = 0; i < selection.length; i++) {
130
				{
119
 
131
					getIMediateur().aucuneSelection();
120
			id_selection[i] = selection[i].getAsString("num_image");
132
				}
121
		}
133
				else
122
 
134
				{
123
		return id_selection;
135
					getIMediateur().selection() ;
124
	}
136
					getIMediateur().synchroniserSelection("galerie") ;
125
 
137
				}
126
	public ImageMediateur getIMediateur() {
138
			}
127
		return iMediateur;
139
			
128
	}
Line 140... Line 129...
140
		});
129
 
141
	}
130
	public Store getSt() {
142
	
131
		return st;
-
 
132
	}
143
	
133
 
144
	// instantiation paresseuse
134
	// instantiation paresseuse
145
	public void initialiser()
135
	public void initialiser() {
146
	{
136
		// Preparation de la dataview et du template
147
		// Preparation de la dataview et du template		
137
		// le template va créer une div contenant une image
148
		// le template va créer une div contenant une image
138
		// pour chacune des photos
149
		// pour chacune des photos
139
		final XTemplate template = new XTemplate(
150
		final XTemplate template = new XTemplate(
140
				new String[] {
151
				new String[]{
141
						"<tpl for='.'>",
152
						"<tpl for='.'>",
142
						"<div class='thumb-wrap' id='{num_image}'>",
153
						"<div class='thumb-wrap' id='{num_image}'>",
143
						"<div class='thumb'><img src='{url_image_M}' title='{num_image}'></div>",
154
						"<div class='thumb'><img src='{url_image_M}' title='{num_image}'></div>",
144
						"<span>{nom}</span></div>", "</tpl>",
155
						"<span>{nom}</span></div>", "</tpl>",
145
						"<div class='x-clear'></div>" });
156
						"<div class='x-clear'></div>"});
-
 
157
		template.compile();
146
		template.compile();
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
161
		dView = new DataView("div.thumb-wrap") {
150
		dView = new DataView("div.thumb-wrap") {
162
			public void prepareData(Data data) {
151
 
163
				data.setProperty("shortName", Format.ellipsis(data
152
			public void prepareData(Data data) {
164
						.getProperty("num_image"), 15));
153
				data.setProperty("shortName", Format.ellipsis(data
165
			}
154
						.getProperty("num_image"), 15));
166
		};
155
			}
-
 
156
		};
167
		dView.setTpl(template);
157
		dView.setTpl(template);
168
		
158
 
169
		// parametre d'affichage de la dataview
159
		// parametre d'affichage de la dataview
170
		this.setAutoScroll(true);
160
		this.setAutoScroll(true);
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");
175
		
-
 
176
		
-
 
177
		// creation du store
-
 
178
		FieldDef defNumImage = new IntegerFieldDef("num_image");
-
 
179
		FieldDef defDatImage = new StringFieldDef("dat_image");
-
 
180
		FieldDef defLieImage = new StringFieldDef("lie_image");
-
 
181
		FieldDef defAppImage = new StringFieldDef("app_image");
-
 
182
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
-
 
183
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
-
 
184
		FieldDef defUrlImage = new StringFieldDef("url_image");
-
 
185
		FieldDef[] defTab = {defNumImage,defDatImage,defLieImage,defAppImage,defUrlImageS,defUrlImageM,defUrlImage};
-
 
186
		RecordDef rd = new RecordDef(defTab) ;
-
 
187
		st = new Store(rd) ;
-
 
188
		dView.setStore(st);
-
 
189
		
-
 
190
		this.getDView().setLoadingText("chargement");
-
 
191
		
-
 
192
		// ajouts de la gestion des evenements pour la dataview
-
 
193
		ajouterListenersDataView();
-
 
194
		
-
 
195
		this.add(dView);	
-
 
196
		
-
 
197
		getIMediateur().obtenirPhotoGalerie(this);
-
 
Line -... Line 165...
-
 
165
 
Line 198... Line 166...
198
	}
166
		// creation du store
199
	
-
 
200
	
167
		FieldDef defNumImage = new IntegerFieldDef("num_image");
Line -... Line 168...
-
 
168
		FieldDef defDatImage = new StringFieldDef("dat_image");
-
 
169
		FieldDef defLieImage = new StringFieldDef("lie_image");
Line -... Line 170...
-
 
170
		FieldDef defAppImage = new StringFieldDef("app_image");
201
	
171
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
202
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
172
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
-
 
173
		FieldDef defUrlImage = new StringFieldDef("url_image");
-
 
174
		FieldDef[] defTab = { defNumImage, defDatImage, defLieImage,
203
		
175
				defAppImage, defUrlImageS, defUrlImageM, defUrlImage };
204
		if(nouvelleDonnees instanceof Store)
-
 
Line 205... Line -...
205
		{	
-
 
206
			st = (Store)nouvelleDonnees;
-
 
207
			st.load() ;
-
 
208
			dView.setStore(st);
-
 
209
			dView.refresh();			
-
 
210
		}
-
 
211
		
-
 
212
		if(repandreRafraichissement)
176
		RecordDef rd = new RecordDef(defTab);
213
		{
177
		st = new Store(rd);
214
			getIMediateur().synchroniserDonneesZoomListeGalerie(nouvelleDonnees, this) ;
-
 
215
		}
178
		dView.setStore(st);
216
	}
-
 
217
 
-
 
218
 
179
 
219
	public ImageMediateur getIMediateur() {
-
 
220
		return iMediateur;
-
 
221
	}
180
		this.getDView().setLoadingText("chargement");
Line 222... Line -...
222
 
-
 
223
 
181
 
224
	public DataView getDView() {
182
		// ajouts de la gestion des evenements pour la dataview
225
		return dView;
183
		ajouterListenersDataView();
226
	}
184
 
227
 
185
		this.add(dView);
228
 
186