Subversion Repositories eFlore/Archives.cel-v2

Compare Revisions

Ignore whitespace Rev 3 → Rev 4

/trunk/src/org/tela_botanica/client/vues/GalerieImageVue.java
New file
0,0 → 1,132
package org.tela_botanica.client.vues;
 
 
import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
 
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Element;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.XTemplate;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.RecordDef;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.util.Format;
import com.gwtext.client.widgets.BoxComponent;
import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.DataView;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.DataView.Data;
import com.gwtext.client.widgets.event.DataViewListener;
import com.gwtext.client.widgets.event.DataViewListenerAdapter;
 
public class GalerieImageVue extends Panel implements Rafraichissable {
 
// instance du médiateur
private ImageMediateur iMediateur = null;
private DataView dView = null ;
private Store st = null ;
public GalerieImageVue(ImageMediateur im)
{
super("Galerie");
iMediateur = im ;
// Preparation de la dataview et du template
// le template va créer une div contenant une image
// pour chacune des photos
final XTemplate template = new XTemplate(
new String[]{
"<tpl for='.'>",
"<div class='thumb-wrap' id='{nom}'>",
"<div class='thumb'><img src='{url}' title='{nom}'></div>",
"<span>{nom}</span></div>", "</tpl>",
"<div class='x-clear'></div>"});
template.compile();
 
// la dataview affichera les images en accord avec le template
// cree precedemment
dView = new DataView("div.thumb-wrap") {
public void prepareData(Data data) {
data.setProperty("shortName", Format.ellipsis(data
.getProperty("name"), 15));
}
};
dView.setTpl(template);
// parametre d'affichage de la dataview
dView.setAutoHeight(true);
dView.setMultiSelect(true);
dView.setOverCls("x-view-over");
dView.setEmptyText("Aucune image à afficher");
// creation du store
FieldDef defNumImage = new StringFieldDef("num_image");
FieldDef defUrlImage = new StringFieldDef("url_image");
FieldDef[] defTab = {defNumImage,defUrlImage};
RecordDef rd = new RecordDef(defTab) ;
st = new Store(rd) ;
dView.setStore(st);
// ajouts de la gestion des evenements pour la dataview
ajouterListeners();
this.add(dView);
}
public void ajouterListeners()
{
// ajout de listeners pour la gestion de la selection
// dans la galerie
dView.addListener(new DataViewListenerAdapter() {
 
 
 
public void onClick(DataView source, int index, Element node,
EventObject e) {
//TODO: appeler le mediateur
}
 
 
public void onContainerClick(DataView source, EventObject e) {
//TODO: appeler le mediateur
}
 
 
public void onContextMenu(DataView source, int index, Element node,
EventObject e) {
//TODO: appeler le mediateur
}
 
 
public void onDblClick(DataView source, int index, Element node,
EventObject e) {
//TODO: appeler le mediateur
}
 
 
public void onSelectionChange(DataView view, Element[] selections) {
//TODO: appeler le mediateur
}
});
}
public void rafraichir(Object nouvelleDonnees) {
// TODO Auto-generated method stub
}
}