Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 195 Rev 401
Line 1... Line 1...
1
package org.tela_botanica.client.vues.image;
1
package org.tela_botanica.client.vues.image;
Line 2... Line 2...
2
 
2
 
Line 3... Line 3...
3
import java.util.Iterator;
3
import java.util.Iterator;
-
 
4
 
4
 
5
import org.tela_botanica.client.image.ImageMediateur;
5
import org.tela_botanica.client.image.ImageMediateur;
6
import org.tela_botanica.client.interfaces.ListePaginable;
6
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
8
import org.tela_botanica.client.modeles.ListeObservation;
Line 7... Line 9...
7
import org.tela_botanica.client.modeles.ListeObservation;
9
import org.tela_botanica.client.modeles.Observation;
8
import org.tela_botanica.client.modeles.Observation;
10
import org.tela_botanica.client.vues.MiniBarrePaginationVue;
9
 
11
 
10
import com.google.gwt.user.client.Window;
12
import com.google.gwt.user.client.Window;
Line 18... Line 20...
18
import com.gwtext.client.widgets.Container;
20
import com.gwtext.client.widgets.Container;
19
import com.gwtext.client.widgets.Toolbar;
21
import com.gwtext.client.widgets.Toolbar;
20
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
22
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
21
import com.gwtext.client.widgets.form.ComboBox;
23
import com.gwtext.client.widgets.form.ComboBox;
22
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
24
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
-
 
25
import com.gwtext.client.widgets.grid.CellMetadata;
23
import com.gwtext.client.widgets.grid.ColumnConfig;
26
import com.gwtext.client.widgets.grid.ColumnConfig;
24
import com.gwtext.client.widgets.grid.ColumnModel;
27
import com.gwtext.client.widgets.grid.ColumnModel;
25
import com.gwtext.client.widgets.grid.GridDragData;
28
import com.gwtext.client.widgets.grid.GridDragData;
26
import com.gwtext.client.widgets.grid.GridPanel;
29
import com.gwtext.client.widgets.grid.GridPanel;
-
 
30
import com.gwtext.client.widgets.grid.Renderer;
27
import com.gwtext.client.widgets.grid.event.GridListenerAdapter;
31
import com.gwtext.client.widgets.grid.event.GridListenerAdapter;
-
 
32
import com.gwtext.client.widgets.grid.event.GridRowListenerAdapter;
-
 
33
import com.gwtext.client.widgets.menu.BaseItem;
-
 
34
import com.gwtext.client.widgets.menu.Item;
-
 
35
import com.gwtext.client.widgets.menu.Menu;
-
 
36
import com.gwtext.client.widgets.menu.event.MenuListenerAdapter;
28
import com.gwtext.client.core.EventObject;
37
import com.gwtext.client.core.EventObject;
29
import com.gwtext.client.core.Ext;
38
import com.gwtext.client.core.Ext;
30
import com.gwtext.client.core.ExtElement;
39
import com.gwtext.client.core.ExtElement;
31
import com.gwtext.client.dd.DragData;
40
import com.gwtext.client.dd.DragData;
Line 32... Line 41...
32
 
41
 
33
/**
42
/**
34
 * liste d'observation pour l'association d'images aux observations
43
 * liste d'observation pour l'association d'images aux observations
35
 * @author aurelien
44
 * @author aurelien
36
 *
45
 *
37
 */
46
 */
