Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 989 Rev 1292
1
package org.tela_botanica.client.vues.observation;
1
package org.tela_botanica.client.vues.observation;
2
 
2
 
3
 
3
 
4
import java.util.Iterator;
4
import java.util.Iterator;
5
 
5
 
6
import org.tela_botanica.client.modeles.objets.ListeObservation;
6
import org.tela_botanica.client.modeles.objets.ListeObservation;
7
import org.tela_botanica.client.modeles.objets.Observation;
7
import org.tela_botanica.client.modeles.objets.Observation;
8
import org.tela_botanica.client.observation.ObservationMediateur;
8
import org.tela_botanica.client.observation.ObservationMediateur;
9
import org.tela_botanica.client.util.Util;
9
import org.tela_botanica.client.util.Util;
10
import org.tela_botanica.client.vues.BarrePaginationVue;
10
import org.tela_botanica.client.vues.BarrePaginationVue;
11
import org.tela_botanica.client.interfaces.ListePaginable;
11
import org.tela_botanica.client.interfaces.ListePaginable;
12
import org.tela_botanica.client.interfaces.Rafraichissable;
12
import org.tela_botanica.client.interfaces.Rafraichissable;
13
import org.tela_botanica.client.interfaces.VueListable;
13
import org.tela_botanica.client.interfaces.VueListable;
14
 
-
 
15
import com.google.gwt.core.client.GWT;
-
 
16
import com.google.gwt.user.client.Window;
14
 
17
import com.gwtext.client.core.EventCallback;
15
import com.gwtext.client.core.EventCallback;
18
import com.gwtext.client.core.EventObject;
16
import com.gwtext.client.core.EventObject;
19
import com.gwtext.client.core.Ext;
17
import com.gwtext.client.core.Ext;
20
import com.gwtext.client.core.ExtElement;
18
import com.gwtext.client.core.ExtElement;
21
import com.gwtext.client.data.ArrayReader;
19
import com.gwtext.client.data.ArrayReader;
22
import com.gwtext.client.data.FieldDef;
20
import com.gwtext.client.data.FieldDef;
23
import com.gwtext.client.data.IntegerFieldDef;
21
import com.gwtext.client.data.IntegerFieldDef;
24
import com.gwtext.client.data.MemoryProxy;
22
import com.gwtext.client.data.MemoryProxy;
25
import com.gwtext.client.data.Record;
23
import com.gwtext.client.data.Record;
26
import com.gwtext.client.data.RecordDef;
24
import com.gwtext.client.data.RecordDef;
27
import com.gwtext.client.data.Store;
25
import com.gwtext.client.data.Store;
28
import com.gwtext.client.data.StringFieldDef;
26
import com.gwtext.client.data.StringFieldDef;
29
import com.gwtext.client.dd.DragData;
27
import com.gwtext.client.dd.DragData;
30
import com.gwtext.client.dd.DragDropConfig;
28
import com.gwtext.client.dd.DragDropConfig;
31
import com.gwtext.client.dd.DragSource;
29
import com.gwtext.client.dd.DragSource;
32
import com.gwtext.client.dd.DropTarget;
30
import com.gwtext.client.dd.DropTarget;
33
import com.gwtext.client.dd.DropTargetConfig;
31
import com.gwtext.client.dd.DropTargetConfig;
34
import com.gwtext.client.widgets.Button;
32
import com.gwtext.client.widgets.Button;
35
import com.gwtext.client.widgets.Component;
33
import com.gwtext.client.widgets.Component;
36
import com.gwtext.client.widgets.Panel;
34
import com.gwtext.client.widgets.Panel;
37
import com.gwtext.client.widgets.Tool;
35
import com.gwtext.client.widgets.Tool;
38
import com.gwtext.client.widgets.Toolbar;
36
import com.gwtext.client.widgets.Toolbar;
39
import com.gwtext.client.widgets.ToolbarButton;
37
import com.gwtext.client.widgets.ToolbarButton;
40
import com.gwtext.client.widgets.ToolbarTextItem;
38
import com.gwtext.client.widgets.ToolbarTextItem;
41
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
39
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
42
import com.gwtext.client.widgets.event.PanelListenerAdapter;
40
import com.gwtext.client.widgets.event.PanelListenerAdapter;
43
import com.gwtext.client.widgets.grid.CellMetadata;
41
import com.gwtext.client.widgets.grid.CellMetadata;
44
import com.gwtext.client.widgets.grid.ColumnConfig;
42
import com.gwtext.client.widgets.grid.ColumnConfig;
45
import com.gwtext.client.widgets.grid.ColumnModel;
43
import com.gwtext.client.widgets.grid.ColumnModel;
46
import com.gwtext.client.widgets.grid.GridDragData;
-
 
47
import com.gwtext.client.widgets.grid.GridPanel;
44
import com.gwtext.client.widgets.grid.GridPanel;
48
import com.gwtext.client.widgets.grid.Renderer;
45
import com.gwtext.client.widgets.grid.Renderer;
49
import com.gwtext.client.widgets.grid.event.GridListenerAdapter;
46
import com.gwtext.client.widgets.grid.event.GridListenerAdapter;
50
import com.gwtext.client.widgets.grid.event.GridRowListener;
-
 
51
import com.gwtext.client.widgets.grid.event.GridRowListenerAdapter;
47
import com.gwtext.client.widgets.grid.event.GridRowListenerAdapter;
52
import com.gwtext.client.widgets.tree.TreeDragData;
48
import com.gwtext.client.widgets.tree.TreeDragData;
53
import com.gwtext.client.widgets.tree.TreeNode;
49
import com.gwtext.client.widgets.tree.TreeNode;
54
 
50
 
55
/**
51
/**
56
 * Liste d'observation composée de ligne d'observation
52
 * Liste d'observation composée de ligne d'observation
57
 * l'interface rafraichissable et l'interface vueListable
53
 * l'interface rafraichissable et l'interface vueListable
58
 * 
54
 * 
59
 * @author David Delon 2008
55
 * @author David Delon 2008
60
 */
56
 */
