Subversion Repositories eFlore/Archives.cel-v2

Rev

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

Rev 30 Rev 32
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.GridView;
28
import com.gwtext.client.widgets.grid.GridView;
28
import com.gwtext.client.widgets.grid.PropertyGridPanel;
29
import com.gwtext.client.widgets.grid.PropertyGridPanel;
-
 
30
import com.gwtext.client.widgets.grid.event.GridCellListener;
29
import com.gwtext.client.widgets.layout.RowLayout;
31
import com.gwtext.client.widgets.layout.RowLayout;
30
import com.gwtext.client.widgets.layout.RowLayoutData;
32
import com.gwtext.client.widgets.layout.RowLayoutData;
31
import com.gwtext.client.widgets.layout.VerticalLayout;
33
import com.gwtext.client.widgets.layout.VerticalLayout;
32
import com.gwtext.client.widgets.menu.DateItem;
34
import com.gwtext.client.widgets.menu.DateItem;
33
import com.gwtext.client.widgets.menu.Menu;
35
import com.gwtext.client.widgets.menu.Menu;
34
import com.gwtext.client.widgets.tree.TreeNode;
36
import com.gwtext.client.widgets.tree.TreeNode;
35
import com.gwtext.client.widgets.tree.TreePanel;
37
import com.gwtext.client.widgets.tree.TreePanel;
36
 
38
 
