Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2615 Rev 2726
Line 1... Line 1...
1
package org.tela_botanica.client.vues.image;
1
package org.tela_botanica.client.vues.image;
Line -... Line 2...
-
 
2
 
-
 
3
import java.util.HashMap;
2
 
4
 
3
import org.tela_botanica.client.i18n.Msg;
5
import org.tela_botanica.client.i18n.Msg;
4
import org.tela_botanica.client.image.ImageMediateur;
6
import org.tela_botanica.client.image.ImageMediateur;
5
import org.tela_botanica.client.interfaces.ListePaginable;
7
import org.tela_botanica.client.interfaces.ListePaginable;
6
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
9
import org.tela_botanica.client.interfaces.VueListable;
-
 
10
import org.tela_botanica.client.modeles.objets.Ontologies;
7
import org.tela_botanica.client.interfaces.VueListable;
11
import org.tela_botanica.client.util.Util;
Line -... Line 12...
-
 
12
import org.tela_botanica.client.vues.BarrePaginationVue;
8
import org.tela_botanica.client.vues.BarrePaginationVue;
13
 
-
 
14
import com.google.gwt.user.client.Timer;
9
 
15
import com.gwtext.client.core.EventObject;
10
import com.gwtext.client.core.EventObject;
16
import com.gwtext.client.core.SortDir;
11
import com.gwtext.client.data.FieldDef;
17
import com.gwtext.client.data.FieldDef;
12
import com.gwtext.client.data.IntegerFieldDef;
18
import com.gwtext.client.data.IntegerFieldDef;
13
import com.gwtext.client.data.Record;
19
import com.gwtext.client.data.Record;
Line 25... Line 31...
25
import com.gwtext.client.widgets.grid.ColumnModel;
31
import com.gwtext.client.widgets.grid.ColumnModel;
26
import com.gwtext.client.widgets.grid.GridDragData;
32
import com.gwtext.client.widgets.grid.GridDragData;
27
import com.gwtext.client.widgets.grid.GridPanel;
33
import com.gwtext.client.widgets.grid.GridPanel;
28
import com.gwtext.client.widgets.grid.Renderer;
34
import com.gwtext.client.widgets.grid.Renderer;
29
import com.gwtext.client.widgets.grid.RowSelectionModel;
35
import com.gwtext.client.widgets.grid.RowSelectionModel;
-
 
36
import com.gwtext.client.widgets.grid.event.GridHeaderListenerAdapter;
30
import com.gwtext.client.widgets.grid.event.GridRowListener;
37
import com.gwtext.client.widgets.grid.event.GridRowListener;
31
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
38
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
Line 32... Line 39...
32
 
39
 
33
/**
40
/**
Line 115... Line 122...
115
	/**
122
	/**
116
	 * Garder ou non l'aspet original des images
123
	 * Garder ou non l'aspet original des images
117
	 */
124
	 */
118
	private boolean garderRatio = true;	
125
	private boolean garderRatio = true;	
Line -... Line 126...
-
 
126
	
-
 
127
	private SortDir directionTri;
-
 
128
 
-
 
129
	private String champTri;
-
 
130
	
-
 
131
	private boolean triActif;
119
	
132
	
120
	/**
133
	/**
121
	 * Constructeur sans arguments (privé car ne doit pas être utilisé)
134
	 * Constructeur sans arguments (privé car ne doit pas être utilisé)
122
	 */
135
	 */
123
	private ListeImageVue() {
136
	private ListeImageVue() {
Line 142... Line 155...
142
		// on place la barre de pagination
155
		// on place la barre de pagination
143
		bt = new BarrePaginationVue(this);
156
		bt = new BarrePaginationVue(this);
144
		bt.setLabelElement(Msg.get("images"));
157
		bt.setLabelElement(Msg.get("images"));
145
		bt.setTaillePageParDefaut(50);
158
		bt.setTaillePageParDefaut(50);
146
		setBottomToolbar(bt);
159
		setBottomToolbar(bt);
-
 
160
		
-
 
161
		directionTri = SortDir.ASC;
Line 147... Line 162...
147
 
162
 
148
		// on construit le modèle de colonnes
163
		// on construit le modèle de colonnes
149
		numImage = new ColumnConfig(Msg.get("numero"), "num_image", 30, true,
164
		numImage = new ColumnConfig(Msg.get("numero"), "num_image", 30, true,
Line 161... Line 176...
161
								+ "</div>";
176
								+ "</div>";
162
					}
177
					}
Line 163... Line 178...
163
 
178
 
Line 164... Line 179...
164
				});
179
				});
Line 165... Line 180...
165
		
180
		
