Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 97 Rev 104
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line 2...
2
 
2
 
3
import org.tela_botanica.client.image.ImageMediateur;
3
import org.tela_botanica.client.image.ImageMediateur;
-
 
4
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.modeles.Configuration;
Line 5... Line 6...
5
import org.tela_botanica.client.observation.ObservationMediateur;
6
import org.tela_botanica.client.observation.ObservationMediateur;
6
 
7
 
7
import com.google.gwt.user.client.DOM;
8
import com.google.gwt.user.client.DOM;
8
import com.google.gwt.user.client.Event;
9
import com.google.gwt.user.client.Event;
9
import com.google.gwt.user.client.Window;
10
import com.google.gwt.user.client.Window;
-
 
11
import com.google.gwt.user.client.ui.ClickListener;
10
import com.google.gwt.user.client.ui.ClickListener;
12
import com.google.gwt.user.client.ui.Image;
11
import com.google.gwt.user.client.ui.Image;
13
import com.google.gwt.user.client.ui.MenuItem;
12
import com.google.gwt.user.client.ui.Widget;
14
import com.google.gwt.user.client.ui.Widget;
13
import com.gwtext.client.core.EventObject;
15
import com.gwtext.client.core.EventObject;
14
import com.gwtext.client.core.RegionPosition;
16
import com.gwtext.client.core.RegionPosition;
Line 20... Line 22...
20
import com.gwtext.client.widgets.Panel;
22
import com.gwtext.client.widgets.Panel;
21
import com.gwtext.client.widgets.event.PanelListenerAdapter;
23
import com.gwtext.client.widgets.event.PanelListenerAdapter;
22
import com.gwtext.client.widgets.grid.GridDragData;
24
import com.gwtext.client.widgets.grid.GridDragData;
23
import com.gwtext.client.widgets.layout.BorderLayout;
25
import com.gwtext.client.widgets.layout.BorderLayout;
24
import com.gwtext.client.widgets.layout.BorderLayoutData;
26
import com.gwtext.client.widgets.layout.BorderLayoutData;
-
 
27
import com.gwtext.client.widgets.menu.BaseItem;
-
 
28
import com.gwtext.client.widgets.menu.Item;
-
 
29
import com.gwtext.client.widgets.menu.Menu;
-
 
30
import com.gwtext.client.widgets.menu.event.MenuListener;
-
 
31
import com.gwtext.client.widgets.menu.event.MenuListenerAdapter;
Line 25... Line 32...
25
 
32
 
26
/**
33
/**
27
 * Panneau d'affichage d'une image avec des boutons précdents et suivant
34
 * Panneau d'affichage d'une image avec des boutons précdents et suivant
28
 * 
35
 * 
Line 121... Line 128...
121
					// ou suivant
128
					// ou suivant
122
					if (event.getMouseWheelVelocityY() <= -1) {
129
					if (event.getMouseWheelVelocityY() <= -1) {
123
						suiv.click();
130
						suiv.click();
124
					}
131
					}
125
				}
132
				}
-
 
133
				
-
 
134
				if(Event.ONCONTEXTMENU == DOM.eventGetType(event)) {
-
 
135
					
-
 
136
					event.preventDefault() ;
-
 
137
					int[] xy = {event.getClientX(),event.getClientY()} ;
-
 
138
					afficherMenu(xy) ;
-
 
139
				}
126
			}
140
			}
Line 127... Line 141...
127
			
141
			
Line 128... Line 142...
128
		};
142
		};
Line 140... Line 154...
140
		// il n'existe pas de méthode pour ajouter un listener pour le double
154
		// il n'existe pas de méthode pour ajouter un listener pour le double
141
		// clic sur une image
155
		// clic sur une image
142
		// alors on lui dit manuellement de capter l'évènement double clic
156
		// alors on lui dit manuellement de capter l'évènement double clic
143
		image.sinkEvents(Event.ONDBLCLICK);
157
		image.sinkEvents(Event.ONDBLCLICK);
144
		image.sinkEvents(Event.ONMOUSEWHEEL);
158
		image.sinkEvents(Event.ONMOUSEWHEEL);
-
 
159
		image.sinkEvents(Event.ONCONTEXTMENU) ;
Line 145... Line 160...
145
 
160
 
146
		// l'image de base est vide
161
		// l'image de base est vide
Line 147... Line 162...
147
		image.setUrl("");
162
		image.setUrl("");
Line 195... Line 210...
195
	{
210
	{
196
		// c'est l'url de l'image qu'on associe à la vue
211
		// c'est l'url de l'image qu'on associe à la vue
197
		if(infosImages.length != 0)
212
		if(infosImages.length != 0)
198
		{
213
		{
199
			activerPanneau() ;
214
			activerPanneau() ;
200
			getImage().setUrl(infosImages[index]);
215
			getImage().setUrl(convertirIdEnUrl(infosImages[index]));
201
		}
216
		}
202
		else
217
		else
203
		{
218
		{
204
			//getImage().setUrl("");
-
 
205
			desactiverPanneau() ;
219
			desactiverPanneau() ;
206
		}
220
		}
207
	}
221
	}
Line 208... Line 222...
208
 
222
 
Line 297... Line 311...
297
	 * Acesseurs pour l'identifiant de l'image
311
	 * Acesseurs pour l'identifiant de l'image
298
	 * @return l'id de l'image
312
	 * @return l'id de l'image
299
	 */