37
public class PanneauMetadonneesVue extends TabPanel implements Rafraichissable {
39
public class PanneauMetadonneesVue extends TabPanel implements Rafraichissable {
38
 
40
 
39
	private ImageMediateur imediateur = null ;
41
	private ImageMediateur imediateur = null ;
40
	
42
	
41
	private PropertyGridPanel ExifGrid = null ;
43
	private PropertyGridPanel ExifGrid = null ;
42
	private PropertyGridPanel IptcGrid = null ;
44
	private PropertyGridPanel IptcGrid = null ;
43
	
45
	
44
	private GridView gViewExif = null ;
46
	private GridView gViewExif = null ;
45
	private GridView gViewIptc = null ;
47
	private GridView gViewIptc = null ;
46
	
48
	
47
	private Panel panneauExifGrid = null; 
49
	private Panel panneauExifGrid = null; 
48
	private Panel panneauIptcGrid = null ;
50
	private Panel panneauIptcGrid = null ;
49
	private Panel panneauInfoGrid = null ;
51
	private Panel panneauInfoGrid = null ;
50
	private ArbreMotsClesVue panneauMotsCles = null ;
52
	private ArbreMotsClesVue panneauMotsCles = null ;
51
	
53
	
52
	private TextField commentaireGeneral = null ;
54
	private TextField commentaireGeneral = null ;
53
	private DateField dateImage = null ;
55
	private DateField dateImage = null ;
54
	Button validerInfo = null ;
56
	Button validerInfo = null ;
55
	
57
	
56
	boolean estInstancie = false ;
58
	boolean estInstancie = false ;
57
	
59
	
58
	public PanneauMetadonneesVue(ImageMediateur im)
60
	public PanneauMetadonneesVue(ImageMediateur im)
59
	{
61
	{
60
		super() ;
62
		super() ;
61
		
63
		
62
		imediateur = im ;
64
		imediateur = im ;
63
		
65
		
64
		panneauExifGrid = new Panel("Exif") ;
66
		panneauExifGrid = new Panel("Exif") ;
65
		panneauIptcGrid = new Panel("Iptc") ;
67
		panneauIptcGrid = new Panel("Iptc") ;
66
		panneauInfoGrid = new Panel("info") ;
68
		panneauInfoGrid = new Panel("info") ;
67
		panneauMotsCles = new ArbreMotsClesVue(im) ;
69
		panneauMotsCles = new ArbreMotsClesVue(im) ;
68
		
70
		
69
		panneauInfoGrid.setLayout(new VerticalLayout());
71
		panneauInfoGrid.setLayout(new VerticalLayout());
70
		panneauInfoGrid.setHeight(500);
72
		panneauInfoGrid.setHeight(500);
71
		Label labelComm = new Label("Commentaires :") ;
73
		Label labelComm = new Label("Commentaires :") ;
72
		labelComm.setHeight("20px") ;
74
		labelComm.setHeight("20px") ;
73
		commentaireGeneral = new TextArea() ;
75
		commentaireGeneral = new TextArea() ;
74
		commentaireGeneral.setAutoWidth(true) ;
76
		commentaireGeneral.setAutoWidth(true) ;
75
		Label labelDate = new Label("Date :") ;
77
		Label labelDate = new Label("Date :") ;
76
		
78
		
77
		labelDate.setHeight("20px") ;
79
		labelDate.setHeight("20px") ;
78
		
80
		
79
		dateImage = new DateField() ;
81
		dateImage = new DateField() ;
80
		dateImage.setAutoWidth(true) ;
82
		dateImage.setAutoWidth(true) ;
81
		dateImage.setFormat("d/m/y") ;
83
		dateImage.setFormat("d/m/y") ;
82
		
84
		
83
		validerInfo = new Button("OK") ;
85
		validerInfo = new Button("OK") ;
84
		validerInfo.addListener(new ButtonListenerAdapter() {
86
		validerInfo.addListener(new ButtonListenerAdapter() {
85
 
87
 
86
			public void onClick(Button button, EventObject e) {
88
			public void onClick(Button button, EventObject e) {
87
				
89
				
88
				getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue()) ;
90
				getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue()) ;
89
				
91
				
90
			}	
92
			}	
91
		});
93
		});
92
		
94
		
93
		panneauInfoGrid.add(labelComm) ;
95
		panneauInfoGrid.add(labelComm) ;
94
		panneauInfoGrid.add(commentaireGeneral) ;
96
		panneauInfoGrid.add(commentaireGeneral) ;
95
		panneauInfoGrid.add(labelDate) ;
97
		panneauInfoGrid.add(labelDate) ;
96
		panneauInfoGrid.add(dateImage) ;
98
		panneauInfoGrid.add(dateImage) ;
97
		panneauInfoGrid.add(validerInfo) ;
99
		panneauInfoGrid.add(validerInfo) ;
98
		
100
		
99
		
101
		
100
		
102
		
101
		this.add(panneauInfoGrid) ;
103
		this.add(panneauInfoGrid) ;
102
		this.add(panneauExifGrid) ;
104
		this.add(panneauExifGrid) ;
103
		this.add(panneauIptcGrid) ;
105
		this.add(panneauIptcGrid) ;
104
		this.add(panneauMotsCles) ;
106
		this.add(panneauMotsCles) ;
105
		
107
		
106
		gViewExif = new GridView();
108
		gViewExif = new GridView();
107
		gViewExif.setForceFit(true);
109
		gViewExif.setForceFit(true);
108
		
110
		
109
		ExifGrid = new PropertyGridPanel() ;
111
		ExifGrid = new PropertyGridPanel() ;
110
		ExifGrid.setId("meta_exif");
112
		ExifGrid.setId("meta_exif");
111
		ExifGrid.setView(gViewExif);
113
		ExifGrid.setView(gViewExif);
112
		ExifGrid.setNameText("Métadonnées Exif");
114
		ExifGrid.setNameText("Métadonnées Exif");
113
		ExifGrid.setAutoWidth(true);
115
		ExifGrid.setAutoWidth(true);
114
		ExifGrid.setAutoHeight(true);
116
		ExifGrid.setAutoHeight(true);
115
		ExifGrid.setSorted(false);
117
		ExifGrid.setSorted(false);
-
 
118
		ExifGrid.addGridCellListener(new GridCellListener() {
-
 
119
 
-
 
120
			public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
-
 
121
					EventObject e) {
-
 
122
				
-
 
123
				e.stopEvent() ;
116
		ExifGrid.setDisableSelection(true);
124
				ExifGrid.stopEditing() ;
-
 
125
				
-
 
126
			}
-
 
127
 
-
 
128
			public void onCellContextMenu(GridPanel grid, int rowIndex,
-
 
129
					int cellIndex, EventObject e) {
-
 
130
				// TODO Auto-generated method stub
-
 
131
				
-
 
132
			}
-
 
133
 
-
 
134
			public void onCellDblClick(GridPanel grid, int rowIndex,
-
 
135
					int colIndex, EventObject e) {
-
 
136
				
-
 
137
				e.stopEvent() ;
-
 
138
				ExifGrid.stopEditing() ;
-
 
139
				
-
 
140
			}
-
 
141
			
-
 
142
		}) ;
117
		
143
		
118
		gViewIptc = new GridView();
144
		gViewIptc = new GridView();
119
		gViewIptc.setForceFit(true);
145
		gViewIptc.setForceFit(true);
120
		
146
		
121
		IptcGrid = new PropertyGridPanel() ;
147
		IptcGrid = new PropertyGridPanel() ;
122
		IptcGrid.setId("meta_iptc");
148
		IptcGrid.setId("meta_iptc");
123
		IptcGrid.setView(gViewIptc);
149
		IptcGrid.setView(gViewIptc);
124
		
150
		
125
		IptcGrid.setNameText("Métadonnées IPTC");
151
		IptcGrid.setNameText("Métadonnées IPTC");
126
		IptcGrid.setAutoWidth(true);
152
		IptcGrid.setAutoWidth(true);
127
		IptcGrid.setAutoHeight(true);
153
		IptcGrid.setAutoHeight(true);
128
		IptcGrid.setSorted(false);
154
		IptcGrid.setSorted(false);
-
 
155
		IptcGrid.addGridCellListener(new GridCellListener() {
-
 
156
 
-
 
157
			public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
-
 
158
					EventObject e) {
-
 
159
				
-
 
160
				e.stopEvent() ;
-
 
161
				ExifGrid.stopEditing() ;
-
 
162
				
-
 
163
			}
-
 
164
 
-
 
165
			public void onCellContextMenu(GridPanel grid, int rowIndex,
-
 
166
					int cellIndex, EventObject e) {
-
 
167
				// TODO Auto-generated method stub
-
 
168
				
-
 
169
			}
-
 
170
 
-
 
171
			public void onCellDblClick(GridPanel grid, int rowIndex,
-
 
172
					int colIndex, EventObject e) {
-
 
173
				
-
 
174
				e.stopEvent() ;
-
 
175
				ExifGrid.stopEditing() ;
-
 
176
				
-
 
177
			}
-
 
178
			
-
 
179
		}) ;