61
public class ListeObservationVue extends GridPanel implements Rafraichissable,
57
public class ListeObservationVue extends GridPanel implements Rafraichissable,
62
		VueListable, ListePaginable {
58
		VueListable, ListePaginable {
63
 
59
 
64
	/**
60
	/**
65
	 * Le médiateur associé à la vue
61
	 * Le médiateur associé à la vue
66
	 */
62
	 */
67
	private ObservationMediateur	observationMediateur		= null;
63
	private ObservationMediateur	observationMediateur		= null;
68
 
64
 
69
 
65
 
70
	/**
66
	/**
71
	 * Config de colonne
67
	 * Config de colonne
72
	 */
68
	 */
73
	private ColumnConfig	etatObservation;
69
	private ColumnConfig	etatObservation;
74
	/**
70
	/**
75
	 * Config de colonne
71
	 * Config de colonne
76
	 */
72
	 */
77
	private ColumnConfig	nomSaisiObservation;
73
	private ColumnConfig	nomSaisiObservation;
78
	/**
74
	/**
79
	 * Config de colonne
75
	 * Config de colonne
80
	 */
76
	 */
81
	private ColumnConfig	nomRetenuObservation;
77
	private ColumnConfig	nomRetenuObservation;
82
	/**
78
	/**
83
	 * Config de colonne
79
	 * Config de colonne
84
	 */
80
	 */
85
	private ColumnConfig	lieuObservation;
81
	private ColumnConfig	lieuObservation;
86
	/**
82
	/**
87
	 * Config de colonne
83
	 * Config de colonne
88
	 */
84
	 */
89
	private ColumnConfig	dateObservation;
85
	private ColumnConfig	dateObservation;
90
	/**
86
	/**
91
	 * Config de colonne
87
	 * Config de colonne
92
	 */
88
	 */
93
	private ColumnConfig	ordreObservation;
89
	private ColumnConfig	ordreObservation;
94
	/**
90
	/**
95
	 * Modele de colonnes
91
	 * Modele de colonnes
96
	 */
92
	 */
97
	private ColumnModel		modeleColonnes;
93
	private ColumnModel		modeleColonnes;
98
 
94
 
99
	
95
	
100
	/**
96
	/**
101
	 * Store qui contient les données à afficher
97
	 * Store qui contient les données à afficher
102
	 */
98
	 */
103
	private Store			st				= null;
99
	private Store			st				= null;
104
	
100
	
105
	
101
	
106
	/**
102
	/**
107
	 * Barre de pagination
103
	 * Barre de pagination
108
	 */
104
	 */
109
	private BarrePaginationVue bt = null ;
105
	private BarrePaginationVue bt = null ;
110
 
106
 
111
	/**
107
	/**
112
	 * Numéro de page en cours
108
	 * Numéro de page en cours
113
	 */
109
	 */
114
	private int pageEncours = 0 ;
110
	private int pageEncours = 0 ;
115
	/**
111
	/**
116
	 * Nombre de pages totales
112
	 * Nombre de pages totales
117
	 */
113
	 */
118
	private int pageMax = 1 ;
114
	private int pageMax = 1 ;
119
	/**
115
	/**
120
	 * Taille de page (par défaut 20)
116
	 * Taille de page (par défaut 20)
121
	 */
117
	 */
122
	private int taillePage = 20 ;
118
	private int taillePage = 20 ;
123
	/**
119
	/**
124
	 * Nombre d'éléments total correspondant à la requete
120
	 * Nombre d'éléments total correspondant à la requete
125
	 */
121
	 */
126
	private int nbElements = 0 ;
122
	private int nbElements = 0 ;
127
	
123
	
128
	private ListeObservation cacheListeObservation = null;
124
	private ListeObservation cacheListeObservation = null;
129
	
125
	
130
	private Tool exporterObservations = null ;
126
	private Tool exporterObservations = null ;
131
	
127
	
132
	private final int KEY_ENTER = 13;
128
	private final int KEY_ENTER = 13;
133
	
129
	
134
	private String modeleLieu = "IDLOCCOMMUNE, LIEUDIT, STATION";
130
	private String modeleLieu = "IDLOCCOMMUNE, LIEUDIT, STATION";
135
 
131
 
136
 
132
 
137
	private boolean tailleInitialisee = false ;
133
	private boolean tailleInitialisee = false ;
138
	
134
	
139
	/**
135
	/**
140
	 * Constructeur sans arguments (privé car ne doit pas être utilisé)
136
	 * Constructeur sans arguments (privé car ne doit pas être utilisé)
141
	 */
137
	 */
142
	@SuppressWarnings("unused")
138
	@SuppressWarnings("unused")
143
	private ListeObservationVue()
139
	private ListeObservationVue()
144
	{
140
	{
145
		super() ;
141
		super() ;
146
	}
142
	}
147
	
143
	
148
	/**
144
	/**
149
	 * Constructeur avec argument
145
	 * Constructeur avec argument
150
	 * @param im le médiateur à associer
146
	 * @param im le médiateur à associer
151
	 */
147
	 */
152
	public ListeObservationVue(ObservationMediateur obs) {		
148
	public ListeObservationVue(ObservationMediateur obs) {		
153
		
149
		
154
		this.observationMediateur = obs;
150
		this.observationMediateur = obs;
155
		
151
		
156
		setId("x-list-obs");
152
		setId("x-list-obs");
157
		
153
		
158
		setHeader(true);
154
		setHeader(true);
159
		
155
		
160
        
156
        
161
		// on place la barre de pagination
157
		// on place la barre de pagination
162
		bt = new BarrePaginationVue(this);		
158
		bt = new BarrePaginationVue(this);		
163
		bt.setLabelElement("Observations");
159
		bt.setLabelElement("Observations");
164
		bt.setTaillePageParDefaut(20);
160
		bt.setTaillePageParDefaut(20);
165
		bt.setIntervallesPages(new String[] {"400","200",  "100" , "50" , "20", "10"}) ;
161
		bt.setIntervallesPages(new String[] {"400","200",  "100" , "50" , "20", "10"}) ;
166
		
162
		
167
		Toolbar barreActions = new Toolbar();
163
		Toolbar barreActions = new Toolbar();
168
		ToolbarButton publier = new ToolbarButton("Rendre publiques");
164
		ToolbarButton publier = new ToolbarButton("Rendre publiques");
169
		publier.addListener(new ButtonListenerAdapter() {
165
		publier.addListener(new ButtonListenerAdapter() {
-
 
166
			@Override
170
			public void onClick(Button b, EventObject e) {
167
			public void onClick(Button b, EventObject e) {
171
				observationMediateur.transmettreObservations(true);
168
				observationMediateur.transmettreObservations(true);
172
			}
169
			}
173
		});
170
		});
174
		
171
		
175
		ToolbarButton privatiser = new ToolbarButton("Rendre privées");
172
		ToolbarButton privatiser = new ToolbarButton("Rendre privées");
176
		privatiser.addListener(new ButtonListenerAdapter() {
173
		privatiser.addListener(new ButtonListenerAdapter() {
-
 
174
			@Override
177
			public void onClick(Button b, EventObject e) {
175
			public void onClick(Button b, EventObject e) {
178
				observationMediateur.transmettreObservations(false);
176
				observationMediateur.transmettreObservations(false);
179
			}
177
			}
180
		});
178
		});
181
		
179
		
182
		ToolbarButton supprimer = new ToolbarButton("Supprimer");
180
		ToolbarButton supprimer = new ToolbarButton("Supprimer");
183
		supprimer.addListener(new ButtonListenerAdapter() {
181
		supprimer.addListener(new ButtonListenerAdapter() {
-
 
182
			@Override
184
			public void onClick(Button b, EventObject e) {
183
			public void onClick(Button b, EventObject e) {
185
				observationMediateur.supprimerObservations();
184
				observationMediateur.supprimerObservations();
186
			}
185
			}
187
		});
186
		});
188
		
187
		
189
		ToolbarButton importer = new ToolbarButton("Importer");
188
		ToolbarButton importer = new ToolbarButton("Importer");
190
		importer.addListener(new ButtonListenerAdapter() {
189
		importer.addListener(new ButtonListenerAdapter() {
-
 
190
			@Override
191
			public void onClick(Button b, EventObject e) {
191
			public void onClick(Button b, EventObject e) {
192
				observationMediateur.afficherFormulaireImportObservation();
192
				observationMediateur.afficherFormulaireImportObservation();
193
			}
193
			}
194
		});
194
		});
195
		
195
		
196
		ToolbarTextItem exporter = new ToolbarTextItem("<a href=\"#\" id=\"lienExport\"> Exporter </a>");
196
		ToolbarTextItem exporter = new ToolbarTextItem("<a href=\"#\" id=\"lienExport\"> Exporter </a>");
197
		
197
		
198
		barreActions.addButton(publier);
198
		barreActions.addButton(publier);
199
		barreActions.addButton(privatiser);
199
		barreActions.addButton(privatiser);
200
		barreActions.addSpacer();
200
		barreActions.addSpacer();
201
		barreActions.addButton(supprimer);
201
		barreActions.addButton(supprimer);
202
		barreActions.addSpacer();
202
		barreActions.addSpacer();
203
		barreActions.addButton(importer);
203
		barreActions.addButton(importer);
204
		barreActions.addSpacer();
204
		barreActions.addSpacer();
205
		barreActions.addItem(exporter);
205
		barreActions.addItem(exporter);
206
		
206
		
207
		this.setTopToolbar(barreActions) ;
207
		this.setTopToolbar(barreActions) ;
208
		this.setBottomToolbar(bt);
208
		this.setBottomToolbar(bt);
209
		
209
		
210
		this.setCollapsible(true);
210
		this.setCollapsible(true);
211
		this.setTitleCollapse(true);
211
		this.setTitleCollapse(true);
212
 
212
 
213
		this.setTitle("Observations") ;
213
		this.setTitle("Observations") ;
214
 
214
 
215
		// on construit le modèle de colonnes
215
		// on construit le modèle de colonnes
216
 
216
 
217
		// Le store suivant est ensuite remplacé par le store contenant les données obtenus depuis le serveur (cf rafraichir) 
217
		// Le store suivant est ensuite remplacé par le store contenant les données obtenus depuis le serveur (cf rafraichir) 
218
				
218
				
219
		Renderer colRend = new Renderer() {
219
		Renderer colRend = new Renderer() {
-
 
220
 
220
 
221
			@Override
221
			public String render(Object value, CellMetadata cellMetadata,
222
			public String render(Object value, CellMetadata cellMetadata,
222
					Record record, int rowIndex, int colNum, Store store) {
223
					Record record, int rowIndex, int colNum, Store store) {
223
				
224
				
224
				if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
225
				if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
225
				
226
				
226
					return "" ;
227
					return "" ;
227
				}	
228
				}	
228
				else
229
				else
229
				{
230
				{
230
					
231
					
231
				}
232
				}
232
				
233
				
233
				return value.toString() ;
234
				return value.toString() ;
234
			}
235
			}
235
			
236
			
236
		} ;
237
		} ;
237
		
238
		
238
		Renderer dateRend = new Renderer() {
239
		Renderer dateRend = new Renderer() {
-
 
240
 
239
 
241
			@Override
240
			public String render(Object value, CellMetadata cellMetadata,
242
			public String render(Object value, CellMetadata cellMetadata,
241
					Record record, int rowIndex, int colNum, Store store) {
243
					Record record, int rowIndex, int colNum, Store store) {
242
				
244
				
243
				if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
245
				if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
244
				
246
				
245
					return "" ;
247
					return "" ;
246
				}	
248
				}	
247
				else
249
				else
248
				{
250
				{
249
					String dateEntiere = value.toString() ;
251
					String dateEntiere = value.toString() ;
250
					String[] dateEtHeure = dateEntiere.split(" ", 2);
252
					String[] dateEtHeure = dateEntiere.split(" ", 2);
251
					if(verifierFormatDate(dateEtHeure[0])) {
253
					if(verifierFormatDate(dateEtHeure[0])) {
252
						String[] dateFormateeTab = dateEtHeure[0].split("-",3);
254
						String[] dateFormateeTab = dateEtHeure[0].split("-",3);
253
						return dateFormateeTab[2]+"/"+dateFormateeTab[1]+"/"+dateFormateeTab[0] ;
255
						return dateFormateeTab[2]+"/"+dateFormateeTab[1]+"/"+dateFormateeTab[0] ;
254
					}
256
					}
255
				}
257
				}
256
				
258
				
257
				return value.toString() ;
259
				return value.toString() ;
258
			}
260
			}
259
			
261
			
260
		} ;
262
		} ;