166
		transmisImage = new ColumnConfig("   ", "obs_associees", 10, true, new Renderer() {
181
		transmisImage = new ColumnConfig("   ", "transmis", 10, true, new Renderer() {
167
 
182
 
Line 352... Line 367...
352
		this.setColumnModel(modeleColonnes);
367
		this.setColumnModel(modeleColonnes);
353
		this.setAutoScroll(true);
368
		this.setAutoScroll(true);
354
		this.setAutoWidth(true);
369
		this.setAutoWidth(true);
355
		this.setEnableColumnResize(true);
370
		this.setEnableColumnResize(true);
Line 356... Line -...
356
 
-
 
357
		// creation du store
-
 
358
		FieldDef defNumImage = new IntegerFieldDef("num_image");
-
 
359
		FieldDef defTransmisImage = new IntegerFieldDef("obs_associees");
-
 
360
		FieldDef defNomImage = new StringFieldDef("nom_original");
-
 
361
		FieldDef defDatImage = new StringFieldDef("dat_image");
-
 
362
		FieldDef defLieImage = new StringFieldDef("lie_image");
-
 
363
		FieldDef defAppImage = new StringFieldDef("app_image");
-
 
364
		FieldDef defUrlImageS = new StringFieldDef("url_image_S");
-
 
365
		FieldDef defUrlImageM = new StringFieldDef("url_image_M");
-
 
366
		FieldDef defUrlImage = new StringFieldDef("url_image");
-
 
367
		FieldDef defNoteImage = new StringFieldDef("note_image");
-
 
368
		FieldDef defTailleX = new IntegerFieldDef("taille_x");
-
 
369
		FieldDef defTailleY = new IntegerFieldDef("taille_y");
-
 
370
		FieldDef defObsAssociees = new StringFieldDef("obs_associees");
-
 
371
		FieldDef[] defTab = { defNumImage,defTransmisImage, defNomImage, defDatImage, defLieImage,
-
 
372
				defAppImage, defUrlImageS, defUrlImageM, defUrlImage,
-
 
373
				defNoteImage, defTailleX, defTailleY, defObsAssociees};
371
 
374
		RecordDef rd = new RecordDef(defTab);
372
		RecordDef rd = new RecordDef(ImageMediateur.getDefinitionsChampsGrilleImages());
375
		st = new Store(rd);
373
		st = new Store(rd);
376
		// on associe le store
374
		// on associe le store
377
		this.setStore(st);
375
		this.setStore(st);
Line 393... Line 391...
393
 
391
 
394
	/**
392
	/**
395
	 * Ajoute les listeners pour la gestion des évènements
393
	 * Ajoute les listeners pour la gestion des évènements
396
	 */
394
	 */
-
 
395
	private void ajouterListeners() {
-
 
396
		
-
 
397
		this.addGridHeaderListener(new GridHeaderListenerAdapter() {		
-
 
398
			@Override
-
 
399
			public void onHeaderClick(GridPanel grid, int colIndex, EventObject e) {
-
 
400
				triActif = true;
-
 
401
				Timer t = new Timer() {
-
 
402
					
-
 
403
					@Override
-
 
404
					public void run() {
-
 
405
						enregistrerEtatTri();
-
 
406
						// Trier ne change pas le nombre de page, on peut donc se passer d'un appel
-
 
407
						// au comptage (ce serait mieux si ces deux appels étaient combinés)
-
 
408
						iMediateur.obtenirPhotoGalerieSansCalculerPages(ListeImageVue.this);
-
 
409
					}
-
 
410
				};
-
 
411
				// Le changement de tri n'est pas immédiat et si on recharge le liste tout de suite 
-
 
412
				// on a l'ancien tri et pas le nouveau (200 millisecondes suffisent et ne se voient pas)
-
 
413
				// #mondeDeMerde
-
 
414
				t.schedule(200);
-
 
415
			}
-
 
416
		});
397
	private void ajouterListeners() {
417
		
Line 398... Line 418...
398
		this.addListener(new ContainerListenerAdapter() {
418
		this.addListener(new ContainerListenerAdapter() {
399
 
419
 
Line 591... Line 611...
591
	public void rafraichir(Object nouvelleDonnees,
611
	public void rafraichir(Object nouvelleDonnees,
592
			boolean repandreRafraichissement) {
612
			boolean repandreRafraichissement) {
Line 593... Line 613...
593
 
613
 
594
		// si on reçoit un store
614
		// si on reçoit un store
595
		if (nouvelleDonnees instanceof Store) {
-
 
596
 
615
		if (nouvelleDonnees instanceof Store) {
597
			// on affecte celui-ci comme gestionnaire de données
616
			// on affecte celui-ci comme gestionnaire de données
-
 
617
			st = (Store) nouvelleDonnees;
598
			st = (Store) nouvelleDonnees;
618
			st.sort(champTri, directionTri);
599
			st.load();
619
			st.load();
600
			// et on reconfigure et rafraichit la vue
620
			// et on reconfigure et rafraichit la vue
601
			this.reconfigure(st, this.getColumnModel());
-
 
602
 
621
			this.reconfigure(st, this.getColumnModel());
Line 603... Line 622...
603
		}
622
		}
604
		
623
		
Line 742... Line 761...
742
			}
761
			}
743
		}
762
		}
Line 744... Line 763...
744
		
763
		
745
		return associeesTranmises;
764
		return associeesTranmises;
-
 
765
	}
-
 
766
	
-
 
767
	private void enregistrerEtatTri() {
-
 
768
		if(triActif) {
-
 
769
			this.directionTri = st.getSortState().getDirection();
-
 
770
			this.champTri = st.getSortState().getField();
-
 
771
		}
-
 
772
		
-
 
773
	}
-
 
774
	
-
 
775
	public String renvoyerTri() {
-
 
776
		String tri = "ordre";
-
 
777
		if(triActif) {
-
 
778
			HashMap<String, String> corr = Ontologies.getCorrespondanceGrilleImageChampsTri();
-
 
779
			if(corr.containsKey(champTri)) {
-
 
780
				tri = corr.get(champTri);
-
 
781
			}
-
 
782
		}
-
 
783
		return tri;
Line -... Line 784...
-
 
784
	}
-
 
785
 
-
 
786
	public String renvoyerDirectionTri() {
-
 
787
		String triDir = "ASC";
-
 
788
		try {
-
 
789
			triDir = (triActif) ? directionTri.getDirection() : "ASC";
-
 
790
		} catch (Exception e) {
-
 
791
			triDir = "ASC";
-
 
792
		}
746
	}
793
		return triDir;