Subversion Repositories eFlore/Archives.cel-v2

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 aperonnet 1
package org.tela_botanica.client;
2
 
3
import com.google.gwt.core.client.JavaScriptObject;
4
import com.google.gwt.user.client.Element;
5
import com.gwtext.client.core.EventObject;
6
import com.gwtext.client.core.XTemplate;
7
import com.gwtext.client.data.FieldDef;
8
import com.gwtext.client.data.RecordDef;
9
import com.gwtext.client.data.Store;
10
import com.gwtext.client.data.StringFieldDef;
11
import com.gwtext.client.util.Format;
12
import com.gwtext.client.widgets.BoxComponent;
13
import com.gwtext.client.widgets.Component;
14
import com.gwtext.client.widgets.DataView;
15
import com.gwtext.client.widgets.Panel;
16
import com.gwtext.client.widgets.DataView.Data;
17
import com.gwtext.client.widgets.event.DataViewListener;
18
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
19
 
20
public class GalerieImageVue extends Panel implements Rafraichissable {
21
 
22
	// instance du médiateur
23
	private ImageMediateur iMediateur = null;
24
	private DataView dView = null ;
25
	private Store st = null ;
26
 
27
	public GalerieImageVue(ImageMediateur im)
28
	{
29
		super("Galerie");
30
		iMediateur = im ;
31
 
32
 
33
		// Preparation de la dataview et du template
34
		// le template va créer une div contenant une image
35
		// pour chacune des photos
36
		final XTemplate template = new XTemplate(
37
				new String[]{
38
						"<tpl for='.'>",
39
						"<div class='thumb-wrap' id='{nom}'>",
40
						"<div class='thumb'><img src='{url}' title='{nom}'></div>",
41
						"<span>{nom}</span></div>", "</tpl>",
42
						"<div class='x-clear'></div>"});
43
		template.compile();
44
 
45
		// la dataview affichera les images en accord avec le template
46
		// cree precedemment
47
		dView = new DataView("div.thumb-wrap") {
48
			public void prepareData(Data data) {
49
				data.setProperty("shortName", Format.ellipsis(data
50
						.getProperty("name"), 15));
51
			}
52
		};
53
		dView.setTpl(template);
54
 
55
		// parametre d'affichage de la dataview
56
		dView.setAutoHeight(true);
57
		dView.setMultiSelect(true);
58
		dView.setOverCls("x-view-over");
59
		dView.setEmptyText("Aucune image à afficher");
60
 
61
 
62
		// creation du store
63
		FieldDef defNumImage = new StringFieldDef("num_image");
64
		FieldDef defUrlImage = new StringFieldDef("url_image");
65
		FieldDef[] defTab = {defNumImage,defUrlImage};
66
		RecordDef rd = new RecordDef(defTab) ;
67
		st = new Store(rd) ;
68
		dView.setStore(st);
69
 
70
		// ajouts de la gestion des evenements pour la dataview
71
		ajouterListeners();
72
 
73
		this.add(dView);
74
 
75
	}
76
 
77
 
78
	public void ajouterListeners()
79
	{
80
		// ajout de listeners pour la gestion de la selection
81
		// dans la galerie
82
		dView.addListener(new DataViewListenerAdapter() {
83
 
84
 
85
 
86
			public void onClick(DataView source, int index, Element node,
87
					EventObject e) {
88
				//TODO: appeler le mediateur
89
 
90
			}
91
 
92
 
93
			public void onContainerClick(DataView source, EventObject e) {
94
				//TODO: appeler le mediateur
95
 
96
			}
97
 
98
 
99
			public void onContextMenu(DataView source, int index, Element node,
100
					EventObject e) {
101
				//TODO: appeler le mediateur
102
 
103
			}
104
 
105
 
106
			public void onDblClick(DataView source, int index, Element node,
107
					EventObject e) {
108
				//TODO: appeler le mediateur
109
 
110
			}
111
 
112
 
113
			public void onSelectionChange(DataView view, Element[] selections) {
114
				//TODO: appeler le mediateur
115
 
116
			}
117
 
118
		});
119
	}
120
 
121
 
122
 
123
	public void rafraichir(Object nouvelleDonnees) {
124
		// TODO Auto-generated method stub
125
 
126
	}
127
}