313
	 */
300
	public String getIdImage()
314
	public String getIdImage()
301
	{
315
	{
302
		return idImage ;
316
		return infosImages[index] ;
303
	}
317
	}
Line 304... Line 318...
304
 
318
 
305
	/**
319
	/**
306
	 * Accesseur pour le bouton précédent
320
	 * Accesseur pour le bouton précédent
Line 360... Line 374...
360
	public Panel getImageConteneur() {
374
	public Panel getImageConteneur() {
Line 361... Line 375...
361
 
375
 
Line 362... Line 376...
362
		return imageConteneur;
376
		return imageConteneur;
-
 
377
 
-
 
378
	}
-
 
379
 
-
 
380
	public void raz() {
-
 
381
		
-
 
382
		infosImages = new String[0] ;
-
 
383
		getImage().setUrl("");
-
 
384
		
-
 
385
	}
-
 
386
	
-
 
387
	public void supprimerLiaisonImage() {
-
 
388
		
-
 
389
		if(infosImages.length > 0) {
-
 
390
			
-
 
391
			getImage().setUrl("") ;
-
 
392
			int nouvelleTaille = infosImages.length - 1 ;
-
 
393
			int indexSupp = index ;
-
 
394
			
-
 
395
			String[] nouveauInfosImages = new String[nouvelleTaille] ;
-
 
396
			int j = 0 ;
-
 
397
			
-
 
398
			for(int i = 0 ; i < infosImages.length ; i++) {
-
 
399
				
-
 
400
				if(i != indexSupp) {
-
 
401
					
-
 
402
					nouveauInfosImages[j] = infosImages[i] ;
-
 
403
					j++ ;
-
 
404
				}
-
 
405
			}
-
 
406
			
-
 
407
			infosImages = nouveauInfosImages ;
-
 
408
			index = 0 ;
-
 
409
			
-
 
410
			afficherImage() ;
-
 
411
		}
-
 
412
	}
-
 
413
	
-
 
414
	public void afficherMenu(int[] xy) {
-
 
415
		
-
 
416
		Menu mn = new Menu() ;
-
 
417
		final Item suppLiaison = new Item("Supprimer la liaison") ;
-
 
418
		
-
 
419
		mn.addItem(suppLiaison) ;
-
 
420
		
-
 
421
		mn.addListener(new MenuListenerAdapter() {
-
 
422
			
-
 
423
			public void onItemClick(BaseItem item, EventObject e) {
-
 
424
				
-
 
425
				// si c'est l'aide
-
 
426
				if (item.equals(suppLiaison)) {
-
 
427
					// on notifie le médiateur
-
 
428
					getIMediateur().supprimerLiaisonObsImage() ;
-
 
429
				}
-
 
430
			}
-
 
431
			
-
 
432
		}) ;
-
 
433
		
-
 
434
		mn.showAt(xy) ;
-
 
435
	}
-
 
436
	
-
 
437
	public String convertirIdEnUrl(String idImg)
-
 
438
	{
-
 
439
		int maxZeros = 9 - idImg.length();
-
 
440
		
-
 
441
		for (int j = 0; j < maxZeros; j++) {
-
 
442
			idImg = "0" + idImg;
-
 
443
		}
-
 
444
		
-
 
445
		String baseUrl = Configuration.getImageBaseUrl() ;
-
 
446
 
-
 
447
		String dossierNv1 = idImg.substring(0, 3);
-
 
448
		String dossierNv2 = idImg.substring(3, 6);
-
 
449
		String fichierNv = idImg.substring(6, 9);
-
 
450
 
-
 
451
		String nomFichier = dossierNv1 + "_" + dossierNv2 + "_" + fichierNv;
-
 
452
 
-
 
453
		String[] infosFichier = { nomFichier, dossierNv1, dossierNv2 };
-
 
454
		
-
 
455
		String urlImg = baseUrl + infosFichier[1] + "/" + infosFichier[2] + "/M/"
-
 
456
		+ infosFichier[0] + "_M.jpg";
-
 
457
		
363
 
458
		return urlImg ;