Subversion Repositories eFlore/Applications.cel

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 61
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line -... Line 2...
-
 
2
 
-
 
3
import java.util.Iterator;
2
 
4
 
3
import org.tela_botanica.client.image.ImageMediateur;
5
import org.tela_botanica.client.image.ImageMediateur;
-
 
6
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
7
import org.tela_botanica.client.modeles.ListeObservation;
Line -... Line 8...
-
 
8
import org.tela_botanica.client.modeles.Observation;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
9
 
5
 
10
import com.google.gwt.user.client.Window;
6
import com.gwtext.client.data.SimpleStore;
11
import com.gwtext.client.data.SimpleStore;
7
import com.gwtext.client.data.Store;
12
import com.gwtext.client.data.Store;
8
import com.gwtext.client.dd.DragSource;
13
import com.gwtext.client.dd.DragSource;
9
import com.gwtext.client.dd.DropTarget;
14
import com.gwtext.client.dd.DropTarget;
-
 
15
import com.gwtext.client.dd.DropTargetConfig;
-
 
16
import com.gwtext.client.widgets.Component;
10
import com.gwtext.client.dd.DropTargetConfig;
17
import com.gwtext.client.widgets.event.ComponentListenerAdapter;
11
import com.gwtext.client.widgets.Component;
18
import com.gwtext.client.widgets.event.ContainerListener;
12
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
19
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
13
import com.gwtext.client.widgets.grid.ColumnConfig;
20
import com.gwtext.client.widgets.grid.ColumnConfig;
14
import com.gwtext.client.widgets.grid.ColumnModel;
21
import com.gwtext.client.widgets.grid.ColumnModel;
Line 38... Line 45...
38
	/**
45
	/**
39
	 * Le modèle de colonnes
46
	 * Le modèle de colonnes
40
	 */
47
	 */
41
	private ColumnModel colModel = null ;
48
	private ColumnModel colModel = null ;
Line -... Line 49...
-
 
49
	
-
 
50
	private SimpleStore store = null ;
42
	
51
	
43
	/**
52
	/**
44
	 * Constructeur avec arguments
53
	 * Constructeur avec arguments
45
	 * @param im le médiateur à associer à la vue
54
	 * @param im le médiateur à associer à la vue
46
	 */
55
	 */
Line 49... Line 58...
49
		iMediateur = im ;
58
		iMediateur = im ;
Line 50... Line 59...
50
		
59
		
Line 51... Line 60...
51
		this.setId("x-view-mini-obs") ;
60
		this.setId("x-view-mini-obs") ;
52
		
61
		
53
		// on crée un store simple contenant un petit set de données et deux colonnes
62
		// on crée un store simple contenant un petit set de données et deux colonnes
54
		final Store store = new SimpleStore(new String[]{"id_obs","plante"}, getObs());  
63
		store = new SimpleStore(new String[]{"id_obs","plante","date"}, getObs());  
55
		ColumnConfig[] columns = {  
64
		ColumnConfig[] columns = {  
-
 
65
		new ColumnConfig("Numero", "id_obs", 55, true),   
Line 56... Line 66...
56
		new ColumnConfig("Numero", "id_obs", 65, true),   
66
		new ColumnConfig("Taxon", "plante", 150, true), 
Line 57... Line 67...
57
		new ColumnConfig("Taxon", "plante", 150, true) } ;
67
		new ColumnConfig("Date", "date", 68, true) } ;
Line 58... Line 68...
58
		   
68
		   
59
        ColumnModel columnModel = new ColumnModel(columns);
69
        ColumnModel columnModel = new ColumnModel(columns);
60
         
70
         
61
        colModel = columnModel ;
71
        colModel = columnModel ;
62
         
72
         
63
        setTitle("Observations");  
73
        setTitle("Observations");  
64
        // on associe le modèle de colonnes
74
        // on associe le modèle de colonnes
65
        setColumnModel(columnModel);  
75
        setColumnModel(columnModel);  
66
        setHeight(390);  
76
        setAutoHeight(true);  
67
        setWidth(200);  
77
        setWidth(200);  
Line 68... Line 78...
68
        // on autorise le drag 'n drop pour un certain groupe