261
		
263
		
262
		etatObservation = new ColumnConfig("Transmis", "etat_observation", 20, true, new Renderer() {
264
		etatObservation = new ColumnConfig("Transmis", "etat_observation", 20, true, new Renderer() {
-
 
265
 
263
 
266
			@Override
264
			public String render(Object value, CellMetadata cellMetadata,
267
			public String render(Object value, CellMetadata cellMetadata,
265
					Record record, int rowIndex, int colNum, Store store) {
268
					Record record, int rowIndex, int colNum, Store store) {
266
				if(value.equals("1"))
269
				if(value.equals("1"))
267
				{
270
				{
268
					return "<img src=\"tela.png\"/></img>" ;
271
					return "<img src=\"tela.png\"/></img>" ;
269
				}
272
				}
270
				else
273
				else
271
				{
274
				{
272
					return "" ;
275
					return "" ;
273
				}
276
				}
274
			}
277
			}
275
			
278
			
276
		});		
279
		});		
277
		nomSaisiObservation = new ColumnConfig("Nom saisi", "nomSaisi_observation", 200, true, colRend);
280
		nomSaisiObservation = new ColumnConfig("Nom saisi", "nomSaisi_observation", 200, true, colRend);
278
		nomRetenuObservation = new ColumnConfig("Nom retenu", "nomRetenu_observation", 200, true, colRend);
281
		nomRetenuObservation = new ColumnConfig("Nom retenu", "nomRetenu_observation", 200, true, colRend);
279
		lieuObservation = new ColumnConfig("Lieu", "lieu_observation", 200, true, colRend);
282
		lieuObservation = new ColumnConfig("Lieu", "lieu_observation", 200, true, colRend);
280
		dateObservation = new ColumnConfig("Date", "date_observation", 120, true, dateRend);
283
		dateObservation = new ColumnConfig("Date", "date_observation", 120, true, dateRend);
281
		ordreObservation = new ColumnConfig("Ordre", "ordre_observation", 50, true, colRend);
284
		ordreObservation = new ColumnConfig("Ordre", "ordre_observation", 50, true, colRend);
282
			
285
			
283
	
286
	
284
		// on associe le modèle de colonnes
287
		// on associe le modèle de colonnes
285
		
288
		
286
		ColumnConfig[] cm = {etatObservation, nomSaisiObservation, nomRetenuObservation, lieuObservation, dateObservation, ordreObservation};
289
		ColumnConfig[] cm = {etatObservation, nomSaisiObservation, nomRetenuObservation, lieuObservation, dateObservation, ordreObservation};
287
		
290
		
288
		modeleColonnes = new ColumnModel(cm);
291
		modeleColonnes = new ColumnModel(cm);
289
		
292
		
290
		this.setColumnModel(modeleColonnes);
293
		this.setColumnModel(modeleColonnes);
291
		
294
		
292
		this.setAutoScroll(true);
295
		this.setAutoScroll(true);
293
		this.setEnableColumnResize(true);
296
		this.setEnableColumnResize(true);
294
		
297
		
295
		// creation du store
298
		// creation du store
296
 
299
 
297
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
300
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
298
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
301
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
299
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
302
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
300
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
303
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
301
		FieldDef defDateObservation = new StringFieldDef("date_observation");
304
		FieldDef defDateObservation = new StringFieldDef("date_observation");
302
		FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
305
		FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
303
		
306
		
304
		
307
		
305
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
308
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
306
				defLieuObservation, defDateObservation, defOrdreObservation };
309
				defLieuObservation, defDateObservation, defOrdreObservation };
307
		
310
		
308
		RecordDef rd = new RecordDef(defTab);
311
		RecordDef rd = new RecordDef(defTab);
309
		st = new Store(rd);
312
		st = new Store(rd);
310
		
313
		
311
		// on associe le store
314
		// on associe le store
312
		
315
		
313
		this.setStore(st);
316
		this.setStore(st);
314
		this.getView().setAutoFill(true);
317
		this.getView().setAutoFill(true);
315
		this.getView().setForceFit(true) ;
318
		this.getView().setForceFit(true) ;
316
				
319
				
317
		// on crée un masque de chargement qui s'affichera lors des mises à jour
320
		// on crée un masque de chargement qui s'affichera lors des mises à jour
318
		this.setLoadMask("Chargement");
321
		this.setLoadMask("Chargement");
319
	
322
	
320
		// on ajoute les listeners
323
		// on ajoute les listeners
321
		ajouterListeners();
324
		ajouterListeners();
322
		
325
		
323
		configDragAndDrop();
326
		configDragAndDrop();
324
 
327
 
325
	}
328
	}
326
 
329
 
327
 
330
 
328
	/**
331
	/**
329
	 * Ajoute les listeners pour la gestion des évènements
332
	 * Ajoute les listeners pour la gestion des évènements
330
	 */
333
	 */
