Subversion Repositories eFlore/Archives.cel-v2

Rev

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

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