Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 47 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 47 Rev 48
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
import org.tela_botanica.client.image.ImageMediateur;
3
import org.tela_botanica.client.image.ImageMediateur;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
 
5
 
6
import com.google.gwt.user.client.ui.Label;
6
import com.google.gwt.user.client.ui.Label;
7
import com.gwtext.client.core.EventObject;
7
import com.gwtext.client.core.EventObject;
8
import com.gwtext.client.core.NameValuePair;
8
import com.gwtext.client.core.NameValuePair;
9
import com.gwtext.client.widgets.Button;
9
import com.gwtext.client.widgets.Button;
10
import com.gwtext.client.widgets.Panel;
10
import com.gwtext.client.widgets.Panel;
11
import com.gwtext.client.widgets.TabPanel;
11
import com.gwtext.client.widgets.TabPanel;
12
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
12
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
13
import com.gwtext.client.widgets.form.DateField;
13
import com.gwtext.client.widgets.form.DateField;
14
import com.gwtext.client.widgets.form.TextArea;
14
import com.gwtext.client.widgets.form.TextArea;
15
import com.gwtext.client.widgets.form.TextField;
15
import com.gwtext.client.widgets.form.TextField;
16
import com.gwtext.client.widgets.grid.GridPanel;
16
import com.gwtext.client.widgets.grid.GridPanel;
17
import com.gwtext.client.widgets.grid.GridView;
17
import com.gwtext.client.widgets.grid.GridView;
18
import com.gwtext.client.widgets.grid.PropertyGridPanel;
18
import com.gwtext.client.widgets.grid.PropertyGridPanel;
19
import com.gwtext.client.widgets.grid.event.GridCellListenerAdapter;
19
import com.gwtext.client.widgets.grid.event.GridCellListenerAdapter;
20
import com.gwtext.client.widgets.layout.VerticalLayout;
20
import com.gwtext.client.widgets.layout.VerticalLayout;
21
 
21
 
22
/**
22
/**
23
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
23
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
24
 * @author aurelien
24
 * @author aurelien
25
 *
25
 *
26
 */
26
 */