331
	private void ajouterListeners() {
334
	private void ajouterListeners() {
332
		
335
		
333
		this.addGridRowListener(new GridRowListenerAdapter() {
336
		this.addGridRowListener(new GridRowListenerAdapter() {
334
			
337
			
335
			// gestion du clic sur une ligne
338
			// gestion du clic sur une ligne
-
 
339
			@Override
336
			public void onRowClick(GridPanel grid, int rowIndex,
340
			public void onRowClick(GridPanel grid, int rowIndex,
337
					EventObject e) {
341
					EventObject e) {
338
				// on notifie le médiateur et on lui passe le numéro de ligne
342
				// on notifie le médiateur et on lui passe le numéro de ligne
339
				
343
				
340
			
344
			
341
				Record rd = st.getAt(rowIndex);
345
				Record rd = st.getAt(rowIndex);
342
				
346
				
343
				String ordreObservation = rd.getAsString("ordre_observation") ;
347
				String ordreObservation = rd.getAsString("ordre_observation") ;
344
				
348
				
345
				observationMediateur.onClicListeObservation(rowIndex,ordreObservation);
349
				observationMediateur.onClicListeObservation(rowIndex,ordreObservation);
346
				
350
				
347
			}
351
			}
348
 
352
 
349
			// gestion du clic droit
353
			// gestion du clic droit
-
 
354
			@Override
350
			public void onRowContextMenu(GridPanel grid, int rowIndex,
355
			public void onRowContextMenu(GridPanel grid, int rowIndex,
351
					EventObject e) {
356
					EventObject e) {
352
				// on stoppe l'évenement pour empecher le navigateur d'afficher son propre menu
357
				// on stoppe l'évenement pour empecher le navigateur d'afficher son propre menu
353
				e.stopEvent() ;
358
				e.stopEvent() ;
354
				// on notifie le médiateur en lui passant l'évenement
359
				// on notifie le médiateur en lui passant l'évenement
355
				observationMediateur.montrerContextMenu(e);
360
				observationMediateur.montrerContextMenu(e);
356
			}
361
			}
357
 
362
 
358
			// gestion du double clic
363
			// gestion du double clic
-
 
364
			@Override
359
			public void onRowDblClick(GridPanel grid, int rowIndex,
365
			public void onRowDblClick(GridPanel grid, int rowIndex,
360
					EventObject e) {
366
					EventObject e) {
361
				// on notifie le médiateur en lui passant le numéro de ligne
367
				// on notifie le médiateur en lui passant le numéro de ligne
362
				observationMediateur.doubleClicListeObservation(rowIndex);
368
				observationMediateur.doubleClicListeObservation(rowIndex);
363
			}
369
			}
364
			
370
			
365
		});
371
		});
366
		
372
		
367
		this.addGridListener(new GridListenerAdapter() {
373
		this.addGridListener(new GridListenerAdapter() {
-
 
374
			@Override
368
			public void onKeyPress(EventObject e) {
375
			public void onKeyPress(EventObject e) {
369
				if(e.getKey() == KEY_ENTER) {
376
				if(e.getKey() == KEY_ENTER) {
370
					Record rd = getSelectionModel().getSelected();
377
					Record rd = getSelectionModel().getSelected();
371
					int rowIndex = st.indexOf(rd);
378
					int rowIndex = st.indexOf(rd);
372
					String ordreObservation = rd.getAsString("ordre_observation") ;
379
					String ordreObservation = rd.getAsString("ordre_observation") ;
373
					observationMediateur.onClicListeObservation(rowIndex, ordreObservation);
380
					observationMediateur.onClicListeObservation(rowIndex, ordreObservation);
374
				}
381
				}
375
			}
382
			}
376
		});
383
		});
377
		
384
		
378
		this.addListener(new PanelListenerAdapter() {
385
		this.addListener(new PanelListenerAdapter() {
-
 
386
			@Override
379
			public void onRender(Component c) {
387
			public void onRender(Component c) {
380
				
388
				
381
				ExtElement lienExport = Ext.get("lienExport") ;
389
				ExtElement lienExport = Ext.get("lienExport") ;
382
				lienExport.addListener("click", new EventCallback() {
390
				lienExport.addListener("click", new EventCallback() {
-
 
391
 
383
 
392
					@Override
384
					public void execute(EventObject e) {
393
					public void execute(EventObject e) {
385
						
394
						
386
						observationMediateur.exporterObservations();
395
						observationMediateur.exporterObservations();
387
					}
396
					}
388
					
397
					
389
				});
398
				});
390
			}
399
			}
391
		});
400
		});
392
		
401
		
393
		this.addListener(new PanelListenerAdapter() {
402
		this.addListener(new PanelListenerAdapter() {
-
 
403
			@Override
394
			public void onBodyResize(Panel panel, java.lang.String width, java.lang.String height) {
404
			public void onBodyResize(Panel panel, java.lang.String width, java.lang.String height) {
395
				doLayout();
405
				doLayout();
396
			}
406
			}
397
		});
407
		});
398
	}
408
	}
399
	
409
	
400
	/**
410
	/**
401
	 * Configure le drag 'n drop pour la liste
411
	 * Configure le drag 'n drop pour la liste
402
	 */
412
	 */
403
	private void configDragAndDrop()
413
	private void configDragAndDrop()
404
	{
414
	{
405
 
415
 
406
		setDdGroup("ObsMotsClesGroup");
416
		setDdGroup("ObsMotsClesGroup");
407
		setEnableDragDrop(true);
417
		setEnableDragDrop(true);
408
		setDragDropText("Glissez les observations sélectionnées sur un projet pour les lier");
418
		setDragDropText("Glissez les observations sélectionnées sur un projet pour les lier");
409
		// on fabrique la nouvelle configuration
419
		// on fabrique la nouvelle configuration
410
		// les éléments sur lesquels on fait du drag 'n drop doivent tous avoir le même ddGroup
420
		// les éléments sur lesquels on fait du drag 'n drop doivent tous avoir le même ddGroup
411
		DropTargetConfig dtc = new DropTargetConfig();
421
		DropTargetConfig dtc = new DropTargetConfig();
412
		dtc.setdDdGroup("ObsMotsClesGroup");
422
		dtc.setdDdGroup("ObsMotsClesGroup");
413
		dtc.setTarget(true);
423
		dtc.setTarget(true);
414
		
424
		
415
		DragDropConfig ddc = new DragDropConfig();
425
		DragDropConfig ddc = new DragDropConfig();
416
 
426
 
417
		//La drop target permet de gérer l'évenement onDrop sur l'élement courant
427
		//La drop target permet de gérer l'évenement onDrop sur l'élement courant
418
		@SuppressWarnings("unused")
428
		@SuppressWarnings("unused")
419
		DropTarget tg = new DropTarget(this, dtc)
429
		DropTarget tg = new DropTarget(this, dtc)
420
		{
430
		{
-
 
431
			@Override
421
			public boolean notifyDrop(DragSource source, EventObject e, DragData data){	
432
			public boolean notifyDrop(DragSource source, EventObject e, DragData data){	
422
				
433
				
423
				// si on reçoit des données provenant d'un arbre
434
				// si on reçoit des données provenant d'un arbre
424
				// on les convertit 
435
				// on les convertit 
425
				if(data instanceof TreeDragData)  {
436
				if(data instanceof TreeDragData)  {
426
			    	TreeDragData tdd = (TreeDragData)data ;
437
			    	TreeDragData tdd = (TreeDragData)data ;
427
			    	
438
			    	
428
			    	TreeNode treeNode = tdd.getTreeNode();  
439
			    	TreeNode treeNode = tdd.getTreeNode();  
429
			    	String idMc = treeNode.getId();  
440
			    	String idMc = treeNode.getId();  
430
			    	
441
			    	
431
			    	int index = getView().findRowIndex(e);
442
			    	int index = getView().findRowIndex(e);
432
			    	if(index < 0) {
443
			    	if(index < 0) {
433
			    		return true;
444
			    		return true;
434
			    	}
445
			    	}
435
			    	
446
			    	
436
			    	Record obsRd = getStore().getRecordAt(index);
447
			    	Record obsRd = getStore().getRecordAt(index);
437
			    	if(obsRd == null) {
448
			    	if(obsRd == null) {
438
			    		return true;
449
			    		return true;
439
			    	}
450
			    	}
440
			    	
451
			    	
441
			    	String ordreObs = obsRd.getAsString("ordre_observation");
452
			    	String ordreObs = obsRd.getAsString("ordre_observation");
442
			    	
453
			    	
443
			    	if(ordreObs != null) {
454
			    	if(ordreObs != null) {
444
			    		observationMediateur.gererDDMotCleSurObs(ordreObs, idMc);
455
			    		observationMediateur.gererDDMotCleSurObs(ordreObs, idMc);
445
			    		return true ;
456
			    		return true ;
446
			    	} else {
457
			    	} else {
447
			    		return true;
458
			    		return true;
448
			    	}
459
			    	}
449
				}
460
				}
450
		    	return true;
461
		    	return true;
451
			}
462
			}
-
 
463
			
452
			
464
			@Override
453
			public String notifyOver(DragSource source, EventObject e, DragData data){
465
			public String notifyOver(DragSource source, EventObject e, DragData data){
454
				
466
				
455
				if(data instanceof TreeDragData)  {
467
				if(data instanceof TreeDragData)  {
456
			    	TreeDragData tdd = (TreeDragData)data ;
468
			    	TreeDragData tdd = (TreeDragData)data ;
457
			    	
469
			    	
458
			    	TreeNode treeNode = tdd.getTreeNode();  
470
			    	TreeNode treeNode = tdd.getTreeNode();  
459
			    	String idMc = treeNode.getId();  
471
			    	String idMc = treeNode.getId();  
460
			    	
472
			    	
461
			    	int index = getView().findRowIndex(e);
473
			    	int index = getView().findRowIndex(e);
462
			    	if(index < 0) {
474
			    	if(index < 0) {
463
			    		return "x-dd-drop-nodrop";
475
			    		return "x-dd-drop-nodrop";
464
			    	}
476
			    	}
465
			    	
477
			    	
466
			    	Record obsRd = getStore().getRecordAt(index);
478
			    	Record obsRd = getStore().getRecordAt(index);
467
			    	
479
			    	
468
			    	if(obsRd == null) {
480
			    	if(obsRd == null) {
469
			    		return "x-dd-drop-nodrop";
481
			    		return "x-dd-drop-nodrop";
470
			    	}
482
			    	}
471
			    	
483
			    	
472
			    	String ordreObs = obsRd.getAsString("ordre_observation");
484
			    	String ordreObs = obsRd.getAsString("ordre_observation");
473
			    	
485
			    	
474
			    	if(ordreObs != null) {
486
			    	if(ordreObs != null) {
475
			    		return observationMediateur.gererOverDDMotCleSurObs(ordreObs, idMc);
487
			    		return observationMediateur.gererOverDDMotCleSurObs(ordreObs, idMc);
476
			    	}
488
			    	}
477
				}
489
				}
478
				
490
				
479
				return "x-dd-drop-nodrop";
491
				return "x-dd-drop-nodrop";
480
			}
492
			}
481
		};
493
		};
482
	}
494
	}
