Subversion Repositories eFlore/Archives.cel-v2

Rev

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

Rev 5 Rev 6
1
 
1
 
2
package org.tela_botanica.client.vues;
2
package org.tela_botanica.client.vues;
3
 
3
 
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
 
7
 
-
 
8
 
8
 
9
import com.google.gwt.user.client.Window;
9
import com.gwtext.client.data.ArrayReader;
10
import com.gwtext.client.data.ArrayReader;
10
import com.gwtext.client.data.FieldDef;
11
import com.gwtext.client.data.FieldDef;
11
import com.gwtext.client.data.MemoryProxy;
12
import com.gwtext.client.data.MemoryProxy;
12
import com.gwtext.client.data.Record;
13
import com.gwtext.client.data.Record;
13
import com.gwtext.client.data.RecordDef;
14
import com.gwtext.client.data.RecordDef;
14
import com.gwtext.client.data.Store;
15
import com.gwtext.client.data.Store;
15
import com.gwtext.client.data.StoreMgr;
16
import com.gwtext.client.data.StoreMgr;
16
import com.gwtext.client.data.StringFieldDef;
17
import com.gwtext.client.data.StringFieldDef;
17
import com.gwtext.client.widgets.Component;
18
import com.gwtext.client.widgets.Component;
-
 
19
import com.gwtext.client.widgets.event.ContainerListener;
18
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
20
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
19
import com.gwtext.client.widgets.event.PanelListener;
21
import com.gwtext.client.widgets.event.PanelListener;
20
import com.gwtext.client.widgets.event.PanelListenerAdapter;
22
import com.gwtext.client.widgets.event.PanelListenerAdapter;
21
import com.gwtext.client.widgets.grid.CellMetadata;
23
import com.gwtext.client.widgets.grid.CellMetadata;
22
import com.gwtext.client.widgets.grid.ColumnConfig;
24
import com.gwtext.client.widgets.grid.ColumnConfig;
23
import com.gwtext.client.widgets.grid.ColumnModel;
25
import com.gwtext.client.widgets.grid.ColumnModel;
24
import com.gwtext.client.widgets.grid.GridPanel;
26
import com.gwtext.client.widgets.grid.GridPanel;
-
 
27
import com.gwtext.client.widgets.grid.GridView;
25
import com.gwtext.client.widgets.grid.Renderer;
28
import com.gwtext.client.widgets.grid.Renderer;
26
import com.gwtextux.client.data.BufferedStore;
29
import com.gwtextux.client.data.BufferedStore;
27
 
30
 