129
		
180
		
130
		panneauExifGrid.add(ExifGrid);
181
		panneauExifGrid.add(ExifGrid);
131
		panneauIptcGrid.add(IptcGrid);
182
		panneauIptcGrid.add(IptcGrid);
132
		
183
		
133
		this.doLayout(true) ;
184
		this.doLayout(true) ;
134
		
185
		
135
	}
186
	}
136
	
187
	
137
	public void desactiverPanneau()
188
	public void desactiverPanneau()
138
	{
189
	{
139
		this.setDisabled(true) ;
190
		this.setDisabled(true) ;
140
	}
191
	}
141
	
192
	
142
	public void activerPanneau()
193
	public void activerPanneau()
143
	{
194
	{
144
		this.setDisabled(false) ;
195
		this.setDisabled(false) ;
145
	}
196
	}
146
	
197
	
147
	public ImageMediateur getIMediateur()
198
	public ImageMediateur getIMediateur()
148
	{
199
	{
149
		return imediateur ;
200
		return imediateur ;
150
	}
201
	}
151
	
202
	
152
	
203
	
153
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
204
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
154
		
205
		
155
		if(nouvelleDonnees instanceof Object[])
206
		if(nouvelleDonnees instanceof Object[])
156
		{
207
		{
157
			Object meta[] = (Object[])nouvelleDonnees ;
208
			Object meta[] = (Object[])nouvelleDonnees ;
158
			String[][] exif = (String[][])meta[0] ;
209
			String[][] exif = (String[][])meta[0] ;
159
			String[][] iptc = (String[][])meta[1] ;
210
			String[][] iptc = (String[][])meta[1] ;
160
			String[][] gen = (String[][])meta[2] ;
211
			String[][] gen = (String[][])meta[2] ;
161
			
212
			
162
			NameValuePair[] exifSource = new NameValuePair[exif.length] ;
213
			NameValuePair[] exifSource = new NameValuePair[exif.length] ;
163
			NameValuePair[] iptcSource = new NameValuePair[iptc.length] ;
214
			NameValuePair[] iptcSource = new NameValuePair[iptc.length] ;
164
			
215
			
165
			
216
			
166
			int maxLength ;
217
			int maxLength ;
167
			if(exif.length <= iptc.length)
218
			if(exif.length <= iptc.length)
168
			{
219
			{
169
				maxLength = iptc.length ;
220
				maxLength = iptc.length ;
170
			}
221
			}
171
			else
222
			else
172
			{
223
			{
173
				maxLength = exif.length ;
224
				maxLength = exif.length ;
174
			}
225
			}
175
			
226
			
176
			for(int i = 0; i < maxLength ; i++)
227
			for(int i = 0; i < maxLength ; i++)
177
			{
228
			{
178
				if(i < exif.length)
229
				if(i < exif.length)
179
				{
230
				{
180
					exifSource[i] = new NameValuePair(exif[i][0],exif[i][1]) ;
231
					exifSource[i] = new NameValuePair(exif[i][0],exif[i][1]) ;
181
				}
232
				}
182
				
233
				
183
				if(i < iptc.length)
234
				if(i < iptc.length)
184
				{
235
				{
185
					iptcSource[i] = new NameValuePair(iptc[i][0],iptc[i][1]) ;
236
					iptcSource[i] = new NameValuePair(iptc[i][0],iptc[i][1]) ;
186
				}
237
				}
187
			}
238
			}
188
			
239
			
189
			commentaireGeneral.setValue(gen[0][1]) ;
240
			commentaireGeneral.setValue(gen[0][1]) ;
190
			
241
			
191
			dateImage.setValue(gen[1][1]) ;
242
			dateImage.setValue(gen[1][1]) ;
192
			
243
			
193
			ExifGrid.setSource(exifSource);
244
			ExifGrid.setSource(exifSource);
194
			IptcGrid.setSource(iptcSource);
245
			IptcGrid.setSource(iptcSource);
195
 
246
 
196
		}	
247
		}	
197
	}
248
	}
198
 
249
 
199
	/**
250
	/**
200
	 * @return the panneauMotsCles
251
	 * @return the panneauMotsCles
201
	 */
252
	 */
202
	public ArbreMotsClesVue getPanneauMotsCles() {
253
	public ArbreMotsClesVue getPanneauMotsCles() {
203
		return panneauMotsCles;
254
		return panneauMotsCles;
204
	}
255
	}
205
}
256
}