Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1488 → Rev 1489

/trunk/src/org/tela_botanica/client/vues/observation/ListeObservationVue.java
5,6 → 5,7
 
import org.tela_botanica.client.modeles.objets.ListeObservation;
import org.tela_botanica.client.modeles.objets.Observation;
import org.tela_botanica.client.modeles.objets.Ontologies;
import org.tela_botanica.client.observation.ObservationMediateur;
import org.tela_botanica.client.util.Util;
import org.tela_botanica.client.vues.BarrePaginationVue;
91,6 → 92,10
* Config de colonne
*/
private ColumnConfig abondanceObservation;
/**
* Config de colonne
*/
private ColumnConfig certitudeObservation;
/**
* Modele de colonnes
216,11 → 221,37
this.setTitleCollapse(true);
 
this.setTitle("Observations") ;
modeleColonnes = new ColumnModel(getConfigColonnes());
this.setColumnModel(modeleColonnes);
this.setAutoScroll(true);
this.setEnableColumnResize(true);
// creation du store
RecordDef rd = new RecordDef(getDefinitionChamps());
st = new Store(rd);
// on associe le store
this.setStore(st);
this.getView().setAutoFill(true);
this.getView().setForceFit(true) ;
// on crée un masque de chargement qui s'affichera lors des mises à jour
this.setLoadMask("Chargement");
// on ajoute les listeners
ajouterListeners();
configDragAndDrop();
 
}
private ColumnConfig[] getConfigColonnes() {
// on construit le modèle de colonnes
 
// Le store suivant est ensuite remplacé par le store contenant les données obtenus depuis le serveur (cf rafraichir)
Renderer colRend = new Renderer() {
 
@Override
287,51 → 318,18
lieuObservation = new ColumnConfig("Lieu", "lieu_observation", 200, true, colRend);
dateObservation = new ColumnConfig("Date", "date_observation", 70, true, dateRend);
abondanceObservation = new ColumnConfig("Abondance", "abondance", 50, true, colRend);
ordreObservation = new ColumnConfig("Ordre", "ordre_observation", 50, true, colRend);
certitudeObservation = new ColumnConfig("Identification", "certitude", 50, true, new Renderer() {
@Override
public String render(Object value, CellMetadata cellMetadata,
Record record, int rowIndex, int colNum, Store store) {
return Ontologies.getCorrespondanceCertitude(record.getAsString("certitude"));
}
});
ordreObservation = new ColumnConfig("Ordre", "ordre_observation", 50, true, colRend);
ColumnConfig[] cm = {etatObservation, nomSaisiObservation, certitudeObservation, nomRetenuObservation, abondanceObservation, lieuObservation, dateObservation, ordreObservation};
// on associe le modèle de colonnes
ColumnConfig[] cm = {etatObservation, nomSaisiObservation, nomRetenuObservation, abondanceObservation, lieuObservation, dateObservation, ordreObservation};
modeleColonnes = new ColumnModel(cm);
this.setColumnModel(modeleColonnes);
this.setAutoScroll(true);
this.setEnableColumnResize(true);
// creation du store
 
FieldDef defEtatObservation = new StringFieldDef("etat_observation");
FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
FieldDef defAbondanceObservation = new IntegerFieldDef("abondance");
FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
FieldDef defDateObservation = new StringFieldDef("date_observation");
FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
defAbondanceObservation, defLieuObservation, defDateObservation, defOrdreObservation };
RecordDef rd = new RecordDef(defTab);
st = new Store(rd);
// on associe le store
this.setStore(st);
this.getView().setAutoFill(true);
this.getView().setForceFit(true) ;
// on crée un masque de chargement qui s'affichera lors des mises à jour
this.setLoadMask("Chargement");
// on ajoute les listeners
ajouterListeners();
configDragAndDrop();
 
return cm;
}
 
 
504,7 → 502,6
* Méthode héritée de l'interface VueListable
* Sélectionne les observations dans la liste suivant les identifiants donnés en paramètres
*/
@Override
public String[] getIdSelectionnees() {
537,7 → 534,6
* Accesseur pour la toolbar de pagination
* @return la toolbar de pagination
*/
public BarrePaginationVue getToolBarVue()
{
return bt ;
549,13 → 545,11
*/
public void masquerChargement()
{
ExtElement masked = Ext.get(getId()) ;
ExtElement masked = Ext.get(getId()) ;
 
 
if (masked!=null) {
masked.mask("Chargement") ;
}
 
if (masked!=null) {
masked.mask("Chargement") ;
}
}
/**
570,25 → 564,18
}
}
 
 
/**
* Méthode héritée de l'interface rafraichissable
* @param nouvelleDonnees les nouvelles données
* @param repandreRafraichissement le booleen de notification du rafraichissement
*/
 
 
@Override
public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
// si l'on a reçu une liste d'observation
// si l'on a reçu une liste d'observation
if(nouvelleDonnees instanceof ListeObservation)
{
{
ListeObservation data = (ListeObservation) nouvelleDonnees ;
Object[][] observationData = new Object[data.size()][8];
Object[][] observationData = new Object[data.size()][9];
int i = 0 ;
if(data.size() == 0)
604,36 → 591,19
observationData[i][0] = obs.getTransmis();
observationData[i][1] = obs.getNomSaisi();
observationData[i][2] = obs.getNomRetenu();
observationData[i][3] = obs.getAbondance();
observationData[i][4] = Util.formaterLieu(obs, modeleLieu);
observationData[i][5] = obs.getDate();
observationData[i][6] = obs.getNumeroOrdre();
observationData[i][7] = obs.getNumeroNomenclaturalSaisi();
observationData[i][2] = obs.getCertitude();
observationData[i][3] = obs.getNomRetenu();
observationData[i][4] = obs.getAbondance();
observationData[i][5] = Util.formaterLieu(obs, modeleLieu);
observationData[i][6] = obs.getDate();
observationData[i][7] = obs.getNumeroOrdre();
observationData[i][8] = obs.getNumeroNomenclaturalSaisi();
i++ ;
}
// creation du store qui les contient
FieldDef defEtatObservation = new StringFieldDef("etat_observation");
FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
FieldDef defAbondanceObservation = new StringFieldDef("abondance");
FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
FieldDef defDateObservation = new StringFieldDef("date_observation");
FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
RecordDef rd = new RecordDef(getDefinitionChamps());
// Non affiches :
FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
// on associe le store
 
FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation, defAbondanceObservation,
defLieuObservation, defDateObservation, defOrdreObservation, defNumeroNomenclaturalSaisiObservation };
RecordDef rd = new RecordDef(defTab);
final MemoryProxy dataProxy = new MemoryProxy(observationData);
final ArrayReader reader = new ArrayReader(rd);
642,21 → 612,14
st = observationStore ;
st.load() ;
// et on reconfigure et rafraichit la vue
this.reconfigure(st, this.getColumnModel());
demasquerChargement();
cacheListeObservation=data;
observationMediateur.onRafraichissementListeObservations();
observationMediateur.onRafraichissementListeObservations();
}
// Si on reçoit un tableau d'entiers
// c'est un tableau d'un seul entier qui est le nombre d'observation correspondant aux critères
if(nouvelleDonnees instanceof int[])
694,7 → 657,6
masquerChargement();
observationMediateur.obtenirNombreObservation();
}
}
710,13 → 672,30
setTailleInitialisee();
}
}
}
private FieldDef[] getDefinitionChamps() {
// creation du store qui les contient
FieldDef defEtatObservation = new StringFieldDef("etat_observation");
FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
FieldDef defCertitudeObservation = new StringFieldDef("certitude");
FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
FieldDef defAbondanceObservation = new StringFieldDef("abondance");
FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
FieldDef defDateObservation = new StringFieldDef("date_observation");
FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
// Non affiches :
FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
 
FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defCertitudeObservation, defNomRetenuObservation, defAbondanceObservation,
defLieuObservation, defDateObservation, defOrdreObservation, defNumeroNomenclaturalSaisiObservation };
return defTab;
}
// GESTION DE LA PAGINATION
 