28
public class ListeImageVue extends GridPanel implements Rafraichissable {
31
public class ListeImageVue extends GridPanel implements Rafraichissable {
29
	
32
	
30
	
33
	
31
	
34
	
32
	// instance du médiateur
35
	// instance du médiateur
33
	private ImageMediateur iMediateur = null; 
36
	private ImageMediateur iMediateur = null; 
34
	
37
	
35
	
38
	
36
	private ColumnConfig numImage ;
39
	private ColumnConfig numImage ;
37
	private ColumnConfig urlImage ;
40
	private ColumnConfig urlImage ;
38
	private ColumnModel modeleColonnes ;
41
	private ColumnModel modeleColonnes ;
39
	
42
	
40
	
43
	
41
	
44
	
42
	// données locales
45
	// données locales
43
	// store qui gère les données de la liste d'images
46
	// store qui gère les données de la liste d'images
44
	private Store st = null ;
47
	private Store st = null ;
45
	private ColumnConfig cl = null ;
48
	private ColumnConfig cl = null ;
46
	
49
	
47
	
50
	
48
	public ListeImageVue(ImageMediateur im) {
51
	public ListeImageVue(ImageMediateur im) {
49
		
52
		
50
		this.iMediateur = im ;
53
		this.iMediateur = im ;
51
		
54
		
52
		
55
		
53
		setAutoWidth(true);
56
		setAutoWidth(true);
54
		setAutoHeight(true);
57
		setAutoHeight(true);
55
		
58
		
56
		numImage = new ColumnConfig("numéro d'image","num_image",150,true);		
59
		numImage = new ColumnConfig("numéro d'image","num_image",150,true);		
57
		urlImage = new ColumnConfig("Image","url_image",150,true,new Renderer() {
60
		urlImage = new ColumnConfig("Image","url_image",150,true,new Renderer() {
58
 
61
 
59
			public String render(Object value, CellMetadata cellMetadata,
62
			public String render(Object value, CellMetadata cellMetadata,
60
					Record record, int rowIndex, int colNum, Store store) {
63
					Record record, int rowIndex, int colNum, Store store) {
61
 
64
 
62
				String ImgUrl = record.getAsString("url_image");
65
				String ImgUrl = record.getAsString("url_image");
63
				return "<img src=\""+ImgUrl+"\" title='example'>";
66
				return "<div class=\"img-list\"> <img src=\""+ImgUrl+"\" title='example'> </div>";
64
			}
67
			}
65
 
68
 
66
		});
69
		});
67
		
70
		
68
		ColumnConfig[] cm = {numImage,urlImage};
71
		ColumnConfig[] cm = {numImage,urlImage};
69
		modeleColonnes = new ColumnModel(cm);
72
		modeleColonnes = new ColumnModel(cm);
70
		this.setColumnModel(modeleColonnes);
73
		this.setColumnModel(modeleColonnes);
-
 
74
		this.setAutoScroll(true);
71
		
75
		
72
		
76
		
73
		FieldDef defNumImage = new StringFieldDef("num_image");
77
		FieldDef defNumImage = new StringFieldDef("num_image");
74
		FieldDef defUrlImage = new StringFieldDef("url_image");
78
		FieldDef defUrlImage = new StringFieldDef("url_image");
75
		FieldDef[] defTab = {defNumImage,defUrlImage};
79
		FieldDef[] defTab = {defNumImage,defUrlImage};
76
		RecordDef rd = new RecordDef(defTab) ;
80
		RecordDef rd = new RecordDef(defTab) ;
77
		st = new Store(rd) ;
81
		st = new Store(rd) ;
78
		this.setStore(st);
82
		this.setStore(st);
79
		
83
		
80
		ajouterListeners() ;
84
		ajouterListeners() ;
-
 
85
		
81
	}
86
	}
82
	
87
	
83
	
88
	
84
	// role : configurer les colonnes affichées dans la grille
89
	// role : configurer les colonnes affichées dans la grille
85
	private void initialiser() {
90
	private void initialiser() {
86
		
91
		
87
		getIMediateur().ObtenirPhotoGalerie(this);
92
		getIMediateur().obtenirPhotoGalerie(this);
88
		
93
		
89
		
94
		
90
	}
95
	}
91
	
96
	
92
	public void ajouterListeners()
97
	public void ajouterListeners()
93
	{
98
	{
94
		this.addListener(new ContainerListenerAdapter() {
99
		this.addListener(new ContainerListenerAdapter() {
95
 
100
 
-
 
101
 
-
 
102
			public boolean doBeforeRender(Component component)
-
 
103
			{
-
 
104
				initialiser();
-
 
105
				return true ;
-
 
106
			}
96
 
107
			
97
			public void onHide(Component component) {
108
			public void onHide(Component component) {
98
				// TODO Auto-generated method stub
109
				// TODO Auto-generated method stub
99
				
110
				
100
			}
111
			}
101
 
112
 
102
 
113
 
103
			public void onRender(Component component) {
114
			public void onRender(Component component) {
104
				// TODO Auto-generated method stub
115
				// TODO Auto-generated method stub
105
				
116
				
106
			}
117
			}
107
 
118
 
108
 
119
 
109
			public void onShow(Component component) {
120
			public void onShow(Component component) {
110
				
-
 
111
				
-
 
112
					initialiser();
121
				
113
			}
122
			}
114
			
123
			
115
		});
124
		});
116
	}
125
	}
117
 
126
 
118
 
127
 
119
	public void rafraichir(Object nouvelleDonnees) {
128
	public void rafraichir(Object nouvelleDonnees) {
120
		// TODO Auto-generated method stub
-
 
121
		
129
		
-
 
130
		Object[][] photoData = (Object[][])nouvelleDonnees ;
122
		Object[][] photoData = (Object[][])nouvelleDonnees ;
131
 
123
		final MemoryProxy dataProxy = new MemoryProxy(photoData);
132
		final MemoryProxy dataProxy = new MemoryProxy(photoData);
124
		final ArrayReader reader = new ArrayReader(new RecordDef(
133
		final ArrayReader reader = new ArrayReader(new RecordDef(
125
				new FieldDef[]{new StringFieldDef("num_image"),
134
				new FieldDef[]{new StringFieldDef("num_image"),
126
						new StringFieldDef("url_image")}));
135
						new StringFieldDef("url_image")}));
127
 
136
 
128
		final Store photoStore = new Store(dataProxy, reader);
137
		final Store photoStore = new Store(dataProxy, reader);
129
		photoStore.load();
-
 
130
 
138
 
131
		st = photoStore;
139
		st = photoStore;
-
 
140
		this.reconfigure(st, this.getColumnModel());
132
		this.reconfigure(st, modeleColonnes);
141
		photoStore.load();
133
	}
142
	}
134
 
143
 
135
 
144
 
136
	public ImageMediateur getIMediateur() {
145
	public ImageMediateur getIMediateur() {
137
		return iMediateur;
146
		return iMediateur;
138
	}
147
	}
139
 
148
 
140
 
149
 
141
	public ColumnConfig getNumImage() {
150
	public ColumnConfig getNumImage() {
142
		return numImage;
151
		return numImage;
143
	}
152
	}
144
 
153
 
145
 
154
 
146
	public ColumnConfig getUrlImage() {
155
	public ColumnConfig getUrlImage() {
147
		return urlImage;
156
		return urlImage;
148
	}
157
	}
149
 
158
 
150
 
159
 
151
	public ColumnModel getModeleColonnes() {
160
	public ColumnModel getModeleColonnes() {
152
		return modeleColonnes;
161
		return modeleColonnes;
153
	}
162
	}
154
 
163
 
155
 
164
 
156
	public Store getSt() {
165
	public Store getSt() {
157
		return st;
166
		return st;
158
	}
167
	}
159
 
168
 
160
 
169
 
161
	public ColumnConfig getCl() {
170
	public ColumnConfig getCl() {
162
		return cl;
171
		return cl;
163
	}
172
	}
164
	
173
	
165
	
174
	
166
 
175
 
167
}
176
}