Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 4 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 5
Line 5... Line 5...
5
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.interfaces.Rafraichissable;
Line 6... Line 6...
6
 
6
 
7
 
7
 
-
 
8
import com.google.gwt.core.client.JavaScriptObject;
8
import com.google.gwt.core.client.JavaScriptObject;
9
import com.google.gwt.user.client.Element;
9
import com.google.gwt.user.client.Element;
10
import com.google.gwt.user.client.Event;
-
 
11
import com.gwtext.client.core.EventObject;
10
import com.gwtext.client.core.EventObject;
12
import com.gwtext.client.core.XTemplate;
-
 
13
import com.gwtext.client.data.ArrayReader;
11
import com.gwtext.client.core.XTemplate;
14
import com.gwtext.client.data.FieldDef;
12
import com.gwtext.client.data.FieldDef;
15
import com.gwtext.client.data.MemoryProxy;
13
import com.gwtext.client.data.RecordDef;
16
import com.gwtext.client.data.RecordDef;
14
import com.gwtext.client.data.Store;
17
import com.gwtext.client.data.Store;
15
import com.gwtext.client.data.StringFieldDef;
18
import com.gwtext.client.data.StringFieldDef;
16
import com.gwtext.client.util.Format;
19
import com.gwtext.client.util.Format;
-
 
20
import com.gwtext.client.widgets.BoxComponent;
17
import com.gwtext.client.widgets.BoxComponent;
21
import com.gwtext.client.widgets.Component;
-
 
22
import com.gwtext.client.widgets.Container;
18
import com.gwtext.client.widgets.Component;
23
import com.gwtext.client.widgets.DataView;
19
import com.gwtext.client.widgets.DataView;
24
import com.gwtext.client.widgets.Observable;
-
 
25
import com.gwtext.client.widgets.Panel;
-
 
26
import com.gwtext.client.widgets.DataView.Data;
20
import com.gwtext.client.widgets.Panel;
27
import com.gwtext.client.widgets.event.ContainerListener;
21
import com.gwtext.client.widgets.DataView.Data;
28
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
Line 22... Line 29...
22
import com.gwtext.client.widgets.event.DataViewListener;
29
import com.gwtext.client.widgets.event.DataViewListener;
Line 23... Line 30...
23
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
30
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
24
 
31
 
