Subversion Repositories eFlore/Applications.cel

Rev

Rev 140 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 140 Rev 146
Line 3... Line 3...
3
import org.tela_botanica.client.image.ImageMediateur;
3
import org.tela_botanica.client.image.ImageMediateur;
4
import org.tela_botanica.client.interfaces.ListePaginable;
4
import org.tela_botanica.client.interfaces.ListePaginable;
5
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.interfaces.Rafraichissable;
6
import org.tela_botanica.client.interfaces.VueListable;
6
import org.tela_botanica.client.interfaces.VueListable;
Line 7... Line 7...
7
 
7
 
8
import com.google.gwt.core.client.GWT;
8
import com.google.gwt.user.client.DOM;
9
import com.google.gwt.user.client.Element;
9
import com.google.gwt.user.client.Element;
-
 
10
import com.google.gwt.user.client.Window;
10
import com.google.gwt.user.client.Window;
11
import com.google.gwt.user.client.ui.ClickListener;
-
 
12
import com.google.gwt.user.client.ui.HTML;
11
import com.google.gwt.user.client.ui.HTML;
13
import com.google.gwt.user.client.ui.Widget;
12
import com.gwtext.client.core.EventCallback;
14
import com.gwtext.client.core.EventCallback;
13
import com.gwtext.client.core.EventObject;
15
import com.gwtext.client.core.EventObject;
14
import com.gwtext.client.core.Ext;
16
import com.gwtext.client.core.Ext;
-
 
17
import com.gwtext.client.core.ExtElement;
15
import com.gwtext.client.core.ExtElement;
18
import com.gwtext.client.core.Function;
16
import com.gwtext.client.core.XTemplate;
19
import com.gwtext.client.core.XTemplate;
17
import com.gwtext.client.data.FieldDef;
20
import com.gwtext.client.data.FieldDef;
18
import com.gwtext.client.data.IntegerFieldDef;
21
import com.gwtext.client.data.IntegerFieldDef;
19
import com.gwtext.client.data.Record;
22
import com.gwtext.client.data.Record;
Line 27... Line 30...
27
import com.gwtext.client.util.Format;
30
import com.gwtext.client.util.Format;
28
import com.gwtext.client.widgets.Component;
31
import com.gwtext.client.widgets.Component;
29
import com.gwtext.client.widgets.Container;
32
import com.gwtext.client.widgets.Container;
30
import com.gwtext.client.widgets.DataView;
33
import com.gwtext.client.widgets.DataView;
31
import com.gwtext.client.widgets.Panel;
34
import com.gwtext.client.widgets.Panel;
-
 
35
import com.gwtext.client.widgets.event.ContainerListener;
32
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
36
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
33
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
37
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
-
 
38
import com.gwtext.client.widgets.event.PanelListenerAdapter;
34
import com.gwtext.client.widgets.grid.GridDragData;
39
import com.gwtext.client.widgets.grid.GridDragData;
Line 35... Line 40...
35
 
40
 
36
/**
41
/**
37
 * Galerie d'images miniatures Avec barre de pagination
42
 * Galerie d'images miniatures Avec barre de pagination
Line 66... Line 71...
66
	private boolean estInstancie = false;
71
	private boolean estInstancie = false;
Line 67... Line 72...
67
	
72
	
Line 68... Line 73...
68
	private boolean garderRatio = false;
73
	private boolean garderRatio = false;
-
 
74
	
-
 
75
	private int tailleOr = 100 ;
-
 
76
	
-
 
77
	boolean lienUploadInitialise = false ;
-
 
78
	
Line 69... Line 79...
69
	
79
	HTML videPanel = null ;
70
	private int tailleOr = 100 ;
80
 
71
 
81
 
72
	/**
82
	/**
Line 84... Line 94...
84
	 *            le médiateur avec lequel la vue va communiquer
94
	 *            le médiateur avec lequel la vue va communiquer
85
	 */
95
	 */