483
 
495
 
484
	/**
496
	/**
485
	 * Méthode héritée de l'interface VueListable
497
	 * Méthode héritée de l'interface VueListable
486
	 * Sélectionne les observations  dans la liste suivant les identifiants donnés en paramètres
498
	 * Sélectionne les observations  dans la liste suivant les identifiants donnés en paramètres
487
	 */
499
	 */
-
 
500
	
488
	
501
	@Override
489
	public String[] getIdSelectionnees() {
502
	public String[] getIdSelectionnees() {
490
		
503
		
491
		Record[] selection = this.getSelectionModel().getSelections();
504
		Record[] selection = this.getSelectionModel().getSelections();
492
		int taille = selection.length;
505
		int taille = selection.length;
493
		String id_selection[] = new String[taille];
506
		String id_selection[] = new String[taille];
494
 
507
 
495
		for (int i = 0; i < selection.length; i++) {
508
		for (int i = 0; i < selection.length; i++) {
496
 
509
 
497
			id_selection[i] = selection[i].getAsString("ordre_observation");
510
			id_selection[i] = selection[i].getAsString("ordre_observation");
498
		}
511
		}
499
 
512
 
500
		return id_selection;
513
		return id_selection;
501
	}
514
	}
502
	
515
	
503
 
516
 
504
	
517
	
505
	/**
518
	/**
506
	 * Sélectionne des enregistrements donné 
519
	 * Sélectionne des enregistrements donné 
507
	 * @param sel un tableau d'enregistrement à selectionner
520
	 * @param sel un tableau d'enregistrement à selectionner
508
	 */
521
	 */
509
	public void selectionnerEnregistrements(Record[] sel) {
522
	public void selectionnerEnregistrements(Record[] sel) {
510
 
523
 
511
			getSelectionModel().clearSelections();
524
			getSelectionModel().clearSelections();
512
			getSelectionModel().selectRecords(sel);
525
			getSelectionModel().selectRecords(sel);
513
		
526
		
514
	}
527
	}
515
	
528
	
516
	/**
529
	/**
517
	 * Accesseur pour la toolbar de pagination
530
	 * Accesseur pour la toolbar de pagination
518
	 * @return la toolbar de pagination
531
	 * @return la toolbar de pagination
519
	 */
532
	 */
520
	
533
	
521
	public BarrePaginationVue getToolBarVue()
534
	public BarrePaginationVue getToolBarVue()
522
	{
535
	{
523
		return bt ;
536
		return bt ;
524
	}
537
	}
525
 
538
 
526
 
539
 
527
	/**
540
	/**
528
	 * Recherche l'élement actuellement affiché et affiche son message de chargement
541
	 * Recherche l'élement actuellement affiché et affiche son message de chargement
529
	 */
542
	 */
530
	public void masquerChargement()
543
	public void masquerChargement()
531
	{
544
	{
532
			ExtElement masked = Ext.get(getId()) ;
545
			ExtElement masked = Ext.get(getId()) ;
533
 
546
 
534
 
547
 
535
			if (masked!=null) {
548
			if (masked!=null) {
536
				masked.mask("Chargement") ;
549
				masked.mask("Chargement") ;
537
			}
550
			}
538
 
551
 
539
	}
552
	}
540
	
553
	
541
	/**
554
	/**
542
	 * Recherche l'élement actuellement affiché et retire son message de chargement si l'était affiché
555
	 * Recherche l'élement actuellement affiché et retire son message de chargement si l'était affiché
543
	 */
556
	 */
544
	public void demasquerChargement()
557
	public void demasquerChargement()
545
	{
558
	{
546
		ExtElement masked = Ext.get(getId()) ;
559
		ExtElement masked = Ext.get(getId()) ;
547
		
560
		
548
		if (masked!=null) {
561
		if (masked!=null) {
549
			masked.unmask() ;
562
			masked.unmask() ;
550
		}
563
		}
551
	}
564
	}
552
	
565
	
553
 
566
 
554
 
567
 
555
	/**
568
	/**
556
	 * Méthode héritée de l'interface rafraichissable
569
	 * Méthode héritée de l'interface rafraichissable
557
	 * @param nouvelleDonnees les nouvelles données
570
	 * @param nouvelleDonnees les nouvelles données
558
	 * @param repandreRafraichissement le booleen de notification du rafraichissement
571
	 * @param repandreRafraichissement le booleen de notification du rafraichissement
559
	 */
572
	 */
560
	
573
	
561
 
574
 
-
 
575
 
562
 
576
	@Override
563
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
577
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
564
	
578
	
565
//		 si l'on a reçu une liste d'observation
579
//		 si l'on a reçu une liste d'observation
566
		if(nouvelleDonnees instanceof ListeObservation)
580
		if(nouvelleDonnees instanceof ListeObservation)