27
public class PanneauMetadonneesVue extends TabPanel implements Rafraichissable {
27
public class PanneauMetadonneesVue extends TabPanel implements Rafraichissable {
28
 
28
 
29
	/**
29
	/**
30
	 * Le médiateur associé à la vue
30
	 * Le médiateur associé à la vue
31
	 */
31
	 */
32
	private ImageMediateur imediateur = null ;
32
	private ImageMediateur imediateur = null ;
33
	/**
33
	/**
34
	 * Le panneau des Exifs
34
	 * Le panneau des Exifs
35
	 */
35
	 */
36
	private PropertyGridPanel ExifGrid = null ;
36
	private PropertyGridPanel ExifGrid = null ;
37
	/**
37
	/**
38
	 * Le panneau des Iptc
38
	 * Le panneau des Iptc
39
	 */
39
	 */
40
	private PropertyGridPanel IptcGrid = null ;
40
	private PropertyGridPanel IptcGrid = null ;
41
	
41
	
42
	/**
42
	/**
43
	 * La grille pour le panneau des Exifs
43
	 * La grille pour le panneau des Exifs
44
	 */
44
	 */
45
	private GridView gViewExif = null ;
45
	private GridView gViewExif = null ;
46
	/**
46
	/**
47
	 * La grille pour le panneau de Iptc
47
	 * La grille pour le panneau de Iptc
48
	 */
48
	 */
49
	private GridView gViewIptc = null ;
49
	private GridView gViewIptc = null ;
50
	
50
	
51
	/**
51
	/**
52
	 * L'onglet des Exifs
52
	 * L'onglet des Exifs
53
	 */
53
	 */
54
	private Panel panneauExifGrid = null; 
54
	private Panel panneauExifGrid = null; 
55
	/**
55
	/**
56
	 * L'onglet des Iptc
56
	 * L'onglet des Iptc
57
	 */
57
	 */
58
	private Panel panneauIptcGrid = null ;
58
	private Panel panneauIptcGrid = null ;
59
	/**
59
	/**
60
	 * L'onglet des infos
60
	 * L'onglet des infos
61
	 */
61
	 */
62
	private Panel panneauInfoGrid = null ;
62
	private Panel panneauInfoGrid = null ;
63
	/**
63
	/**
64
	 * L'onglet des mots clés
64
	 * L'onglet des mots clés
65
	 */
65
	 */
66
	private ArbreMotsClesVue panneauMotsCles = null ;
66
	private ArbreMotsClesVue panneauMotsCles = null ;
67
	
67
	
68
	/**
68
	/**
69
	 * Le champ commentaire
69
	 * Le champ commentaire
70
	 */
70
	 */
71
	private TextField commentaireGeneral = null ;
71
	private TextField commentaireGeneral = null ;
72
	/**
72
	/**
73
	 * Le champ date
73
	 * Le champ date
74
	 */
74
	 */
75
	private DateField dateImage = null ;
75
	private DateField dateImage = null ;
76
	/**
76
	/**
77
	 * Le bouton de validation
77
	 * Le bouton de validation
78
	 */
78
	 */
79
	Button validerInfo = null ;
79
	Button validerInfo = null ;
80
	
80
	
81
	/**
81
	/**
82
	 * Barre de notation
82
	 * Barre de notation
83
	 */
83
	 */
84
	BarreNotationVue noteVue = null ;
84
	BarreNotationVue noteVue = null ;
85
	
85
	
86
	/**
86
	/**
87
	 * Booleen d'instanciation
87
	 * Booleen d'instanciation
88
	 */
88
	 */
89
	boolean estInstancie = false ;
89
	boolean estInstancie = false ;
90
	
90
	
91
	/**
91
	/**
92
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
92
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
93
	 */
93
	 */
94
	private PanneauMetadonneesVue()
94
	private PanneauMetadonneesVue()
95
	{
95
	{
96
		super() ;
96
		super() ;
97
	}
97
	}
98
	
98
	
99
	/**
99
	/**
100
	 * Constructeur avec argument
100
	 * Constructeur avec argument
101
	 * @param im
101
	 * @param im
102
	 */
102
	 */
103
	public PanneauMetadonneesVue(ImageMediateur im)
103
	public PanneauMetadonneesVue(ImageMediateur im)
104
	{
104
	{
105
		super() ;
105
		super() ;
106
		
106
		
107
		// on associe le médiateur
107
		// on associe le médiateur
108
		imediateur = im ;
108
		imediateur = im ;
109
		
109
		
110
		// on crée et dispose les panneaux et les champs
110
		// on crée et dispose les panneaux et les champs
111
		panneauExifGrid = new Panel("Exif") ;
111
		panneauExifGrid = new Panel("Exif") ;
112
		panneauIptcGrid = new Panel("Iptc") ;
112
		panneauIptcGrid = new Panel("Iptc") ;
113
		panneauInfoGrid = new Panel("info") ;
113
		panneauInfoGrid = new Panel("info") ;
114
		panneauMotsCles = new ArbreMotsClesVue(im) ;
114
		panneauMotsCles = new ArbreMotsClesVue(im) ;
115
		
115
		
116
		
116
		
117
		Panel sousPanneauInfosGenerales = new Panel("Infos Générales") ;
117
		Panel sousPanneauInfosGenerales = new Panel("Infos Générales") ;
118
		sousPanneauInfosGenerales.setLayout(new VerticalLayout());
118
		sousPanneauInfosGenerales.setLayout(new VerticalLayout());
119
		sousPanneauInfosGenerales.setBorder(false) ;
119
		sousPanneauInfosGenerales.setBorder(false) ;
120
		sousPanneauInfosGenerales.setHeight(200);
120
		sousPanneauInfosGenerales.setHeight(200);
121
		sousPanneauInfosGenerales.setAutoWidth(true) ;
121
		sousPanneauInfosGenerales.setAutoWidth(true) ;
122
		sousPanneauInfosGenerales.setMargins(5) ;
122
		sousPanneauInfosGenerales.setMargins(5) ;
123
		sousPanneauInfosGenerales.setPaddings(5) ;
123
		sousPanneauInfosGenerales.setPaddings(5) ;
124
		sousPanneauInfosGenerales.setCollapsible(true) ;
124
		sousPanneauInfosGenerales.setCollapsible(true) ;
125
		
125
		
126
		Label labelComm = new Label("Commentaires :") ;
126
		Label labelComm = new Label("Commentaires :") ;
127
		labelComm.setHeight("20px") ;
127
		labelComm.setHeight("20px") ;
128
		commentaireGeneral = new TextArea() ;
128
		commentaireGeneral = new TextArea() ;
129
		commentaireGeneral.setAutoWidth(true) ;
129
		commentaireGeneral.setWidth("90%") ;
130
		Label labelDate = new Label("Date :") ;
130
		Label labelDate = new Label("Date :") ;
131
		Label labelNote = new Label("Note :") ;
131
		Label labelNote = new Label("Note :") ;
132
		
132
		
133
		labelDate.setHeight("20px") ;
133
		labelDate.setHeight("20px") ;
134
		
134
		
135
		dateImage = new DateField() ;
135
		dateImage = new DateField() ;
136
		dateImage.setAutoWidth(true) ;
136
		dateImage.setAutoWidth(true) ;
137
		dateImage.setFormat("d/m/y") ;
137
		dateImage.setFormat("d/m/y") ;
138
		
138
		
139
		validerInfo = new Button("OK") ;
139
		validerInfo = new Button("OK") ;
140
		
140
		
141
		noteVue = new BarreNotationVue(im, 5) ;
141
		noteVue = new BarreNotationVue(im, 5) ;
142
		
142
		
143
		sousPanneauInfosGenerales.add(labelComm) ;
143
		sousPanneauInfosGenerales.add(labelComm) ;
144
		sousPanneauInfosGenerales.add(commentaireGeneral) ;
144
		sousPanneauInfosGenerales.add(commentaireGeneral) ;
145
		sousPanneauInfosGenerales.add(labelDate) ;
145
		sousPanneauInfosGenerales.add(labelDate) ;
146
		sousPanneauInfosGenerales.add(dateImage) ;
146
		sousPanneauInfosGenerales.add(dateImage) ;
147
		sousPanneauInfosGenerales.add(labelNote) ;
147
		sousPanneauInfosGenerales.add(labelNote) ;
148
		sousPanneauInfosGenerales.add(noteVue) ;
148
		sousPanneauInfosGenerales.add(noteVue) ;
149
		sousPanneauInfosGenerales.add(validerInfo) ;
149
		sousPanneauInfosGenerales.add(validerInfo) ;
150
		sousPanneauInfosGenerales.setAutoHeight(true);
150
		sousPanneauInfosGenerales.setAutoHeight(true);
151
		panneauMotsCles.setAutoHeight(true) ;
151
		panneauMotsCles.setAutoHeight(true) ;
152
		
152
		
153
		panneauInfoGrid.setBorder(false);
153
		panneauInfoGrid.setBorder(false);
154
		panneauInfoGrid.setAutoHeight(true);
154
		panneauInfoGrid.setAutoHeight(true);
155
		
155
		
156
		
156
		
157
		panneauInfoGrid.add(sousPanneauInfosGenerales) ;
157
		panneauInfoGrid.add(sousPanneauInfosGenerales) ;
158
		panneauInfoGrid.add(panneauMotsCles) ;
158
		panneauInfoGrid.add(panneauMotsCles) ;
159
		
159
		
160
		
160
		
161
		this.add(panneauInfoGrid) ;
161
		this.add(panneauInfoGrid) ;
162
		this.add(panneauExifGrid) ;
162
		this.add(panneauExifGrid) ;
163
		this.add(panneauIptcGrid) ;
163
		this.add(panneauIptcGrid) ;
164
		
164
		
165
		gViewExif = new GridView();
165
		gViewExif = new GridView();
166
		gViewExif.setForceFit(true);
166
		gViewExif.setForceFit(true);
167
		
167
		
168
		ExifGrid = new PropertyGridPanel() ;
168
		ExifGrid = new PropertyGridPanel() ;
169
		ExifGrid.setId("meta_exif");
169
		ExifGrid.setId("meta_exif");
170
		ExifGrid.setView(gViewExif);
170
		ExifGrid.setView(gViewExif);
171
		ExifGrid.setNameText("Métadonnées Exif");
171
		ExifGrid.setNameText("Métadonnées Exif");
172
		ExifGrid.setAutoWidth(true);
172
		ExifGrid.setAutoWidth(true);
173
		ExifGrid.setAutoHeight(true);
173
		ExifGrid.setAutoHeight(true);
174
		ExifGrid.setSorted(false);
174
		ExifGrid.setSorted(false);
175
		
175
		
176
		gViewIptc = new GridView();
176
		gViewIptc = new GridView();
177
		gViewIptc.setForceFit(true);
177
		gViewIptc.setForceFit(true);
178
		
178
		
179
		IptcGrid = new PropertyGridPanel() ;
179
		IptcGrid = new PropertyGridPanel() ;
180
		IptcGrid.setId("meta_iptc");
180
		IptcGrid.setId("meta_iptc");
181
		IptcGrid.setView(gViewIptc);
181
		IptcGrid.setView(gViewIptc);
182
		
182
		
183
		IptcGrid.setNameText("Métadonnées IPTC");
183
		IptcGrid.setNameText("Métadonnées IPTC");
184
		IptcGrid.setAutoWidth(true);
184
		IptcGrid.setAutoWidth(true);
185
		IptcGrid.setAutoHeight(true);
185
		IptcGrid.setAutoHeight(true);
186
		IptcGrid.setSorted(false);
186
		IptcGrid.setSorted(false);
187
		
187
		
188
		
188
		
189
		panneauExifGrid.add(ExifGrid);
189
		panneauExifGrid.add(ExifGrid);
190
		panneauIptcGrid.add(IptcGrid);
190
		panneauIptcGrid.add(IptcGrid);
191
		
191
		
192
		// on ajoute les listeners
192
		// on ajoute les listeners
193
		ajouterListeners() ;
193
		ajouterListeners() ;
194
		
194
		
195
		
195
		
196
		// on effectue le rendu
196
		// on effectue le rendu
197
		this.doLayout(true) ;
197
		this.doLayout(true) ;
198
		
198
		
199
	}
199
	}
200
	
200
	
201
	private void ajouterListeners()
201
	private void ajouterListeners()
202
	{
202
	{
203
		// on ajoute un écouteur
203
		// on ajoute un écouteur
204
		validerInfo.addListener(new ButtonListenerAdapter() {
204
		validerInfo.addListener(new ButtonListenerAdapter() {
205
 
205
 
206
			// gestion du clic
206
			// gestion du clic
207
			
207
			
208
			public void onClick(Button button, EventObject e) {
208
			public void onClick(Button button, EventObject e) {
209
				
209
				
210
				// lors du clic sur le bouton valider on met à jour les commentaires et la date
210
				// lors du clic sur le bouton valider on met à jour les commentaires et la date
211
				getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue(), noteVue.getNote()) ;
211
				getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue(), noteVue.getNote()) ;
212
				
212
				
213
			}	
213
			}	
214
		});
214
		});
215
		
215
		
216
		// gestion des clics dans la grille
216
		// gestion des clics dans la grille
217
		ExifGrid.addGridCellListener(new GridCellListenerAdapter() {
217
		ExifGrid.addGridCellListener(new GridCellListenerAdapter() {
218
 
218
 
219
			// lors d'un clic d'une cellule
219
			// lors d'un clic d'une cellule
220
			
220
			
221
			public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
221
			public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
222
					EventObject e) {
222
					EventObject e) {
223
				
223
				
224
				// on empeche l'édition
224
				// on empeche l'édition
225
				e.stopEvent() ;
225
				e.stopEvent() ;
226
				ExifGrid.stopEditing() ;
226
				ExifGrid.stopEditing() ;
227
				
227
				
228
			}
228
			}
229
 
229
 
230
			// lors du double clic sur une cellule
230
			// lors du double clic sur une cellule
231
			
231
			
232
			public void onCellDblClick(GridPanel grid, int rowIndex,
232
			public void onCellDblClick(GridPanel grid, int rowIndex,
233
					int colIndex, EventObject e) {
233
					int colIndex, EventObject e) {
234
				
234
				
235
				// on empêche l'édition
235
				// on empêche l'édition
236
				e.stopEvent() ;
236
				e.stopEvent() ;
237
				ExifGrid.stopEditing() ;
237
				ExifGrid.stopEditing() ;
238
				
238
				
239
			}
239
			}
240
			
240
			
241
		}) ;
241
		}) ;