86
	public GalerieImageVue(ImageMediateur im) {
96
	public GalerieImageVue(ImageMediateur im) {
87
		super("Galerie");
97
		super("Galerie");
88
		iMediateur = im;
98
		iMediateur = im;
89
 
99
		
90
		// on ajoute des listeners au composant tout entier
100
		// on ajoute des listeners au composant tout entier
91
		this.addListener(new ContainerListenerAdapter() {
101
		this.addListener(new ContainerListenerAdapter() {
Line 92... Line 102...
92
 
102
 
93
			// pour gagner du temps on n'instancie la vue en elle même que lors
103
			// pour gagner du temps on n'instancie la vue en elle même que lors
Line 96... Line 106...
96
			public void onShow(Component component) {
106
			public void onShow(Component component) {
Line 97... Line 107...
97
 
107
 
98
				if (!estInstancie) {
108
				if (!estInstancie) {
99
					initialiser();
109
					initialiser();
100
				}
-
 
101
			}
-
 
102
			
-
 
Line 103... Line -...
103
			public void onAfterLayout(Container c) {
-
 
104
				
-
 
105
				ExtElement lienUpload = Ext.get("lienUpload");
-
 
106
				if(lienUpload != null) {
-
 
107
					lienUpload.addListener("click", new EventCallback() {
-
 
108
	
-
 
109
						public void execute(EventObject e) {
-
 
110
							
-
 
111
							getIMediateur().uploaderImages();
-
 
112
						}
-
 
113
						
-
 
114
					}) ;
110
				}
115
				}
-
 
116
			}
111
				
-
 
112
			}
-
 
113
		});
Line 117... Line 114...
117
 
114
		
118
		});
115
		AjouterListenersLiens();
119
 
116
 
120
		// et on ajoute la tool bar
117
		// et on ajoute la tool bar
Line 131... Line 128...
131
	 */
128
	 */
132
	public void ajouterListenersDataView() {
129
	public void ajouterListenersDataView() {
Line 133... Line 130...
133
 
130
 
134
		// ajout de listeners pour la gestion de la selection
131
		// ajout de listeners pour la gestion de la selection
-
 
132
		// dans la galerie
135
		// dans la galerie
133
		
Line 136... Line 134...
136
		dView.addListener(new DataViewListenerAdapter() {
134
		dView.addListener(new DataViewListenerAdapter() {
Line 137... Line 135...
137
 
135
 
138
			// gestion du clic sur une image
136
			// gestion du clic sur une image
139
 
137
 
140
			public void onClick(DataView source, int index, Element node,
138
			public void onClick(DataView source, int index, Element node,
141
					EventObject e) {
139
					EventObject e) {
Line 142... Line 140...
142
 
140
				
Line 181... Line 179...
181
					// et on lui demande de synchroniser la séléction avec les
179
					// et on lui demande de synchroniser la séléction avec les
182
					// autres vues
180
					// autres vues
183
					getIMediateur().synchroniserSelection("galerie");
181
					getIMediateur().synchroniserSelection("galerie");
184
				}
182
				}
185
			}
183
			}
186
 
-
 
187
		});
184
		});
188
	}
185
	}
Line 189... Line 186...
189
 
186
 
