Subversion Repositories eFlore/Applications.cel

Rev

Rev 97 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 david 1
package org.tela_botanica.client.vues;
2
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.observation.ObservationMediateur;
5
 
97 jpm 6
import com.google.gwt.user.client.DOM;
7
import com.google.gwt.user.client.Event;
8
import com.google.gwt.user.client.Window;
99 jpm 9
import com.google.gwt.user.client.ui.HTML;
54 david 10
import com.google.gwt.user.client.ui.Image;
11
import com.gwtext.client.widgets.Panel;
99 jpm 12
import com.gwtext.client.widgets.ToolTip;
97 jpm 13
import com.gwtext.client.widgets.Window.CloseAction;
54 david 14
 
15
/**
16
 * Un panneau affichant une image generique provenant d eflore
17
 *
18
 * @author David Delon
19
 *
20
 */
21
public class ImageGeneriqueVue extends Panel implements Rafraichissable {
22
 
23
	/**
24
	 * Le médiateur associé
25
	 */
26
 
27
	private ObservationMediateur observationMediateur = null;
28
 
29
 
30
	/**
31
	 * l'image à afficher
32
	 */
33
	private Image image = new Image();
34
 
97 jpm 35
	private String urlImage = "" ;
54 david 36
 
97 jpm 37
	private com.gwtext.client.widgets.Window imgZoom = new com.gwtext.client.widgets.Window("Agrandissement") ;
38
 
99 jpm 39
	private ToolTip tp = new ToolTip("<div class=\"x-tooltip-help\"> Double cliquez pour agrandir l'image </div>") ;
97 jpm 40
 
54 david 41
	/**
42
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
43
	 */
44
 
45
	@SuppressWarnings("unused")
46
	private ImageGeneriqueVue() {
47
		super();
48
	}
49
 
50
	/**
51
	 * Constructeur avec argument
52
	 * @param obs le médiateur à associer
53
	 */
54
 
55
 
56
	public ImageGeneriqueVue(ObservationMediateur obs) {
57
 
58
 
59
		this.observationMediateur = obs;
97 jpm 60
		imgZoom.setCloseAction(com.gwtext.client.widgets.Window.HIDE) ;
61
		image = new Image() {
62
 
63
			public void onBrowserEvent(Event event) {
64
 
65
				// lors du double clic
66
				if (Event.ONDBLCLICK == DOM.eventGetType(event)) {
67
 
68
					// on notifie le médiateur
69
					agrandirImage() ;
70
				}
71
			}
72
 
73
		};
74
 
99 jpm 75
		tp.applyTo(image.getElement()) ;
97 jpm 76
 
99 jpm 77
 
97 jpm 78
		this.setCls("x-image-gen") ;
54 david 79
		image.setPixelSize(150, 150);
80
		add(image);
81
 
97 jpm 82
		image.sinkEvents(Event.ONDBLCLICK);
83
 
54 david 84
		// on ajoute les listeners
85
		ajouterListeners();
86
 
87
	}
88
 
89
 
90
	/**
91
	 * Affichage image generique
92
	 *
93
	 */
94
 
95
	public void rafraichir(Object nouvelleDonnees,boolean repandreRaffraichissement) {
96
 
97
		// si on recoit une String contenant une URL
98
		if (nouvelleDonnees instanceof String) {
99
 
97 jpm 100
			urlImage=(String) nouvelleDonnees;
54 david 101
 
102
			if (urlImage.length()==0) {
84 jpm 103
				raz() ;
54 david 104
			}
105
			else {
106
				image.setUrl(urlImage);
107
			}
108
		}
84 jpm 109
 
110
		observationMediateur.deMasquerChargementInfosObservations() ;
54 david 111
 
112
	}
97 jpm 113
 
114
	public void agrandirImage() {
115
 
116
		if(!imgZoom.isVisible())
117
		{
118
			String urlAgrandie = urlImage.replace("min", "max") ;
119
			imgZoom.setHtml("<img src=\""+urlAgrandie+"\" />") ;
120
			imgZoom.setPagePosition( Window.getClientWidth()/2, Window.getClientHeight()/5) ;
121
			imgZoom.setAutoHeight(true) ;
122
			imgZoom.setAutoWidth(true) ;
123
			imgZoom.show(this.getElement()) ;
124
		}
54 david 125
 
97 jpm 126
 
127
	}
128
 
54 david 129
 
130
	/**
131
	 * Ajoute les listeners pour la gestions d'évènement
132
	 */
133
	public void ajouterListeners() {
134
 
135
	}
136
 
84 jpm 137
	public void raz() {
138
		image.setUrl("");
139
	}
140
 
54 david 141
 
142
}