242
		
242
		
243
		IptcGrid.addGridCellListener(new GridCellListenerAdapter() {
243
		IptcGrid.addGridCellListener(new GridCellListenerAdapter() {
244
 
244
 
245
			// lors d'un clic d'une cellule
245
			// lors d'un clic d'une cellule
246
			
246
			
247
			public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
247
			public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
248
					EventObject e) {
248
					EventObject e) {
249
				// on empeche l'édition
249
				// on empeche l'édition
250
				e.stopEvent() ;
250
				e.stopEvent() ;
251
				ExifGrid.stopEditing() ;
251
				ExifGrid.stopEditing() ;
252
				
252
				
253
			}
253
			}
254
 
254
 
255
			// lors d'un double clic d'une cellule
255
			// lors d'un double clic d'une cellule
256
			
256
			
257
			public void onCellDblClick(GridPanel grid, int rowIndex,
257
			public void onCellDblClick(GridPanel grid, int rowIndex,
258
					int colIndex, EventObject e) {
258
					int colIndex, EventObject e) {
259
				// on empeche l'édition
259
				// on empeche l'édition
260
				e.stopEvent() ;
260
				e.stopEvent() ;
261
				ExifGrid.stopEditing() ;
261
				ExifGrid.stopEditing() ;
262
				
262
				
263
			}
263
			}
264
			
264
			
265
		}) ;