190
	/**
187
	/**
Line 283... Line 280...
283
				}
280
				}
Line 284... Line 281...
284
				
281
				
285
				data.setProperty("taille_x_s", XYresize[0]);
282
				data.setProperty("taille_x_s", XYresize[0]);
286
				data.setProperty("taille_y_s", XYresize[1]);	
283
				data.setProperty("taille_y_s", XYresize[1]);	
287
			}
-
 
288
			
284
			}
289
		};
285
		};
Line 290... Line 286...
290
		dView.setTpl(template);
286
		dView.setTpl(template);
291
 
287
 
292
		// parametre d'affichage de la dataview
288
		// parametre d'affichage de la dataview
293
		this.setAutoScroll(true);
289
		this.setAutoScroll(true);
294
		dView.setAutoHeight(true);
290
		dView.setAutoHeight(true);
295
		dView.setMultiSelect(true);
291
		dView.setMultiSelect(true);
Line 296... Line 292...
296
		dView.setOverCls("x-view-over");
292
		dView.setOverCls("x-view-over");
297
		dView.setEmptyText("<div class=\"avertissement\" >Aucune image à afficher. <a id=\"lienUpload\" href=# > Cliquez ici</a>  pour en ajouter ou allez dans le menu Fichier -> Ajouter des images </div>");
293
		dView.setEmptyText("");
298
 
294
 
299
		// creation du store
295
		// creation du store
Line 312... Line 308...
312
		st = new Store(rd);
308
		st = new Store(rd);
313
		dView.setStore(st);
309
		dView.setStore(st);
Line 314... Line 310...
314
 
310
 
Line -... Line 311...
-
 
311
		this.getDView().setLoadingText("chargement");
-
 
312
 
-
 
313
		this.add(dView);
-
 
314
		dView.hide();
-
 
315
		
-
 
316
		videPanel = new HTML("<div class=\"avertissement\" >Aucune image à afficher. <br/> <a id=\"lienUploadMultiple\" href=\"#\" > Cliquez ici pour ajouter un dossier entier ou plusieurs fichiers </a> (nécessite Java) <br/> " +
-
 
317
				"			<a id=\"lienUploadSimple\" href=\"#\" > Cliquez ici pour ajouter un fichier à la fois </a> <br/> " +
-
 
318
				"			Pour ajouter des images plus tard, allez dans le menu Fichier -> Ajouter des images </div>");
315
		this.getDView().setLoadingText("chargement");
319
		this.add(videPanel);
316
 
-
 
317
		// ajouts de la gestion des evenements pour la dataview
320
		
318
		ajouterListenersDataView();
-
 
319
		configDragAndDrop() ;
321
		// ajouts de la gestion des evenements pour la dataview
320
 
322
		configDragAndDrop() ;
321
		this.add(dView);
-
 
322
 
323
		ajouterListenersDataView();
-
 
324
		
323
		// et on déclare le composant comme instancié
325
		estInstancie = true ;
Line 324... Line 326...
324
		estInstancie = true;
326
		
325
	}
327
	}
326
	
328
	
Line 367... Line 369...
367
			if(st.getCount() != 0) {
369
			if(st.getCount() != 0) {
Line 368... Line 370...
368
				
370
				
369
				// on le charge
371
				// on le charge
Line -... Line 372...
-
 
372
				st.load();
-
 
373
	
-
 
374
				if(videPanel.isVisible()) {
-
 
375
					videPanel.setVisible(false) ;
-
 
376
				}
-
 
377
				
-
 
378
				if(!dView.isVisible()) {
370
				st.load();
379
					dView.setVisible(true);
371
	
380
				}
372
					// on l'affecte à la vue
381
					// on l'affecte à la vue
373
					dView.setStore(st);
382
					dView.setStore(st);
374
					// et on rafrachit la vue
383
					// et on rafrachit la vue
375
					dView.refresh();
384
					dView.refresh();
376
			}
385
			}
377
			else 
386
			else 
378
			{
387
			{
379
				st.removeAll();
388
				st.removeAll();
-
 
389
				st.load();
-
 
390
				dView.setStore(st);
380
				st.load();
391
				
-
 
392
				if(dView.isVisible()) {
-
 
393
					dView.hide() ;
-
 
394
				}
-
 
395
				
-
 
396
				if(!videPanel.isVisible()) {
-
 
397
					videPanel.setVisible(true);
-
 
398
					AjouterListenersLiens();
381
				dView.setStore(st);
399
				}
382
				dView.refresh();
-
 
383
			}
400
				
Line 384... Line 401...
384
 
401
			}
385
		}
402
		}
386
 
403
 
387
		// si le composant doit répandre le rafraichissement
404
		// si le composant doit répandre le rafraichissement
388
		if (repandreRafraichissement) {
405
		if (repandreRafraichissement) {
389
			// il en notifie le médiateur en lui donnant une copie des données
406
			// il en notifie le médiateur en lui donnant une copie des données
390
			// et en notifiant qu'il en est l'expéditeur
407
			// et en notifiant qu'il en est l'expéditeur
391
			getIMediateur().synchroniserDonneesZoomListeGalerie(
-
 
392
					nouvelleDonnees, this);
-
 
393
		}
-
 
394
 
-
 
395
		// si c'est la première mise à jour que l'on reçoit
-
 
396
		if (!estInstancie) {
-
 
397
			// alors le composant est considéré comme instancié
408
			getIMediateur().synchroniserDonneesZoomListeGalerie(
Line 398... Line 409...
398
			estInstancie = true;
409
					nouvelleDonnees, this);
399
		}
410
		}	
400
	}
411
	}
Line 442... Line 453...
442
        
453
        
Line 443... Line 454...
443
        int[] res = {Math.round(XYresize[0]),Math.round(XYresize[1])} ;
454
        int[] res = {Math.round(XYresize[0]),Math.round(XYresize[1])} ;
444
        
455
        
-
 
456
        return res;
-
 
457
    }
-
 
458
	
-
 
459
	private void AjouterListenersLiens() {
-
 
460
 
-
 
461
		addListener(new PanelListenerAdapter() {
-
 
462
			
-
 
463
			public void onAfterLayout(Container c) {
-
 
464
				ExtElement uploadS = Ext.get("lienUploadSimple");
-
 
465
				uploadS.removeAllListeners();
-
 
466
				uploadS.addListener("click", new EventCallback() {
-
 
467
					public void execute(EventObject e) {
-
 
468
						getIMediateur().uploaderImages(false);
-
 
469
					}
-
 
470
					
-
 
471
				}) ;
-
 
472
			
-
 
473
				ExtElement uploadM = Ext.get("lienUploadMultiple");
-
 
474
				uploadM.removeAllListeners();
-
 
475
				uploadM.addListener("click", new EventCallback() {
-
 
476
					public void execute(EventObject e) {
-
 
477
						getIMediateur().uploaderImages(true);
-
 
478
					}
Line -... Line 479...
-
 
479
				});
-
 
480
			}
445
        return res;
481