567
		{
581
		{
568
			
582
			
569
				ListeObservation data = (ListeObservation) nouvelleDonnees ;
583
				ListeObservation data = (ListeObservation) nouvelleDonnees ;
570
				Object[][] observationData = new Object[data.size()][7];
584
				Object[][] observationData = new Object[data.size()][7];
571
				int i = 0 ;
585
				int i = 0 ;
572
				
586
				
573
				if(data.size() == 0)
587
				if(data.size() == 0)
574
				{
588
				{
575
					pageEncours = 0 ;
589
					pageEncours = 0 ;
576
				}
590
				}
577
				
591
				
578
				// on la parse et on récupère les informations qui nous interessent
592
				// on la parse et on récupère les informations qui nous interessent
579
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
593
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
580
				{
594
				{
581
					
595
					
582
					Observation obs=(Observation) data.get(it.next());
596
					Observation obs=data.get(it.next());
583
					
597
					
584
					observationData[i][0] = obs.getTransmis();
598
					observationData[i][0] = obs.getTransmis();
585
					observationData[i][1] = obs.getNomSaisi();
599
					observationData[i][1] = obs.getNomSaisi();
586
					observationData[i][2] = obs.getNomRetenu();
600
					observationData[i][2] = obs.getNomRetenu();
587
 
601
 
588
					observationData[i][3] = Util.formaterLieu(obs, modeleLieu);
602
					observationData[i][3] = Util.formaterLieu(obs, modeleLieu);
589
					observationData[i][4] = obs.getDate();
603
					observationData[i][4] = obs.getDate();
590
					observationData[i][5] = obs.getNumeroOrdre();		
604
					observationData[i][5] = obs.getNumeroOrdre();		
591
					observationData[i][6] = obs.getNumeroNomenclaturalSaisi();
605
					observationData[i][6] = obs.getNumeroNomenclaturalSaisi();
592
									
606
									
593
					i++ ;
607
					i++ ;
594
				}
608
				}
595
		
609
		
596
				// creation du store qui les contient
610
				// creation du store qui les contient
597
				FieldDef defEtatObservation = new StringFieldDef("etat_observation");
611
				FieldDef defEtatObservation = new StringFieldDef("etat_observation");
598
				FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
612
				FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
599
				FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
613
				FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
600
				FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
614
				FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
601
				FieldDef defDateObservation = new StringFieldDef("date_observation");
615
				FieldDef defDateObservation = new StringFieldDef("date_observation");
602
				FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
616
				FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
603
				
617
				
604
				// Non affiches :
618
				// Non affiches :
605
				FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
619
				FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
606
				
620
				
607
				
621
				
608
				// on associe le store
622
				// on associe le store
609
 
623
 
610
				FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
624
				FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
611
						defLieuObservation, defDateObservation, defOrdreObservation, defNumeroNomenclaturalSaisiObservation };
625
						defLieuObservation, defDateObservation, defOrdreObservation, defNumeroNomenclaturalSaisiObservation };
612
				
626
				
613
				RecordDef rd = new RecordDef(defTab);
627
				RecordDef rd = new RecordDef(defTab);
614
				
628
				
615
				final MemoryProxy dataProxy = new MemoryProxy(observationData);
629
				final MemoryProxy dataProxy = new MemoryProxy(observationData);
616
				final ArrayReader reader = new ArrayReader(rd);
630
				final ArrayReader reader = new ArrayReader(rd);
617
		
631
		
618
				final Store observationStore = new Store(dataProxy, reader);
632
				final Store observationStore = new Store(dataProxy, reader);
619
				
633
				
620
				
634
				
621
				st = observationStore ;
635
				st = observationStore ;
622
				st.load() ;
636
				st.load() ;
623
				
637
				
624
				
638
				
625
				// et on reconfigure et rafraichit la vue
639
				// et on reconfigure et rafraichit la vue
626
				this.reconfigure(st, this.getColumnModel());
640
				this.reconfigure(st, this.getColumnModel());
627
				
641
				
628
				demasquerChargement();
642
				demasquerChargement();
629
				
643
				
630
			    cacheListeObservation=data;
644
			    cacheListeObservation=data;
631
			    
645
			    
632
				observationMediateur.onRafraichissementListeObservations();
646
				observationMediateur.onRafraichissementListeObservations();
633
				
647
				
634
				
648
				
635
		}
649
		}
636
		
650
		
637
		
651
		
638
		// Si on reçoit un tableau d'entiers
652
		// Si on reçoit un tableau d'entiers
639
		// c'est un tableau d'un seul entier qui est le nombre d'observation correspondant aux critères
653
		// c'est un tableau d'un seul entier qui est le nombre d'observation correspondant aux critères
640
		if(nouvelleDonnees instanceof int[])
654
		if(nouvelleDonnees instanceof int[])
641
		{
655
		{
642
			int[] pages = (int[])nouvelleDonnees ;
656
			int[] pages = (int[])nouvelleDonnees ;
643
			
657
			
644
			// on calcule le nombre de pages nécessaires et on les met à jour dans le modèle
658
			// on calcule le nombre de pages nécessaires et on les met à jour dans le modèle
645
			pageMax  = calculerNbPages(pages[0]) ;
659
			pageMax  = calculerNbPages(pages[0]) ;
646
			nbElements = pages[0] ;
660
			nbElements = pages[0] ;
647
			
661
			
648
			
662
			
649
			// et on notifie de le mediateur du changement des valeurs
663
			// et on notifie de le mediateur du changement des valeurs
650
			changerPageMaxEtCourante(pageMax,pageEncours,taillePage,pages[0]) ;
664
			changerPageMaxEtCourante(pageMax,pageEncours,taillePage,pages[0]) ;
651
			
665
			
652
			masquerChargement();
666
			masquerChargement();
653
			observationMediateur.obtenirListeObservation(this);
667
			observationMediateur.obtenirListeObservation(this);
654
		}
668
		}
655
		
669
		
656
		
670
		
657
		// si l'on a reçu une Observation 
671
		// si l'on a reçu une Observation 
658
		if(nouvelleDonnees instanceof Observation) {
672
		if(nouvelleDonnees instanceof Observation) {
659
		
673
		
660
			Observation obs= (Observation) nouvelleDonnees;
674
			Observation obs= (Observation) nouvelleDonnees;
661
			if (obs.getNumeroOrdre()==null) { 
675
			if (obs.getNumeroOrdre()==null) { 
662
				
676
				
663
				// Nouvelle observation
677
				// Nouvelle observation
664
				// On affiche la dernière page
678
				// On affiche la dernière page
665
				pageEncours = pageMax ;
679
				pageEncours = pageMax ;
666
				masquerChargement();
680
				masquerChargement();
667
	
681
	
668
				observationMediateur.obtenirNombreObservation();
682
				observationMediateur.obtenirNombreObservation();
669
			
683
			
670
			}
684
			}
671
			else { // Modification d'une observation
685
			else { // Modification d'une observation
672
					
686
					
673
				masquerChargement();
687
				masquerChargement();
674
				observationMediateur.obtenirNombreObservation();		
688
				observationMediateur.obtenirNombreObservation();		
675
				
689
				
676
			}
690
			}
677
		}
691
		}
678
		
692
		
679
		// Si on a effectué une suppression
693
		// Si on a effectué une suppression
680
		if(nouvelleDonnees instanceof String)
694
		if(nouvelleDonnees instanceof String)
681
		{
695
		{
682
			observationMediateur.obtenirNombreObservation() ;
696
			observationMediateur.obtenirNombreObservation() ;
683
		}
697
		}
684
		
698
		
685
		if(!getTailleInitialisee()) {
699
		if(!getTailleInitialisee()) {
686
			if((int)Math.round(observationMediateur.getPanneauPrincipalObservation().getHeight() * 0.6) != 0) {
700
			if((int)Math.round(observationMediateur.getPanneauPrincipalObservation().getHeight() * 0.6) != 0) {
687
				doLayout();
701
				doLayout();
688
				setTailleInitialisee();
702
				setTailleInitialisee();
689
			}
703
			}
690
		}
704
		}
691
		
705
		
692
	}
706
	}
693
	
707
	
694
	
708
	
695
	// GESTION DE LA PAGINATION
709
	// GESTION DE LA PAGINATION
696
 
710
 
697
	
711
	
698
	public ListeObservation getCacheListeObservation() {
712
	public ListeObservation getCacheListeObservation() {
699
		return cacheListeObservation;
713
		return cacheListeObservation;
700
	}
714
	}
701
 
715
 
702
	/**
716
	/**
703
	 * Calcule le nombre de pages nécessaires pour afficher un nombre d'élements donnés en fonction de la taille de page
717
	 * Calcule le nombre de pages nécessaires pour afficher un nombre d'élements donnés en fonction de la taille de page
704
	 * en cours
718
	 * en cours
705
	 * @param nbElements le nombre d'élements total
719
	 * @param nbElements le nombre d'élements total
706
	 * @return le nombre de pages 
720
	 * @return le nombre de pages 
707
	 */
721
	 */
708
	public int calculerNbPages(int nbElements)
722
	public int calculerNbPages(int nbElements)
