Subversion Repositories eFlore/Archives.cel-v2

Rev

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

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