/trunk/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java |
---|
14,7 → 14,9 |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
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; |
48,7 → 50,8 |
private Button modifier; |
private Button supprimer; |
private Button ajouter; |
private BarrePaginationVue pagination = null; |
public CollectionListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
123,6 → 126,10 |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new CollectionListe(), mediateur); |
setBottomComponent(pagination); |
} |
private void clicListe(Collection collection) { |
155,6 → 162,10 |
if (nouvellesDonnees instanceof CollectionListe) { |
CollectionListe collections = (CollectionListe) nouvellesDonnees; |
pagination.setlistePaginable(collections); |
int[] pt = collections.getPageTable(); |
pagination.rafraichir(collections.getPageTable()); |
if (collections != null) { |
List<Collection> liste = collections.toList(); |
store.removeAll(); |
/trunk/src/org/tela_botanica/client/vues/collection/CollectionForm.java |
---|
60,7 → 60,7 |
creerFieldsetPrincipal(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateurCourrant.selectionnerCollection(this, collectionId); |
mediateurCourrant.selectionnerCollection(this, collectionId, null); |
mediateurCourrant.selectionnerCollectionAPersonne(this, collectionId, null); |
mediateurCourrant.selectionnerCollectionAPublication(this, collectionId); |
mediateurCourrant.selectionnerCollectionACommentaire(this, collectionId); |
/trunk/src/org/tela_botanica/client/vues/structure/StructureListeVue.java |
---|
154,7 → 154,6 |
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()); |
/trunk/src/org/tela_botanica/client/Modele.java |
---|
200,9 → 200,9 |
// GESTION DES COLLECTIONS |
//+----------------------------------------------------------------------------------------------------------------+ |
public void selectionnerCollection(Rafraichissable vueARafraichir, String projetId, String collectionId) { |
public void selectionnerCollection(Rafraichissable vueARafraichir, String projetId, String collectionId, String nom, int start, int nbElements) { |
CollectionAsyncDao cDao = new CollectionAsyncDao(vueARafraichir); |
cDao.selectionner(projetId, collectionId); |
cDao.selectionner(projetId, collectionId, nom, start, nbElements); |
} |
public void ajouterCollection(Rafraichissable vueARafraichir, Collection collection) { |
/trunk/src/org/tela_botanica/client/modeles/collection/CollectionListe.java |
---|
1,8 → 1,16 |
package org.tela_botanica.client.modeles.collection; |
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.structure.Structure; |
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,10 → 20,14 |
* @author david delon |
* |
*/ |
public class CollectionListe extends aDonneeListe<Collection> { |
public class CollectionListe extends aDonneeListe<Collection> implements ListePaginable{ |
private static final long serialVersionUID = 8024454926649039456L; |
private int currentPage = 0; |
private int nbElementsPage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
private int nbElementsTotal; |
private Rafraichissable vueARafraichir; |
public CollectionListe() { |
super(); |
} |
44,5 → 56,98 |
} |
} |
} |
public CollectionListe(JSONArray collectionListe, JSONNumber nbElements, Rafraichissable vueARafraichir) { |
super(collectionListe.size()); |
this.nbElementsTotal = Integer.valueOf(nbElements.toString()); |
final int taillemax = collectionListe.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject collection = collectionListe.get(i).isObject() ; |
if (collection != null) { |
Collection collectionCourante = new Collection(collection); |
this.put(collectionCourante.getId(), collectionCourante); |
} |
} |
this.vueARafraichir = vueARafraichir; |
} |
@Override |
public void changerNumeroPage(int pageCourante) { |
currentPage = pageCourante; |
selectionnerCollection(); |
} |
@Override |
public void changerTaillePage(int nouvelleTaillePage) { |
nbElementsPage = nouvelleTaillePage; |
selectionnerCollection(); |
} |
@Override |
public void recharger() { |
selectionnerCollection(); |
} |
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 selectionnerCollection() { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerCollection(vueARafraichir, null, null, currentPage, nbElementsPage); |
} |
public void filtrerParNom(String nom) { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerCollection(vueARafraichir, null, nom, 0, nbElementsPage); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/collection/CollectionAsyncDao.java |
---|
1,5 → 1,7 |
package org.tela_botanica.client.modeles.collection; |
import java.util.HashMap; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.http.JsonRestRequestBuilder; |
14,6 → 16,7 |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONObject; |
import com.google.gwt.json.client.JSONValue; |
28,17 → 31,25 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
} |
public void selectionner(final String projetId, final String collectionId) { |
public void selectionner(final String projetId, final String collectionId, final String nomCollection, final int start, final int nbElements) { |
// Ajout des paramètres et données à selectionner dans l'URL |
String[] parametres = {projetId, collectionId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres); |
String[] parametres = {projetId, collectionId, nomCollection}; |
HashMap<String, String> restrictions = new HashMap<String, String>(); |
restrictions.put("start", String.valueOf(start)); |
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) { |
if (responseValue != null) { |
// 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(); |
Collection collection = new Collection(reponse); |
CollectionBotanique collectionBotanique = new CollectionBotanique(reponse); |
collection.setBotanique(collectionBotanique); |
47,8 → 58,11 |
info.setDonnee(0, collection); |
vueARafraichir.rafraichir(info); |
} else if (responseValue.isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
CollectionListe collections = new CollectionListe(reponse); |
final JSONArray reponse = responseArray.get(1).isArray(); |
CollectionListe collections = new CollectionListe(reponse, responseArray.get(0).isNumber(), vueARafraichir); |
collections.setTaillePage(nbElements); |
collections.setPageCourante(start); |
vueARafraichir.rafraichir(collections); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null); |
/trunk/src/org/tela_botanica/client/Mediateur.java |
---|
96,7 → 96,7 |
private StatutVue panneauSud = null; |
private IdentificationFenetre fenetreIdentification = null; |
private int nbElements = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
public Mediateur() { |
// Enregistrement du Médiateur dans le Registre |
Registry.register(RegistreId.MEDIATEUR, this); |
220,7 → 220,7 |
} else if (codeMenuClique.equals(MenuApplicationId.STRUCTURE)) { |
selectionnerStructure(panneauCentre, null); |
} else if (codeMenuClique.equals(MenuApplicationId.COLLECTION)) { |
selectionnerCollection(panneauCentre, null); |
selectionnerCollection(panneauCentre, null, null); |
} else if (codeMenuClique.equals(MenuApplicationId.PERSONNE)) { |
selectionnerPersonne(panneauCentre, null, null); |
} else if (codeMenuClique.equals(MenuApplicationId.PUBLICATION)) { |
476,7 → 476,7 |
} else if (panneauCentre.getContenu() instanceof StructureVue) { |
selectionnerStructure(panneauCentre.getContenu(), null); |
} else if (panneauCentre.getContenu() instanceof CollectionVue) { |
selectionnerCollection(panneauCentre.getContenu(), null); |
selectionnerCollection(panneauCentre.getContenu(), null, null); |
} else if (panneauCentre.getContenu() instanceof PersonneVue) { |
selectionnerPersonne(panneauCentre.getContenu(), null, getProjetId()); |
} else if (panneauCentre.getContenu() instanceof PublicationVue) { |
573,9 → 573,6 |
} |
public void selectionnerStructure(Rafraichissable vueARafraichir, String structureId) { |
int nbElements = Integer.valueOf(((Dictionary) Dictionary |
.getDictionary("configuration")).get("nbElementsPage")); |
modele.selectionnerStructure(vueARafraichir, getProjetId(), structureId, null, 0, nbElements); |
} |
720,12 → 717,18 |
} |
} |
public void selectionnerCollection(Rafraichissable vueARafraichir, String collectionId) { |
modele.selectionnerCollection(vueARafraichir, getProjetId(), collectionId); |
public void selectionnerCollection(Rafraichissable vueARafraichir, String collectionId, String nom) { |
System.out.println(nbElements); |
selectionnerCollection(vueARafraichir, collectionId, nom, 0, nbElements); |
} |
public void selectionnerCollection(Rafraichissable vueARafraichir, String collectionId, String nom, int start, int nbElements) { |
modele.selectionnerCollection(vueARafraichir, getProjetId(), collectionId, nom, start, this.nbElements); |
} |
public void selectionnerCollectionParProjet(Rafraichissable vueARafraichir, String projetId) { |
modele.selectionnerCollection(vueARafraichir, projetId, null); |
modele.selectionnerCollection(vueARafraichir, projetId, null, null, 0, nbElements); |
} |
public void ajouterCollection(Rafraichissable vueARafraichir, Collection collection) { |
947,8 → 950,6 |
} |
public void selectionnerPersonne(Rafraichissable vueARafraichir, Personne personne, String projetId) { |
int nbElements = Integer.valueOf(((Dictionary) Dictionary |
.getDictionary("configuration")).get("nbElementsPage")); |
selectionnerPersonne(vueARafraichir, personne, projetId, 0, nbElements); |
} |