709
	{
723
	{
710
		// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement
724
		// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement
711
		// pour eviter qu'il arrondisse mal la division
725
		// pour eviter qu'il arrondisse mal la division
712
		// nombre de pages = (nombre d'element / taille de la page) arrondie à l'entier superieur
726
		// nombre de pages = (nombre d'element / taille de la page) arrondie à l'entier superieur
713
		
727
		
714
		double nPage = (1.0*nbElements)/(1.0*taillePage) ; 
728
		double nPage = (1.0*nbElements)/(1.0*taillePage) ; 
715
		double nPageRound = Math.ceil(nPage) ;
729
		double nPageRound = Math.ceil(nPage) ;
716
		Double nPageInt = new Double(nPageRound) ;
730
		Double nPageInt = new Double(nPageRound) ;
717
		
731
		
718
		// on convertit en entier
732
		// on convertit en entier
719
		return nPageInt.intValue() ; 
733
		return nPageInt.intValue() ; 
720
	}
734
	}
721
 
735
 
722
	
736
	
723
	/**
737
	/**
724
	 * Recalcule la page en cours lors du changement du nombre d'élements
738
	 * Recalcule la page en cours lors du changement du nombre d'élements
725
	 * @param nbElements le nombre d'élements total
739
	 * @param nbElements le nombre d'élements total
726
	 * @return la nouvelle page encours
740
	 * @return la nouvelle page encours
727
	 */
741
	 */
728
	public int calculerPageCourante(int nbElements)
742
	public int calculerPageCourante(int nbElements)
729
	{
743
	{
730
		// on calcule le nombre de page
744
		// on calcule le nombre de page
731
		int nouvelNbPages = calculerNbPages(nbElements) ;
745
		int nouvelNbPages = calculerNbPages(nbElements) ;
732
		// la nouvelle page en cours
746
		// la nouvelle page en cours
733
		double nPageCourante = (1.0*pageEncours)/(1.0*pageMax) * (1.0*nouvelNbPages) ;
747
		double nPageCourante = (1.0*pageEncours)/(1.0*pageMax) * (1.0*nouvelNbPages) ;
734
		
748
		
735
		// on arrondit au supérieur
749
		// on arrondit au supérieur
736
		double nPageRound = Math.ceil(nPageCourante) ;
750
		double nPageRound = Math.ceil(nPageCourante) ;
737
		Double nPageInt = new Double(nPageRound) ;
751
		Double nPageInt = new Double(nPageRound) ;
738
		
752
		
739
		// on convertit en entier
753
		// on convertit en entier
740
		return Math.abs(nPageInt.intValue()) ; 
754
		return Math.abs(nPageInt.intValue()) ; 
741
	}
755
	}
742
	
756
	
743
 
757
 
744
	/**
758
	/**
745
	 * Appelle le modèle pour lui demander les données d'une page à afficher
759
	 * Appelle le modèle pour lui demander les données d'une page à afficher
746
	 * @param pageCourante le numéro de page à affciher
760
	 * @param pageCourante le numéro de page à affciher
747
	 */
761
	 */
-
 
762
	@Override
748
	public void changerNumeroPage(int pageCourante) {
763
	public void changerNumeroPage(int pageCourante) {
749
		
764
		
750
		
765
		
751
		
766
		
752
		pageEncours = pageCourante ;
767
		pageEncours = pageCourante ;
753
		
768
		
754
		masquerChargement();
769
		masquerChargement();
755
 
770
 
756
		// On lance le chargerment des observations
771
		// On lance le chargerment des observations
757
		observationMediateur.obtenirNombreObservation();
772
		observationMediateur.obtenirNombreObservation();
758
		
773
		
759
		getToolBarVue().changerPageCourante(pageCourante);
774
		getToolBarVue().changerPageCourante(pageCourante);
760
		
775
		
761
	}
776
	}
762
	
777
	
763
	
778
	
764
	/**
779
	/**
765
	 * Appelle le modèle pour qu'il change la taille de page utilisée
780
	 * Appelle le modèle pour qu'il change la taille de page utilisée
766
	 * @param nouvelleTaillePage la nouvelle taille de page
781
	 * @param nouvelleTaillePage la nouvelle taille de page
767
	 */
782
	 */
-
 
783
	
768
	
784
	@Override
769
	public void changerTaillePage(int nouvelleTaillePage)
785
	public void changerTaillePage(int nouvelleTaillePage)
770
	{
786
	{
771
	
787
	
772
		taillePage = nouvelleTaillePage ;
788
		taillePage = nouvelleTaillePage ;
773
		pageEncours = calculerPageCourante(nbElements) ;
789
		pageEncours = calculerPageCourante(nbElements) ;
774
 
790
 
775
		masquerChargement();
791
		masquerChargement();
776
 
792
 
777
		// 	On lance le chargement des observations
793
		// 	On lance le chargement des observations
778
		observationMediateur.obtenirNombreObservation();
794
		observationMediateur.obtenirNombreObservation();
779
		
795
		
780
		
796
		
781
		// et on met à jour la taille de page dans les barres d'outils
797
		// et on met à jour la taille de page dans les barres d'outils
782
		getToolBarVue().selectionnerTaillePage(nouvelleTaillePage);
798
		getToolBarVue().selectionnerTaillePage(nouvelleTaillePage);
783
		
799
		
784
		
800
		
785
	}
801
	}
786
 
802
 
787
	
803
	
788
	/**
804
	/**
789
	 * Met à jour les barre d'outils avec des nouvelles valeurs
805
	 * Met à jour les barre d'outils avec des nouvelles valeurs
790
	 * @param pageMax le nombre de pages
806
	 * @param pageMax le nombre de pages
791
	 * @param pageEncours la page en cours
807
	 * @param pageEncours la page en cours
792
	 * @param taillePage la taille de page
808
	 * @param taillePage la taille de page
793
	 * @param nbElement le nombre d'élements par page
809
	 * @param nbElement le nombre d'élements par page
794
	 */
810
	 */
795
	public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement) 
811
	public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement) 
796
	{
812
	{
797
				
813
				
798
		int[] pages = {pageMax,pageEncours, taillePage, nbElement} ;
814
		int[] pages = {pageMax,pageEncours, taillePage, nbElement} ;
799
		getToolBarVue().rafraichir(pages, false) ;
815
		getToolBarVue().rafraichir(pages, false) ;
800
		
816
		
801
	}
817
	}
802
	
818
	
803
	/**
819
	/**
804
	 * Renvoie la taille de page en cours d'utilisation
820
	 * Renvoie la taille de page en cours d'utilisation
805
	 * @return la taille de page
821
	 * @return la taille de page
806
	 */
822
	 */
807
	public int getTaillePage() {
823
	public int getTaillePage() {
808
		
824
		
809
		return taillePage;
825
		return taillePage;
810
	}
826
	}
811
	
827
	
812
	/**
828
	/**
813
	 * Renvoie le numéro de la page encours (attention on commence à 0)
829
	 * Renvoie le numéro de la page encours (attention on commence à 0)
814
	 * @return le numéro de la page en cours
830
	 * @return le numéro de la page en cours
815
	 */
831
	 */
816
	public int getPageEncours() {
832
	public int getPageEncours() {
817
		
833
		
818
		return pageEncours;
834
		return pageEncours;
819
	}
835
	}
820
	
836
	