public ListeObservation getCacheListeObservation() {
return cacheListeObservation;
}
731,17 → 710,14
{
// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement
// pour eviter qu'il arrondisse mal la division
// nombre de pages = (nombre d'element / taille de la page) arrondie à l'entier superieur
// nombre de pages = (nombre d'element / taille de la page) arrondi à l'entier superieur
double nPage = (1.0*nbElements)/(1.0*taillePage) ;
double nPageRound = Math.ceil(nPage) ;
Double nPageInt = new Double(nPageRound) ;
// on convertit en entier
return nPageInt.intValue() ;
}
 
/**
* Recalcule la page en cours lors du changement du nombre d'élements
* @param nbElements le nombre d'élements total
758,11 → 734,9
double nPageRound = Math.ceil(nPageCourante) ;
Double nPageInt = new Double(nPageRound) ;
// on convertit en entier
return Math.abs(nPageInt.intValue()) ;
}
 
/**
* Appelle le modèle pour lui demander les données d'une page à afficher
* @param pageCourante le numéro de page à affciher
769,18 → 743,11
*/
@Override
public void changerNumeroPage(int pageCourante) {
pageEncours = pageCourante ;
masquerChargement();
 
// On lance le chargerment des observations
observationMediateur.obtenirNombreObservation();
getToolBarVue().changerPageCourante(pageCourante);
getToolBarVue().changerPageCourante(pageCourante);
}
788,10 → 755,8
* Appelle le modèle pour qu'il change la taille de page utilisée
* @param nouvelleTaillePage la nouvelle taille de page
*/
@Override
public void changerTaillePage(int nouvelleTaillePage)
{
public void changerTaillePage(int nouvelleTaillePage) {
taillePage = nouvelleTaillePage ;
pageEncours = calculerPageCourante(nbElements) ;
801,11 → 766,8
// On lance le chargement des observations
observationMediateur.obtenirNombreObservation();
// et on met à jour la taille de page dans les barres d'outils
getToolBarVue().selectionnerTaillePage(nouvelleTaillePage);
getToolBarVue().selectionnerTaillePage(nouvelleTaillePage);
}
 
816,12 → 778,9
* @param taillePage la taille de page
* @param nbElement le nombre d'élements par page
*/
public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement)
{
public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement) {
int[] pages = {pageMax,pageEncours, taillePage, nbElement} ;
getToolBarVue().rafraichir(pages, false) ;
}
/**
935,32 → 894,11
}
 
public void raz() {
// creation du store qui les contient
FieldDef defEtatObservation = new StringFieldDef("etat_observation");
FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
FieldDef defAbondanceObservation = new IntegerFieldDef("abondance");
FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
FieldDef defDateObservation = new StringFieldDef("date_observation");
FieldDef defOrdreObservation = new IntegerFieldDef("ordre_observation");
// Non affiches :
FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
defAbondanceObservation, defLieuObservation, defDateObservation, defOrdreObservation };
RecordDef rd = new RecordDef(defTab);
public void raz() {
RecordDef rd = new RecordDef(getDefinitionChamps());
st = new Store(rd);
// on associe le store
this.setStore(st);
this.setStore(st);
}
public boolean verifierFormatDate(String date) {
981,5 → 919,4
public void setTailleInitialisee() {
tailleInitialisee = true;
}
 
}