265
		}) ;
266
	}
266
	}
267
	
267
	
268
	/**
268
	/**
269
	 * Desactive visuellement ce panneau
269
	 * Desactive visuellement ce panneau
270
	 */
270
	 */
271
	public void desactiverPanneau()
271
	public void desactiverPanneau()
272
	{
272
	{
273
		this.setDisabled(true) ;
273
		this.setDisabled(true) ;
274
	}
274
	}
275
	
275
	
276
	/**
276
	/**
277
	 * Active visuellement ce panneau
277
	 * Active visuellement ce panneau
278
	 */
278
	 */
279
	public void activerPanneau()
279
	public void activerPanneau()
280
	{
280
	{
281
		this.setDisabled(false) ;
281
		this.setDisabled(false) ;
282
	}
282
	}
283
	
283
	
284
	/**
284
	/**
285
	 * Accesseur pour le médiateur
285
	 * Accesseur pour le médiateur
286
	 * @return le médiateur associé à la vue
286
	 * @return le médiateur associé à la vue
287
	 */
287
	 */
288
	public ImageMediateur getIMediateur()
288
	public ImageMediateur getIMediateur()
289
	{
289
	{
290
		return imediateur ;
290
		return imediateur ;
291
	}
291
	}
292
	
292
	
293
	/**
293
	/**
294
	 * Méthode héritée de l'interface rafraichissable
294
	 * Méthode héritée de l'interface rafraichissable
295
	 * @param nouvelleDonnees les nouvelles données
295
	 * @param nouvelleDonnees les nouvelles données
296
	 * @param repandreRafraichissement le booleen de notification de mise à jour
296
	 * @param repandreRafraichissement le booleen de notification de mise à jour
297
	 */