78
        // on autorise le drag 'n drop pour un certain groupe
69
 		this.setEnableDragDrop(true);
79
 		this.setEnableDragDrop(true);
-
 
80
 		this.setDdGroup("DragGroupName");
-
 
81
        store.load();       
-
 
82
		setStore(store) ;
-
 
83
		
-
 
84
		// on configure le drag 'n drop
-
 
85
		configDragAndDrop() ;
-
 
86
		
-
 
87
		this.addListener(new ComponentListenerAdapter() {
-
 
88
			
-
 
89
			public void onRender(Component c) {
Line 70... Line 90...
70
 		this.setDdGroup("DragGroupName");
90
				
Line 71... Line 91...
71
        store.load();       
91
				obtenirMiniListeObservations() ;
72
		setStore(store) ;
92
				
Line 128... Line 148...
128
	/**
148
	/**
129
	 * Méthode héritée de l'interface rafraichissable
149
	 * Méthode héritée de l'interface rafraichissable
130
	 */
150
	 */
131
	public void rafraichir(Object nouvelleDonnees,
151
	public void rafraichir(Object nouvelleDonnees,
132
			boolean repandreRaffraichissement) {
152
			boolean repandreRaffraichissement) {
-
 
153
		
-
 
154
		if(nouvelleDonnees instanceof ListeObservation)
-
 
155
		{
-
 
156
			ListeObservation data = (ListeObservation)nouvelleDonnees ;
-
 
157
			String[][] listeObs = new String[data.size()][3] ;
-
 
158
			int i = 0 ;
-
 
159
			
-
 
160
			for (Iterator it = data.keySet().iterator(); it.hasNext();) 
-
 
161
			{
-
 
162
				
-
 
163
				Observation obs=(Observation) data.get(it.next());
-
 
164
				
-
 
165
				listeObs[i][0] = obs.getNumeroOrdre();
-
 
166
				listeObs[i][1] = obs.getNomSaisi();
-
 
167
				listeObs[i][2] = obs.getDate() ;
-
 
168
			
-
 
169
				i++ ;
-
 
170
			}
-
 
171
 
-
 
172
			store = new SimpleStore(new String[]{"id_obs","plante","date"}, listeObs);  	
-
 
173
			store.load();       
133
		// TODO Auto-generated method stub
174
			this.reconfigure(store, colModel) ;
-
 
175
	
-
 
176
		}
Line 134... Line 177...
134
		
177
		
Line -... Line 178...
-
 
178
	}
-
 
179
	
-
 
180
	private void obtenirMiniListeObservations()
-
 
181
	{
-
 
182
		iMediateur.obtenirMiniListeObservations(this) ;
135
	}
183
	}
136
	
184
	
137
	/**
185
	/**
138
	 * Renvoie le faux set de données pour le store
186
	 * Renvoie le faux set de données pour le store
139
	 * @return un tableau à deux colonnes int - String
187
	 * @return un tableau à deux colonnes int - String
140
	 */
188
	 */
141
	private Object[][] getObs() {  
-
 
142
	         return new Object[][]{  
-
 
143
		                 new Object[]{"1","Plantum bizarrum"},
-
 
144
		                 new Object[]{"2","Feuillum etrangum"},
-
 
145
		                 new Object[]{"3","Spirus cotapilis"},
-
 
146
		                 new Object[]{"4","Birita raborum"},
-
 
147
		                 new Object[]{"5","Spacea sinea"},
-
 
148
		                 new Object[]{"6","Spacea subtea"},
-
 
149
		                 new Object[]{"7","Buissnum petitum"},
-
 
150
		                 new Object[]{"8","Acer monspessulanum"},
-
 
151
		                 new Object[]{"9","Geranium prouticorum"},
-
 
152
		                 new Object[]{"10","Rosae epania"},
-
 
153
		                 new Object[]{"11","Rosea rougea"},
-
 
154
		                 new Object[]{"12","Liciea rosa"},
189
	private Object[][] getObs() {  
155
		                 new Object[]{"13","Liciea bella"}
190
	         return new Object[][]{  
156
		        
191
		              
-
 
192
	         } ;
-
 
193
	 }
Line 157... Line 194...
157
	         } ;
194