Line 38... Line 47...
38
public class MiniListeObservationVue extends GridPanel implements Rafraichissable {
47
public class MiniListeObservationVue extends GridPanel implements Rafraichissable, ListePaginable {
39
 
48
 
40
	/**
49
	/**
41
	 * Le médiateur associé à la vue
50
	 * Le médiateur associé à la vue
Line 52... Line 61...
52
	 */
61
	 */
53
	private ColumnModel colModel = null ;
62
	private ColumnModel colModel = null ;
Line 54... Line 63...
54
	
63
	
Line 55... Line 64...
55
	private SimpleStore store = null ;
64
	private SimpleStore store = null ;
Line 56... Line 65...
56
	
65
	
Line 57... Line 66...
57
	//private BarrePaginationVue pgBar = new BarrePaginationVue(iMediateur) ;
66
	private MiniBarrePaginationVue pgBar = new MiniBarrePaginationVue(iMediateur) ;
58
	
67
	
Line 66... Line 75...
66
	
75
	
Line 67... Line 76...
67
	Store storeMode = null ;
76
	Store storeMode = null ;
Line -... Line 77...
-
 
77
 
-
 
78
	private boolean liaison;
68
 
79
	
69
	private boolean liaison;
80
	int pageEnCours = 0;
70
	
81
	
71
	/**
82
	/**
72
	 * Constructeur avec arguments
83
	 * Constructeur avec arguments
Line 77... Line 88...
77
		iMediateur = im ;
88
		iMediateur = im ;
Line 78... Line 89...
78
		
89
		
Line 79... Line 90...
79
		this.setId("x-view-mini-obs") ;
90
		this.setId("x-view-mini-obs") ;
80
		
91
		
81
		// on crée un store simple contenant un petit set de données et deux colonnes
92
		// on crée un store simple contenant un petit set de données et deux colonnes
-
 
93
		store = new SimpleStore(new String[]{"transmis","id_obs","plante","date","lieu"}, getObs());  
-
 
94
		ColumnConfig[] columns = { 
-
 
95
		new ColumnConfig("", "transmis", 30, true, new Renderer() {
-
 
96
 
-
 
97
			public String render(Object value, CellMetadata cellMetadata,
-
 
98
					Record record, int rowIndex, int colNum, Store store) {
-
 
99
				if(value.equals("1"))
-
 
100
				{
-
 
101
					return "<img src=\"tela.png\"/></img>" ;
-
 
102
				}
-
 
103
				else
-
 
104
				{
-
 
105
					return "" ;
-
 
106
				}
-
 
107
			}
82
		store = new SimpleStore(new String[]{"id_obs","plante","date","lieu"}, getObs());  
108
			
83
		ColumnConfig[] columns = {  
109
		}), 
84
		new ColumnConfig("Numero", "id_obs", 50, true),   
110
		new ColumnConfig("Numero", "id_obs", 50, true),   
85
		new ColumnConfig("Taxon", "plante", 145, true), 
111
		new ColumnConfig("Taxon", "plante", 145, true), 
Line 101... Line 127...
101
 		this.setEnableDragDrop(true);
127
 		this.setEnableDragDrop(true);
102
 		this.setDdGroup("DragGroupName");
128
 		this.setDdGroup("DragGroupName");
103
        store.load();       
129
        store.load();       
104
		setStore(store) ;
130
		setStore(store) ;
Line 105... Line 131...
105
		
131
		
Line 106... Line 132...
106
		//setBottomToolbar(pgBar) ;
132
		setBottomToolbar(pgBar) ;
107
		
133
		
108
		Object[][] mode = {{"toutes les observations",false} , {"observations liées", true} };
134
		Object[][] mode = {{"toutes les observations",false} , {"observations liées", true} };
109
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
135
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
Line 156... Line 182...
156
		
182
		
Line 157... Line 183...
157
		this.addGridListener(new GridListenerAdapter() {
183
		this.addGridListener(new GridListenerAdapter() {
Line -... Line 184...
-
 
184
 
-
 
185
			public void onContextMenu(EventObject e) {
-
 
186
				
-
 
187
				// si pas de selection, on selection au moins la ligne sur laquelle on a fait le clic
-
 
188
				if(getSelectionModel().getSelections().length <= 0) {
-
 
189
					int index = getView().findRowIndex(e);
-
 
190
			  		Record rddrop = getStore().getRecordAt(index) ;
158
 
191
					getSelectionModel().selectRecords(rddrop);
159
			public void onContextMenu(EventObject e) {
192
				}
160
				
193
				
Line 161... Line 194...
161
				e.stopEvent() ;
194
				e.stopEvent() ;
Line 162... Line 195...
162
				MenuLiaisonVue mlv = new MenuLiaisonVue(iMediateur,liaison) ;
195
				MenuLiaisonVue mlv = new MenuLiaisonVue(iMediateur,liaison) ;
163
				mlv.showAt(e.getXY()) ;
196
				mlv.showAt(e.getXY()) ;
Line 164... Line 197...
164
				
197
				
165
			}
198
			}
166
			
199
			
Line 225... Line 258...
225
		if(nouvelleDonnees instanceof ListeObservation)
258
		if(nouvelleDonnees instanceof ListeObservation)
226
		{
259
		{
227
			if(this.getView() != null)
260
			if(this.getView() != null)
228
			{
261
			{
229
				ListeObservation data = (ListeObservation)nouvelleDonnees ;
262
				ListeObservation data = (ListeObservation)nouvelleDonnees ;
230
				String[][] listeObs = new String[data.size()][4] ;
263
				String[][] listeObs = new String[data.size()][5] ;
231
				int i = 0 ;
264
				int i = 0 ;
Line 232... Line 265...
232
				
265
				
233
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
266
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
Line 234... Line 267...
234
				{
267
				{
Line 235... Line 268...
235
					
268
					
-
 
269
					Observation obs=(Observation) data.get(it.next());
236
					Observation obs=(Observation) data.get(it.next());
270
					
237
					
271
					listeObs[i][0] = obs.getNumeroOrdre();
238
					listeObs[i][0] = obs.getNumeroOrdre();
272
					listeObs[i][1] = obs.getTransmis();
Line 239... Line 273...
239
					listeObs[i][1] = obs.getNomSaisi();
273
					listeObs[i][2] = obs.getNomSaisi();
240
					listeObs[i][2] = obs.getDate() ;
274
					listeObs[i][3] = obs.getDate() ;
Line 241... Line 275...
241
					listeObs[i][3] = obs.getLocalite();
275
					listeObs[i][4] = obs.getLocalite();
242
				
276
				
243
					i++ ;
277
					i++ ;
244
				}
278
				}
245
	
279
	
246
				store = new SimpleStore(new String[]{"id_obs","plante","date","lieu"}, listeObs);  	
280
				store = new SimpleStore(new String[]{"id_obs","transmis","plante","date","lieu"}, listeObs);  	
Line 288... Line 322...
288
	public Store getStore()
322
	public Store getStore()
289
	{
323
	{
290
		return store ;
324
		return store ;
291
	}
325
	}
Line 292... Line 326...
292
	
326
	
293
	/*public BarrePaginationVue getBarrePagination()
327
	public MiniBarrePaginationVue getBarrePagination()
294
	{
328
	{
295
		return pgBar ;
329
		return pgBar ;
Line 296... Line 330...
296
	}*/
330
	}
297
	
331
	
298
	private void setModification(String mode)
332
	private void setModification(String mode)
Line 377... Line 411...
377
		}