297
	 */
298
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
298
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
299
		
299
		
300
		// si on reçoit un tableau d'objets
300
		// si on reçoit un tableau d'objets
301
		if(nouvelleDonnees instanceof Object[])
301
		if(nouvelleDonnees instanceof Object[])
302
		{
302
		{
303
			// extrait infos, exifs et iptc
303
			// extrait infos, exifs et iptc
304
			Object meta[] = (Object[])nouvelleDonnees ;
304
			Object meta[] = (Object[])nouvelleDonnees ;
305
			String[][] exif = (String[][])meta[0] ;
305
			String[][] exif = (String[][])meta[0] ;
306
			String[][] iptc = (String[][])meta[1] ;
306
			String[][] iptc = (String[][])meta[1] ;
307
			String[][] gen = (String[][])meta[2] ;
307
			String[][] gen = (String[][])meta[2] ;
308
			
308
			
309
			NameValuePair[] exifSource = new NameValuePair[exif.length] ;
309
			NameValuePair[] exifSource = new NameValuePair[exif.length] ;
310
			NameValuePair[] iptcSource = new NameValuePair[iptc.length] ;
310
			NameValuePair[] iptcSource = new NameValuePair[iptc.length] ;
311
			
311
			
312
			
312
			
313
			int maxLength ;
313
			int maxLength ;
314
			if(exif.length <= iptc.length)
314
			if(exif.length <= iptc.length)
315
			{
315
			{
316
				maxLength = iptc.length ;
316
				maxLength = iptc.length ;
317
			}
317
			}
318
			else
318
			else
319
			{
319
			{
320
				maxLength = exif.length ;
320
				maxLength = exif.length ;
321
			}
321
			}
322
			
322
			
323
			for(int i = 0; i < maxLength ; i++)
323
			for(int i = 0; i < maxLength ; i++)
324
			{
324
			{
325
				if(i < exif.length)
325
				if(i < exif.length && !exif[i][0].equals("null"))
326
				{
326
				{
327
					exifSource[i] = new NameValuePair(exif[i][0],exif[i][1]) ;
327
					exifSource[i] = new NameValuePair(exif[i][0],exif[i][1]) ;
328
				}
328
				}
329
				
329
				
330
				if(i < iptc.length)
330
				if(i < iptc.length && !iptc[i][0].equals("null"))
331
				{
331
				{
332
					iptcSource[i] = new NameValuePair(iptc[i][0],iptc[i][1]) ;
332
					iptcSource[i] = new NameValuePair(iptc[i][0],iptc[i][1]) ;
333
				}
333
				}
334
			}
334
			}
335
			
335
			
336
			commentaireGeneral.setValue(gen[0][1]) ;
336
			commentaireGeneral.setValue(gen[0][1]) ;
337
			
337
			
338
			dateImage.setValue(gen[1][1]) ;
338
			dateImage.setValue(gen[1][1]) ;
339
			
339
			
340
			// et on met à jour les données pour l'affichage
340
			// et on met à jour les données pour l'affichage
341
			ExifGrid.setSource(exifSource);
341
			ExifGrid.setSource(exifSource);
342
			IptcGrid.setSource(iptcSource);
342
			IptcGrid.setSource(iptcSource);
343
 
343
 
344
		}	
344
		}	
345
	}
345
	}
346
 
346
 
347
	/**
347
	/**
348
	 * Accesseur pour le panneau des mots clés
348
	 * Accesseur pour le panneau des mots clés
349
	 * @return the panneauMotsCles
349
	 * @return the panneauMotsCles
350
	 */
350
	 */
351
	public ArbreMotsClesVue getPanneauMotsCles() {
351
	public ArbreMotsClesVue getPanneauMotsCles() {
352
		return panneauMotsCles;
352
		return panneauMotsCles;
353
	}
353
	}
354
	
354
	
355
	public BarreNotationVue getNoteVue() {
355
	public BarreNotationVue getNoteVue() {
356
		return noteVue ;
356
		return noteVue ;
357
	}
357
	}
358
}
358
}