Subversion Repositories eFlore/Archives.cel-v2

Rev

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

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