821
	public void afficherFiltres(String[][] filtresEnCours) {
837
	public void afficherFiltres(String[][] filtresEnCours) {
822
		
838
		
823
		String texteFiltresEnCours = "";
839
		String texteFiltresEnCours = "";
824
		
840
		
825
		for(int i = 0; i < filtresEnCours.length; i++) {
841
		for(int i = 0; i < filtresEnCours.length; i++) {
826
			if(Util.filtreValide(filtresEnCours[i])) {
842
			if(Util.filtreValide(filtresEnCours[i])) {
827
				
843
				
828
				if(!texteFiltresEnCours.equals("")) {
844
				if(!texteFiltresEnCours.equals("")) {
829
					texteFiltresEnCours += " - ";
845
					texteFiltresEnCours += " - ";
830
				}
846
				}
831
				
847
				
832
				texteFiltresEnCours += "<span class=\"affichage_filtre\">"+
848
				texteFiltresEnCours += "<span class=\"affichage_filtre\">"+
833
											transformerNomFiltre(filtresEnCours[i][0])+": "+transformerValeurFiltre(filtresEnCours[i][0], filtresEnCours[i][1])+
849
											transformerNomFiltre(filtresEnCours[i][0])+": "+transformerValeurFiltre(filtresEnCours[i][0], filtresEnCours[i][1])+
834
									   " <input value=\"X\" type=\"button\" rel=\""+filtresEnCours[i][0]+"\" id=\"bouton_raz_filtres_obs_"+filtresEnCours[i][0]+"\" />"+
850
									   " <input value=\"X\" type=\"button\" rel=\""+filtresEnCours[i][0]+"\" id=\"bouton_raz_filtres_obs_"+filtresEnCours[i][0]+"\" />"+
835
										"</span>";
851
										"</span>";
836
			}
852
			}
837
		}
853
		}
838
		
854
		
839
		if(!texteFiltresEnCours.equals("")) {
855
		if(!texteFiltresEnCours.equals("")) {
840
			texteFiltresEnCours = "- <span class=\"indicateur_filtres\"> Filtres - "+texteFiltresEnCours+"</span>";
856
			texteFiltresEnCours = "- <span class=\"indicateur_filtres\"> Filtres - "+texteFiltresEnCours+"</span>";
841
		}
857
		}
842
		
858
		
843
		this.setTitle("Observations"+texteFiltresEnCours) ;
859
		this.setTitle("Observations"+texteFiltresEnCours) ;
844
		
860
		
845
		for(int i = 0; i < filtresEnCours.length; i++) {
861
		for(int i = 0; i < filtresEnCours.length; i++) {
846
			
862
			
847
			if(Util.filtreValide(filtresEnCours[i])) {
863
			if(Util.filtreValide(filtresEnCours[i])) {
848
				if(Ext.get("bouton_raz_filtres_obs_"+filtresEnCours[i][0]) != null) {
864
				if(Ext.get("bouton_raz_filtres_obs_"+filtresEnCours[i][0]) != null) {
849
					
865
					
850
					Ext.get("bouton_raz_filtres_obs_"+filtresEnCours[i][0]).addListener("click", new EventCallback() {
866
					Ext.get("bouton_raz_filtres_obs_"+filtresEnCours[i][0]).addListener("click", new EventCallback() {
-
 
867
						
851
						
868
						@Override
852
						public void execute(EventObject e) {
869
						public void execute(EventObject e) {
853
							e.stopEvent();
870
							e.stopEvent();
854
							observationMediateur.viderFiltre(e.getTarget().getAttribute("rel"));
871
							observationMediateur.viderFiltre(e.getTarget().getAttribute("rel"));
855
						}
872
						}
856
						
873
						
857
					});
874
					});
858
				}
875
				}
859
			}
876
			}
860
		}
877
		}
861
	}
878
	}
862
	
879
	
863
	private String transformerNomFiltre(String nomFiltre) {
880
	private String transformerNomFiltre(String nomFiltre) {
864
		
881
		
865
		if(nomFiltre.equals("departement")) {
882
		if(nomFiltre.equals("departement")) {
866
			nomFiltre = "departement";
883
			nomFiltre = "departement";
867
		}
884
		}
868
		
885
		
869
		if(nomFiltre.equals("commune")) {
886
		if(nomFiltre.equals("commune")) {
870
			nomFiltre = "commune";
887
			nomFiltre = "commune";
871
		}
888
		}
872
		
889
		
873
		if(nomFiltre.equals("nom_taxon")) {
890
		if(nomFiltre.equals("nom_taxon")) {
874
			nomFiltre = "recherche";
891
			nomFiltre = "recherche";
875
		}
892
		}
876
		
893
		
877
		if(nomFiltre.equals("id_mots_cles")) {
894
		if(nomFiltre.equals("id_mots_cles")) {
878
			nomFiltre = "projets";
895
			nomFiltre = "projets";
879
		}
896
		}
880
		
897
		
881
		return nomFiltre;
898
		return nomFiltre;
882
		
899
		
883
	}
900
	}
884
	
901
	
885
	private String transformerValeurFiltre(String nomFiltre, String valeurFiltre) {
902
	private String transformerValeurFiltre(String nomFiltre, String valeurFiltre) {
886
		
903
		
887
		String valeurFiltreTransformee = valeurFiltre;
904
		String valeurFiltreTransformee = valeurFiltre;
888
		
905
		
889
		if(nomFiltre.equals("id_mots_cles")) {
906
		if(nomFiltre.equals("id_mots_cles")) {
890
			
907
			
891
			String[] tabMotsCles = valeurFiltre.split(";");
908
			String[] tabMotsCles = valeurFiltre.split(";");
892
			String[] tabMotsClesTexte = observationMediateur.obtenirTexteMotsCles(tabMotsCles);
909
			String[] tabMotsClesTexte = observationMediateur.obtenirTexteMotsCles(tabMotsCles);
893
			
910
			
894
			if(tabMotsClesTexte.length > 1) {
911
			if(tabMotsClesTexte.length > 1) {
895
				valeurFiltreTransformee = Util.implode(",", tabMotsClesTexte);
912
				valeurFiltreTransformee = Util.implode(",", tabMotsClesTexte);
896
			} else {
913
			} else {
897
				valeurFiltreTransformee = tabMotsClesTexte[0];
914
				valeurFiltreTransformee = tabMotsClesTexte[0];
898
			}
915
			}
899
		}
916
		}
900
		
917
		
901
		if(nomFiltre.equals("mois")) {
918
		if(nomFiltre.equals("mois")) {
902
			valeurFiltreTransformee = Util.renvoyerMois(Integer.parseInt(valeurFiltre));
919
			valeurFiltreTransformee = Util.renvoyerMois(Integer.parseInt(valeurFiltre));
903
		}
920
		}
904
		
921
		
905
		valeurFiltreTransformee = valeurFiltreTransformee.replaceAll("000null", "inconnue");
922
		valeurFiltreTransformee = valeurFiltreTransformee.replaceAll("000null", "inconnue");
906
 
923
 
907
		return valeurFiltreTransformee;
924
		return valeurFiltreTransformee;
908
		
925
		
909
	}
926
	}
910
 
927
 
911
	public void raz() {
928
	public void raz() {
912
		
929
		
913
		
930
		
914
		// creation du store qui les contient
931
		// creation du store qui les contient
915
		
932
		
916
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
933
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
917
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
934
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
918
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
935
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
919
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
936
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
920
		FieldDef defDateObservation = new StringFieldDef("date_observation");
937
		FieldDef defDateObservation = new StringFieldDef("date_observation");
921
		FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
938
		FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
922
		
939
		
923
		// Non affiches :
940
		// Non affiches :
924
		FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
941
		FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
925
		
942
		
926
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
943
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
927
				defLieuObservation, defDateObservation, defOrdreObservation };
944
				defLieuObservation, defDateObservation, defOrdreObservation };
928
		
945
		
929
		RecordDef rd = new RecordDef(defTab);
946
		RecordDef rd = new RecordDef(defTab);
930
		st = new Store(rd);
947
		st = new Store(rd);
931
		
948
		
932
		// on associe le store
949
		// on associe le store
933
		
950
		
934
		this.setStore(st);
951
		this.setStore(st);
935
		
952
		
936
	}
953
	}
937
	
954
	
938
	public boolean verifierFormatDate(String date) {
955
	public boolean verifierFormatDate(String date) {
939
		
956
		
940
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
957
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
941
		if(date.matches(regex) && !date.equals("0000-00-00")) {
958
		if(date.matches(regex) && !date.equals("0000-00-00")) {
942
			return true ;
959
			return true ;
943
		}
960
		}
944
		else {
961
		else {
945
			return false;
962
			return false;
946
		}
963
		}
947
	}
964
	}
948
	
965
	
949
	public boolean getTailleInitialisee() {
966
	public boolean getTailleInitialisee() {
950
		return tailleInitialisee ;
967
		return tailleInitialisee ;
951
	}
968
	}
952
	
969
	
953
	public void setTailleInitialisee() {
970
	public void setTailleInitialisee() {
954
		tailleInitialisee = true;
971
		tailleInitialisee = true;
955
	}
972
	}
956
 
973
 
957
}
974
}