25
public class GalerieImageVue extends Panel implements Rafraichissable {
32
public class GalerieImageVue extends Panel implements Rafraichissable, Observable {
26
 
33
 
Line 32... Line 39...
32
	public GalerieImageVue(ImageMediateur im)
39
	public GalerieImageVue(ImageMediateur im)
33
	{
40
	{
34
		super("Galerie");
41
		super("Galerie");
35
		iMediateur = im ;
42
		iMediateur = im ;
Line 36... Line -...
36
		
-
 
37
		
-
 
38
		// Preparation de la dataview et du template		
43
		
39
		// le template va créer une div contenant une image
-
 
40
		// pour chacune des photos
-
 
41
		final XTemplate template = new XTemplate(
-
 
42
				new String[]{
-
 
43
						"<tpl for='.'>",
-
 
44
						"<div class='thumb-wrap' id='{nom}'>",
-
 
45
						"<div class='thumb'><img src='{url}' title='{nom}'></div>",
-
 
46
						"<span>{nom}</span></div>", "</tpl>",
-
 
47
						"<div class='x-clear'></div>"});
-
 
Line 48... Line -...
48
		template.compile();
-
 
49
 
-
 
50
		// la dataview affichera les images en accord avec le template
-
 
-
 
44
		this.addListener(new ContainerListenerAdapter() {
51
		// cree precedemment
45
 
52
		dView = new DataView("div.thumb-wrap") {
-
 
53
			public void prepareData(Data data) {
46
 
-
 
47
			public void onHide(Component component) {
54
				data.setProperty("shortName", Format.ellipsis(data
48
				// TODO Auto-generated method stub
55
						.getProperty("name"), 15));
49
				
56
			}
-
 
57
		};
50
			}
58
		dView.setTpl(template);
51
 
59
		
52
 
-
 
53
			public void onRender(Component component) {
60
		// parametre d'affichage de la dataview
54
				// TODO Auto-generated method stub
61
		dView.setAutoHeight(true);
-
 
62
		dView.setMultiSelect(true);
-
 
63
		dView.setOverCls("x-view-over");
55
				
64
		dView.setEmptyText("Aucune image à afficher");
56
			}
65
		
-
 
66
		
-
 
67
		// creation du store
-
 
68
		FieldDef defNumImage = new StringFieldDef("num_image");
-
 
69
		FieldDef defUrlImage = new StringFieldDef("url_image");
57
 
70
		FieldDef[] defTab = {defNumImage,defUrlImage};
-
 
71
		RecordDef rd = new RecordDef(defTab) ;
-
 
-
 
58
 
72
		st = new Store(rd) ;
59
			public void onShow(Component component) {
73
		dView.setStore(st);
60
				
-
 
61
				
74
		
62
				if(dView == null)
-
 
63
				{
-
 
64
					initialiser();
75
		// ajouts de la gestion des evenements pour la dataview
65
				}
76
		ajouterListeners();
66
			}
Line 77... Line 67...
77
		
67
			
Line 78... Line 68...
78
		this.add(dView);		
68
		});
79
		
69
		
-
 
70
	}
80
	}
71
	
81
	
72
	
82
	
73
	public void ajouterListenersDataView()
Line 83... Line 74...
83
	public void ajouterListeners()
74
	{
84
	{
75
		
-
 
76
		// ajout de listeners pour la gestion de la selection
85
		// ajout de listeners pour la gestion de la selection
77
		// dans la galerie
Line 86... Line 78...
86
		// dans la galerie
78
		dView.addListener(new DataViewListenerAdapter() {
Line 87... Line 79...
87
		dView.addListener(new DataViewListenerAdapter() {
79
 
Line 108... Line 100...
108
			}
100
			}
Line 109... Line 101...
109
 
101
 
110
 
102
 
-
 
103
			public void onDblClick(DataView source, int index, Element node,
111
			public void onDblClick(DataView source, int index, Element node,
104
					EventObject e) {
-
 
105
				
Line 112... Line 106...
112
					EventObject e) {
106
				//TODO: appeler le mediateur
Line 113... Line 107...
113
				//TODO: appeler le mediateur
107
				getIMediateur().ClicGalerieImage(index, node, e);
Line 122... Line 116...
122
			
116
			
123
		});
117
		});
Line -... Line 118...
-
 
118
	}
-
 
119
	
-
 
120
	
-
 
121
	// instantiation paresseuse
-
 
122
	public void initialiser()
-
 
123
	{
-
 
124
		// Preparation de la dataview et du template		
-
 
125
		// le template va créer une div contenant une image
-
 
126
		// pour chacune des photos
-
 
127
		final XTemplate template = new XTemplate(
-
 
128
				new String[]{
-
 
129
						"<tpl for='.'>",
-
 
130
						"<div class='thumb-wrap' id='{num_image}'>",
-
 
131
						"<div class='thumb'><img src='{url_image}' title='{num_image}'></div>",
-
 
132
						"<span>{nom}</span></div>", "</tpl>",
-
 
133
						"<div class='x-clear'></div>"});
-
 
134
		template.compile();
-
 
135
 
-
 
136
		// la dataview affichera les images en accord avec le template
-
 
137
		// cree precedemment
-
 
138
		dView = new DataView("div.thumb-wrap") {
-
 
139
			public void prepareData(Data data) {
-
 
140
				data.setProperty("shortName", Format.ellipsis(data
-
 
141
						.getProperty("num_image"), 15));
-
 
142
			}
-
 
143
		};
-
 
144
		dView.setTpl(template);
-
 
145
		
-
 
146
		// parametre d'affichage de la dataview
-
 
147
		dView.setAutoHeight(true);
-
 
148
		dView.setMultiSelect(true);
-
 
149
		dView.setOverCls("x-view-over");
-
 
150
		dView.setEmptyText("Aucune image à afficher");
-
 
151
		
-
 
152
		
-
 
153
		// creation du store
-
 
154
		FieldDef defNumImage = new StringFieldDef("num_image");
-
 
155
		FieldDef defUrlImage = new StringFieldDef("url_image");
-
 
156
		FieldDef[] defTab = {defNumImage,defUrlImage};
-
 
157
		RecordDef rd = new RecordDef(defTab) ;
-
 
158
		st = new Store(rd) ;
-
 
159
		dView.setStore(st);
-
 
160
		
-
 
161
		// ajouts de la gestion des evenements pour la dataview
-
 
162
		ajouterListenersDataView();
-
 
163
		
-
 
164
		this.add(dView);	
-
 
165
		
-
 
166
		getIMediateur().ObtenirPhotoGalerie(this);
Line 124... Line 167...
124
	}
167
	}
125
	
-
 
Line -... Line 168...
-
 
168
	
-
 
169
	
-
 
170
	
-
 
171
	public void rafraichir(Object nouvelleDonnees) {
-
 
172
		
-
 
173
			Object[][] photoData = (Object[][])nouvelleDonnees ;
-
 
174
			final MemoryProxy dataProxy = new MemoryProxy(photoData);
-
 
175
			final ArrayReader reader = new ArrayReader(new RecordDef(
-
 
176
					new FieldDef[]{new StringFieldDef("num_image"),
-
 
177
							new StringFieldDef("url_image")}));
-
 
178
	
-
 
179
			final Store photoStore = new Store(dataProxy, reader);
-
 
180
			photoStore.load();
-
 
181
	
-
 
182
			st = photoStore;
-
 
183
			dView.setStore(st);
-
 
184
			dView.refresh();
-
 
185
	}
-
 
186
 
-
 
187
 
-
 
188
	public ImageMediateur getIMediateur() {
-
 
189
		return iMediateur;
-
 
190
	}
-
 
191
 
-
 
192
 
-
 
193
	public DataView getDView() {
-
 
194
		return dView;
126
	
195
	}
127
	
196