/trunk/src/org/tela_botanica/client/Mediateur.java |
---|
573,11 → 573,18 |
} |
public void selectionnerStructure(Rafraichissable vueARafraichir, String structureId) { |
modele.selectionnerStructure(vueARafraichir, getProjetId(), structureId); |
int nbElements = Integer.valueOf(((Dictionary) Dictionary |
.getDictionary("configuration")).get("nbElementsPage")); |
modele.selectionnerStructure(vueARafraichir, getProjetId(), structureId, null, 0, nbElements); |
} |
public void selectionnerStructure(Rafraichissable vueARafraichir, String structureId, String projetId, String nom, int start, int nbElements) { |
modele.selectionnerStructure(vueARafraichir, getProjetId(), structureId, nom, start, nbElements); |
} |
public void selectionnerStructureParProjet(Rafraichissable vueARafraichir, String projetId) { |
modele.selectionnerStructure(vueARafraichir, projetId, null); |
modele.selectionnerStructure(vueARafraichir, projetId, null, null, 0, -1); |
} |
public void ajouterStructure(Rafraichissable vueARafraichir, Structure structure, StructureConservation conservation, StructureValorisation valorisation) { |
940,16 → 947,19 |
} |
public void selectionnerPersonne(Rafraichissable vueARafraichir, Personne personne, String projetId) { |
int nbElements = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
int nbElements = Integer.valueOf(((Dictionary) Dictionary |
.getDictionary("configuration")).get("nbElementsPage")); |
selectionnerPersonne(vueARafraichir, personne, projetId, 0, nbElements); |
} |
public void selectionnerPersonne(Rafraichissable vueARafraichir, Personne personne, String projetId, int start, int nbElements) { |
String personneId = null; |
String personneNom = null; |
if (personne != null) { |
personneId = personne.getId(); |
personneNom = personne.getNom(); |
} |
modele.selectionnerPersonne(vueARafraichir, personneId, projetId, null, start, nbElements); |
modele.selectionnerPersonne(vueARafraichir, personneId, projetId, personneNom, start, nbElements); |
} |
public void selectionnerPersonneParNomComplet(Rafraichissable vueARafraichir, String projetId, String nomComplet) { |
/trunk/src/org/tela_botanica/client/vues/structure/StructureForm.java |
---|
681,6 → 681,9 |
} |
} |
System.out.println(structureARetourner); |
return structureARetourner; |
} |
/trunk/src/org/tela_botanica/client/vues/structure/StructureListeVue.java |
---|
12,7 → 12,7 |
import org.tela_botanica.client.modeles.Utilisateur; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
34,6 → 34,7 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.user.client.Window; |
public class StructureListeVue extends ContentPanel implements Rafraichissable { |
46,6 → 47,8 |
private Button modifier; |
private Button supprimer; |
private Button ajouter; |
private BarrePaginationVue pagination = null; |
public StructureListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
119,6 → 122,10 |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new StructureListe(), mediateur); |
setBottomComponent(pagination); |
} |
private void clicListe(Structure structure) { |
147,6 → 154,9 |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof StructureListe) { |
StructureListe structures = (StructureListe) nouvellesDonnees; |
System.out.println("rafraichir structure liste"); |
pagination.setlistePaginable(structures); |
pagination.rafraichir(structures.getPageTable()); |
if (structures != null) { |
List<Structure> liste = structures.toList(); |
156,6 → 166,7 |
gererEtatActivationBouton(); |
mediateur.actualiserPanneauCentral(); |
grille.fireEvent(Events.ViewReady); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
/trunk/src/org/tela_botanica/client/vues/BarrePaginationVue.java |
---|
25,6 → 25,7 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.event.dom.client.KeyCodes; |
import com.google.gwt.i18n.client.Dictionary; |
import com.google.gwt.user.client.Window; |
public class BarrePaginationVue extends ToolBar implements Rafraichissable { |
39,7 → 40,12 |
private TextField<String> champPage = new TextField<String>(); |
private SimpleComboBox selecteurTaillePage = new SimpleComboBox(); |
private Text labelFiltre; |
private TextField<String> filtre; |
private Button annulerFiltre; |
private boolean filtreActive = false; |
private String termeRecherche = ""; |
LinkedList<Integer> intervallePages = new LinkedList<Integer>(); |
ListStore storeIntervalle = new ListStore() ; |
145,6 → 151,19 |
add(nbElemParPage); |
// Ajout d'un espace pour mettre le nombre d'éléments à droite |
labelFiltre = new Text("Recherche rapide : "); |
labelFiltre.setStyleAttribute("padding-left", "15px"); |
labelFiltre.setStyleAttribute("padding-right", "5px"); |
add(labelFiltre); |
filtre = new TextField<String>(); |
filtre.setWidth(150); |
this.add(filtre); |
annulerFiltre = new Button(); |
annulerFiltre.setIcon(Images.ICONES.annuler()); |
add(annulerFiltre); |
add(new FillToolItem()); |
intervalleElements = new Text(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
153,11 → 172,15 |
// on ajoute les différents listeners |
ajouterListeners(); |
} |
/** |
* Texte nommant les elements pagines (Images, Observation, truc, machin etc...). |
* @param label |
256,8 → 279,34 |
listePaginable.changerNumeroPage(pageCourante); |
} |
}); |
annulerFiltre.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
filtre.setValue(""); |
termeRecherche = ""; |
filtreActive = false; |
listePaginable.changerNumeroPage(pageCourante); |
} |
}); |
filtre.addKeyListener(new KeyListener(){ |
public void componentKeyUp(ComponentEvent ce) { |
if (ce.getKeyCode() == KeyCodes.KEY_ENTER) { |
System.out.println(pageCourante +" ---- " + nbElement); |
termeRecherche = filtre.getValue(); |
if (termeRecherche == null || termeRecherche.equals("")) { |
filtreActive = false; |
listePaginable.changerNumeroPage(pageCourante); |
} else { |
listePaginable.filtrerParNom(termeRecherche); |
filtreActive = true; |
} |
} |
} |
}); |
champPage.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
296,8 → 345,9 |
champPage.focus(); |
} |
} |
} |
} |
/* public void onFocus(Field field) { |
champPage.focus(); |
360,28 → 410,33 |
*/ |
public void rafraichirNumeroPage() { |
surTotalPage.setText(" sur " + pageTotale); |
if (nbElement == 0) { |
champPage.setValue("" + (0)); |
// on met simplement à jour l'intervalle qui contient toujours le |
// même nombre d'éléments |
intervalleElements.setText(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), 0,0,0)); |
if (filtreActive == true) { |
intervalleElements.setText("<i>Recherche rapide : </i>" + termeRecherche); |
} else { |
champPage.setValue("" + (pageCourante + 1)); |
// si la page n'est pas la dernière |
if (pageCourante + 1 != pageTotale) { |
// sauf pour la dernière page qui contient souvent moins |
// d'élements que le nombre d'élements par page |
intervalleElements.setText(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
(pageCourante + 1) * taillePage, nbElement)); |
surTotalPage.setText(" sur " + pageTotale); |
if (nbElement == 0) { |
champPage.setValue("" + (0)); |
// on met simplement à jour l'intervalle qui contient toujours le |
// même nombre d'éléments |
intervalleElements.setText(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), 0,0,0)); |
} else { |
// on met simplement à jour l'intervalle qui contient toujours |
// le même nombre d'éléments |
intervalleElements.setText(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
nbElement, nbElement)); |
champPage.setValue("" + (pageCourante + 1)); |
// si la page n'est pas la dernière |
if (pageCourante + 1 != pageTotale) { |
// sauf pour la dernière page qui contient souvent moins |
// d'élements que le nombre d'élements par page |
intervalleElements.setText(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
(pageCourante + 1) * taillePage, nbElement)); |
} else { |
// on met simplement à jour l'intervalle qui contient toujours |
// le même nombre d'éléments |
intervalleElements.setText(mediateur.i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
nbElement, nbElement)); |
} |
} |
} |
} |
/trunk/src/org/tela_botanica/client/interfaces/ListePaginable.java |
---|
11,6 → 11,6 |
public void changerTaillePage(int nouvelleTaillePage); |
public void changerNumeroPage(int pageCourante); |
public void recharger(); |
public void filtrerParNom(String nom); |
} |
/trunk/src/org/tela_botanica/client/Modele.java |
---|
145,10 → 145,10 |
// GESTION DES STRUCTURES |
//+----------------------------------------------------------------------------------------------------------------+ |
public void selectionnerStructure(Rafraichissable vueARafraichir, String projetId, String structureId) { |
public void selectionnerStructure(Rafraichissable vueARafraichir, String projetId, String structureId, String nomStructure, int start, int nbElements) { |
// Gestion des données des tables coel_structure, coel_structure_conservation et coel_structure_valorisation |
StructureAsyncDao sDao = new StructureAsyncDao(vueARafraichir); |
sDao.selectionner(projetId, structureId); |
sDao.selectionner(projetId, structureId, nomStructure, start, nbElements); |
} |
/** Lance la creation d'une Structure |
/trunk/src/org/tela_botanica/client/modeles/personne/PersonneListe.java |
---|
13,105 → 13,116 |
import com.google.gwt.json.client.JSONObject; |
/** |
* Table de hachage composée d'informations sur les Valeurs des listes, renvoyé par un objet de type DAO |
* La clé est le nom de l'entite + le nom de l'entite parente |
* Table de hachage composée d'informations sur les Valeurs des listes, renvoyé |
* par un objet de type DAO La clé est le nom de l'entite + le nom de l'entite |
* parente |
* |
* @author david delon |
* |
*/ |
public class PersonneListe extends aDonneeListe<Personne> implements ListePaginable{ |
public class PersonneListe extends aDonneeListe<Personne> implements |
ListePaginable { |
private static final long serialVersionUID = 2930530504922300155L; |
private int currentPage = 0; |
private int nbElementsPage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
private int nbElementsPage = Integer.valueOf(((Dictionary) Dictionary |
.getDictionary("configuration")).get("nbElementsPage")); |
private int nbElementsTotal; |
private Rafraichissable vueARafraichir; |
/** |
* Constructeur sans paramètres |
* Constructeur sans paramètres |
*/ |
public PersonneListe() { |
super(); |
} |
/** |
* Constructeur avec paramètre |
* @param taille la taille de la table de hachage |
* |
* @param taille |
* la taille de la table de hachage |
*/ |
public PersonneListe(int taille) { |
super(taille); |
} |
/** |
* Constructeur pour une liste de personne |
* |
* @param dates |
*/ |
public PersonneListe(JSONArray personneListe) { |
super(personneListe.size()); |
final int taillemax = personneListe.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject personneCourante = personneListe.get(i).isObject() ; |
if (personneCourante != null) { |
JSONObject personneCourante = personneListe.get(i).isObject(); |
if (personneCourante != null) { |
Personne personne = new Personne(personneCourante); |
this.put(personne.getId(), personne); |
this.put(personne.getId(), personne); |
} |
} |
} |
public PersonneListe(JSONArray personneListe, JSONNumber nbElements, Rafraichissable vueARafraichir) { |
public PersonneListe(JSONArray personneListe, JSONNumber nbElements, |
Rafraichissable vueARafraichir) { |
super(personneListe.size()); |
this.nbElementsTotal = Integer.valueOf(nbElements.toString()); |
final int taillemax = personneListe.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject personneCourante = personneListe.get(i).isObject() ; |
if (personneCourante != null) { |
JSONObject personneCourante = personneListe.get(i).isObject(); |
if (personneCourante != null) { |
Personne personne = new Personne(personneCourante); |
this.put(personne.getId(), personne); |
this.put(personne.getId(), personne); |
} |
} |
this.vueARafraichir = vueARafraichir; |
} |
public int[] getPageTable() { |
int[] page = new int[4]; |
//nombre de pages au total |
// nombre de pages au total |
page[0] = calculerNbPages(); |
//Page En Cours |
// Page En Cours |
page[1] = currentPage; |
//nbElementsParPage |
// nbElementsParPage |
page[2] = nbElementsPage; |
// et le dernier le nombre total d'éléments |
page[3] = nbElementsTotal; |
return page; |
} |
/** |
* Calcule le nombre de pages nécessaires pour afficher un nombre d'élements donnés en fonction de la taille de page |
* en cours |
* @return le nombre de pages |
* Calcule le nombre de pages nécessaires pour afficher un nombre d'élements |
* donnés en fonction de la taille de page en cours |
* |
* @return le nombre de pages |
*/ |
public int calculerNbPages() { |
// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement |
// 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 |
double nPage = (1.0*nbElementsTotal)/(1.0*nbElementsPage) ; |
double nPageRound = Math.ceil(nPage) ; |
Double nPageInt = new Double(nPageRound) ; |
// nombre de pages = (nombre d'element / taille de la page) arrondie à |
// l'entier superieur |
double nPage = (1.0 * nbElementsTotal) / (1.0 * nbElementsPage); |
double nPageRound = Math.ceil(nPage); |
Double nPageInt = new Double(nPageRound); |
// on convertit en entier |
return nPageInt.intValue() ; |
return nPageInt.intValue(); |
} |
@Override |
public void changerNumeroPage(int pageCourante) { |
currentPage = pageCourante; |
123,23 → 134,33 |
nbElementsPage = nouvelleTaillePage; |
selectionnerPersonne(); |
} |
@Override |
public void recharger() { |
selectionnerPersonne(); |
} |
public void setPageCourante(int pageCourante) { |
this.currentPage = pageCourante; |
} |
public void setTaillePage(int taillePage) { |
public void setTaillePage(int taillePage) { |
this.nbElementsPage = taillePage; |
} |
public void selectionnerPersonne() { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerPersonne(vueARafraichir, null, null, currentPage, nbElementsPage); |
public void selectionnerPersonne() { |
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerPersonne(vueARafraichir, null, null, currentPage, |
nbElementsPage); |
} |
@Override |
public void filtrerParNom(String nom) { |
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR); |
Personne personne = new Personne(); |
personne.setNom(nom); |
mediateur.selectionnerPersonne(vueARafraichir, personne, null, currentPage, |
nbElementsPage); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/personne/PersonneAsyncDao.java |
---|
26,6 → 26,7 |
} |
public void selectionner(String personneId, String projetId, String nomComplet, final int pageCourante, final int nbElements) { |
System.out.println(pageCourante +" " + nbElements); |
String[] parametres = {personneId, projetId, nomComplet}; |
HashMap<String, String> restrictions = new HashMap<String, String>(); |
/trunk/src/org/tela_botanica/client/modeles/structure/StructureListe.java |
---|
1,8 → 1,16 |
package org.tela_botanica.client.modeles.structure; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.interfaces.ListePaginable; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.aDonneeListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import com.extjs.gxt.ui.client.Registry; |
import com.google.gwt.i18n.client.Dictionary; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONObject; |
/** |
12,9 → 20,13 |
* @author david delon |
* |
*/ |
public class StructureListe extends aDonneeListe<Structure> { |
public class StructureListe extends aDonneeListe<Structure> implements ListePaginable{ |
private static final long serialVersionUID = 7384579567038300856L; |
private int currentPage = 0; |
private int nbElementsPage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
private int nbElementsTotal; |
private Rafraichissable vueARafraichir; |
public StructureListe() { |
super(); |
45,5 → 57,97 |
} |
} |
} |
public StructureListe(JSONArray structureListe, JSONNumber nbElements, Rafraichissable vueARafraichir) { |
super(structureListe.size()); |
this.nbElementsTotal = Integer.valueOf(nbElements.toString()); |
final int taillemax = structureListe.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject structure = structureListe.get(i).isObject() ; |
if (structure != null) { |
Structure structureCourante = new Structure(structure); |
this.put(structureCourante.getId(), structureCourante); |
} |
} |
this.vueARafraichir = vueARafraichir; |
} |
@Override |
public void changerNumeroPage(int pageCourante) { |
currentPage = pageCourante; |
selectionnerStructure(); |
} |
@Override |
public void changerTaillePage(int nouvelleTaillePage) { |
nbElementsPage = nouvelleTaillePage; |
selectionnerStructure(); |
} |
@Override |
public void recharger() { |
selectionnerStructure(); |
} |
public void setPageCourante(int pageCourante) { |
this.currentPage = pageCourante; |
} |
public void setTaillePage(int taillePage) { |
this.nbElementsPage = taillePage; |
} |
public int[] getPageTable() { |
int[] page = new int[4]; |
// nombre de pages au total |
page[0] = calculerNbPages(); |
// Page En Cours |
page[1] = currentPage; |
// nbElementsParPage |
page[2] = nbElementsPage; |
// et le dernier le nombre total d'éléments |
page[3] = nbElementsTotal; |
return page; |
} |
/** |
* Calcule le nombre de pages nécessaires pour afficher un nombre d'élements |
* donnés en fonction de la taille de page en cours |
* |
* @return le nombre de pages |
*/ |
public int calculerNbPages() { |
// 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 |
double nPage = (1.0 * nbElementsTotal) / (1.0 * nbElementsPage); |
double nPageRound = Math.ceil(nPage); |
Double nPageInt = new Double(nPageRound); |
// on convertit en entier |
return nPageInt.intValue(); |
} |
public void selectionnerStructure() { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerStructure(vueARafraichir, null, null, null, currentPage, nbElementsPage); |
} |
public void filtrerParNom(String nom) { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerStructure(vueARafraichir, null, null, nom, 0, nbElementsPage); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/structure/StructureAsyncDao.java |
---|
1,5 → 1,7 |
package org.tela_botanica.client.modeles.structure; |
import java.util.HashMap; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.http.JsonRestRequestBuilder; |
6,6 → 8,7 |
import org.tela_botanica.client.http.JsonRestRequestCallback; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.util.UtilDAO; |
28,9 → 31,16 |
GWT.log("ID utilisateur :"+utilisateurId, null); |
} |
public void selectionner(final String projetId, final String structureId) { |
String[] parametres = {projetId, structureId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres); |
public void selectionner(final String projetId, final String structureId, final String nomStructure, final int pageCourante, final int nbElements) { |
String[] parametres = {projetId, structureId, nomStructure}; |
HashMap<String, String> restrictions = new HashMap<String, String>(); |
restrictions.put("start", String.valueOf(pageCourante)); |
if (nbElements != -1) { |
restrictions.put("limit", String.valueOf(nbElements)); |
} |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions); |
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
37,8 → 47,9 |
if (responseValue != null) { |
Information info = new Information("selection_structure"); |
// Si la requête est un succès, reception d'un objet ou d'un tableau |
if (responseValue.isObject() != null) { |
final JSONObject reponse = responseValue.isObject(); |
JSONArray responseArray = responseValue.isArray(); |
if (responseArray.get(1).isObject() != null) { |
final JSONObject reponse = responseArray.get(1).isObject(); |
Structure structure = new Structure(reponse); |
StructureConservation structureConservation = new StructureConservation(reponse); |
StructureValorisation structureValorisation = new StructureValorisation(reponse); |
46,9 → 57,18 |
info.setDonnee(1, structureConservation); |
info.setDonnee(2, structureValorisation); |
vueARafraichir.rafraichir(info); |
} else if (responseValue.isArray() != null) { |
} else if (responseArray.get(1).isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
StructureListe structures = new StructureListe(reponse); |
StructureListe structures; // = new StructureListe(reponse); |
if (reponse.get(1).isObject() != null) { |
structures = new StructureListe(reponse.get(1).isArray()); |
} else { |
structures = new StructureListe(reponse.get(1).isArray(), reponse.get(0).isNumber(), vueARafraichir); |
} |
structures.setTaillePage(nbElements); |
structures.setPageCourante(pageCourante); |
info.setDonnee(0, structures); |
vueARafraichir.rafraichir(structures); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null); |