/trunk/src/org/tela_botanica/client/Mediateur.java |
---|
10,6 → 10,7 |
import org.tela_botanica.client.i18n.ErrorMessages; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Collection; |
import org.tela_botanica.client.modeles.CollectionAPersonne; |
import org.tela_botanica.client.modeles.CollectionListe; |
import org.tela_botanica.client.modeles.Configuration; |
import org.tela_botanica.client.modeles.Information; |
22,6 → 23,7 |
import org.tela_botanica.client.modeles.PublicationListe; |
import org.tela_botanica.client.modeles.Structure; |
import org.tela_botanica.client.modeles.StructureAPersonne; |
import org.tela_botanica.client.modeles.CollectionAPersonneListe; |
import org.tela_botanica.client.modeles.StructureAPersonneListe; |
import org.tela_botanica.client.modeles.StructureConservation; |
import org.tela_botanica.client.modeles.StructureListe; |
546,6 → 548,45 |
} |
//+----------------------------------------------------------------------------------------------------------------+ |
// GESTION de la relation COLLECTION A PERSONNE |
public void selectionnerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, String roleId) { |
modele.selectionnerCollectionAPersonne(vueARafraichir, collectionId, roleId); |
} |
public void ajouterCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, CollectionAPersonneListe personnesAjoutees) { |
if (personnesAjoutees != null && personnesAjoutees.size() > 0) { |
for (Iterator<String> it = personnesAjoutees.keySet().iterator(); it.hasNext();) { |
modele.ajouterCollectionAPersonne(vueARafraichir, collectionId, (CollectionAPersonne) personnesAjoutees.get(it.next())); |
} |
} |
} |
public void modifierCollectionAPersonne(Rafraichissable vueARafraichir, CollectionAPersonneListe personnesModifiees) { |
if (personnesModifiees != null && personnesModifiees.size() > 0) { |
for (Iterator<String> it = personnesModifiees.keySet().iterator(); it.hasNext();) { |
modele.modifierCollectionAPersonne(vueARafraichir, (CollectionAPersonne) personnesModifiees.get(it.next())); |
} |
} |
} |
public void supprimerCollectionAPersonne(Rafraichissable vueARafraichir, CollectionAPersonneListe personnesSupprimees) { |
if (personnesSupprimees != null && personnesSupprimees.size() > 0) { |
String idCollectionAPersonneSeparesParVirgule = "" ; |
for (Iterator<String> it = personnesSupprimees.keySet().iterator(); it.hasNext();) { |
idCollectionAPersonneSeparesParVirgule += personnesSupprimees.get(it.next()).getId()+"," ; |
} |
modele.supprimerCollectionAPersonne(vueARafraichir, idCollectionAPersonneSeparesParVirgule); |
} |
} |
//+----------------------------------------------------------------------------------------------------------------+ |
// GESTION de la relation COLLECTION A PUBLICATION |
//+----------------------------------------------------------------------------------------------------------------+ |
// GESTION de la relation COLLECTION A COMMENTAIRE |
//+----------------------------------------------------------------------------------------------------------------+ |
// GESTION DES PERSONNES |
//+----------------------------------------------------------------------------------------------------------------+ |
572,23 → 613,15 |
} |
public void afficherPersonneForm(Personne personne) { |
String mode = ""; |
String personneId = null; |
if (personne != null) { |
mode = PersonneForm.MODE_MODIFIER; |
personneId = personne.getId(); |
} else { |
mode = PersonneForm.MODE_AJOUTER; |
} |
panneauCentre.removeAll(); |
PersonneForm formulairePersonneVue = new PersonneForm(this, mode, personneId); |
PublicationForm publicationForm = new PublicationForm(this, personneId); |
panneauCentre.add(publicationForm); |
if (mode.equals(PersonneForm.MODE_MODIFIER)) { |
selectionnerPersonne(formulairePersonneVue, personne, null); |
} |
panneauCentre.add(formulairePersonneVue); |
panneauCentre.layout(); |
} |
/trunk/src/org/tela_botanica/client/vues/Formulaire.java |
---|
61,6 → 61,7 |
protected String menuIdCourant = null; |
protected static Boolean clicBoutonvalidation = false; |
protected Rafraichissable vueExterneARafraichirApresValidation = null; |
public FormPanel getFormulaire() { |
return panneauFormulaire; |
/trunk/src/org/tela_botanica/client/vues/CollectionFormPersonne.java |
---|
7,14 → 7,20 |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Collection; |
import org.tela_botanica.client.modeles.CollectionAPersonne; |
import org.tela_botanica.client.modeles.CollectionAPersonneListe; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.InterneValeur; |
import org.tela_botanica.client.modeles.Personne; |
import org.tela_botanica.client.modeles.PersonneListe; |
import org.tela_botanica.client.modeles.Publication; |
import org.tela_botanica.client.modeles.StructureAPersonne; |
import org.tela_botanica.client.modeles.UniteBase; |
import org.tela_botanica.client.modeles.UniteRangement; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
25,6 → 31,7 |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.store.Record; |
import com.extjs.gxt.ui.client.store.Store; |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
33,12 → 40,15 |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; |
import com.extjs.gxt.ui.client.widget.grid.EditorGrid; |
import com.extjs.gxt.ui.client.widget.grid.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig; |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer; |
50,19 → 60,25 |
public class CollectionFormPersonne extends FormulaireOnglet implements Rafraichissable { |
private Collection collection = null; |
private Collection collectionCollectee = null; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private Grid<Personne> grille; |
private Grid<CollectionAPersonne> grille; |
private ComboBox<Valeur> typeRelationCombo = null; |
private PersonneListe personnes = null; |
private PersonneListe personnesAjoutes = null; |
private PersonneListe personnesSupprimes = null; |
private CollectionAPersonneListe personnes = null; |
private CollectionAPersonneListe personnesAjoutees = null; |
private CollectionAPersonneListe personnesModifiees = null; |
private CollectionAPersonneListe personnesSupprimees = null; |
private ComboBox<Personne> personnesSaisisComboBox = null; |
private Button personnesBoutonSupprimer = null; |
private Button personnesBoutonModifier = null; |
private Button ajouterPersonneSaisiBouton = null; |
private ValeurListe listeIon = null; |
private FenetreForm fenetreFormulaire = null; |
private static final String ETAT_AJOUTE = "A"; |
private static final String ETAT_SUPPRIME = "S"; |
77,6 → 93,7 |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
mediateur.obtenirListeValeurEtRafraichir(this, "ion"); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonneCollection"); |
add(panneauPrincipal); |
85,12 → 102,18 |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
personnesAjoutes = new PersonneListe(); |
personnesSupprimes = new PersonneListe(); |
personnesAjoutees = new CollectionAPersonneListe(); |
personnesModifiees = new CollectionAPersonneListe(); |
personnesSupprimees = new CollectionAPersonneListe(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
111,7 → 134,7 |
barreOutils.add(new Text(" ou ")); |
personnesSaisisComboBox = creerComboBoxAuteursSaisis(); |
personnesSaisisComboBox = creerComboBoxPersonnesSaisies(); |
barreOutils.add(personnesSaisisComboBox); |
barreOutils.add(new SeparatorToolItem()); |
136,10 → 159,11 |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
FenetreForm fenetre = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetre.show(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
151,12 → 175,12 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
Personne auteurSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (auteurSaisiSelectionne == null) { |
CollectionAPersonne personneSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (personneSaisiSelectionne == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne()); |
} else { |
FenetreForm fenetre = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetre.show(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
164,33 → 188,30 |
} |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String personneId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
CollectionAPersonne personneSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
personneId = personneSaisieSelectionnee.getId(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PersonneForm formulaire = creerFormulairePersonne(fenetre); |
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre) { |
PersonneForm formulaire = new PersonneForm(mediateur, PersonneForm.MODE_AJOUTER, null); |
/*fenetre.setHeading(formulaire.getHeading()); |
formulaire.setHeaderVisible(false); |
formulaire.setTopComponent(null);*/ |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, String personneId) { |
PersonneForm formulaire = new PersonneForm(mediateur, personneId, this); |
FormPanel panneauFormulaire = formulaire.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
// TODO : gérer la barre d'outil avec des évènements spécifique au contexte de fenêtre modale |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulaire); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
//formulaire.setBottomComponent(barreValidation); |
panneauFormulaire.setBottomComponent(barreValidation); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
// TODO : simplifier la gestion de l'ajout des données d'une Personne au form pour la modification... (pas besoin de passer par une liste). |
Information info = new Information("liste_personne"); |
PersonneListe personnes = new PersonneListe(); |
Personne auteurSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
personnes.put(auteurSaisiSelectionne.getId(), auteurSaisiSelectionne); |
info.setDonnee(0, personnes); |
formulaire.rafraichir(info); |
} |
return formulaire; |
} |
200,20 → 221,17 |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
Boolean ok = formulaire.enregistrer(); |
if (ok == true) { |
// Fermer fenêtre et ajouter/modifier l'élément dans la liste |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
fenetre.hide(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
Boolean ok = formulaire.enregistrer(); |
if (ok == true) { |
// Fermer fenêtre et ajouter/modifier l'élément dans la liste |
} |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
formulaire.reinitialiserFormulaire(); |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
227,11 → 245,11 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
Personne auteurSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (auteurSaisiSelectionne == null) { |
CollectionAPersonne personneSaisiSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (personneSaisiSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne()); |
} else { |
supprimerDansGrille(auteurSaisiSelectionne); |
supprimerDansGrille(personneSaisiSelectionnee); |
} |
} |
}); |
250,7 → 268,7 |
return bouton; |
} |
private ComboBox<Personne> creerComboBoxAuteursSaisis() { |
private ComboBox<Personne> creerComboBoxPersonnesSaisies() { |
ListStore<Personne> personnesSaisiesStore = new ListStore<Personne>(); |
personnesSaisiesStore.add(new ArrayList<Personne>()); |
274,8 → 292,8 |
@Override |
public void handleEvent(BaseEvent be) { |
if (personnesSaisisComboBox.getValue() instanceof Personne) { |
Personne auteurSaisiSelectionne = personnesSaisisComboBox.getValue(); |
ajouterDansGrille(auteurSaisiSelectionne); |
Personne personneSaisiSelectionnee = personnesSaisisComboBox.getValue(); |
ajouterDansGrille(personneSaisiSelectionnee); |
personnesSaisisComboBox.setValue(null); |
} |
} |
285,33 → 303,38 |
private void ajouterDansGrille(Personne personne) { |
if (personne != null) { |
CollectionAPersonne relationCollectionPersonne = new CollectionAPersonne(); |
relationCollectionPersonne.setPersonne(personne); |
// Ajout de la personne ajoutée à la liste |
if (personne.getId() != null && !personne.getId().equals("")) { |
personnesAjoutes.put(personne.getId(), personne); |
if (relationCollectionPersonne.getId() != null && !relationCollectionPersonne.getId().equals("")) { |
personnesAjoutees.put(relationCollectionPersonne.getId(), relationCollectionPersonne); |
} |
// Définition de l'état |
personne.set("etat", ETAT_AJOUTE); |
relationCollectionPersonne.set("etat", ETAT_AJOUTE); |
// Ajout à la grille |
grille.getStore().insert(personne, 0); |
grille.getStore().insert(relationCollectionPersonne, 0); |
grille.getSelectionModel().select(0, false); |
} |
} |
private void supprimerDansGrille(Personne personne) { |
if (personne != null) { |
private void supprimerDansGrille(CollectionAPersonne relationCollectionPersonne) { |
if (relationCollectionPersonne != null) { |
// Ajout de la personne supprimée à la liste |
if ((personne.get("etat") == null || !personne.get("etat").equals(ETAT_AJOUTE)) && personne.getId() != null && !personne.getId().equals("")) { |
personnesSupprimes.put(personne.getId(), personne); |
if ((relationCollectionPersonne.get("etat") == null || !relationCollectionPersonne.get("etat").equals(ETAT_AJOUTE)) |
&& relationCollectionPersonne.getId() != null |
&& !relationCollectionPersonne.getId().equals("")) { |
personnesSupprimees.put(relationCollectionPersonne.getId(), relationCollectionPersonne); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(personne); |
grille.getStore().remove(relationCollectionPersonne); |
} |
} |
private Grid<Personne> creerGrille() { |
private Grid<CollectionAPersonne> creerGrille() { |
ListStore<Personne> storeGrille = new ListStore<Personne>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<Personne>>() { |
public void handleEvent(StoreEvent<Personne> ce) { |
363,7 → 386,7 |
} |
}; |
ColumnConfig typeRelationColonne = new ColumnConfig("type_relation", i18nC.typeRelationPersonneCollection(), 75); |
ColumnConfig typeRelationColonne = new ColumnConfig("id_role", i18nC.typeRelationPersonneCollection(), 75); |
typeRelationColonne.setEditor(editeurRelation); |
colonnes.add(typeRelationColonne); |
370,15 → 393,13 |
colonnes.add(new ColumnConfig("fmt_nom_complet", i18nC.personneNomComplet(), 150)); |
colonnes.add(new ColumnConfig("nom", i18nC.personneNom(), 75)); |
colonnes.add(new ColumnConfig("prenom", i18nC.personnePrenom(), 75)); |
colonnes.add(new ColumnConfig("prefixe", i18nC.personnePrefixe(), 50)); |
//colonnes.add(new ColumnConfig("truk_nom_autre", i18nC.personneNomAutre(), 200)); |
colonnes.add(new ColumnConfig("naissance_date", i18nC.date(), 75)); |
colonnes.add(new ColumnConfig("naissance_lieu", i18nC.lieu(), 100)); |
colonnes.add(new ColumnConfig("ce_deces", i18nC.personneDecedeeInterogation(), 50)); |
colonnes.add(creerColonneDeces()); |
colonnes.add(new ColumnConfig("deces_date", i18nC.date(), 75)); |
colonnes.add(new ColumnConfig("deces_lieu", i18nC.lieu(), 100)); |
GridSelectionModel<Personne> modeleDeSelection = new GridSelectionModel<Personne>(); |
GridSelectionModel<CollectionAPersonne> modeleDeSelection = new GridSelectionModel<CollectionAPersonne>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.addHeaderGroup(0, 1, new HeaderGroupConfig(i18nC.personneIdentite(), 1, 4)); |
385,7 → 406,7 |
modeleDeColonnes.addHeaderGroup(0, 5, new HeaderGroupConfig(i18nC.personneNaissance(), 1, 2)); |
modeleDeColonnes.addHeaderGroup(0, 7, new HeaderGroupConfig(i18nC.personneDeces(), 1, 3)); |
EditorGrid<Personne> grillePersonne = new EditorGrid<Personne>(storeGrille, modeleDeColonnes); |
EditorGrid<CollectionAPersonne> grillePersonne = new EditorGrid<CollectionAPersonne>(storeGrille, modeleDeColonnes); |
grillePersonne.setHeight("100%"); |
grillePersonne.setBorders(true); |
grillePersonne.setSelectionModel(modeleDeSelection); |
398,6 → 419,23 |
return grillePersonne; |
} |
public ColumnConfig creerColonneDeces() { |
GridCellRenderer<CollectionAPersonne> decesRendu = new GridCellRenderer<CollectionAPersonne>() { |
@Override |
public String render(CollectionAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPersonne> store, Grid<CollectionAPersonne> grid) { |
String deces = modele.getPersonne().getDeces(); |
if (listeIon != null && modele.getPersonne().getDeces().matches("[0-9]+")) { |
deces = listeIon.get(modele.getPersonne().getDeces()).getNom(); |
} |
modele.set("_deces_", deces); |
return deces; |
} |
}; |
ColumnConfig decesColonne = new ColumnConfig("_deces_", Mediateur.i18nC.personneDecedeeInterogation(), 50); |
decesColonne.setRenderer(decesRendu); |
return decesColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
424,7 → 462,9 |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("relationPersonneCollection"))) { |
if (listeValeurs.getId().equals(config.getListeId("ion"))) { |
listeIon = listeValeurs; |
} else if (listeValeurs.getId().equals(config.getListeId("relationPersonneCollection"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo); |
} else { |
GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null); |
452,14 → 492,100 |
//auteurs = (CollectionAPersonneListe) info.getDonnee(0); |
peupler(); |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées |
// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées |
mediateur.ajouterCollectionAPersonne(this, collectionId, personnesAjoutees); |
} else { |
Info.display("Ajout d'une Institution", info.toString()); |
} |
} else if (info.getType().equals("modif_collection_a_personne")) { |
Info.display("Modification des personnes liées à la collection", info.toString()); |
} else if (info.getType().equals("suppression_collection_a_personne")) { |
Info.display("Suppression des personnes liées à la collection", info.toString()); |
} else if (info.getType().equals("ajout_collection_a_personne")) { |
Info.display("Ajout des personnes liées à la collection", info.toString()); |
} |
} |
private void peupler() { |
public void peupler() { |
initialiserCollection(); |
layout(); |
Info.display(i18nC.chargementPersonne(), i18nC.ok()); |
} |
public ArrayList<String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
String personneNumero = ""; |
int nbrePersonne = grille.getStore().getCount(); |
if (nbrePersonne > 0) { |
for (int i = 0; i < nbrePersonne; i++) { |
CollectionAPersonne personne = grille.getStore().getAt(i); |
if (personne.getIdRole().equals("")) { |
personneNumero += (i != 0 ? ", " : "")+(i+1); |
} |
} |
if (!personneNumero.equals("")) { |
messages.add("Veuillez indiquez le type de relation existant entre la collection et les personnes numéros : "+personneNumero); |
} |
} |
return messages; |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
int nbrePersonne = grille.getStore().getCount(); |
for (int i = 0; i < nbrePersonne; i++) { |
CollectionAPersonne personne = grille.getStore().getAt(i); |
// Seules les lignes ajoutées ou modifiées sont prises en compte. |
Record enregistrement = grille.getStore().getRecord(personne); |
if (grille.getStore().getModifiedRecords().contains(enregistrement) == true |
|| (personne.get("etat") != null && personne.get("etat").equals(aDonnee.ETAT_AJOUTE) )) { |
// Gestion de l'id de la structure |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
personne.setIdCollection(collection.getId()); |
} |
// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié) |
if (personne.get("etat") != null && personne.get("etat").equals(aDonnee.ETAT_AJOUTE)) {// Une personne ajoutée |
personnesAjoutees.put(""+i, personne); |
} else {// Une personne modifiée |
personnesModifiees.put(personne.getId(), personne); |
} |
} else { |
GWT.log("Personne non modifiées : "+personne.getPersonne().getPrenom()+" "+personne.getPersonne().getNom(), null); |
} |
} |
} |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (personnesModifiees.size() == 0 && personnesAjoutees.size() == 0 && personnesSupprimees.size() == 0) { |
Info.display("Modification des personnes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
if (personnesModifiees.size() != 0) { |
mediateur.modifierCollectionAPersonne(this, personnesModifiees); |
} |
// Ajout des relations CollectionAPersonne |
if (personnesAjoutees.size() != 0) { |
mediateur.ajouterCollectionAPersonne(this, collection.getId(), personnesAjoutees); |
} |
// Suppression des relations StructureAPersonne |
if (personnesSupprimees.size() != 0) { |
mediateur.supprimerCollectionAPersonne(this, personnesSupprimees); |
} |
} |
} |
} |
private void obtenirPersonnesSaisis(String nom) { |
mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%"); |
} |
/trunk/src/org/tela_botanica/client/vues/PersonneForm.java |
---|
24,6 → 24,7 |
import org.tela_botanica.client.modeles.PersonneListe; |
import org.tela_botanica.client.modeles.Projet; |
import org.tela_botanica.client.modeles.ProjetListe; |
import org.tela_botanica.client.modeles.Publication; |
import org.tela_botanica.client.modeles.Utilisateur; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
87,7 → 88,7 |
private Mediateur mediateur; |
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG); |
private Personne personneSelectionnee, personneSauvegarde = null; |
private String mode = ""; |
protected String mode = ""; |
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite |
private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>(); |
100,32 → 101,45 |
public static final String MODE_AJOUTER = "AJOUT"; |
public static final String MODE_MODIFIER = "MODIF"; |
private final String personneId; |
private Personne personne = null; |
private String personneId = null; |
private FormBinding binding = null; |
// CONSTRUCTEUR |
public PersonneForm(Mediateur mediateurCourrant, String mode, String personneId) { |
initialiserPersonneForm(mediateurCourrant, personneId); |
} |
public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) { |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation; |
initialiserPersonneForm(mediateurCourrant, personneId); |
} |
public PersonneForm(Mediateur mediateur, String mode, String personneId) { |
private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) { |
personne = new Personne(); |
personne.setId(personneIdCourrant); |
personneId = personneIdCourrant; |
this.personneId = personneId; |
this.mediateur = mediateur; |
initialiserFormulaire(mediateur, mode, MenuApplicationId.PERSONNE); |
String modeDeCreation = (personneId.isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE); |
initialiserComposants(); |
genererTitreFormulaire(); |
String titreFormulaire = ""; |
if (mode.equals(MODE_MODIFIER)) { |
titreFormulaire = mediateur.i18nC.personneModeModifier() + " ID: " + personneId; |
} else { |
titreFormulaire = mediateur.i18nC.personneModeAjout(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerPersonne(this, personne, null); |
} |
panneauFormulaire.setHeading(titreFormulaire); |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.personneModeAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId; |
} |
panneauFormulaire.setHeading(titre); |
} |
public void initialiserComposants() { |
personneSelectionnee = new Personne(); |
personneSauvegarde = new Personne(); |
148,7 → 162,7 |
TabPanel formulaireOnglets = new TabPanel(); |
//Tab 1 : identite |
tiIdentite = new TabItem(mediateur.i18nC.personneIdentite()); |
tiIdentite = new TabItem(i18nC.personneIdentite()); |
tiIdentite.setLayout(new FormLayout()); |
tiIdentite.setScrollMode(Scroll.AUTO); |
156,13 → 170,13 |
hmIdentite.put("tiIdentite", tiIdentite); |
//Tab 2 : Adresse |
tiAdresses = new TabItem(mediateur.i18nC.adresse()); |
tiAdresses = new TabItem(i18nC.adresse()); |
tiAdresses.setLayout(new FormLayout()); |
tiAdresses.setScrollMode(Scroll.AUTO); |
formulaireOnglets.add(tiAdresses); |
//Tab 3 : Infos Naturalistes |
tiInfosNat = new TabItem(mediateur.i18nC.personneInfoNat()); |
tiInfosNat = new TabItem(i18nC.personneInfoNat()); |
tiInfosNat.setLayout(new FormLayout()); |
tiInfosNat.setScrollMode(Scroll.AUTO); |
200,13 → 214,13 |
formLayout.setLabelAlign(LabelAlign.LEFT); |
FieldSet fsProjet = new FieldSet(); |
fsProjet.setHeading(mediateur.i18nC.menuProjet()); |
fsProjet.setHeading(i18nC.menuProjet()); |
fsProjet.setLayout(new FormLayout()); |
ListStore<Projet> storeProjets = new ListStore<Projet>(); |
ComboBox cbProjets = new ComboBox<Projet>(); |
cbProjets.setFieldLabel(mediateur.i18nC.personneProjet()+ " :"); |
cbProjets.setEmptyText(mediateur.i18nC.txtListeProjetDefaut()); |
cbProjets.setFieldLabel(i18nC.personneProjet()+ " :"); |
cbProjets.setEmptyText(i18nC.txtListeProjetDefaut()); |
cbProjets.setLabelSeparator(""); |
cbProjets.setDisplayField("nom"); |
cbProjets.setEditable(false); |
227,7 → 241,7 |
// Nom complet : Affiché que si valeurs saisies |
LabelField nomComplet = new LabelField(); |
nomComplet.setFieldLabel(mediateur.i18nC.personneNomComplet() +" :"); |
nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :"); |
nomComplet.hide(); |
fsNoms.add(nomComplet); |
469,7 → 483,7 |
LayoutContainer lcLogoUrl = new LayoutContainer(); |
hmIdentite.put("lcLogoUrl", lcLogoUrl); |
ChampMultiValeursImage logo = new ChampMultiValeursImage(mediateur.i18nC.personneLogos()); |
ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos()); |
logo.setImageHeight("150px"); |
logo.setValeurParDefaut("http://"); |
logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg"); |
606,11 → 620,11 |
FieldSet fsInfosNat = new FieldSet(); |
fsInfosNat.setTitle("Informations Naturaliste"); |
ChampMultiValeurs specialite = new ChampMultiValeurs(mediateur.i18nC.personneSpecialite()); |
ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite()); |
fsInfosNat.add(specialite); |
hmInfosNat.put("specialite", specialite); |
ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(mediateur.i18nC.personneRecolte()); |
ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte()); |
recolte.initialiserType("pays"); |
hmInfosNat.put("recolte", recolte); |
/trunk/src/org/tela_botanica/client/vues/CollectionFormGeneral.java |
---|
1,5 → 1,7 |
package org.tela_botanica.client.vues; |
import java.util.ArrayList; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeurs; |
68,9 → 70,6 |
setId("general"); |
setText(Mediateur.i18nC.collectionGeneral()); |
collection = ((CollectionForm) formulaire).collection; |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
creerChampsCache(); |
creerFieldsetLiaison(); |
creerFieldsetAdministratif(); |
79,6 → 78,11 |
creerFieldsetType(); |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
} |
private void creerChampsCache() { |
// Champs cachés |
idCollectionChp = new HiddenField<String>(); |
273,8 → 277,12 |
} |
public void peupler() { |
initialiserCollection(); |
if (collection != null) { |
idCollectionChp.setValue(collection.getId()); |
setValeurComboProjets(); |
setValeurComboStructures(); |
setValeurComboCollections(); |
typeDepotCombo.peupler(collection.getTypeDepot()); |
coteChp.setValue(collection.getCote()); |
292,15 → 300,27 |
lieuCouvertureChp.peupler(collection.getCouvertureLieu()); |
specimenTypeCombo.peupler(collection.getSpecimenType()); |
nbreTypeChp.setValue(Integer.parseInt(collection.getSpecimenTypeNbre())); |
nbreTypeChp.setValue((collection.getSpecimenTypeNbre().equals("") ? 0 : Integer.parseInt(collection.getSpecimenTypeNbre()))); |
precisionTypeNbreCombo.peupler(collection.getSpecimenTypeNbrePrecision()); |
classementSpecimenTypeCombo.peupler(collection.getSpecimenTypeClassement()); |
} |
} |
public ArrayList<String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
if (projetsCombo.getValue() == null || projetsCombo.getValue().equals("") || collection.getIdProjet().equals("")) { |
messages.add("Veuillez sélectionner un projet pour la collection."); |
} |
return messages; |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionCollectee.setId(idCollectionChp.getValue()); |
collectionCollectee.setCollectionMereId(getValeurComboProjets()); |
collectionCollectee.setIdStructure(getValeurComboStructures()); |
collectionCollectee.setCollectionMereId(getValeurComboCollections()); |
collectionCollectee.setTypeDepot(typeDepotCombo.getValeur()); |
collectionCollectee.setCote(coteChp.getValue()); |
324,19 → 344,40 |
} |
} |
private void mettreAJourValeurComboProjets() { |
private String getValeurComboProjets() { |
String valeur = ""; |
if (projetsCombo.getValue() != null) { |
valeur = projetsCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboProjets() { |
if (projetsCombo.getStore() != null && collection != null) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", collection.getIdProjet())); |
} |
} |
private void mettreAJourValeurComboStructures() { |
private String getValeurComboStructures() { |
String valeur = ""; |
if (structuresCombo.getValue() != null) { |
valeur = structuresCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboStructures() { |
if (structuresCombo.getStore() != null && collection != null) { |
structuresCombo.setValue(structuresCombo.getStore().findModel("id_structure", collection.getIdStructure())); |
} |
} |
private void mettreAJourValeurComboCollections() { |
private String getValeurComboCollections() { |
String valeur = ""; |
if (collectionsCombo.getValue() != null) { |
valeur = collectionsCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboCollections() { |
if (collectionsCombo.getStore() != null && collection != null) { |
collectionsCombo.setValue(collectionsCombo.getStore().findModel("id_collection", collection.getCollectionMereId())); |
} |
346,15 → 387,15 |
if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(projets, projetsCombo); |
mettreAJourValeurComboProjets(); |
setValeurComboProjets(); |
} else if (nouvellesDonnees instanceof StructureListe) { |
StructureListe structures = (StructureListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(structures, structuresCombo); |
mettreAJourValeurComboStructures(); |
setValeurComboStructures(); |
} else if (nouvellesDonnees instanceof CollectionListe) { |
CollectionListe collections = (CollectionListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(collections, collectionsCombo); |
mettreAJourValeurComboCollections(); |
setValeurComboCollections(); |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
/trunk/src/org/tela_botanica/client/vues/FormulaireOnglet.java |
---|
31,6 → 31,7 |
parametrer(this); |
addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
setAcces(true); |
actualiser(); |
} |
}); |
/trunk/src/org/tela_botanica/client/vues/CollectionForm.java |
---|
1,5 → 1,7 |
package org.tela_botanica.client.vues; |
import java.util.ArrayList; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
7,6 → 9,7 |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.util.UtilArray; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
14,6 → 17,7 |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.button.Button; |
169,7 → 173,7 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
if (info.getType().equals("modif_structure")) { |
if (info.getType().equals("modif_collection")) { |
Info.display("Modification d'une collection", info.toString()); |
} else if (info.getType().equals("selection_collection")) { |
Info.display("Modification d'une collection", info.toString()); |
178,6 → 182,17 |
} |
peupler(); |
actualiserTitrePanneau(); |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
Info.display("Ajout d'une collection", "La collection '"+collectionId+"' a bien été ajoutée"); |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées |
personneOnglet.rafraichir(info); |
publicationOnglet.rafraichir(info); |
} else { |
Info.display("Ajout d'une Institution", info.toString()); |
} |
} |
} |
192,6 → 207,7 |
private void peuplerOnglets() { |
generalOnglet.peupler(); |
personneOnglet.peupler(); |
} |
private void actualiserTitrePanneau() { |
239,10 → 255,16 |
mediateur.modifierCollection(this, collection); |
} |
} |
soumettreOnglets(); |
} |
return fomulaireValide; |
} |
private void soumettreOnglets() { |
personneOnglet.soumettre(); |
} |
protected void reinitialiserFormulaire() { |
if (mode.equals(StructureForm.MODE_MODIFIER)) { |
mediateur.afficherFormCollection(collection.getId()); |
274,6 → 296,34 |
} |
protected boolean verifierFormulaire() { |
ArrayList<String> messages = new ArrayList<String>(); |
// Vérification des infos sur le nom de la collection |
if (nomChp.getValue() == null || nomChp.getValue().equals("") || collection.getNom().equals("")) { |
messages.add("Veuillez donner un nom à la collection."); |
} |
// Vérification des infos sur le type de collection |
if (typesCollectionCombo.getValue() == null || typesCollectionCombo.getValue().equals("") || collection.getIdProjet().equals("")) { |
messages.add("Veuillez sélectionner un type pour la collection."); |
} |
messages.addAll(verifierOnglets()); |
// Affichage des messages d'alerte |
if (messages.size() != 0) { |
String[] tableauDesMessages = {}; |
tableauDesMessages = messages.toArray(tableauDesMessages); |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null); |
return false; |
} |
return true; |
} |
private ArrayList<String> verifierOnglets() { |
ArrayList<String> messages = new ArrayList<String>(); |
messages.addAll(generalOnglet.verifier()); |
messages.addAll(personneOnglet.verifier()); |
return messages; |
} |
} |
/trunk/src/org/tela_botanica/client/vues/StructureForm.java |
---|
1852,7 → 1852,7 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} catch (Exception e) { |
GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e); |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e); |
} |
controlerFermetureApresRafraichissement(); |
/trunk/src/org/tela_botanica/client/vues/PublicationForm.java |
---|
66,9 → 66,6 |
private boolean publicationValideOk = false; |
private boolean auteursValideOk = false; |
private Rafraichissable vueExterneARafraichirApresValidation = null; |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) { |
initialiserPublicationForm(mediateurCourrant, publicationId); |
} |
/trunk/src/org/tela_botanica/client/vues/CollectionDetailVue.java |
---|
128,9 → 128,7 |
" <span class='{css_label}'>{i18n_cote} :</span> {cote}<br />"+ |
" <span class='{css_label}'>{i18n_mere} :</span> {mere}<br />"+ |
" <span class='{css_label}'>{i18n_type_ncd} :</span> {type_ncd}<br />"+ |
" <span class='{css_label}'>{i18n_type_botanique} :</span> {type_botanique}<br />"+ |
" <span class='{css_label}'>{i18n_type_depot} :</span> {type_depot}<br />"+ |
" <span class='{css_label}'>{i18n_nbre_echantillon} :</span> {nbre_echantillon}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_general_collection_titre}</h2>"+ |
170,6 → 168,8 |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_description}</h2>"+ |
" <span class='{css_label}'>{i18n_type_botanique} :</span> {type_botanique}<br />"+ |
" <span class='{css_label}'>{i18n_nbre_echantillon} :</span> {nbre_echantillon}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
"</div>"; |
196,7 → 196,7 |
} |
private void chargerOntologie() { |
String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot"}; |
String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot", "groupementPrincipe", "realisationBut"}; |
lancerChargementListesValeurs(listesCodes); |
} |
266,9 → 266,7 |
generalParams.set("i18n_cote", i18nC.cote()); |
generalParams.set("i18n_mere", i18nC.collectionMere()); |
generalParams.set("i18n_type_ncd", i18nC.typeCollectionNcd()); |
generalParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique()); |
generalParams.set("i18n_type_depot", i18nC.typeDepot()); |
generalParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon()); |
generalParams.set("i18n_general_collection_titre", i18nC.collectionGeneralTitre()); |
generalParams.set("i18n_description", i18nC.description()); |
283,8 → 281,9 |
String nomAlternatif = construireTxtTruck(collection.getNomAlternatif()); |
String urls = construireTxtTruck(collection.getUrls()); |
String typeNcd = construireTxtListeOntologie(collection.getTypeNcd()); |
String typeBota = construireTxtListeOntologie(collection.getBotanique().getType()); |
String typeDepot = construireTxtListeOntologie(collection.getTypeDepot()); |
String groupementBut = construireTxtListeOntologie(collection.getGroupementBut()); |
String groupementPrincipe = construireTxtListeOntologie(collection.getGroupementPrincipe()); |
generalParams.set("nom_alternatif", nomAlternatif); |
generalParams.set("acronyme", acronyme); |
292,16 → 291,14 |
generalParams.set("cote", collection.getCote()); |
generalParams.set("mere", collection.getCollectionMereNom()); |
generalParams.set("type_ncd", typeNcd); |
generalParams.set("type_botanique", typeBota); |
generalParams.set("type_depot", typeDepot); |
generalParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon()); |
generalParams.set("description", collection.getDescription()); |
generalParams.set("description_specialiste", collection.getDescriptionSpecialiste()); |
generalParams.set("historique", collection.getHistorique()); |
generalParams.set("web", urls); |
generalParams.set("groupement_principe", collection.getGroupementPrincipe()); |
generalParams.set("groupement_but", collection.getGroupementBut()); |
generalParams.set("groupement_principe", groupementPrincipe); |
generalParams.set("groupement_but", groupementBut); |
afficherOnglet(generalTpl, generalParams, generalOnglet); |
} |
323,7 → 320,14 |
private void afficherDescription() { |
Params descriptionParams = new Params(); |
descriptionParams.set("i18n_titre_description", i18nC.collectionDescriptionTitre()); |
descriptionParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique()); |
descriptionParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon()); |
String typeBota = construireTxtListeOntologie(collection.getBotanique().getType()); |
descriptionParams.set("type_botanique", typeBota); |
descriptionParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon()); |
afficherOnglet(descriptionTpl, descriptionParams, descriptionOnglet); |
} |
/trunk/src/org/tela_botanica/client/Modele.java |
---|
5,6 → 5,8 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Collection; |
import org.tela_botanica.client.modeles.CollectionAPersonne; |
import org.tela_botanica.client.modeles.CollectionAPersonneAsyncDao; |
import org.tela_botanica.client.modeles.CollectionAsyncDao; |
import org.tela_botanica.client.modeles.Personne; |
import org.tela_botanica.client.modeles.PersonneAsyncDao; |
159,6 → 161,32 |
} |
//+----------------------------------------------------------------------------------------------------------------+ |
// GESTION de la relation COLLECTION A PERSONNE |
public void selectionnerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, String roleId) { |
// Gestion des données de la table coel_collection_a_personne |
if (collectionId != null && roleId != null) { |
CollectionAPersonneAsyncDao sapDao = new CollectionAPersonneAsyncDao(vueARafraichir); |
sapDao.selectionner(collectionId, roleId); |
} |
} |
public void modifierCollectionAPersonne(Rafraichissable vueARafraichir, CollectionAPersonne collectionAPersonne) { |
CollectionAPersonneAsyncDao collectionAPersonneDao = new CollectionAPersonneAsyncDao(vueARafraichir); |
collectionAPersonneDao.modifier(collectionAPersonne); |
} |
public void ajouterCollectionAPersonne(Rafraichissable vueARafraichir, String collectionId, CollectionAPersonne collectionAPersonne) { |
CollectionAPersonneAsyncDao collectionAPersonneDao = new CollectionAPersonneAsyncDao(vueARafraichir); |
collectionAPersonneDao.ajouter(collectionId, collectionAPersonne); |
} |
public void supprimerCollectionAPersonne(Rafraichissable vueARafraichir, String collectionAPersonneId) { |
CollectionAPersonneAsyncDao collectionAPersonneDao = new CollectionAPersonneAsyncDao(vueARafraichir); |
collectionAPersonneDao.supprimer(collectionAPersonneId); |
} |
//+----------------------------------------------------------------------------------------------------------------+ |
// GESTION DES PERSONNES |
//+----------------------------------------------------------------------------------------------------------------+ |
/trunk/src/org/tela_botanica/client/composants/ChampComboBoxListeValeurs.java |
---|
84,7 → 84,11 |
} |
public String getValeur() { |
return getValue().getId(); |
String valeur = ""; |
if (getValue() != null) { |
valeur = getValue().getId(); |
} |
return valeur; |
} |
public void peupler(String valeur) { |
/trunk/src/org/tela_botanica/client/modeles/aDonnee.java |
---|
30,6 → 30,7 |
public static final String SEPARATEUR_TYPE_VALEUR = "##"; |
public static final String SEPARATEUR_VALEURS = ";;"; |
public static final String SEPARATEUR_DONNEES = "||"; |
public static final String ETAT_AJOUTE = "A"; |
protected abstract String getPrefixe(); |
/trunk/src/org/tela_botanica/client/modeles/CollectionAPersonne.java |
---|
New file |
0,0 → 1,96 |
package org.tela_botanica.client.modeles; |
import com.google.gwt.json.client.JSONObject; |
public class CollectionAPersonne extends aDonnee { |
private static final long serialVersionUID = 1L; |
public static final String PREFIXE = "ccap"; |
private Personne personneLiee = null; |
public CollectionAPersonne() { |
initialiser(new JSONObject()); |
} |
public CollectionAPersonne(JSONObject collectionAPersonneListe) { |
initialiser(collectionAPersonneListe); |
} |
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
private void initialiser(JSONObject collectionAPersonneListe) { |
setPersonne(new Personne(collectionAPersonneListe)); |
initialiserChampsPourGrille(); |
initialiserModele(collectionAPersonneListe); |
} |
// PERSONNE |
public Personne getPersonne() { |
return personneLiee; |
} |
public void setPersonne(Personne personne) { |
personneLiee = personne; |
initialiserChampsPourGrille(); |
} |
private void initialiserChampsPourGrille() { |
set("fmt_nom_complet", getPersonne().getNomComplet()); |
set("nom", getPersonne().getNom()); |
set("prenom", getPersonne().getPrenom()); |
set("naissance_date", getPersonne().getNaissanceDate()); |
set("naissance_lieu", getPersonne().getNaissanceLieu()); |
set("ce_deces", getPersonne().getDeces()); |
set("deces_date", getPersonne().getDecesDate()); |
set("deces_lieu", getPersonne().getDecesLieu()); |
} |
// ID |
/** Génère un identifiant de CollectionAPersonne. |
* |
* C'est une concaténation des clés primaires de la table coel_collection_a_personne séparées par un tiret "-". |
* |
* @return identifiant unique d'une relation "collection à personne". |
*/ |
public String getId() { |
String idCollection = getIdCollection(); |
String idPersonne = getIdPersonne(); |
String idRole = getIdRole(); |
if (idCollection.equals("") && idPersonne.equals("") && idRole.equals("")) { |
return null; |
} else { |
return (idCollection+"-"+idPersonne+"-"+idRole); |
} |
} |
//+---------------------------------------------------------------------------------------------------------------+ |
// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_PERSONNE |
// ID COLLECTION |
public String getIdCollection() { |
return renvoyerValeurCorrecte("id_collection"); |
} |
public void setIdCollection(String idCollection) { |
set("id_collection", idCollection); |
} |
// ID PERSONNE |
public String getIdPersonne() { |
return renvoyerValeurCorrecte("id_personne"); |
} |
public void setIdPersonne(String ip) { |
set("id_personne", ip); |
} |
// ID RôLE |
public String getIdRole() { |
return renvoyerValeurCorrecte("id_role"); |
} |
public void setIdRole(String ir) { |
set("id_role", ir); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/CollectionAPersonneListe.java |
---|
New file |
0,0 → 1,39 |
package org.tela_botanica.client.modeles; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
/** |
* Table de hachage composée d'informations sur les Structures et les Personnes, renvoyé par un objet de type DAO |
* La clé est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-". |
* |
* @author david delon |
* |
*/ |
public class CollectionAPersonneListe extends aDonneeListe<CollectionAPersonne> { |
private static final long serialVersionUID = 1L; |
public CollectionAPersonneListe() { |
super(); |
} |
public CollectionAPersonneListe(int taille) { |
super(taille); |
} |
public CollectionAPersonneListe(JSONArray structures) { |
super(structures.size()) ; |
final int taillemax = structures.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject collectionAPersonneCourante = structures.get(i).isObject() ; |
if (collectionAPersonneCourante != null) { |
CollectionAPersonne collectionAPersonne = new CollectionAPersonne(collectionAPersonneCourante); |
this.put(collectionAPersonne.getId(), collectionAPersonne); |
} |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/Configuration.java |
---|
83,8 → 83,8 |
listesId.put("inventaireEtat", Integer.valueOf(configuration.get("listeInventaireEtat"))); |
listesId.put("groupementPrincipe", Integer.valueOf(configuration.get("listeGroupementPrincipe"))); |
listesId.put("realisationBut", Integer.valueOf(configuration.get("listeRealisationBut"))); |
listesId.put("ion", Integer.valueOf(configuration.get("listeION"))); |
listesId.put("prefixe", Integer.valueOf(configuration.get("listePrefixes"))); |
listesId.put("suffixes", Integer.valueOf(configuration.get("listeSuffixes"))); |
listesId.put("sexe", Integer.valueOf(configuration.get("listeSexe"))); |
/trunk/src/org/tela_botanica/client/modeles/CollectionAPersonneAsyncDao.java |
---|
New file |
0,0 → 1,121 |
package org.tela_botanica.client.modeles; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.http.JsonRestRequestBuilder; |
import org.tela_botanica.client.http.JsonRestRequestCallback; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.util.UtilDAO; |
import com.extjs.gxt.ui.client.Registry; |
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.JSONValue; |
public class CollectionAPersonneAsyncDao { |
private static final String SERVICE_NOM = "CoelCollectionAPersonne"; |
private String utilisateurId = null; |
private Rafraichissable vueARafraichir = null; |
public CollectionAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) { |
vueARafraichir = vueARafraichirCourrante; |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
} |
public void selectionner(final String collectionId, final String roleId) { |
String[] parametres = {collectionId, roleId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres); |
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
Information info = new Information("liste_collection_a_personne"); |
if (responseValue != null) { |
// Si la requête est un succès, reception d'un tableau |
if (responseValue.isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
// Transformation du tableau JSON réponse en ListeInstitution |
CollectionAPersonneListe personnes = new CollectionAPersonneListe(reponse); |
info.setDonnee(0, personnes); |
// et on met à jour le demandeur des données |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un talbeau JSON et vaut : "+responseValue.toString(), null); |
} |
} else { |
if (collectionId == null) { |
// Dans le cas, où nous demandons toutes les relations Collection à Personne et qu'il n'y en a pas, nous retournons un message d'information |
info.setMessage("Aucune relations entre la collection et les personnes"); |
vueARafraichir.rafraichir(info); |
} |
} |
} |
}); |
} |
public void ajouter(String collectionId, CollectionAPersonne personnes) { |
String postDonneesEncodees = construirePost(collectionId, personnes); |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
// Si la requête est un succès, reception d'une chaine |
if (responseValue.isString() != null) { |
Information info = new Information("ajout_collection_a_personne"); |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
public void modifier(CollectionAPersonne personnes) { |
String[] parametres = {personnes.getIdCollection(), personnes.getIdPersonne(), personnes.getIdRole()}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
String postDonneesEncodees = construirePost(personnes.getIdCollection(), personnes); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
Information info = new Information("modif_collection_a_personne"); |
// Si la requête est un succès, reception d'une chaine |
if (responseValue.isString() != null) { |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
public void supprimer(String idCollectionAPersonne) { |
String[] parametres = {utilisateurId, idCollectionAPersonne}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
rb.envoyerRequeteSuppression(new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
if (responseValue.isString() != null) { |
Information info = new Information("suppression_collection_a_personne"); |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
private String construirePost(String collectionId, CollectionAPersonne personne) { |
String postDonnees = "cmhl_ce_modifier_par=" + URL.encodeComponent(utilisateurId) + |
"&ccap_id_collection=" + URL.encodeComponent(collectionId) + |
"&ccap_id_personne=" + URL.encodeComponent(personne.getIdPersonne()) + |
"&ccap_id_role=" + URL.encodeComponent(personne.getIdRole()); |
return postDonnees; |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/Personne.java |
---|
19,6 → 19,8 |
public static final String TELEPHONE_FIXE = "FIX"; |
public static final String TELEPHONE_GSM = "GSM"; |
public static final String TELEPHONE_FAX = "FAX"; |
public static final String ETRE_DECEDE = "30745"; |
public static final String ETRE_VIVANT = "30746"; |
public Personne() { |
} |
34,10 → 36,64 |
return PREFIXE; |
} |
public Object obtenirValeurChamp(String nomChamp) { |
return renvoyerValeurCorrecte(nomChamp); |
} |
public Date getDate(String nomChamp) { |
String strDate = renvoyerValeurCorrecte(nomChamp); |
Date dateRetour = null; |
try { |
if ((strDate != null) && (!strDate.equals("0000-00-00"))) { |
dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate); |
} |
} catch (StringIndexOutOfBoundsException e) { |
GWT.log("Impossible de parser la date " + strDate, e); |
} |
return dateRetour; |
} |
public String getString(String nomChamp) { |
return String.valueOf(renvoyerValeurCorrecte(nomChamp)); |
} |
//Traitement des truks |
protected void remplacerTypeDansChaineDenormalise(String champ, String type, Object valeur) { |
if (valeur != null && !valeur.equals("")) { |
ajouterChaineDenormaliseAvecType(champ, type, valeur); |
} else { |
supprimerTypeDansChaineDenormalise(champ, type); |
} |
} |
/** |
* Ajoute un nouvel élément sans type à une chaine dénormalisée. |
* Champ de type "truk" contenant seulement des valeurs séparées par ";;". |
* Si l'élément existe déjà, il ne sera pas ajouté. |
* |
* @param champ le nom du champ dénormalisé |
* @param valeur la valeur à ajouter |
*/ |
protected void ajouterChaineDenormalise(String champ, Object valeur) { |
if (valeur instanceof String) { |
String chaineExistante = renvoyerValeurCorrecte(champ); |
if (chaineExistante.equals("")) { |
this.set(champ, valeur); |
} else { |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons |
if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) { |
this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur); |
} |
} |
} |
} |
// ID PERSONNE |
public String getId() { |
return renvoyerValeurCorrecte("id_personne"); |
} |
public void setId(String personneId) { |
this.set("id_personne", personneId); |
} |
// ID PROJET |
public String getIdProjet() { |
48,6 → 104,26 |
public String getNomComplet() { |
return renvoyerValeurCorrecte("fmt_nom_complet"); |
} |
public void setFmtNomComplet(String prefixe, String suffixe) { |
String fmtNomComplet = ""; |
if ((prefixe != null)&&(!prefixe.trim().equals(""))) { |
fmtNomComplet += prefixe + " "; |
} |
if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals(""))) { |
fmtNomComplet += this.getPrenom() + " "; |
} |
if ((this.getNom()!=null)&&(!this.getNom().trim().equals(""))) { |
fmtNomComplet += this.getNom() + " "; |
} |
if ((suffixe!=null)&&(!suffixe.trim().equals(""))) { |
fmtNomComplet += suffixe; |
} |
this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet)); |
} |
// NOM |
public String getNom() { |
59,22 → 135,6 |
return renvoyerValeurCorrecte("prenom"); |
} |
public Date getDate(String nomChamp) { |
String strDate = renvoyerValeurCorrecte(nomChamp); |
Date dateRetour = null; |
try |
{ |
if ((strDate != null) && (!strDate.equals("0000-00-00"))) { |
dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate); |
} |
} catch (StringIndexOutOfBoundsException e) { |
GWT.log("Impossible de parser la date " + strDate, e); |
} |
return dateRetour; |
} |
// TÉLÉPHONE |
public String getTelephone() { |
return renvoyerValeurCorrecte("truk_telephone"); |
129,15 → 189,15 |
return getChaineDenormaliseUnique("ce_truk_specialite"); |
} |
public Object obtenirValeurChamp(String nomChamp) { |
return renvoyerValeurCorrecte(nomChamp); |
// NAISSANCE DATE |
public String getNaissanceDate() { |
String dateNaiss = ""; |
dateNaiss = get("naissance_date"); |
if (UtilString.isEmpty(dateNaiss)||dateNaiss.equals("0000-00-00")) { |
dateNaiss = Mediateur.i18nC.inconnue(); |
} |
return dateNaiss; |
} |
public String getString(String champ) { |
return String.valueOf(renvoyerValeurCorrecte(champ)); |
} |
public void setNaissanceDate(Date naissanceDate) { |
if (naissanceDate != null) { |
this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate)); |
144,103 → 204,62 |
} |
} |
public void setDeces(Date decesDate, String lieuDeces) { |
set("ce_deces", "1"); |
setDecesDate(decesDate); |
set("deces_lieu", lieuDeces); |
// NAISSANCE LIEU |
public String getNaissanceLieu() { |
return renvoyerValeurCorrecte("naissance_lieu"); |
} |
public void setNonDecedee() { |
set("ce_deces", "0"); |
setDecesDate(null); |
set("deces_lieu", ""); |
public void setNaissanceLieu(String naissanceLieu) { |
this.set("naissance_lieu", naissanceLieu); |
} |
// DÉCÉS |
public boolean estDecedee() { |
String ceDeces = get("ce_deces"); |
if ((ceDeces == null)||(ceDeces.equals("0"))) { |
String ceDeces = getDeces(); |
if (ceDeces.isEmpty() || ceDeces.equals(ETRE_DECEDE)) { |
return false; |
} else { |
} else { |
return true; |
} |
} |
public void setDecesDate(Date decesDate) { |
if (decesDate != null) { |
this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate)); |
} else { |
this.set("deces_date", ""); |
} |
public String getDeces() { |
return renvoyerValeurCorrecte("ce_deces"); |
} |
public void setDeces(String deces) { |
set("ce_deces", deces); |
} |
public void setDeces(Date decesDate, String lieuDeces) { |
set("ce_deces", ETRE_DECEDE); |
setDecesDate(decesDate); |
setDecesLieu(lieuDeces); |
} |
public void setNonDecedee() { |
set("ce_deces", ETRE_VIVANT); |
setDecesDate(null); |
setDecesLieu(""); |
} |
// DÉCÉS DATE |
public String getDecesDate() { |
String dateDeces = ""; |
dateDeces = get("deces_date"); |
if (UtilString.isEmpty(dateDeces)||dateDeces.equals("0000-00-00")) { |
String dateDeces = renvoyerValeurCorrecte("deces_date"); |
if (UtilString.isEmpty(dateDeces) || dateDeces.equals("0000-00-00")) { |
dateDeces = Mediateur.i18nC.inconnue(); |
} |
return dateDeces; |
} |
public String getNaissanceDate() { |
String dateNaiss = ""; |
dateNaiss = get("naissance_date"); |
if (UtilString.isEmpty(dateNaiss)||dateNaiss.equals("0000-00-00")) { |
dateNaiss = Mediateur.i18nC.inconnue(); |
public void setDecesDate(Date decesDate) { |
if (decesDate != null) { |
this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate)); |
} else { |
this.set("deces_date", ""); |
} |
return dateNaiss; |
} |
public void setFmtNomComplet(String prefixe, String suffixe) { |
String fmtNomComplet = ""; |
if ((prefixe != null)&&(!prefixe.trim().equals(""))) { |
fmtNomComplet += prefixe + " "; |
} |
if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals(""))) { |
fmtNomComplet += this.getPrenom() + " "; |
} |
if ((this.getNom()!=null)&&(!this.getNom().trim().equals(""))) { |
fmtNomComplet += this.getNom() + " "; |
} |
if ((suffixe!=null)&&(!suffixe.trim().equals(""))) { |
fmtNomComplet += suffixe; |
} |
this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet)); |
// DÉCÉS LIEU |
public String getDecesLieu() { |
return renvoyerValeurCorrecte("deces_lieu"); |
} |
//Traitement des truks |
protected void remplacerTypeDansChaineDenormalise(String champ, String type, Object valeur) { |
if (valeur != null && !valeur.equals("")) { |
ajouterChaineDenormaliseAvecType(champ, type, valeur); |
} else { |
supprimerTypeDansChaineDenormalise(champ, type); |
} |
public void setDecesLieu(String decesLieu) { |
this.set("deces_lieu", decesLieu); |
} |
/** |
* Ajoute un nouvel élément sans type à une chaine dénormalisée. |
* Champ de type "truk" contenant seulement des valeurs séparées par ";;". |
* Si l'élément existe déjà, il ne sera pas ajouté. |
* |
* @param champ le nom du champ dénormalisé |
* @param valeur la valeur à ajouter |
*/ |
protected void ajouterChaineDenormalise(String champ, Object valeur) { |
if (valeur instanceof String) { |
String chaineExistante = renvoyerValeurCorrecte(champ); |
if (chaineExistante.equals("")) { |
this.set(champ, valeur); |
} else { |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons |
if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) { |
this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur); |
} |
} |
} |
} |
} |
} |