411
		}
378
		else {
412
		else {
379
			Window.alert("null");			
413
			Window.alert("null");			
380
		}
414
		}
381
	}
415
	}
-
 
416
	
-
 
417
	/**
-
 
418
	 * Montre le menu de liaison aux coordonnées indiquées
-
 
419
	 * @param e
-
 
420
	 */
-
 
421
	public void montrerContextMenuLiaison(EventObject e) {
-
 
422
		
-
 
423
		final Menu liObs = new Menu();
-
 
424
		final Item lierObservation = new Item("Lier aux images selectionnées");
-
 
425
		liObs.addItem(lierObservation);
-
 
426
		
-
 
427
		liObs.addListener(new MenuListenerAdapter() {
-
 
428
 
-
 
429
			// gestion du clic sur un item
-
 
430
			public void onItemClick(BaseItem item, EventObject ev) {
-
 
431
 
-
 
432
				// si c'est la suppression
-
 
433
				if (item.equals(lierObservation)) {
-
 
434
					// on notifie le médiateur
-
 
435
 
-
 
436
				}
-
 
437
				
-
 
438
				// enfin, on cache le menu
-
 
439
				liObs.hide();
-
 
440
 
-
 
441
			}
-
 
442
 
-
 
443
		});
-
 
444
		
-
 
445
		liObs.showAt(e.getXY());
-
 
446
	}
-
 
447
 
-
 
448
	@Override
-
 
449
	public void changerNumeroPage(int pageCourante) {
-
 
450
		
-
 
451
		pageEnCours = pageCourante ;	
-
 
452
		masquerChargement();
-
 
453
 
-
 
454
		// On lance le chargerment des observations
-
 
455
		iMediateur.obtenirMiniListeObservations(this);
-
 
456
		
-
 
457
		pgBar.changerPageCourante(pageCourante);
-
 
458
		
-
 
459
	}
-
 
460
 
-
 
461
	@Override
-
 
462
	public void changerTaillePage(int nouvelleTaillePage) {
-
 
463
		// TODO Auto-generated method stub
-
 
464
		
-
 
465
	}
382
}
466
}