Subversion Repositories eFlore/Applications.coel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1940 → Rev 1943

/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/Formulaire.java
New file
0,0 → 1,373
package org.tela_botanica.client.vues;
 
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.i18n.ErrorMessages;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonneeListe;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
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.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
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.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.client.GWT;
 
public abstract class Formulaire extends LayoutContainer implements Rafraichissable {
 
public static final String MODE_AJOUTER = "AJOUT";
public static final String MODE_MODIFIER = "MODIF";
public Constantes i18nC = null;
public ErrorMessages i18nM = null;
public Mediateur mediateur = null;
public Configuration config = null;
public String mode = null;
public int tabIndex = 100;
public FormPanel panneauFormulaire = null;
public ButtonBar barreOutilsValidation = null;
public String menuIdCourant = null;
public static Boolean clicBoutonvalidation = false;
public Rafraichissable vueExterneARafraichirApresValidation = null;
 
public FormPanel getFormulaire() {
return panneauFormulaire;
}
public void initialiserFormulaire(Mediateur mediateurCourrant, String modeDeCreation, String idMenuCourrant) {
// Initialisation de variables
mode = modeDeCreation;
mediateur = mediateurCourrant;
i18nC = Mediateur.i18nC;
i18nM = Mediateur.i18nM;
menuIdCourant = idMenuCourrant;
config = (Configuration) Registry.get(RegistreId.CONFIG);
// Iniatilisation du layoutContainer
setLayout(new FitLayout());
setBorders(false);
// Création du panneau du FORMULAIRE GÉNÉRAL
panneauFormulaire = new FormPanel();
panneauFormulaire.setBodyBorder(false);
panneauFormulaire.setFrame(true);
panneauFormulaire.setCollapsible(false);
panneauFormulaire.setButtonAlign(HorizontalAlignment.CENTER);
panneauFormulaire.setLayout(new FitLayout());
panneauFormulaire.setPadding(0);
if (modeDeCreation.equals(MODE_AJOUTER)) {
panneauFormulaire.setIcon(Images.ICONES.formAjouter());
} else if (modeDeCreation.equals(MODE_AJOUTER)) {
panneauFormulaire.setIcon(Images.ICONES.formModifier());
}
barreOutilsValidation = new FormulaireBarreValidation(creerEcouteurValidation());
panneauFormulaire.setBottomComponent(barreOutilsValidation);
add(panneauFormulaire);
}
public SelectionListener<ButtonEvent> creerEcouteurValidation() {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (mediateur.getUtilisateur().isIdentifie()) {
clicBoutonvalidation = true;
soumettreFormulaire();
} else {
InfoLogger.display(i18nC.modeAnonyme(), i18nC.identificationNecessaire());
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
if (mediateur.getUtilisateur().isIdentifie()) {
soumettreFormulaire();
} else {
InfoLogger.display(i18nC.modeAnonyme(), i18nC.identificationNecessaire());
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fermerFormulaire();
}
}
};
return ecouteur;
}
public abstract boolean verifierFormulaire();
public abstract boolean soumettreFormulaire();
public TabItem creerOnglet(String nom, String id) {
TabItem onglet = new TabItem();
onglet.setId(id);
onglet.setText(nom);
FormulaireOnglet.parametrer(onglet);
return onglet;
}
 
public void controlerFermeture() {
if (clicBoutonvalidation) {
fermerFormulaire();
}
}
public void fermerFormulaire() {
clicBoutonvalidation = false;
panneauFormulaire.setEnabled(false);
surFermetureFormulaire();
//mediateur.clicMenu(menuIdCourant);
}
public void surFermetureFormulaire() {
// A surcharger si jamais une action spécifique doit être entreprise
}
/** Méthode simplifiant la création de FormLayout.
* Chacun des paramètres peut prendre la valeur null pour utiliser la valeur par défaut.
*
* @param labelWidth largeur des labels.
* @param labelAlign alignement des labels
* @return
*/
public static FormLayout creerFormLayout(Integer labelWidth, LabelAlign labelAlign) {
FormLayout formLayout = new FormLayout();
if (labelWidth != null) {
formLayout.setLabelWidth(labelWidth);
}
if (labelAlign != null) {
formLayout.setLabelAlign(labelAlign);
}
return formLayout;
}
/** Méthode simplifiant la création de bouton radio oui/non
*
* @param listeNom nom de la liste de valeur
* @return
*/
public RadioGroup creerChoixUniqueRadioGroupe(String groupeNom, String listeNom) {
groupeNom += "_grp";
// NOTE : il semblerait qu'il faille aussi utiliser setName() pour éviter tout problème...
RadioGroup radioGroup = new RadioGroup(groupeNom);
radioGroup.setName(groupeNom);
 
if (listeNom.equals("ouiNon")) {
ValeurListe ouiNonListe = new ValeurListe();
ouiNonListe.ajouter(new Valeur("1", i18nC.oui(), "NULL", "NULL"));
ouiNonListe.ajouter(new Valeur("0", i18nC.non(), "NULL", "NULL"));
creerChoixUniqueBoutonRadio(radioGroup, ouiNonListe);
}
return radioGroup;
}
public void creerChoixUniqueBoutonRadio(RadioGroup radioGroupe, ValeurListe listeValeurs) {
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
Valeur val = listeValeurs.get(it.next());
Radio radioBtn = new Radio();
radioBtn.setName(radioGroupe.getName().replace("_grp", ""));
radioBtn.setId(val.getId()+"_"+radioBtn.getName());
radioBtn.setBoxLabel(val.getNom());
radioBtn.setValueAttribute(val.getId());
radioBtn.addListener(Events.Change, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
//Window.alert(((Radio) be.component).getName());
afficherChampSupplementaire(((Radio) be.getComponent()));
}
});
if (! val.getDescription().equals("NULL")) {
radioBtn.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription()));
}
radioGroupe.add(radioBtn);
}
}
public void afficherChampSupplementaire(Radio radioBtn) {
GWT.log("Vous devez redéfinir la méthode afficherChampSupplementaire(Radio radioBtn) dans votre classe formulaire.", null);
};
/** Méthode simplifiant la création de choix multiple sous forme de case à cocher.
* Apelle un service retournant la liste des valeurs représentant les cases à cocher.
* Ajoute ou pas un champ "Autre".
*
* @return ContentPanel le panneau contenant les cases à cocher
*/
public static LayoutContainer creerChoixMultipleCp() {
LayoutContainer conteneur = new LayoutContainer();
conteneur.setLayout(creerFormLayout(650, LabelAlign.TOP));
return conteneur;
}
/** Méthode simplifiant la création de choix multiple sous forme de case à cocher.
* Apelle un service retournant la liste des valeurs représentant les cases à cocher.
* Ajoute ou pas un champ "Autre".
*
* @param cp panneau conteant le groupe de case à cocher
* @param cacGroup le groupe de case à cocher
* @param listeValeurs la liste de valeurs à transformer en case à cocher
* @param boolAutreChp booléen indiquant si oui ou non le champ autre doit apparaître
* @return
*/
public static void creerChoixMultipleCac(LayoutContainer cp, final CheckBoxGroup cacGroupe, ValeurListe listeValeurs, final Field<String> autreChp) {
cp.addListener(Events.Hide, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
cacGroupe.reset();
autreChp.setValue("");
}
});
cacGroupe.setAutoWidth(true);
cacGroupe.setStyleAttribute("padding", "3px");
cacGroupe.setData("liste_id", listeValeurs.getId());
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
Valeur val = listeValeurs.get(it.next());
String nom = val.get("nom");
CheckBox cac = new CheckBox();
cac.setId("val-"+val.getId());
cac.setData("id", val.getId());
cac.setBoxLabel(nom);
if (! val.getDescription().equals("NULL")) {
cac.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription()));
}
cacGroupe.add(cac);
}
cp.add(cacGroupe);
if (autreChp != null) {
// FIXME : éviter le chevauchement du texte des cases à cocher avec le label "Autre" sur les petits écrans
LayoutContainer conteneur = new LayoutContainer();
conteneur.setLayout(creerFormLayout(50, LabelAlign.TOP));
autreChp.setFieldLabel("Autre");
autreChp.setLabelStyle("font-weight:normal;");
conteneur.add(autreChp, new FormData(500, 0));
cp.add(conteneur);
}
cp.layout();
}
@SuppressWarnings({"unchecked"})
public static void rafraichirComboBox(aDonneeListe<?> listeValeurs, ComboBox combo) {
rafraichirComboBox(listeValeurs, combo, "nom");
}
@SuppressWarnings({"unchecked"})
public static void rafraichirComboBox(aDonneeListe<?> listeValeurs, ComboBox combo, String champATrier) {
List<?> liste = listeValeurs.toList();
if (liste.size() > 0) {
ListStore store = combo.getStore();
store.removeAll();
store.add(liste);
store.sort(champATrier, SortDir.ASC);
combo.setStore(store);
}
}
public static Listener<BaseEvent> creerEcouteurChampObligatoire() {
return new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
Field<?> champ = null;
boolean etreVide = true;
if (be.getSource() instanceof TextField<?>) {
champ = (TextField<?>) be.getSource();
etreVide = (champ.getRawValue().isEmpty()) ? true : false;
} else if (be.getSource() instanceof TextArea) {
champ = (TextArea) be.getSource();
etreVide = (champ.getRawValue().isEmpty()) ? true : false;
} else if (be.getSource() instanceof ChampComboBoxListeValeurs) {
champ = (ChampComboBoxListeValeurs) be.getSource();
etreVide = (champ.getValue() == null) ? true : false;
} else if (be.getSource() instanceof ComboBox<?>) {
champ = (ComboBox<?>) be.getSource();
etreVide = (champ.getValue() == null) ? true : false;
}
champ.removeStyleName(ComposantClass.OBLIGATOIRE);
champ.removeStyleName(ComposantClass.OBLIGATOIRE_OK);
if (etreVide == false) {
champ.addStyleName(ComposantClass.OBLIGATOIRE_OK);
} else {
champ.addStyleName(ComposantClass.OBLIGATOIRE);
}
}
};
}
public static ValeurListe trierListeOuiNonEnPartie(ValeurListe listeValeurs) {
ValeurListe listeValeursTriees = new ValeurListe();
Valeur valeurOui = null;
Valeur valeurNon = null;
Valeur valeurEnpartie = null;
String idValeurOui = null;
String idValeurNon = null;
String idValeurEnpartie = null;
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
String strId = it.next();
Valeur valeurDeLaListe = listeValeurs.get(strId);
//Window.alert(strId+" "+valeurDeLaListe.getNom());
if(valeurDeLaListe.getNom().equals("Oui")) {
idValeurOui = strId;
valeurOui = valeurDeLaListe;
}
if(valeurDeLaListe.getNom().equals("Non")) {
idValeurNon = strId;
valeurNon = valeurDeLaListe;
}
if(valeurDeLaListe.getNom().equals("En partie")) {
idValeurEnpartie = strId;
valeurEnpartie = valeurDeLaListe;
}
}
listeValeursTriees.put(idValeurOui, valeurOui);
listeValeursTriees.put(idValeurNon, valeurNon);
listeValeursTriees.put(idValeurEnpartie, valeurEnpartie);
return listeValeursTriees;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/Formulaire.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/Formulaire.java:r11-636,649-686,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/Formulaire.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java
New file
0,0 → 1,728
package org.tela_botanica.client.vues.personne;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.GrillePaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPublication;
import org.tela_botanica.client.composants.pagination.ProxyPublications;
import org.tela_botanica.client.composants.pagination.ProxyPublicationsAPersonne;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.modeles.publication.PublicationListe;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.FenetreForm;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireBarreValidation;
import org.tela_botanica.client.vues.FormulaireOnglet;
import org.tela_botanica.client.vues.publication.PublicationForm;
 
import com.extjs.gxt.ui.client.core.XTemplate;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.KeyListener;
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.Store;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Text;
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.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Validator;
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.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.RowExpander;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
 
public class PersonneFormPublication extends FormulaireOnglet implements Rafraichissable {
private Personne personneSelectionnee = null;
private static int idGenere = 1;
private ContentPanel panneauPrincipal = null;
private ToolBar barreOutils = null;
private GrillePaginable<ModelData> grille;
private PublicationAPersonneListe publicationsAjoutees = null;
private PublicationAPersonneListe publicationsSupprimees = null;
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null;
private Button publicationsBoutonSupprimer = null;
private Button publicationsBoutonModifier = null;
private ComboBox<Valeur> typeRelationCombo = null;
private List<Valeur> roles = null;
private PublicationAPersonneListe listePublicationsLiees = new PublicationAPersonneListe();
boolean personneRecue = false;
boolean rolesRecus = false;
private FenetreForm fenetreFormulaire = null;
public PersonneFormPublication(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setId("publication");
setText(Mediateur.i18nC.personneOngletPublication());
setStyleAttribute("padding", "0");
initialiser();
panneauPrincipal = creerPanneauContenantGrille();
setLayout(new FitLayout());
barreOutils = creerBarreOutilsGrille();
panneauPrincipal.setTopComponent(barreOutils);
panneauPrincipal.setLayout(new FitLayout());
grille = creerGrille();
panneauPrincipal.add(grille);
add(panneauPrincipal);
}
private void initialiser() {
// Remise à zéro des modification dans la liste des auteurs
idGenere = 1;
publicationsAjoutees = new PublicationAPersonneListe();
publicationsSupprimees = new PublicationAPersonneListe();
}
public void mettreAJourPersonne() {
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee;
}
private ContentPanel creerPanneauContenantGrille() {
ContentPanel panneau = new ContentPanel();
panneau.setHeadingHtml(i18nC.personneOngletPublication()+" " + i18nC.personnePublication());
panneau.setIcon(Images.ICONES.table());
panneau.setLayout(new FitLayout());
panneau.setFrame(true);
return panneau;
}
 
private ToolBar creerBarreOutilsGrille() {
ToolBar barreOutils = new ToolBar();
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis();
barreOutils.add(publicationsSaisiesComboBox);
barreOutils.add(new Text(" ou "));
Button ajouterBouton = creerBoutonAjouter();
barreOutils.add(ajouterBouton);
barreOutils.add(new SeparatorToolItem());
publicationsBoutonModifier = creerBoutonModifier();
barreOutils.add(publicationsBoutonModifier);
barreOutils.add(new SeparatorToolItem());
publicationsBoutonSupprimer = creerBoutonSupprimer();
barreOutils.add(publicationsBoutonSupprimer);
barreOutils.add(new SeparatorToolItem());
Button rafraichirBouton = creerBoutonRafraichir();
barreOutils.add(rafraichirBouton);
return barreOutils;
}
 
private Button creerBoutonAjouter() {
Button bouton = new Button(i18nC.ajouter());
bouton.setIcon(Images.ICONES.vcardAjouter());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
fenetreFormulaire.show();
}
});
return bouton;
}
private Button creerBoutonModifier() {
Button bouton = new Button(i18nC.modifier());
bouton.setIcon(Images.ICONES.vcardModifier());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
ModelData publicationSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
if (publicationSaisieSelectionnee == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
} else {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
fenetreFormulaire.show();
}
}
});
return bouton;
}
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
String publicationId = null;
if (mode.equals(Formulaire.MODE_MODIFIER)) {
PublicationAPersonne publicationSaisiSelectionne = new PublicationAPersonne(grille.getGrille().getSelectionModel().getSelectedItem(), false);
publicationId = publicationSaisiSelectionne.getIdPublication();
}
final FenetreForm fenetre = new FenetreForm("");
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId);
fenetre.add(formulaire);
return fenetre;
}
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) {
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this);
FormPanel panneauFormulaire = formulairePublication.getFormulaire();
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
panneauFormulaire.setHeaderVisible(false);
panneauFormulaire.setTopComponent(null);
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
panneauFormulaire.getBottomComponent().hide();
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication);
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
fenetre.setBottomComponent(barreValidation);
return formulairePublication;
}
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (formulaire.soumettreFormulaire()) {
fenetre.hide();
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
formulaire.soumettreFormulaire();
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fenetre.hide();
}
}
};
return ecouteur;
}
private Button creerBoutonSupprimer() {
Button bouton = new Button(i18nC.supprimer());
bouton.setIcon(Images.ICONES.vcardSupprimer());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
List<ModelData> listeDonneesSelectionnees = grille.getGrille().getSelectionModel().getSelectedItems();
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
PublicationAPersonne publicationSaisieSelectionnee = new PublicationAPersonne(donneeSelectionnee, false);
supprimerDansGrille(publicationSaisieSelectionnee, donneeSelectionnee);
}
}
});
return bouton;
}
private Button creerBoutonRafraichir() {
Button bouton = new Button(i18nC.rafraichir());
bouton.setIcon(Images.ICONES.rafraichir());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
actualiserGrille();
}
});
return bouton;
}
private void actualiserGrille() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), "%", null);
} else {
grille.getStore().removeAll();
layout();
}
}
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() {
ModelType modelTypePublications = new ModelType();
modelTypePublications.setRoot("publications");
modelTypePublications.setTotalName("nbElements");
modelTypePublications.addField("ccapu_id_personne");
modelTypePublications.addField("ccapu_id_publication");
modelTypePublications.addField("cpu_id_publication");
modelTypePublications.addField("cpu_fmt_nom_complet");
modelTypePublications.addField("cpu_titre");
modelTypePublications.addField("cpu_nom");
modelTypePublications.addField("cpu_fmt_auteur");
modelTypePublications.addField("cpu_indication_nvt");
modelTypePublications.addField("cpu_truk_pages");
modelTypePublications.addField("cpu_fascicule");
modelTypePublications.addField("cpu_date_parution");
modelTypePublications.addField("cpu_ce_truk_editeur");
modelTypePublications.addField("cpu_collection");
String displayNamePublications = "cpu_fmt_nom_complet";
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null);
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications);
publicationsCombo.getCombo().setTabIndex(tabIndex++);
publicationsCombo.getCombo().setForceSelection(true);
 
publicationsCombo.getCombo().setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
}
return retour;
}
});
publicationsCombo.getCombo().setEmptyText("Rechercher et sélectionner une publication existante dans la base");
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) {
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur(), false);
ajouterDansGrille(publicationSaisieSelectionne);
publicationsSaisiesComboBox.getCombo().setValue(null);
}
}
});
return publicationsCombo;
}
private void ajouterDansGrille(Publication publication) {
ajouterDansGrille(publication, 0);
}
private void ajouterDansGrille(Publication publication, int index) {
if (publication != null) {
if (!listePublicationsLiees.containsKey(publication.getId())) {
PublicationAPersonne publicationLiee = new PublicationAPersonne(false);
publicationLiee.setPersonne(personneSelectionnee);
publicationLiee.setPublicationLiee(publication);
publicationLiee.setIdPublication(publication.getId());
 
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
listePublicationsLiees.put(publication.getId(), publicationLiee);
// Ajout à la grille
grille.getGrille().stopEditing();
grille.getGrille().getStore().insert(publicationLiee, 0);
grille.getGrille().startEditing(index, 0);
grille.getGrille().getSelectionModel().select(index, false);
} else {
InfoLogger.display("Information", "La publication choisie existe déjà dans la liste.");
}
}
}
/**
* Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees
*/
private void mettreAJourGrille() {
 
grille.getStore().removeAll();
grille.getStore().add(listePublicationsLiees.toList());
}
private void supprimerDansGrille(PublicationAPersonne publicationLiee, ModelData publicationLieeModele) {
if (publicationLiee != null) {
// Ajout de la personne supprimée à la liste
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
&& publicationLiee.getId() != null
&& !publicationLiee.getId().equals("")) {
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
}
// Suppression de l'enregistrement de la grille
grille.getStore().remove(publicationLieeModele);
}
}
 
private GrillePaginable<ModelData> creerGrille() {
GrillePaginable<ModelData> grillePublications = null;
// ModelType
ModelType modelTypePublicationAPersonne = new ModelType();
modelTypePublicationAPersonne.setRoot("publicationsAPersonne");
modelTypePublicationAPersonne.setTotalName("nbElements");
modelTypePublicationAPersonne.addField("cpuap_id_personne");
modelTypePublicationAPersonne.addField("cpuap_id_publication");
modelTypePublicationAPersonne.addField("cpuap_id_role");
modelTypePublicationAPersonne.addField("cpu_id_publication");
modelTypePublicationAPersonne.addField("cpu_fmt_auteur");
modelTypePublicationAPersonne.addField("cpu_titre");
modelTypePublicationAPersonne.addField("cpu_collection");
modelTypePublicationAPersonne.addField("cpu_ce_truk_editeur");
modelTypePublicationAPersonne.addField("cpu_date_parution");
modelTypePublicationAPersonne.addField("cpu_fascicule");
modelTypePublicationAPersonne.addField("cpu_truk_pages");
modelTypePublicationAPersonne.addField("cpu_indication_nvt");
// Proxy
ProxyPublicationsAPersonne<ModelData> proxyPublicationsAPersonne = new ProxyPublicationsAPersonne<ModelData>(null, null, null);
 
// Colonnes
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
RowNumberer numeroPlugin = new RowNumberer();
numeroPlugin.setHeaderHtml("#");
XTemplate infoTpl = XTemplate.create("<p>"+
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {cpu_fmt_auteur}<br />"+
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {cpu_titre}<br />"+
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {cpu_collection}<br />"+
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+
"</p>");
RowExpander expansionPlugin = new RowExpander();
expansionPlugin.setTemplate(infoTpl);
colonnes.add(expansionPlugin);
colonnes.add(numeroPlugin);
colonnes.add(creerColonneTypeRelation());
colonnes.add(new ColumnConfig("cpu_fmt_auteur", i18nC.publicationAuteurs(), 150));
colonnes.add(new ColumnConfig("cpu_titre", i18nC.publicationTitre(), 150));
colonnes.add(new ColumnConfig("cpu_collection", i18nC.publicationRevueCollection(), 75));
colonnes.add(creerColonneEditeur());
colonnes.add(creerColonneAnneePublication());
colonnes.add(new ColumnConfig("cpu_indication_nvt", i18nC.publicationNvt(), 75));
colonnes.add(new ColumnConfig("cpu_fascicule", i18nC.publicationFascicule(), 75));
colonnes.add(new ColumnConfig("cpu_truk_pages", i18nC.publicationPage(), 50));
HashMap<String, String> virtualFields = new HashMap<String, String>();
virtualFields.put("_editeur_", "cpu_ce_truk_editeur");
virtualFields.put("_annee_", "cpu_date_parution");
virtualFields.put("_role_", "cpuap_id_role");
virtualFields.put("_etat_", "");
// Modele de selection
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info");
// Grille
grillePublications = new GrillePaginable<ModelData>(modelTypePublicationAPersonne, virtualFields, proxyPublicationsAPersonne, colonnes, modeleDeColonnes);
grillePublications.getGrille().setBorders(true);
grillePublications.getGrille().setSelectionModel(modeleDeSelection);
grillePublications.getGrille().addPlugin(expansionPlugin);
grillePublications.getGrille().addPlugin(numeroPlugin);
grillePublications.getGrille().getView().setForceFit(true);
grillePublications.getGrille().setAutoExpandColumn("titre");
grillePublications.getGrille().setStripeRows(true);
grillePublications.getGrille().setTrackMouseOver(true);
// Rajouter des écouteurs
grillePublications.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
actualiserEtatBoutonsBarreOutils();
}
});
grillePublications.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
actualiserEtatBoutonsBarreOutils();
}
});
grillePublications.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
if (ce.getModel().get("_role_") != null && ce.getRecord().isModified("_role_") && ce.getModel().get("_etat_") != null && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
}
}
});
return grillePublications;
}
private ColumnConfig creerColonneEditeur() {
GridCellRenderer<ModelData> editeurRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
PublicationAPersonne pap = new PublicationAPersonne(model, true);
String editeur = pap.getPublicationLiee().getNomEditeur();
model.set("_editeur_", editeur);
return editeur;
}
};
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135);
editeurColonne.setRenderer(editeurRendu);
return editeurColonne;
}
private ColumnConfig creerColonneAnneePublication() {
GridCellRenderer<ModelData> datePublicationRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
PublicationAPersonne pap = new PublicationAPersonne(model, true);
String annee = pap.getPublicationLiee().getAnneeParution();
model.set("_annee_", annee);
return annee;
}
};
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75);
datePublicationColonne.setRenderer(datePublicationRendu);
return datePublicationColonne;
}
private ColumnConfig creerColonneTypeRelation() {
typeRelationCombo = new ComboBox<Valeur>();
typeRelationCombo.setForceSelection(true);
typeRelationCombo.setTriggerAction(TriggerAction.ALL);
typeRelationCombo.setDisplayField("nom");
typeRelationCombo.setStore(new ListStore<Valeur>());
typeRelationCombo.setEditable(false);
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE);
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire());
CellEditor editeurRelation = new CellEditor(typeRelationCombo) {
public Object preProcessValue(Object valeur) {
Valeur retour = null;
if (valeur != null ) {
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) {
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString());
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) {
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString());
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) {
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString());
}
}
return retour;
}
 
public Object postProcessValue(Object valeur) {
String retour = null;
if (valeur != null ) {
if (valeur instanceof Valeur) {
Valeur valeurOntologie = (Valeur) valeur;
retour = valeurOntologie.getId();
}
}
return retour;
}
};
GridCellRenderer<ModelData> relationRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grille) {
// Gestion du texte afficher dans la cellule
String role = modele.get("_role_");
String roleNom = "";
if (typeRelationCombo.getStore() != null && role!=null && role.matches("[0-9]+")) {
if (typeRelationCombo.getStore().findModel("id_valeur", role) != null) {
roleNom = typeRelationCombo.getStore().findModel("id_valeur", role).getNom();
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId();
} else { Debug.log("role recherche="+role);
Debug.log("typeRelationCombo.getStore().getCount()="+typeRelationCombo.getStore().getCount());
for(int i=0; i<typeRelationCombo.getStore().getCount(); i++) {
Debug.log(""+typeRelationCombo.getStore().getAt(i));
}
}
}
modele.set("_role_", role);
return roleNom;
}
};
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonne(), 75);
typeRelationColonne.setEditor(editeurRelation);
typeRelationColonne.setRenderer(relationRendu);
return typeRelationColonne;
}
 
public void actualiserEtatBoutonsBarreOutils() {
// Activation des boutons si la grille contient un élément
if (grille.getStore().getCount() > 0) {
publicationsBoutonSupprimer.enable();
publicationsBoutonModifier.enable();
}
// Désactivation des boutons si la grille ne contient plus d'élément
if (grille.getStore().getCount() == 0) {
publicationsBoutonSupprimer.disable();
publicationsBoutonModifier.disable();
}
}
public void rafraichir(Object nouvellesDonnees) {
 
if (nouvellesDonnees instanceof Information)
{
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
}
else if (nouvellesDonnees instanceof ValeurListe)
{
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo);
roles = listeValeurs.toList();
rolesRecus = true;
((ProxyPublicationsAPersonne)grille.getProxy()).setRolesId(roles);
if (rolesRecus && personneRecue) grille.reload();
}
}
else if (nouvellesDonnees instanceof PublicationAPersonneListe)
{
PublicationAPersonneListe papl = (PublicationAPersonneListe) nouvellesDonnees;
List<PublicationAPersonne> paplListe = papl.toList();
if (paplListe.size()>0){
Iterator<PublicationAPersonne> it = paplListe.iterator();
while (it.hasNext()) {
PublicationAPersonne pap = it.next();
listePublicationsLiees.put(pap.getPublicationLiee().getId(), pap);
}
mettreAJourGrille();
}
}
else
{
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
public void rafraichirInformation(Information info) {
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
}
String type = info.getType();
if (type.equals("personne")) {
mettreAJourPersonne();
((ProxyPublicationsAPersonne)grille.getProxy()).setPersonneId(personneSelectionnee.getId());
personneRecue = true;
if (rolesRecus && personneRecue) grille.reload();
} else if (type.equals("publication_liees")) {
if (info.getDonnee(0) != null) {
initialiser();
personneSelectionnee.setPublicationsLiees((PublicationAPersonneListe) info.getDonnee(0));
peupler();
}
} else if (type.equals("publication_modifiee")) {
if (info.getDonnee(0) != null) {
Publication publication = (Publication) info.getDonnee(0);
ModelData publicationDansGrille = grille.getStore().findModel("cpu_id_publication", publication.getId());
int index = grille.getStore().indexOf(publicationDansGrille);
grille.getStore().remove(publicationDansGrille);
ajouterDansGrille(publication, index);
}
} else if (type.equals("publication_ajoutee")) {
if (info.getDonnee(0) != null) {
Publication publication = (Publication) info.getDonnee(0);
ajouterDansGrille(publication);
}
} else if (type.equals("ajout_publication_a_personne")) {
InfoLogger.display("Ajout publication à personne", info.getDonnees().toString());
} else if (type.equals("suppression_publication_a_personne")) {
InfoLogger.display("Suppression publication à personne", info.getMessages().toString());
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null);
}
}
 
public void peupler() {
grille.getStore().removeAll();
grille.getStore().add(personneSelectionnee.getPublicationsLiees().toList());
layout();
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok());
}
 
public void collecter() {
if (etreAccede()) {
int nbrePublication = grille.getStore().getCount();
for (int i = 0; i < nbrePublication; i++) {
ModelData publicationLiee = grille.getStore().getAt(i);
PublicationAPersonne pap = new PublicationAPersonne(publicationLiee, false);
if (publicationLiee.get("_etat_") != null) {
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
publicationsSupprimees.put("id"+idGenere++, pap);
PublicationAPersonne relationAAjouter = pap;
publicationsAjoutees.put("id"+idGenere++, relationAAjouter);
}
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
publicationsAjoutees.put("id"+idGenere++, pap);
}
// Initialisation de la grille
publicationLiee.set("_etat_", "");
}
}
grille.getStore().commitChanges();
}
}
public List verifier() {
List lstMessageErreur = new LinkedList<String>();
//Vérifier les roles
List<ModelData> listePublis = grille.getStore().getModels();
Iterator<ModelData> itPublis = listePublis.iterator();
while (itPublis.hasNext()) {
ModelData publi = itPublis.next();
if (UtilString.isEmpty((String) publi.get("_role_"))) {
lstMessageErreur.add("Vous devez choisir le rôle de la relation " + (grille.getStore().indexOf(publi) + 1));
}
}
return lstMessageErreur;
}
public void soumettre() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) {
//InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
} else {
// Ajout des relations PublicationAPersonne
if (publicationsAjoutees.size() != 0) {
//TODO : utiliser le role d'une liste déroulante
mediateur.ajouterPublicationAPersonne(this, publicationsAjoutees, personneSelectionnee.getId(), null, null);
}
// Suppression des relations PublicationAPersonne
if (publicationsSupprimees.size() != 0) {
mediateur.supprimerPublicationAPersonne(this, publicationsSupprimees);
}
}
}
}
private void obtenirPublicationsSaisies(String nom) {
mediateur.selectionnerPublicationParNomComplet(this, "%"+nom+"%");
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java:r11-990,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneVue.java
New file
0,0 → 1,84
package org.tela_botanica.client.vues.personne;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.core.client.GWT;
 
public class PersonneVue extends LayoutContainer implements Rafraichissable {
 
private PersonneListeVue panneauPersonneListe;
private PersonneDetailVue panneauPersonneDetail;
private Mediateur mediateur = null;
 
//Sequenceur pour la gestion du synchrone
private Sequenceur sequenceur = new Sequenceur();
public PersonneVue(Mediateur mediateur) {
this.mediateur = mediateur;
BorderLayout layout = new BorderLayout();
layout.setEnableState(false);
setLayout(layout);
 
panneauPersonneListe = new PersonneListeVue();
//Charger les ontologies nécessaires à l'affichage des personnes
this.add(panneauPersonneListe, new BorderLayoutData(LayoutRegion.CENTER));
 
panneauPersonneDetail = new PersonneDetailVue(mediateur);
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000);
southData.setSplit(true);
southData.setMargins(new Margins(5, 0, 0, 0));
this.add(panneauPersonneDetail, southData);
 
mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur);
mediateur.obtenirListeValeurEtRafraichir(this, "tel", sequenceur);
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur);
}
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Personne) {
sequenceur.enfilerRafraichissement(panneauPersonneDetail, (Personne) nouvellesDonnees);
} else if (nouvellesDonnees instanceof PersonneListe) {
panneauPersonneListe.rafraichir((PersonneListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
// Affichage des éventuels messages de déboguage ou d'alerte
if (!UtilString.isEmpty(info.getMessages())) {
GWT.log(info.getMessages().toString(), null);
}
// Traitement en fonction des types d'information
if (info.getType().equals("liste_personne")) {
panneauPersonneListe.rafraichir((PersonneListe) info.getDonnee(0));
InfoLogger.display("Chargement d'une liste de personnes", "");
} else {
panneauPersonneListe.rafraichir(info);
}
} else if (nouvellesDonnees instanceof ValeurListe) {
panneauPersonneDetail.rafraichir((ValeurListe) nouvellesDonnees);
} else {
GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java
New file
0,0 → 1,267
package org.tela_botanica.client.vues.personne;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampFiltreRecherche;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
import org.tela_botanica.client.modeles.personne.PersonneListe;
import org.tela_botanica.client.vues.BarrePaginationVue;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
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.i18n.client.Constants;
import com.google.gwt.user.client.Window;
 
public class PersonneListeVue extends ContentPanel implements Rafraichissable {
private Mediateur mediateur = null ;
private Grid<Personne> grille = null;
private ListStore<Personne> store = null;
private ChampFiltreRecherche champFiltreRecherche = null;
private BarrePaginationVue pagination = null;
private ColumnModel modeleColonnes = null;
private Button ajouter = null;
private Button modifier = null;
private Button supprimer = null;
private int indexElementSelectionne = 0;
private Personne personneSelectionnee = null;
public PersonneListeVue() {
mediateur = Registry.get(RegistreId.MEDIATEUR);
Constants i18nC = mediateur.i18nC;
setHeaderVisible(false);
setLayout(new FitLayout());
//Définition de la barre d'outil
ToolBar toolBar = new ToolBar();
ajouter = new Button(Mediateur.i18nC.ajouter());
ajouter.setIcon(Images.ICONES.ajouter());
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
mediateur.clicAjouterPersonne();
}
});
ajouter.setToolTip(mediateur.i18nC.indicationCreerUneFiche()+" "+mediateur.i18nC.collectionSingulier());
toolBar.add(ajouter);
 
modifier = new Button(Mediateur.i18nC.modifier());
modifier.setIcon(Images.ICONES.formModifier());
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
mediateur.clicModifierPersonne(grille.getSelectionModel().getSelectedItems());
}
});
modifier.setToolTip(mediateur.i18nC.indicationModifierUneFiche());
toolBar.add(modifier);
supprimer = new Button(Mediateur.i18nC.supprimer());
supprimer.setIcon(Images.ICONES.supprimer());
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
clicSupprimerPersonne(grille.getSelectionModel().getSelectedItems());
}
});
supprimer.setToolTip(mediateur.i18nC.indicationSupprimerUneFiche());
toolBar.add(supprimer);
setTopComponent(toolBar);
 
// Définition des colomnes de la grille:
List<ColumnConfig> lstColumns = new ArrayList<ColumnConfig>();
lstColumns.add(new ColumnConfig("id_personne", "Id", 45));
lstColumns.add(new ColumnConfig("nom", "Nom", 100));
lstColumns.add(new ColumnConfig("prenom", "Prénom", 100));
lstColumns.add(new ColumnConfig("fmt_nom_complet", "Nom Complet", 200));
lstColumns.add(new ColumnConfig("code_postal", "Code postal", 100));
lstColumns.add(new ColumnConfig("ville", "Ville", 100));
lstColumns.add(new ColumnConfig("_courriel_princ_", "Courriel", 200));
 
lstColumns.get(0).setHidden(true);
lstColumns.get(1).setHidden(true);
lstColumns.get(2).setHidden(true);
modeleColonnes = new ColumnModel(lstColumns);
 
// Définition de la grille
GridSelectionModel<Personne> gsmSelectionGrille = new GridSelectionModel<Personne>();
gsmSelectionGrille.addSelectionChangedListener(new SelectionChangedListener<Personne>() {
public void selectionChanged(SelectionChangedEvent<Personne> event) {
personneSelectionnee = (Personne) event.getSelectedItem();
indexElementSelectionne = store.indexOf(personneSelectionnee);
clicListe(personneSelectionnee);
}
});
store = new ListStore<Personne>();
grille = new Grid<Personne>(store, modeleColonnes);
grille.setSelectionModel(gsmSelectionGrille);
grille.setWidth("100%");
grille.setAutoExpandColumn("fmt_nom_complet");
grille.getView().setAutoFill(true);
grille.getView().setForceFit(true);
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
grille.getSelectionModel().select(0, false);
}
});
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be) {
modifier.fireEvent(Events.Select);
}
});
 
grille.addListener(Events.SortChange, new Listener<BaseEvent>() {
 
@Override
public void handleEvent(BaseEvent be) {
GridEvent ge = (GridEvent<Personne>) be;
ge.preventDefault();
// TODO rajouter un test sur le sort state pour trier par nom par défaut
// bref, on verra plus tard parce que c'est chiant et qu'on en a marre de coel
String tri = ge.getSortInfo().getSortField();
if(tri.equals("_courriel_princ_")) {
tri = "truk_courriel";
}
if(tri.equals("fmt_nom_complet")) {
tri = "nom";
}
PersonneAsyncDao.tri = Personne.PREFIXE+"_"+tri+" "+ge.getSortInfo().getSortDir().toString();
pagination.changePage();
}
});
add(grille);
PersonneListe personneListe = new PersonneListe();
champFiltreRecherche = new ChampFiltreRecherche(mediateur, toolBar, personneListe);
// Définition de la barre de pagination
pagination = new BarrePaginationVue(personneListe, mediateur, champFiltreRecherche);
setBottomComponent(pagination);
}
 
private void clicListe(Personne personne) {
if (personne != null && store.getCount() > 0) {
mediateur.clicListePersonne(personne);
}
}
private void clicSupprimerPersonne(List<Personne> personnesASupprimer) {
if (store.getCount() > 0) {
mediateur.clicSupprimerPersonne(this, personnesASupprimer);
}
}
private void gererEtatActivationBouton() {
int nbreElementDuMagazin = store.getCount();
ajouter.enable();
if (nbreElementDuMagazin == 0) {
supprimer.disable();
modifier.disable();
} else if (nbreElementDuMagazin > 0) {
modifier.enable();
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
supprimer.enable();
}
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof PersonneListe) {
PersonneListe listePersonnes = (PersonneListe) nouvellesDonnees;
// la grille de gxt est case sensitive, on harmonise donc tous les noms en majuscule et sans espaces
// au début et à la fin afin de pouvoir trier correctement
// (la colonne nom ne sert qu'au tri et n'est pas affichée)
for (Iterator<Personne> iterator = listePersonnes.toList().iterator(); iterator.hasNext();) {
Personne personne = iterator.next();
personne.setNom(personne.getNom().toUpperCase().trim());
}
champFiltreRecherche.setListePaginable(listePersonnes);
pagination.setlistePaginable(listePersonnes);
pagination.rafraichir(listePersonnes.getPageTable());
if (listePersonnes != null) {
List<Personne> liste = (List<Personne>) listePersonnes.toList();
store.removeAll();
store.add(liste);
mediateur.actualiserPanneauCentral();
grille.fireEvent(Events.ViewReady);
}
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if(info.getType().equals("personne_modifiee")) {
// curieusement la suppression efface aussi l'index de l'élément
// car elle redéclenche l'évenement de selection (on le stocke donc temporairement)
int temporaire = indexElementSelectionne;
if(personneSelectionnee != null) {
store.remove(indexElementSelectionne);
personneSelectionnee = null;
}
Personne personneModifiee = (Personne)info.getDonnee(0);
// au cas ou le bouton appliquer aurait été cliqué avant de valider
store.remove(personneModifiee);
indexElementSelectionne = temporaire;
store.insert(personneModifiee, temporaire);
personneSelectionnee = personneModifiee;
int indexElementSelectionne = store.indexOf(personneSelectionnee);
grille.getSelectionModel().select(indexElementSelectionne, false);
grille.getView().focusRow(indexElementSelectionne);
clicListe(personneSelectionnee);
} else if (info.getType().equals("suppression_personne")) {
InfoLogger.display("Suppression de personne", info.getMessages().toString());
pagination.getlistePaginable().recharger();
gererEtatActivationBouton();
} else if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else {
InfoLogger.display("Erreur", info.getMessages().toString(), true);
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
layout();
}
}
 
 
 
 
 
 
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java
New file
0,0 → 1,407
package org.tela_botanica.client.vues.personne;
 
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.vues.DetailVue;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.user.client.ui.Image;
 
public class PersonneDetailVue extends DetailVue implements Rafraichissable {
 
private TabPanel tabPanel;
private Html entete;
private TabItem tabIdentite;
private TabItem tabAdresse;
private TabItem tabInfosNat;
private TabItem tabLogos;
private TabItem tabPublications;
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
private Personne personneAAfficher = null;
 
private String tableauPublicationsLieesTpl = "";
private String lignePublicationLieeTpl = "";
private Sequenceur sequenceur = new Sequenceur();
public PersonneDetailVue(Mediateur mediateur) {
super(mediateur);
 
setLayout(new FitLayout());
 
entete = new Html();
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
 
ContentPanel panneauPrincipal = new ContentPanel();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.setHeaderVisible(false);
panneauPrincipal.setBodyBorder(true);
panneauPrincipal.setTopComponent(entete);
 
tabIdentite = new TabItem(i18nC.personneIdentite());
tabIdentite.setTitle(i18nC.personneIdentite());
tabIdentite.setLayout(new AnchorLayout());
tabIdentite.setScrollMode(Scroll.AUTO);
 
tabAdresse = new TabItem(i18nC.personneAdresses());
tabAdresse.setTitle(i18nC.personneAdresses());
tabAdresse.setLayout(new FitLayout());
tabAdresse.setScrollMode(Scroll.AUTO);
 
tabInfosNat = new TabItem(i18nC.personneInfoNat());
tabInfosNat.setTitle(i18nC.personneInfoNat());
tabInfosNat.setScrollMode(Scroll.AUTO);
 
tabPublications = new TabItem(i18nC.tabPublications());
tabPublications.setTitle(i18nC.tabPublications());
tabPublications.setScrollMode(Scroll.AUTO);
tabPublications.setLayout(new FlowLayout());
tabLogos = new TabItem(i18nC.personneLogos());
tabLogos.setTitle(i18nC.personneLogos());
tabLogos.setScrollMode(Scroll.AUTO);
tabLogos.setLayout(new FlowLayout());
 
tabPanel = new TabPanel();
tabPanel.setId(ComposantId.ZONE_DETAIL_CORPS);
tabPanel.setBodyBorder(false);
 
tabPanel.add(tabIdentite);
tabPanel.add(tabAdresse);
tabPanel.add(tabInfosNat);
tabPanel.add(tabPublications);
tabPanel.add(tabLogos);
 
panneauPrincipal.add(tabPanel);
add(panneauPrincipal);
}
 
public void afficherDetailPersonne(Personne personne) {
if (personne != null) {
String tplEntete = initialiserTplEntete();
//Sélection des publication à personne
mediateur.selectionnerPublicationAPersonne(this, null, personne.getId(), new LinkedList(), null);
 
Params enteteParams = new Params();
enteteParams.set("nom", (String) personne.get("fmt_nom_complet"));
enteteParams.set("mail", (String) personne.getCourrielPrinc());
 
tabLogos.removeAll();
LinkedList lstLogos = (LinkedList) personne
.getChaineDenormaliseAsMapOrList("truk_logo");
if (lstLogos != null && lstLogos.size() > 0) {
 
String urlLogoPrinc = (String) lstLogos.get(0);
if (!urlLogoPrinc.trim().equals("")) {
tplEntete = "<div id='personne-logo-div'><img src='{image}' alt='logo' /></div>"
+ tplEntete;
enteteParams.set("image", urlLogoPrinc);
}
 
Iterator<String> itLogo = lstLogos.iterator();
while (itLogo.hasNext()) {
String urlLogoCourant = itLogo.next();
Image imgCourante = new Image(urlLogoCourant);
tabLogos.add(imgCourante);
}
tabLogos.enable();
 
} else {
enteteParams.set("image", "");
tabLogos.disable();
}
 
entete.el().setInnerHtml(Format.substitute(tplEntete, enteteParams));
 
String tplIdentite = initialiserTplIdentite();
 
Params tabIdentiteParams = new Params();
tabIdentiteParams.set("nom_complet", personne.getString("fmt_nom_complet"));
tabIdentiteParams.set("abreviation", personne.getString("abreviation"));
tabIdentiteParams.set("naissance_date", personne.getAnneeOuDateNaiss().equals("") ? "" : personne.getAnneeOuDateNaiss());
tabIdentiteParams.set("naissance_lieu", personne.getString("naissance_lieu"));
String tplDeces = "";
if (personne.estDecedee()) {
tplDeces = " <h2>Décès:</h2>"
+ " <span><b>"
+ i18nC.personneDateDeces()
+ ":</b></span> {deces_date}<br />"
+ " <span><b>"
+ i18nC.personneLieuDeces()
+ ":</b></span> {deces_lieu}<br /><br />";
tabIdentiteParams.set("deces_date", personne.getAnneeOuDateDeces().equals("") ? "" : personne.getAnneeOuDateDeces());
tabIdentiteParams.set("deces_lieu", personne.getString("deces_lieu"));
}
Params paramsDeces = new Params();
paramsDeces.set("tplDeces", tplDeces);
tplIdentite = Format.substitute(tplIdentite, paramsDeces);
tabIdentiteParams.set("description", personne.getString("description"));
 
tabInfosNat.removeAll();
 
tabIdentiteParams.set("nom_autre", construireTxtTruck(personne.getString("truk_nom_autre")));
tabIdentiteParams.set("abreviation_autre", construireTxtTruck(personne.getString("truk_abreviation_autre")));
 
tplIdentite += construireTxtListeOntologie(personne.getString("truk_telephone"));
 
// Courriel :Champ truk de la forme
// "Adresse@adr.com;; adr2@adr.fr ..."
LinkedList<String> listeCourriel = (LinkedList<String>) personne
.getChaineDenormaliseAsMapOrList("truk_courriel");
if ((listeCourriel != null) && (listeCourriel.size() > 0)) {
String strLabelCourriel = "Courriel";
if (listeCourriel.size() > 1) {
strLabelCourriel += "s";
}
 
String valeurCourriel = "";
Iterator<String> itCourriel = listeCourriel.iterator();
while (itCourriel.hasNext()) {
String valeurCourante = itCourriel.next();
valeurCourriel += "<br /><a href=\"mailto:"
+ valeurCourante + "\">" + valeurCourante + "</a>";
}
tplIdentite += valeurCourriel;
}
 
// Url Site Webs
LinkedList listeUrl = (LinkedList) personne
.getChaineDenormaliseAsMapOrList("truk_url");
if (listeUrl != null && listeUrl.size() > 0) {
 
tplIdentite += "<br /><br /><b>Sites web:</b><br /><span style='display:inline-block'>";
String strUrl = "";
Iterator<String> urlIt = listeUrl.iterator();
while (urlIt.hasNext()) {
String urlCourante = urlIt.next();
strUrl += "<a href=\"" + urlCourante + "\">" + urlCourante
+ "</a> <br/>";
}
tplIdentite += strUrl + "</span><br />";
}
 
tplIdentite += "</div>";
 
afficherOnglet(tplIdentite, tabIdentiteParams, tabIdentite);
 
String tabAdresseTpl = "<div class='{css_corps}'>"
+ " <div class='{css_fieldset}'>"
+ " <h2>Adresse personnelle:</h2>"
+ " <b>Adresse:</b> {adresse01} <br />"
+ " <b>Boite postale: </b>{boitePostale}<br />"
+ " <b>Code postal:</b>{codePostal} <br />"
+ " <b>Pays :</b><span style='uppercase'>{pays}</span><br />"
+ "</div>";
// Adresses :
Params paramAdresseTpl = new Params();
paramAdresseTpl.set("adresse01", (String) personne
.obtenirValeurChamp("adresse_01"));
paramAdresseTpl.set("boitePostale", (String) personne
.obtenirValeurChamp("bp"));
paramAdresseTpl.set("codePostal", (String) personne
.obtenirValeurChamp("code_postal"));
paramAdresseTpl.set("ville", (String) personne
.obtenirValeurChamp("ville"));
paramAdresseTpl.set("pays", construireTxtListeOntologie((String) personne
.obtenirValeurChamp("ce_truk_pays")));
 
afficherOnglet(tabAdresseTpl, paramAdresseTpl, tabAdresse);
tabAdresse.setStyleAttribute("padding", "15px");
 
// Infos naturalistes :Biographie, Spécialité (typé)
String tplInfosNat = "<div class='{css_corps}'>"
+ " <div class='{css_fieldset}'>" + " <h2>"
+ i18nC.personneBiographie() + "</h2>"
+ " {biographie}" + " "
+ "<h2>" + i18nC.personneSpecialite() + "</h2>"
+ " {specialites}" + " <h2>"
+ i18nC.personneRecolte() + "</h2>"
+ " {recoltes}" + " </div>" + "</div>";
Params prmInfosNat = new Params();
 
prmInfosNat.set("biographie", personne.get("biographie"));
String specialite = construireTxtTruck(personne.getSpecialite());
prmInfosNat.set("specialites", specialite);
 
String recolte = construireTxtListeOntologie(personne.getString("truk_recolte"));
prmInfosNat.set("recoltes", recolte);
 
afficherOnglet(tplInfosNat, prmInfosNat, tabInfosNat);
tabAdresse.setStyleAttribute("padding", "15px");
 
layout();
}
}
 
public String initialiserTplEntete() {
return "<div id='{css_id}'>" + "<h1>{nom}</h1>"
+ "<h2><a href='{mail}'>{mail}</a></h2>" + "</div>";
}
 
public String initialiserTplIdentite() {
return "<div class='{css_corps}'>" + " <div class='{css_fieldset}'>"
+ " <h2>Noms:</h2>" + " <span><b>"
+ i18nC.personneNomComplet()
+ ":</b></span> {nom_complet}<br />"
+ " <span><b>"
+ i18nC.personneNomAutre()
+ ":</b></span> {nom_autre}<br />"
+ " <span><b>"
+ i18nC.personneAbreviation()
+ ":</b></span> {abreviation}<br />"
+ " <span><b>"
+ i18nC.personneAbreviationAutre()
+ ":</b></b></span> {abreviation_autre}<br /><br />"
+ " <h2>Naissance:</h2>"
+ " <span><b>"
+ i18nC.personneDateNaissance()
+ ":</b></span> {naissance_date}<br />"
+ " <span><b>"
+ i18nC.personneLieuNaissance()
+ ":</b></span> {naissance_lieu}<br /><br />"
+ "{tplDeces}"
+ " </div>"
+ "</div>"
+ "<div class='{css_corps}'>"
+ " <div class='css_fieldset'> "
+ " <h2>Description:</h2>"
+ " {description}<br />" + " </div>" + "<br />";
}
private void initialiserTableauPublicationsLieesTpl() {
tableauPublicationsLieesTpl =
"<div class='{css_corps}'>" +
" <h2>{i18n_titre_publication}</h2>"+
" <table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_relation}</th>" +
" <th>{i18n_auteur}</th>" +
" <th>{i18n_titre}</th>" +
" <th>{i18n_revue}</th>" +
" <th>{i18n_editeur}</th>" +
" <th>{i18n_annee}</th>" +
" <th>{i18n_nvt}</th>" +
" <th>{i18n_fascicule}</th>" +
" <th>{i18n_page}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLignePublicationLieeTpl() {
lignePublicationLieeTpl =
"<tr>"+
" <td>{relation}</td>"+
" <td>{auteur}</td>"+
" <td>{titre}</td>"+
" <td>{revue}</td>"+
" <td>{editeur}</td>"+
" <td>{annee}</td>"+
" <td>{nvt}</td>"+
" <td>{fascicule}</td>"+
" <td>{page}</td>"+
"</tr>";
}
/**
* @author greg
* Rempli l'onglet des publications liées
* @param listePublications la liste des publications
*/
private void afficherPublications(PublicationAPersonneListe listePublications) {
List<PublicationAPersonne> publicationsLiees = listePublications.toList();
Iterator<PublicationAPersonne> iterateur = publicationsLiees.iterator();
//Onglet Publications
initialiserTableauPublicationsLieesTpl();
Params paramsPublis = new Params();
String contenuLignes = "";
while (iterateur.hasNext()) {
initialiserLignePublicationLieeTpl();
PublicationAPersonne publicationAPersonneCourante = iterateur.next();
Publication publication = publicationAPersonneCourante.getPublicationLiee();
Params ligneParams = new Params();
ligneParams.set("relation", construireTxtListeOntologie(publicationAPersonneCourante.getRole()));
ligneParams.set("auteur", publication.getAuteur());
ligneParams.set("titre", publication.getTitre());
ligneParams.set("revue", publication.getCollection());
ligneParams.set("editeur", publication.getEditeur());
ligneParams.set("annee", publication.getAnneeParution());
ligneParams.set("nvt", publication.getIndicationNvt());
ligneParams.set("fascicule", publication.getFascicule());
ligneParams.set("page", publication.getPages());
contenuLignes += Format.substitute(lignePublicationLieeTpl, ligneParams);
}
paramsPublis.set("lignes", contenuLignes);
paramsPublis.set("i18n_titre_publication", i18nC.tabPublications());
paramsPublis.set("i18n_relation", i18nC.publicationAuteurs());
paramsPublis.set("i18n_auteur", i18nC.publicationAuteurs());
paramsPublis.set("i18n_titre", i18nC.publicationTitre());
paramsPublis.set("i18n_revue", i18nC.publicationRevueCollection());
paramsPublis.set("i18n_editeur", i18nC.publicationEditeur());
paramsPublis.set("i18n_annee", i18nC.publicationDateParution());
paramsPublis.set("i18n_nvt", i18nC.publicationNvt());
paramsPublis.set("i18n_fascicule", i18nC.publicationFascicule());
paramsPublis.set("i18n_page", i18nC.publicationPage());
afficherOnglet(tableauPublicationsLieesTpl, paramsPublis, tabPublications);
}
public void rafraichir(Object nouvellesDonnees) {
 
if (nouvellesDonnees instanceof ValeurListe) {
ajouterListeValeursAOntologie((ValeurListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof Personne) {
afficherDetailPersonne((Personne) nouvellesDonnees);
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
afficherPublications((PublicationAPersonneListe) nouvellesDonnees);
layout();
}
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/personne/PersonneForm.java
New file
0,0 → 1,1412
package org.tela_botanica.client.vues.personne;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampMultiValeurs;
import org.tela_botanica.client.composants.ChampMultiValeursImage;
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable;
import org.tela_botanica.client.composants.HashMapComposants;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
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.modeles.ValeurListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
import org.tela_botanica.client.modeles.personne.PersonneListe;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.modeles.publication.PublicationListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.UtilDate;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
 
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
 
import com.extjs.gxt.ui.client.binding.FieldBinding;
import com.extjs.gxt.ui.client.binding.FormBinding;
 
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.WidgetListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
 
import com.extjs.gxt.ui.client.widget.ContentPanel;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.Proxy;
import org.tela_botanica.client.composants.pagination.ProxyValeur;
 
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Text;
 
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.DateField;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.GWT;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.Window;
 
public class PersonneForm extends Formulaire implements Rafraichissable {
 
// VARIABLES
private TabItem tiIdentite, tiAdresses, tiInfosNat;
PersonneFormPublication tiPubli;
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
protected Personne personneSelectionnee, personneSauvegarde = null;
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
private HashMapComposants hmIdentite = new HashMapComposants();
private HashMapComposants hmAdresse = new HashMapComposants();
private HashMapComposants hmInfosNat = new HashMapComposants();
private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
private FormData fd100 = new FormData("95%");
private Button enregistrer, enregistrerEtRevenir;
private Personne personne = null;
private String personneId = null;
private FormBinding binding = null;
//Gestion du mode synchrone
private Sequenceur sequenceur;
//Publi
private ComboBox<Publication> cbPubli;
private ListStore<Publication> storePubli;
// Gestion de la vérification des doublons
private boolean verificationDoublonEffectuee = false;
// CONSTRUCTEUR
public PersonneForm(Mediateur mediateurCourrant, String personneId) {
initialiserPersonneForm(mediateurCourrant, personneId);
}
public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
initialiserPersonneForm(mediateurCourrant, personneId);
}
private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
//Initialisation du séquenceur
sequenceur = new Sequenceur();
personne = new Personne();
personne.setId(personneIdCourrant);
personneId = personneIdCourrant;
String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
 
initialiserComposants();
genererTitreFormulaire();
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur);
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", null);
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerPersonne(this, personne.getId(), sequenceur);
}
}
private void genererTitreFormulaire() {
String titre = i18nC.personneModeAjout();
if (mode.equals(Formulaire.MODE_MODIFIER)) {
titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
}
panneauFormulaire.setHeadingHtml(titre);
}
public void initialiserComposants() {
personneSelectionnee = new Personne();
personneSauvegarde = new Personne();
initialiserOnglets();
creerComposantsIdentite();
creerComposantsAdresse();
creerComposantsInfosNat();
//creerComposantsPubli();
binderPersonne(personneSelectionnee);
}
/**
* Crée les onglets identité, adresse et informations naturaliste
*
* */
public void initialiserOnglets() {
//TabPanel
TabPanel formulaireOnglets = new TabPanel();
//Tab 1 : identite
tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite");
tiIdentite.setStyleAttribute("padding", "0");
formulaireOnglets.add(tiIdentite);
//Tab 2 : Adresse
tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses");
formulaireOnglets.add(tiAdresses);
//Tab 3 : Infos Naturalistes
tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat");
formulaireOnglets.add(tiInfosNat);
//Tab 4 : Publications
tiPubli = new PersonneFormPublication(this);
formulaireOnglets.add(tiPubli);
getFormulaire().add(formulaireOnglets);
}
/**
* Crée les widgets pour l'onglet identité
*
* */
public void creerComposantsIdentite() {
// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout());
left.setStyleAttribute("padding", "15px");
LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout());
right.setStyleAttribute("padding", "15px");
LayoutContainer main = new LayoutContainer();
main.add(left, new ColumnData(.45));
main.add(right, new ColumnData(.50));
main.setLayout(new ColumnLayout());
main.setHeight("100%");
main.setScrollMode(Scroll.AUTO);
// Création des champs
FormLayout formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset NOM
FieldSet fsNoms = new FieldSet();
fsNoms.setHeadingHtml("Noms");
fsNoms.setLayout(formLayout);
// Nom complet : Affiché que si valeurs saisies
LabelField nomComplet = new LabelField();
nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
nomComplet.hide();
fsNoms.add(nomComplet);
hmIdentite.put("nomComplet", nomComplet);
//Préfixe
ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
cbPrefixe.setStore(storePrefixe);
cbPrefixe.setDisplayField("nom");
cbPrefixe.setEmptyText("Choisissez le préfixe:");
cbPrefixe.setFieldLabel("Prefix");
fsNoms.add(cbPrefixe);
hmIdentite.put("cbPrefixe", cbPrefixe);
mediateur.obtenirListeValeurEtRafraichir(this, "prefixe", sequenceur);
 
//Prénom
TextField<String> tfPrenom = new TextField<String>();
tfPrenom.setFieldLabel("Prénom");
tfPrenom.setName("prenom");
 
fsNoms.add(tfPrenom, new FormData(300, 0));
hmIdentite.put("tfPrenom", tfPrenom);
tfPrenom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
tfPrenom.addListener(Events.Change, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
verificationDoublonEffectuee = false;
}
});
 
//Nom
TextField<String> tfNom = new TextField<String>();
tfNom.setFieldLabel("Nom");
tfNom.setAllowBlank(false);
tfNom.setName("nom");
tfNom.addStyleName(ComposantClass.OBLIGATOIRE);
tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire());
tfNom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
tfNom.addListener(Events.Change, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
verificationDoublonEffectuee = false;
}
});
fsNoms.add(tfNom, new FormData(300, 0));
hmIdentite.put("tfNom", tfNom);
//Suffixe
ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
cbSuffixe.setStore(storeSuffixe);
cbSuffixe.setFieldLabel("Suffixe");
cbSuffixe.setDisplayField("nom");
cbSuffixe.setEmptyText("Choisissez un suffixe:");
fsNoms.add(cbSuffixe);
hmIdentite.put("cbSuffixe", cbSuffixe);
mediateur.obtenirListeValeurEtRafraichir(this, "suffixes", sequenceur);
 
TextField<String> tfAbreviation = new TextField<String>();
tfAbreviation.setFieldLabel("Abréviation");
tfAbreviation.setName("abreviation");
fsNoms.add(tfAbreviation);
hmIdentite.put("tfAbreviation", tfAbreviation);
 
TableLayout layoutAutreNoms = new TableLayout(2);
layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
hmIdentite.put("nomAutre", nomAutre);
autresNoms.add(nomAutre, new TableData("200px", "15px"));
ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
hmIdentite.put("abreviationAutre", abreviationAutre);
autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
fsNoms.add(autresNoms);
left.add(fsNoms);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset NAISSANCE ET DÉCÈS
FieldSet fsNaissanceEtDeces = new FieldSet();
fsNaissanceEtDeces.setHeadingHtml("Naissance et Décès");
fsNaissanceEtDeces.setLayout(new ColumnLayout());
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.TOP);
LayoutContainer containerNaissance = new LayoutContainer(formLayout);
//Remplacement du DateField par un champ texte
TextField tfDateNaissance = new TextField();
tfDateNaissance.setFieldLabel("Date de naissance");
containerNaissance.add(tfDateNaissance);
hmIdentite.put("tfDateNaissance", tfDateNaissance);
// Lieu naissance
TextField<String> tfLieuNaissance = new TextField<String>();
tfLieuNaissance.setFieldLabel("Lieu de naissance");
tfLieuNaissance.setName("naissance_lieu");
containerNaissance.add(tfLieuNaissance);
hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5));
left.add(fsNaissanceEtDeces);
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.TOP);
LayoutContainer containerDeces = new LayoutContainer(formLayout);
Radio rbEstDecedee = new Radio();
rbEstDecedee.setId("ce_deces");
rbEstDecedee.setBoxLabel("oui");
rbEstDecedee.setValueAttribute("1");
rbEstDecedee.setId("rbEstD");
rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
if(((Radio) be.getComponent()).getValue().equals(true)) {
hmIdentite.getTextField("tfDateDeces").setVisible(true);
hmIdentite.getTextField("tfLieuDeces").setVisible(true);
} else {
TextField tfDateDeces = hmIdentite.getTextField("tfDateDeces");
tfDateDeces.setValue(null);
tfDateDeces.setVisible(false);
TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces");
tfLieuDeces.setValue(null);
tfLieuDeces.setVisible(false);
}
}
});
TextField tfDateDeces = new TextField();
tfDateDeces.setFieldLabel("Date de décès");
tfDateDeces.setVisible(false);
 
containerDeces.add(tfDateDeces);
hmIdentite.put("tfDateDeces", tfDateDeces);
 
TextField<String> tfLieuDeces = new TextField<String>();
tfLieuDeces.setFieldLabel("Lieu de décès");
tfLieuDeces.setName("deces_lieu");
tfLieuDeces.setVisible(false);
containerDeces.add(tfLieuDeces);
hmIdentite.put("tfLieuDeces", tfLieuDeces);
hmIdentite.put("rbEstDecedee", rbEstDecedee);
Radio rbNestPasDecedee = new Radio();
rbNestPasDecedee.setValueAttribute("0");
rbNestPasDecedee.setBoxLabel("non");
rbNestPasDecedee.setValue(true);
RadioGroup rbgDeces = new RadioGroup();
rbgDeces.setId("rbgDeces");
rbgDeces.setFieldLabel("Est décédée");
rbgDeces.add(rbEstDecedee);
rbgDeces.add(rbNestPasDecedee);
hmIdentite.put("rbgDeces", rbgDeces);
containerDeces.add(rbgDeces);
fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5));
tiIdentite.add(main);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset CONTACT
FieldSet fsContact = new FieldSet();
fsContact.setHeadingHtml("Contact");
fsContact.setWidth("95%");
fsContact.setLayout(new RowLayout());
ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100);
telephones.initialiserType("tel");
fsContact.add(telephones, new FormData(450, 0));
hmIdentite.put("telephones", telephones);
ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280);
courriels.setValidation(Pattern.email, "moi@domaine.fr");
fsContact.add(courriels, new FormData(450, 0));
hmIdentite.put("courriels", courriels);
LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
fsContact.add(lcCourrielContainer);
hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
 
fsContact.add(new Text(""));
ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
sites.setWidth("95%");
sites.setValeurParDefaut("http://");
sites.setValidation(Pattern.url, "http://www.monsite.com");
fsContact.add(sites);
hmIdentite.put("sites", sites);
right.add(fsContact);
//+------------------------------------------------------------------------------------------------------------+
// Fieldset AUTRES INFOS
FieldSet fsAutresInfos = new FieldSet();
fsAutresInfos.setHeadingHtml("Autres informations");
fsAutresInfos.setWidth("95%");
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.LEFT);
fsAutresInfos.setLayout(formLayout);
formLayout = new FormLayout();
formLayout.setLabelAlign(LabelAlign.TOP);
LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
ListStore<Valeur> storeSexe = new ListStore<Valeur>();
ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
cbSexe.setStore(storeSexe);
cbSexe.setFieldLabel("Sexe");
cbSexe.setDisplayField("nom");
cbSexe.setEmptyText("Choisissez le sexe:");
cbSexe.setTypeAhead(true);
cbSexe.setTriggerAction(TriggerAction.ALL);
FormData fd = new FormData();
fd.setWidth(100);
lcAutreInformations1.add(cbSexe, fd);
hmIdentite.put("cbSexe", cbSexe);
mediateur.obtenirListeValeurEtRafraichir(this, "sexe", sequenceur);
//Description
final TextArea taDescription = new TextArea();
taDescription.setEmptyText("Saisissez une description");
taDescription.setFieldLabel("Description");
taDescription.setName("description");
lcAutreInformations1.add(taDescription, new FormData(300, 200));
hmIdentite.put("taDescription", taDescription);
fsAutresInfos.add(lcAutreInformations1);
// Logo
LayoutContainer lcLogoUrl = new LayoutContainer();
hmIdentite.put("lcLogoUrl", lcLogoUrl);
final ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
logo.setImageHeight("150px");
logo.setValeurParDefaut("http://");
logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
logo.setValeurBoutonSupprimer("Supprimer");
logo.setWidth("95%");
hmIdentite.put("logos", logo);
lcLogoUrl.add(logo);
fsAutresInfos.add(logo);
LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
fsAutresInfos.add(lcAutreInformations2);
right.add(fsAutresInfos);
//+------------------------------------------------------------------------------------------------------------+
// Ajout des évènements saisi
KeyListener klNoms = new KeyListener() {
public void componentKeyUp(ComponentEvent ev) {
rafraichir(null);
}
};
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
public void selectionChanged(SelectionChangedEvent se) {
rafraichir(null);
}
};
cbPrefixe.addSelectionChangedListener(selectionChange);
cbPrefixe.addKeyListener(klNoms);
tfPrenom.addKeyListener(klNoms);
tfNom.addKeyListener(klNoms);
cbSuffixe.addSelectionChangedListener(selectionChange);
}
public void creerComposantsAdresse() {
// Gauche
LayoutContainer left = new LayoutContainer();
left.setLayout(new FormLayout());
left.setStyleAttribute("padding", "15px");
// Droite
LayoutContainer right = new LayoutContainer();
right.setLayout(new FormLayout());
// Principal
LayoutContainer main = new LayoutContainer();
main.setLayout(new TableLayout(2));
// Ajout au principal
main.add(left);
main.add(right);
TextField<String> tfAdresse1 = new TextField();
tfAdresse1.setFieldLabel("Adresse");
tfAdresse1.setName("adresse_01");
left.add(tfAdresse1, fd100);
hmAdresse.put("tfAdresse1", tfAdresse1);
ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
cbPays.setFieldLabel("Pays");
cbPays.setDisplayField("nom");
cbPays.setEmptyText("Sélectionnez le pays:");
ListStore<Valeur> storePays = new ListStore<Valeur>();
cbPays.setStore(storePays);
right.add(cbPays, fd100);
hmAdresse.put("cbPays", cbPays);
TextField<String> tfBoitePostale = new TextField<String>();
tfBoitePostale.setFieldLabel("Boite postale");
tfBoitePostale.setName("bp");
left.add(tfBoitePostale, fd100);
hmAdresse.put("tfBoitePostale", tfBoitePostale);
TextField<Integer> tfCodePostal = new TextField<Integer>();
tfCodePostal.setFieldLabel("Code postal");
tfCodePostal.setName("code_postal");
right.add(tfCodePostal, fd100);
hmAdresse.put("tfCodePostal", tfCodePostal);
TextField tfVille = new TextField();
tfVille.setFieldLabel("Ville");
tfVille.setName("ville");
right.add(tfVille, fd100);
hmAdresse.put("tfVille", tfVille);
// MAJ ComboBox
mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur);
FieldSet fsAdresse = new FieldSet();
fsAdresse.setHeadingHtml("Adresse personnelle");
fsAdresse.add(main);
tiAdresses.add(fsAdresse);
}
public void creerComposantsInfosNat() {
FormLayout fl = new FormLayout();
fl.setLabelAlign(LabelAlign.TOP);
FieldSet fsInfosNat = new FieldSet();
fsInfosNat.setLayout(fl);
fsInfosNat.setTitle("Informations Naturaliste");
 
TextArea taBiographie = new TextArea();
taBiographie.setFieldLabel("Vie et renommée de l'auteur");
taBiographie.setWidth("400");
taBiographie.setName("biographie");
fsInfosNat.add(taBiographie, new FormData(800, 200));
 
ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
fsInfosNat.add(specialite);
hmInfosNat.put("specialite", specialite);
 
ModelType typeTypes = new ModelType();
typeTypes.setRoot("valeurs");
typeTypes.setTotalName("nbElements");
typeTypes.addField("cmlv_nom");
typeTypes.addField("cmlv_id_valeur");
typeTypes.addField("cmlv_abreviation");
typeTypes.addField("cmlv_description");
String displayNameTypes = "cmlv_nom";
String nomListeTypes = "pays";
ProxyValeur<ModelData> proxyTypes = new ProxyValeur<ModelData>(nomListeTypes, null);
ChampMultiValeursMultiTypesPaginable recolte = new ChampMultiValeursMultiTypesPaginable(i18nC.personneRecolte(), 450, false, null, null, null, typeTypes, proxyTypes, displayNameTypes);
hmInfosNat.put("recolte", recolte);
fsInfosNat.add(recolte);
tiInfosNat.add(fsInfosNat);
}
public void creerComposantsPubli(){
//Création des composants de l'onglet publication
 
ContentPanel cp = new ContentPanel();
cp.setHeadingHtml("Publications dont la personne est le sujet");
cp.setIcon(Images.ICONES.table());
cp.setLayout(new FitLayout());
cp.setFrame(true);
ToolBar toolBar = new ToolBar();
 
Button ajouterPubli = new Button("Ajouter");
ajouterPubli.setIcon(Images.ICONES.vcardAjouter());
ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
ajouterMembreAGrillePersonnel(membreDuPersonnel);*/
}
});
toolBar.add(ajouterPubli);
toolBar.add(new SeparatorToolItem());
Button supprimerPubli = new Button("Supprimer");
supprimerPubli.setIcon(Images.ICONES.vcardSupprimer());
supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
if (personne != null) {
// Ajout de la personne supprimée à la liste
if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
personnelSupprime.put(personne.getId(), personne);
}
// Suppression de l'enregistrement de la grille
grillePersonnel.getStore().remove(personne);
// Désactivation du bouton supprimer si la grille contient plus d'élément
if (grillePersonnel.getStore().getCount() == 0) {
//TODO : check : Item -> component
ce.getComponent().disable();
}
}*/
Window.alert("supprimer");
}
});
toolBar.add(supprimerPubli);
toolBar.add(new SeparatorToolItem());
Button rafraichirPersonnelBtn = new Button("Rafraichir");
rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
//rafraichirPersonnel();
Window.alert("rafraichir");
}
});
toolBar.add(rafraichirPersonnelBtn);
//Ajout d'une ComboBox
storePubli = new ListStore<Publication>();
storePubli.add(new ArrayList<Publication>());
cbPubli = new ComboBox<Publication>();
cbPubli.setWidth(200);
cbPubli.setEmptyText("Chercher une publication existante...");
cbPubli.setTriggerAction(TriggerAction.ALL);
cbPubli.setEditable(true);
cbPubli.setDisplayField("fmt_nom_complet");
cbPubli.setStore(storePubli);
cbPubli.addKeyListener(new KeyListener() {
public void componentKeyUp(ComponentEvent ce) {
if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) {
rafraichirPublicationsExistante(cbPubli.getRawValue());
}
}
});
toolBar.add(cbPubli);
toolBar.add(new SeparatorToolItem());
cp.setTopComponent(toolBar);
tiPubli.add(cp);
}
 
public void rafraichirPublicationsExistante(String nomPubli) {
nomPubli +="%";
mediateur.selectionnerPublicationParNomComplet(this, nomPubli);
}
/**
* Ajouter le bouton annuler à la barre d'outils donnée
*
* @param barreOutils la barre d'outils à modifier
* */
public static void ajouterBoutonAnnuler(ButtonBar barreOutils) {
// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
Button annuler = new Button("Revenir à la liste");
annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
}
});
annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
barreOutils.add(annuler);
}
// RAFRAICHISSEMENT DU PANNEAU
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof PublicationAPersonneListe) {
Information info = new Information();
info.setType("publication_liees");
info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees);
tiPubli.rafraichir(info);
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
// Créer une liste de valeurs
List<Valeur> liste = new ArrayList<Valeur>();
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
liste.add(listeValeurs.get(it.next()));
}
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
tiPubli.rafraichir(nouvellesDonnees);
} else if (listeValeurs.getId().equals(config.getListeId("prefixe"))) {
remplirCombobox("cbPrefixe", liste, "hmIdentite");
} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
remplirCombobox("cbSuffixe", liste, "hmIdentite");
} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
//Ajout de la valeur "Inconnu"
ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe");
Valeur inconnu = new Valeur();
inconnu.set("nom", "Inconnu");
inconnu.set("id", "0");
liste.add(0, inconnu);
remplirCombobox("cbSexe", liste, "hmIdentite");
/*List<Valeur> selection = new LinkedList<Valeur>();
selection.add(inconnu);
cbSexe.setSelection(s);*/
} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
remplirCombobox("cbTelephone", liste, "hmIdentite");
 
//Préselection du tél
ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone");
cbTelephone.setValue(liste.get(1));
} else if (listeValeurs.getId().equals(config.getListeId("pays"))) {
remplirCombobox("cbPays", liste, "hmAdresse");
}
} else if (nouvellesDonnees instanceof PublicationListe) {
PublicationListe publicationListe = (PublicationListe) nouvellesDonnees;
List<Publication> liste = publicationListe.toList();
storePubli.removeAll();
storePubli.add(liste);
cbPubli.setStore(storePubli);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("ajout_personne")) {
if (info.getDonnee(0) != null) {
personneSelectionnee.setId(info.getDonnee(0).toString());
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
this.personne = personneSelectionnee;
this.personneId = personneSelectionnee.getId();
InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
repandreRafraichissement();
if (clicBoutonvalidation) {
mediateur.clicMenu(menuIdCourant);
} else {
this.mode = MODE_MODIFIER;
}
} else {
InfoLogger.display("Enregistrement", info.getMessages().toString());
}
} else if (info.getType().equals("modification_personne")) {
InfoLogger.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
repandreRafraichissement();
controlerFermeture();
} else if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if (info.getDonnee(0) instanceof PersonneListe) {
Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
Iterator itPersonneListe = colPersonneListe.iterator();
Personne personne = (Personne) itPersonneListe.next();
//TODO : Je vois pas l'intérêt des lignes ci dessous..
personneSauvegarde = new Personne();
personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
binderPersonne(personne);
mettreAJourPersonne(personne);
this.personne = personne;
this.personneId = personne.getId();
tiPubli.rafraichirInformation(new Information("personne"));
nouvellesDonnees = null;
} else {
InfoLogger.display("messages", info.getMessages().toString());
}
}
if (nouvellesDonnees == null) {
ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe");
//Met à jour le nom Complet du formulaire
String valeurRetour = "";
// Prefixe
String prefixe = "";
Valeur valPrefixe = cb.getValue();
if (valPrefixe != null) {
prefixe = valPrefixe.getNom();
} else {
prefixe = (String) cb.getRawValue();
}
// Prénom
String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
// Nom
String nom = (String) hmIdentite.getTextField("tfNom").getValue();
// Suffixe
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
String suffixe = "";
Valeur valSuffixe = cbSuffixe.getValue();
if (valSuffixe != null) {
suffixe = valSuffixe.getNom();
} else {
suffixe = (String) cbSuffixe.getRawValue();
}
// Mettre à jour la valeur
valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
valeurRetour = valeurRetour.replaceAll("null", "");
hmIdentite.getLabelField("nomComplet").setValue(valeurRetour);
if (!valeurRetour.trim().equals("")) {
hmIdentite.getLabelField("nomComplet").show();
} else {
hmIdentite.getLabelField("nomComplet").hide();
}
}
mediateur.masquerPopinChargement();
if (this.mode.equals(MODE_AJOUTER)) {
gererEtatActivationBouton();
}
}
 
private void repandreRafraichissement() {
if (vueExterneARafraichirApresValidation != null) {
String type = "personne_modifiee";
if (mode.equals(Formulaire.MODE_AJOUTER)) {
type = "personne_ajoutee";
}
Information info = new Information(type);
info.setDonnee(0, personneSelectionnee);
vueExterneARafraichirApresValidation.rafraichir(info);
}
}
private void mettreAJourPersonne(Personne personne) {
//Mise à jour de la personne
//Prefixe
String prefixe = personne.get("ce_truk_prefix");
ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe");
String prefixeCourant = personne.get("ce_truk_prefix");
if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null) {
cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
} else {
cbPrefixe.setRawValue(prefixeCourant);
}
hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom"));
hmIdentite.getTextField("tfNom").setValue(personne.get("nom"));
//Suffixe
String suffixe = personne.get("ce_truk_suffixe");
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
String suffixeCourant = personne.get("ce_truk_suffix");
if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null) {
cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
} else {
cbSuffixe.setRawValue(suffixeCourant);
}
hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre"));
hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation"));
hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre"));
hmIdentite.getTextField("tfDateNaissance").setValue(personne.getAnneeOuDateNaiss());
hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu"));
if (personne.estDecedee()) {
hmIdentite.getTextField("tfDateDeces").setValue(personne.getAnneeOuDateDeces());
hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu"));
Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee");
rbEstDecede.setValue(true);
}
hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone"));
//Courriel
hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel());
//Sites web
hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url"));
// Sexe
String strSexe = personne.get("ce_sexe");
ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe");
 
if (cbSexe.getStore().findModel("id_valeur", strSexe) != null) {
cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
}
hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description"));
//Logo
hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo"));
/*--------------------------------------------------
Adresse
---------------------------------------------------*/
// Adresse
hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
//Boite postale
hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
//Pays
String strPays = personne.get("ce_truk_pays");
ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
cbPays.getStore().sort("nom", SortDir.ASC);
if (cbPays.getStore().findModel("id_valeur", strPays) != null) {
cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays));
cbPays.fireEvent(Events.OnChange);
} else {
cbPays.setRawValue(strPays);
}
//Cp
hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
//Ville
hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
/*--------------------------------------------------------
* Infos naturalistes
* -----------------------------------------------------*/
hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
String tr = personne.getString("truk_recolte");
hmInfosNat.getChampMultiValeursMultiTypesPaginable("recolte").peupler(tr);
//Onglet publi
tiPubli.mettreAJourPersonne();
gererEtatActivationBouton();
}
public void remplirCombobox(String idComboBox, List liste, String hashMapId) {
HashMap hm = null;
if (hashMapId.equals("hmIdentite")) {
hm = hmIdentite;
} else if (hashMapId.equals("hmAdresse")){
hm = hmAdresse;
} else {
hm = hmInfosNat;
}
ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
store.removeAll();
store.add(liste);
((ComboBox) hm.get(idComboBox)).setStore(store);
}
private void gererEtatActivationBouton() {
/* if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false) {
enregistrer.setEnabled(false);
enregistrerEtRevenir.setEnabled(false);
} else {
enregistrer.setEnabled(true);
enregistrerEtRevenir.setEnabled(true);
}*/
}
public void binderPersonne(Personne personne) {
binding = new FormBinding(getFormulaire());
personneSelectionnee = personne;
FieldBinding f = new FieldBinding((RadioGroup) hmIdentite.get("rbgDeces"), null);
binding.autoBind();
binding.removeFieldBinding(f);
binding.bind(personneSelectionnee);
layout();
}
 
private String obtenirValeurCombo(String strComboName) {
String strValeur = "";
Valeur valeur;
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
if (combo == null) {
combo = hmAdresse.getComboBoxValeur(strComboName);
}
strValeur = combo.getRawValue();
valeur = combo.getValue();
if (valeur != null) {
strValeur = valeur.getId();
}
return strValeur;
}
 
public boolean soumettreFormulaire() {
tiPubli.collecter();
if (verifierFormulaire()) {
tiPubli.soumettre();
mediateur.enregistrerPersonne(this, personneSelectionnee);
return true;
}
else return false;
}
 
public boolean verifierFormulaire() {
boolean success = true;
LinkedList<String> lstMessageErreur = new LinkedList<String>();
String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
if ((strTfNom == null)||(strTfNom.trim().equals(""))) {
lstMessageErreur.add("Le nom n'a pas été saisi");
} else {
strTfNom = UtilString.ucFirst(strTfNom);
personneSelectionnee.set("nom", strTfNom);
}
String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
//Préparer les données
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
Valeur valeur;
String strValeur = "";
valeur = combo.getValue();
if (valeur!=null) {
personneSelectionnee.set("ce_sexe", valeur.getId());
}
strValeur = obtenirValeurCombo("cbPrefixe");
personneSelectionnee.set("ce_truk_prefix", strValeur);
strValeur = obtenirValeurCombo("cbSuffixe");
personneSelectionnee.set("ce_truk_suffix", strValeur);
String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
personneSelectionnee.set("truk_nom_autre", nomAutre);
String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
String strPrefixe = "";
combo = hmIdentite.getComboBoxValeur("cbPrefixe");
valeur = combo.getValue();
if (valeur != null) {
strPrefixe = valeur.getNom();
} else {
strPrefixe = combo.getRawValue();
}
String strSuffixe = "";
combo = hmIdentite.getComboBox("cbSuffixe");
valeur = combo.getValue();
if (valeur != null) {
strSuffixe = valeur.getNom() + " ";
} else {
strSuffixe = combo.getRawValue() +" ";
}
personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
 
/** NAISSANCE **/
String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue();
traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur);
/** DECES **/
Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
if (rbEstDecedee.getValue() == true) {
// date
String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue();
traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur);
// lieu
String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
personneSelectionnee.setDecesLieu(decesLieu);
} else {
personneSelectionnee.setNonDecedee();
}
strValeur = obtenirValeurCombo("cbPays");
personneSelectionnee.set("ce_truk_pays", strValeur);
success = hmIdentite.getChampMultiValeursMultiTypes("telephones").estValide(true);
personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
personneSelectionnee.set("truk_logo", logoUrls);
personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
//Infos Naturalistes
String recolte = ((ChampMultiValeursMultiTypesPaginable) hmInfosNat.get("recolte")).getValeurs();
personneSelectionnee.set("truk_recolte", recolte);
String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
personneSelectionnee.set("ce_truk_specialite", specialite);
lstMessageErreur.addAll(tiPubli.verifier());
if (lstMessageErreur.size() != 0) {
String strMessagesErreur = "<span><br />";
Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
while (itMessagesErreur.hasNext()) {
strMessagesErreur += "<br /> - " + itMessagesErreur.next();
}
strMessagesErreur += "</span>";
MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
success = false;
}
return success;
}
private void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) {
String valeurDate = date;
if (!UtilString.isEmpty(valeurDate)){
String jour = "";
String mois = "";
String annee = "";
String dateComplete = "";
String messageErreur = null;
/** JJ/MM/AAAA **/
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
jour = valeurDate.substring(0,2);
mois = valeurDate.substring(3,5);
annee = valeurDate.substring(6,10);
if (jour.equals("00") || mois.equals("00") || annee.equals("0000")) {
messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
} else {
dateComplete = annee+"-"+mois+"-"+jour;
}
/** MM/AAAA **/
} else if (valeurDate.matches("\\d{2}/\\d{4}")) {
jour = "00";
mois = valeurDate.substring(0,2);
annee = valeurDate.substring(3,7);
if (mois.equals("00") || annee.equals("0000")) {
messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
} else {
dateComplete = annee+"-"+mois+"-"+jour;
}
}
/** AAAA **/
else if (valeurDate.matches("\\d{4}")) {
if (valeurDate.equals("0000")) {
messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
}
else {
dateComplete = valeurDate + "-00-00";
}
}
else {
lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
}
if (messageErreur == null) {
if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete);
else if (typeDate=="décès") {
personneSelectionnee.set("deces_date", dateComplete);
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
}
} else {
lstMessageErreur.add(messageErreur);
}
if(typeDate.equals("décès")) {
String valeurDateDeces = hmIdentite.getTextField("tfDateDeces").getRawValue();
String valeurDateNaissance = hmIdentite.getTextField("tfDateNaissance").getRawValue();
if(valeurDateDeces != null && valeurDateNaissance != null &&
!valeurDateDeces.isEmpty() && !valeurDateNaissance.isEmpty()) {
Date dateNaissance = parserDate(valeurDateNaissance);
Date dateDeces = parserDate(valeurDateDeces);
if(dateDeces.compareTo(dateNaissance) < 0) {
lstMessageErreur.add("La date de décès ne peut pas précéder la date de naissance");
}
}
}
/** Date vide **/
} else {
if (typeDate=="naissance") {
personneSelectionnee.setNaissanceDate(null);
} else if (typeDate=="décès") {
personneSelectionnee.setDecesDate(null);
personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
}
}
}
private Date parserDate(String valeurDate) {
Date dateParsee = new Date();
String[] composantsDate = valeurDate.split("/");
// Attention : la fonction setYear ajoute 1900 à l'année
int annee = Integer.parseInt(composantsDate[(composantsDate.length-1)]) - 1900;
// Attention : les mois commencent à 0, donc janvier = 0, février = 1
int mois = (composantsDate.length > 1) ? Integer.parseInt(composantsDate[(composantsDate.length-2)]) - 1 : 0;
int jour = (composantsDate.length > 2) ? Integer.parseInt(composantsDate[0]) : 1;
dateParsee.setYear(annee);
dateParsee.setMonth(mois);
dateParsee.setDate(jour);
return dateParsee;
}
public Personne getPersonne() {
return this.personne;
}
public String getPersonneId() {
return this.personneId;
}
private Listener<BaseEvent> creerEcouteurNomPrenomExistant() {
return new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if(mode.equals(MODE_AJOUTER) && !verificationDoublonEffectuee) {
TextField<String> nom = (TextField<String>) hmIdentite.get("tfNom");
TextField<String> prenom = (TextField<String>) hmIdentite.get("tfPrenom");
LabelField nomComplet = (LabelField) hmIdentite.get("nomComplet");
if(nom.getValue() != null && !nom.getValue().isEmpty()) {
PersonneAsyncDao dao = new PersonneAsyncDao(PersonneForm.this);
// Suppression d'éventuels doubles espaces (ou plus) et ajout d'un joker devant
// (pour gérer la recherche lorsqu'on a qu'un nom de famille)
String nomCompletStr = "%"+nomComplet.getValue().toString().trim().replaceAll(" +", " ");
if(prenom.getValue() != null && !prenom.getValue().isEmpty()) {
// Ajouter un % derrière le prénom permet de gérer facilement le cas de l'initiale
// et également de rechercher des noms potentiels si l'on a saisi qu'une initiale
nomCompletStr = nomCompletStr.replaceAll(prenom+" ", prenom+"%");
}
dao.testerExistencePersonne(nomCompletStr, new Callback<JSONObject, String>() {
@Override
public void onSuccess(JSONObject objet) {
String message = formaterMessageAvertissementDoublon(objet);
verificationDoublonEffectuee = true;
if(!message.isEmpty()) {
Window.alert(message);
}
}
@Override
public void onFailure(String reason) {
// TODO Auto-generated method stub
}
});
}
}
}
};
}
private String formaterMessageAvertissementDoublon(JSONObject objet) {
double nbPers = objet.get("nbElements").isNumber().getValue();
JSONArray personnes = objet.isObject().get("personnes").isArray();
String message = "";
if(nbPers > 0) {
String pers = nbPers == 1 ? "personne" : "personnes";
String exist = nbPers == 1 ? "existe" : "existent";
message = "Attention : "+(int)nbPers+" "+pers+" portant ce nom "+exist+" déjà"+"\n";
for(int i = 0; i < personnes.size(); i++) {
message += "- "+personnes.get(i).isObject().get("cp_fmt_nom_complet").isString().stringValue();
if(personnes.get(i).isObject().get("cp_ville") != null && personnes.get(i).isObject().get("cp_ville").isString() != null) {
message += " à "+personnes.get(i).isObject().get("cp_ville").isString().stringValue();
}
if(personnes.get(i).isObject().get("cp_naissance_date") != null
&& personnes.get(i).isObject().get("cp_naissance_date").isString()!= null
&& !personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue().equals("0000-00-00")) {
String dateChaine = personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue();
String dateNaissance = "";
// Quelque fois on ne possède que l'année de naissance de la personne,
// dans ce cas là la date est de la forme XXXX-00-00
if(dateChaine.endsWith("-00-00")) {
dateNaissance = dateChaine.substring(0, 4);
} else {
dateNaissance = UtilDate.formaterEnStringFormatFr(UtilString.formaterEnDate(dateChaine));
}
 
message += ", date de naissance : "+dateNaissance;
}
message += "\n";
}
}
return message;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/personne/PersonneForm.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java
New file
0,0 → 1,652
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxMultiSelect;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.GrillePaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyCollectionACommentaire;
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne;
import org.tela_botanica.client.composants.pagination.ProxyCommentaires;
import org.tela_botanica.client.composants.pagination.ProxyPublications;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.vues.FenetreForm;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireBarreValidation;
import org.tela_botanica.client.vues.FormulaireOnglet;
import org.tela_botanica.client.vues.commentaire.CommentaireForm;
 
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.KeyListener;
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.Store;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Text;
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.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Validator;
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;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
 
public class CollectionFormCommentaire extends FormulaireOnglet implements Rafraichissable {
public static final String ID = "commentaire";
private Collection collection = null;
private static int idGenere = 1;
private ContentPanel panneauPrincipal = null;
private ToolBar barreOutils = null;
private GrillePaginable<ModelData> grille = null;
private ChampComboBoxMultiSelect<Valeur> typeCombo = null;
private CollectionACommentaireListe commentairesAjoutes = null;
private CollectionACommentaireListe commentairesModifies = null;
private CollectionACommentaireListe commentairesSupprimes = null;
private ChampComboBoxRechercheTempsReelPaginable commentairesSaisisComboBox = null;
private Button commentairesBoutonSupprimer = null;
private Button commentairesBoutonModifier = null;
private static boolean chargementTypesOk = false;
private static boolean chargementCommentairesOk = false;
private FenetreForm fenetreFormulaire = null;
private Sequenceur sequenceur;
public CollectionFormCommentaire(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setLayout(new FitLayout());
setId(ID);
setText(Mediateur.i18nC.collectionCommentaire());
setStyleAttribute("padding", "0");
initialiser();
panneauPrincipal = creerPanneauContenantGrille();
barreOutils = creerBarreOutilsGrille();
panneauPrincipal.setTopComponent(barreOutils);
grille = creerGrille();
panneauPrincipal.add(grille);
mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection", null);
add(panneauPrincipal);
}
private void initialiser() {
// Remise à zéro des modification dans la liste des commentaires
initialiserGestionCommentaires();
collection = ((CollectionForm) formulaire).collection;
}
private void initialiserGestionCommentaires() {
idGenere = 1;
commentairesAjoutes = new CollectionACommentaireListe();
commentairesModifies = new CollectionACommentaireListe();
commentairesSupprimes = new CollectionACommentaireListe();
}
private void initialiserChargement() {
chargementCommentairesOk = false;
}
private ContentPanel creerPanneauContenantGrille() {
ContentPanel panneau = new ContentPanel();
panneau.setHeadingHtml(i18nC.collectionCommentaireTitre());
panneau.setIcon(Images.ICONES.table());
panneau.setLayout(new FitLayout());
panneau.setFrame(true);
return panneau;
}
 
private ToolBar creerBarreOutilsGrille() {
ToolBar barreOutils = new ToolBar();
commentairesSaisisComboBox = creerComboBoxCommentairesSaisies();
barreOutils.add(commentairesSaisisComboBox);
barreOutils.add(new Text(" ou "));
Button ajouterPersonneBouton = creerBoutonAjouter();
barreOutils.add(ajouterPersonneBouton);
barreOutils.add(new SeparatorToolItem());
commentairesBoutonModifier = creerBoutonModifier();
barreOutils.add(commentairesBoutonModifier);
barreOutils.add(new SeparatorToolItem());
commentairesBoutonSupprimer = creerBoutonSupprimer();
barreOutils.add(commentairesBoutonSupprimer);
barreOutils.add(new SeparatorToolItem());
Button rafraichirPersonneBouton = creerBoutonRafraichir();
barreOutils.add(rafraichirPersonneBouton);
return barreOutils;
}
 
private Button creerBoutonAjouter() {
Button bouton = new Button(i18nC.ajouter());
bouton.setIcon(Images.ICONES.vcardAjouter());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 
@Override
public void componentSelected(ButtonEvent ce) {
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_AJOUTER);
fenetreFormulaire.show();
}
});
return bouton;
}
private Button creerBoutonModifier() {
Button bouton = new Button(i18nC.modifier());
bouton.setIcon(Images.ICONES.vcardModifier());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
ModelData commentaireSaisiSelectionne = grille.getGrille().getSelectionModel().getSelectedItem();
if (commentaireSaisiSelectionne == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire());
} else {
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_MODIFIER);
fenetreFormulaire.show();
}
}
});
return bouton;
}
private FenetreForm creerFenetreModaleAvecFormulaireCommentaire(String mode) {
String commentaireId = null;
if (mode.equals(Formulaire.MODE_MODIFIER)) {
ModelData commentaierSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
CollectionACommentaire cac = new CollectionACommentaire(commentaierSaisieSelectionnee, false);
commentaireId = cac.getIdCommentaire();
}
final FenetreForm fenetre = new FenetreForm("");
final CommentaireForm formulaire = creerFormulaireCommentaire(fenetre, commentaireId);
fenetre.add(formulaire);
return fenetre;
}
private CommentaireForm creerFormulaireCommentaire(final FenetreForm fenetre, String commentaireId) {
CommentaireForm formulaire = new CommentaireForm(mediateur, commentaireId, this);
FormPanel panneauFormulaire = formulaire.getFormulaire();
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
panneauFormulaire.setHeaderVisible(false);
panneauFormulaire.setTopComponent(null);
 
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
panneauFormulaire.getBottomComponent().hide();
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulaireCommentaire(fenetre, formulaire);
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
fenetre.setBottomComponent(barreValidation);
return formulaire;
}
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulaireCommentaire(final FenetreForm fenetre, final CommentaireForm formulaire) {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (formulaire.soumettreFormulaire()) {
fenetre.hide();
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
formulaire.soumettreFormulaire();
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fenetre.hide();
}
}
};
return ecouteur;
}
private Button creerBoutonSupprimer() {
Button bouton = new Button(i18nC.supprimer());
bouton.setIcon(Images.ICONES.vcardSupprimer());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
ModelData commentaireSaisiSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
CollectionACommentaire cac = new CollectionACommentaire(commentaireSaisiSelectionnee, false);
if (commentaireSaisiSelectionnee == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire());
} else {
supprimerDansGrille(cac);
}
}
});
return bouton;
}
private Button creerBoutonRafraichir() {
Button bouton = new Button(i18nC.rafraichir());
bouton.setIcon(Images.ICONES.rafraichir());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
actualiserGrille();
}
});
return bouton;
}
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxCommentairesSaisies() {
ModelType modelTypeCommentaires = new ModelType();
modelTypeCommentaires.setRoot("commentaires");
modelTypeCommentaires.setTotalName("nbElements");
modelTypeCommentaires.addField("ccm_id_commentaire");
modelTypeCommentaires.addField("ccm_ce_pere");
modelTypeCommentaires.addField("ccm_titre");
modelTypeCommentaires.addField("ccm_texte");
modelTypeCommentaires.addField("ccm_ponderation");
modelTypeCommentaires.addField("ccm_mark_public");
String displayNameCommentaires = "ccm_titre";
ProxyCommentaires<ModelData> proxyCommentaires = new ProxyCommentaires<ModelData>(null);
final ChampComboBoxRechercheTempsReelPaginable commentairesCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyCommentaires, modelTypeCommentaires, displayNameCommentaires);
commentairesCombo.getCombo().setTabIndex(tabIndex++);
commentairesCombo.getCombo().setForceSelection(true);
commentairesCombo.getCombo().setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (commentairesCombo.getStore().findModel("ccm_titre", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
}
return retour;
}
});
commentairesCombo.getCombo().setEmptyText("Rechercher et sélectionner une note existante dans la base");
commentairesCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if (commentairesSaisisComboBox.getValeur() instanceof ModelData) {
Commentaire commentaireSaisiSelectionnee = new Commentaire(commentairesSaisisComboBox.getValeur());
ajouterDansGrille(commentaireSaisiSelectionnee);
commentairesSaisisComboBox.getCombo().setValue(null);
}
}
});
return commentairesCombo;
}
private void ajouterDansGrille(Commentaire commentaire) {
ajouterDansGrille(commentaire, null, 0);
}
private void ajouterDansGrille(Commentaire commentaire, String type, int index) {
if (commentaire != null) {
CollectionACommentaire relationCollectionACommentaire = new CollectionACommentaire();
relationCollectionACommentaire.setCommentaire(commentaire);
relationCollectionACommentaire.setIdCommentaire(commentaire.getId());
if (type != null) {
relationCollectionACommentaire.set("_type_", type);
}
// Gestion de l'id de la collection
if (mode.equals(Formulaire.MODE_MODIFIER)) {
relationCollectionACommentaire.setIdCollection(collection.getId());
}
relationCollectionACommentaire.set("_etat_", aDonnee.ETAT_AJOUTE);
corrigerChampsGrille(relationCollectionACommentaire);
// Ajout à la grille
grille.getGrille().stopEditing();
grille.getGrille().getStore().insert(relationCollectionACommentaire, index);
grille.getGrille().startEditing(index, 0);
grille.getGrille().getSelectionModel().select(index, false);
}
}
private void supprimerDansGrille(CollectionACommentaire relationCollectionACommentaire) {
if (relationCollectionACommentaire != null) {
// Ajout de la personne supprimée à la liste
if ((relationCollectionACommentaire.get("_etat_").equals("") || !relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
&& relationCollectionACommentaire.getId() != null
&& !relationCollectionACommentaire.getId().equals("")) {
commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire);
}
// Suppression de l'enregistrement de la grille
grille.getStore().remove(relationCollectionACommentaire);
}
}
 
private GrillePaginable<ModelData> creerGrille() {
GrillePaginable<ModelData> grillePaginable = null;
 
// ModelType
ModelType modelTypeCollectionACommentaire = new ModelType();
modelTypeCollectionACommentaire.setRoot("collectionsACommentaire");
modelTypeCollectionACommentaire.setTotalName("nbElements");
modelTypeCollectionACommentaire.addField("ccac_id_commentaire");
modelTypeCollectionACommentaire.addField("ccac_id_collection");
modelTypeCollectionACommentaire.addField("ccac_truk_type");
modelTypeCollectionACommentaire.addField("ccm_id_commentaire");
modelTypeCollectionACommentaire.addField("ccm_titre");
modelTypeCollectionACommentaire.addField("ccm_texte");
modelTypeCollectionACommentaire.addField("ccm_ponderation");
modelTypeCollectionACommentaire.addField("ccm_mark_public");
modelTypeCollectionACommentaire.addField("ccm_ce_pere");
// Proxy
ProxyCollectionACommentaire<ModelData> proxyCollectionACommentaire = new ProxyCollectionACommentaire<ModelData>(null, collection.getId());
// Colonnes
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
RowNumberer pluginLigneNumero = new RowNumberer();
colonnes.add(pluginLigneNumero);
colonnes.add(creerColonneType());
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150));
colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75));
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35));
colonnes.add(creerColonneAcces());
// Modèle de colonnes
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
HashMap<String, String> virtualFields = new HashMap<String, String>();
virtualFields.put("_titre_", "ccm_titre");
virtualFields.put("_texte_", "ccm_texte");
virtualFields.put("_ponderation_", "ccm_ponderation");
virtualFields.put("_type_", "ccac_truk_type");
virtualFields.put("_public_", "ccm_mark_public");
virtualFields.put("_etat_", "");
// Grille
grillePaginable = new GrillePaginable<ModelData>(modelTypeCollectionACommentaire, virtualFields, proxyCollectionACommentaire, colonnes, modeleDeColonnes);
grillePaginable.getGrille().setBorders(true);
grillePaginable.getGrille().setSelectionModel(modeleDeSelection);
grillePaginable.getGrille().addPlugin(pluginLigneNumero);
grillePaginable.getGrille().getView().setForceFit(true);
grillePaginable.getGrille().setAutoExpandColumn("_titre_");
grillePaginable.getGrille().setStripeRows(true);
grillePaginable.getGrille().setTrackMouseOver(true);
// Rajouter des écouteurs
grillePaginable.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
if (ce.getRecord().isModified("_type_") && ce.getModel().get("_etat_") == null || !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
}
}
});
return grillePaginable;
}
private ColumnConfig creerColonneType() {
typeCombo = new ChampComboBoxMultiSelect<Valeur>();
typeCombo.setDisplayField("nom");
typeCombo.setValueField("id_valeur");
typeCombo.setStore(new ListStore<Valeur>());
typeCombo.setEditable(false);
typeCombo.setForceSelection(true);
CellEditor typeEditeur = new CellEditor(typeCombo) {
@SuppressWarnings("unchecked")
@Override
public Object preProcessValue(Object valeur) {
Valeur retour = new Valeur();
if (valeur != null ) {
if (valeur instanceof String) {
((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString());
}
}
return retour;
}
 
@Override
public Object postProcessValue(Object valeur) {
String retour = null;
if (getField().getRawValue() != null ) {
retour = getField().getRawValue();
}
return retour;
}
};
 
GridCellRenderer<ModelData> typeRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
String type = model.get("_type_");
if (typeCombo.getStore() != null && type != null && (type.matches("[0-9]+") || type.contains(aDonnee.SEPARATEUR_VALEURS))) {
type = typeCombo.formaterIdentifiantsEnTexte(type);
model.set("_type_", type);
}
return type;
}
};
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100);
typeColonne.setEditor(typeEditeur);
typeColonne.setRenderer(typeRendu);
return typeColonne;
}
private ColumnConfig creerColonneAcces() {
GridCellRenderer<ModelData> accesRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
CollectionACommentaire cac = new CollectionACommentaire(model, true);
String acces = (cac.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
model.set("_public_", acces);
return acces;
}
};
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30);
accesColonne.setRenderer(accesRendu);
return accesColonne;
}
public void actualiserEtatBoutonsBarreOutils() {
// Activation des boutons si la grille contient un élément
if (grille.getStore().getCount() > 0) {
commentairesBoutonSupprimer.enable();
commentairesBoutonModifier.enable();
}
// Désactivation des boutons si la grille ne contient plus d'élément
if (grille.getStore().getCount() == 0) {
commentairesBoutonSupprimer.disable();
commentairesBoutonModifier.disable();
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
if (chargementTypesOk && chargementCommentairesOk) {
peupler();
initialiserChargement();
}
}
private void rafraichirValeurListe(ValeurListe listeValeurs) {
if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) {
List<Valeur> liste = listeValeurs.toList();
if (liste.size() > 0) {
ListStore<Valeur> store = typeCombo.getStore();
store.removeAll();
store.add(liste);
store.sort("nom", SortDir.ASC);
typeCombo.setStore(store);
}
chargementTypesOk = true;
} else {
GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null);
}
}
public void rafraichirInformation(Information info) {
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
}
String type = info.getType();
if (info.getType().equals("liste_collection_a_commentaire")) {
if (info.getDonnee(0) != null) {
initialiser();
collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0));
chargementCommentairesOk = true;
}
} 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.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes);
}
} else if (type.equals("commentaire_modifiee")) {
if (info.getDonnee(0) != null) {
Commentaire commentaire = (Commentaire) info.getDonnee(0);
ModelData commentaireDansGrille = grille.getStore().findModel("ccm_id_commentaire", commentaire.getId());
int index = grille.getStore().indexOf(commentaireDansGrille);
grille.getStore().remove(commentaireDansGrille);
String typeCommentaire = (String) commentaireDansGrille.get("_type_");
ajouterDansGrille(commentaire, typeCommentaire, index);
}
} else if (type.equals("commentaire_ajoutee")) {
if (info.getDonnee(0) != null) {
Commentaire commentaire = (Commentaire) info.getDonnee(0);
ajouterDansGrille(commentaire);
}
} else if (info.getType().equals("modif_collection_a_commentaire")) {
InfoLogger.display("Modification des notes liées à la collection", info.toString());
initialiserGestionCommentaires();
} else if (info.getType().equals("suppression_collection_a_commentaire")) {
InfoLogger.display("Suppression des notes liées à la collection", info.toString());
initialiserGestionCommentaires();
} else if (info.getType().equals("ajout_collection_a_commentaire")) {
InfoLogger.display("Ajout des notes liées à la collection", info.toString());
initialiserGestionCommentaires();
}
}
public void peupler() {
grille.getStore().removeAll();
grille.getStore().add(collection.getCommentairesLiees().toList());
grille.recalculate();
layout();
InfoLogger.display(i18nC.chargementCommentaire(), i18nC.ok());
}
public void collecter() {
if (etreAccede()) {
int nbreCommentaire = grille.getStore().getCount();
for (int i = 0; i < nbreCommentaire; i++) {
ModelData relationCollectionACommentaire = grille.getStore().getAt(i);
CollectionACommentaire cac = new CollectionACommentaire(relationCollectionACommentaire, false);
if (relationCollectionACommentaire.get("_etat_") != null) {
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
corrigerChampsGrille(cac);// Nous modifions l'id_type
commentairesModifies.put("id"+idGenere++, cac);
}
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
corrigerChampsGrille(cac);// Nous modifions l'id_type
commentairesAjoutes.put("id"+idGenere++, cac);
}
// Initialisation de la grille
relationCollectionACommentaire.set("_etat_", "");
}
}
grille.getStore().commitChanges();
}
}
private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) {
String type = relationCollectionACommentaire.get("_type_");
relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type));
relationCollectionACommentaire.setIdCollection(collection.getId());
}
 
public void soumettre() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) {
//InfoLogger.display("Modification des notes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
} else {
mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes);
mediateur.modifierCollectionACommentaire(this, commentairesModifies);
mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes);
}
}
}
private void actualiserGrille() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerCollectionACommentaire(this, collection.getId(), null);
} else {
grille.getStore().removeAll();
layout();
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java:r11-996,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java
New file
0,0 → 1,473
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampCaseACocher;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
import org.tela_botanica.client.composants.ChampSliderPourcentage;
import org.tela_botanica.client.composants.ChampNombre;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.InterneValeur;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionBotanique;
import org.tela_botanica.client.modeles.collection.UniteBase;
import org.tela_botanica.client.modeles.collection.UniteRangement;
import org.tela_botanica.client.modeles.OntologiesLocales;
import org.tela_botanica.client.modeles.SimpleModelData;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.ui.HorizontalPanel;
 
 
public class CollectionFormDescription extends FormulaireOnglet implements Rafraichissable {
public static final String ID = "description";
private Collection collection = null;
private CollectionBotanique collectionBotanique = null;
private Collection collectionCollectee = null;
private CollectionBotanique collectionBotaniqueCollectee = null;
private static ListStore<InterneValeur> precisionStore = null;
private ChampComboBoxListeValeurs typesCollectionBotaCombo = null;
private NumberField nbreEchantillonChp = null;
private EditorGrid<UniteRangement> uniteRangementGrille = null;
private ComboBox<SimpleModelData> etatUniteRangementCombo = null;
private EditorGrid<UniteBase> uniteBaseGrille = null;
private ChampCaseACocher typePapierConservationChp = null;
private ChampCaseACocher methodeConservationChp = null;
private ChampSliderPourcentage specimenFixationPourcentChp = null;
private ChampSliderPourcentage etiquetteFixationPourcentChp = null;
private ChampCaseACocher specimentMethodeFixationChp = null;
private ChampCaseACocher etiquetteMethodeFixationSurSupportChp = null;
private ChampCaseACocher etiquetteMethodeFixationSurSpecimenChp = null;
private ChampCaseACocher typeEcritureChp = null;
private ChampComboBoxListeValeurs traitementCombo = null;
private ChampCaseACocher poisonTraitementChp = null;
private ChampCaseACocher insecteTraitementChp = null;
private ComboBox<SimpleModelData> etatGeneralCombo = null;
private ChampComboBoxListeValeurs determinationCombo = null;
private ChampMultiValeursMultiTypes specimenDegradationChp = null;
private ChampMultiValeursMultiTypes presentationDegradationChp = null;
private Text labelPresentationDegradationChp = null;
private ChampNombre planchesHerbier = null;
private ChampNombre nbEspeces = null;
private ChampNombre nbCartonsHerbier = null;
private TextField<String> cartonsHerbierFormat = null;
private ChampNombre nbLiasses = null;
private TextField<String> liassesFormat = null;
private TextArea autresUnitesRangement = null;
public CollectionFormDescription(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setId(ID);
setText(Mediateur.i18nC.collectionDescription());
 
FormLayout formulaireLayout = (FormLayout) this.getLayout();
formulaireLayout.setLabelAlign(LabelAlign.LEFT);
formulaireLayout.setLabelWidth(300);
creerFieldsetTypesUniteEtat();
creerFieldsetConservation(); // Papier
creerFieldsetEtiquette(); // RAS
creerFieldsetTraitement(); // RAS
creerFieldsetPrecision(); // A supprimer ou déplacer plus tard
creerStorePrecision();
layout();
}
private void creerFieldsetPrecision() {
FieldSet precisionFieldSet = new FieldSet();
precisionFieldSet.setHeadingHtml(i18nC.collectionTitrePrecision());
precisionFieldSet.setCollapsible(true);
precisionFieldSet.collapse();
precisionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
typesCollectionBotaCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionBotanique(), "typeCollectionBota");
typesCollectionBotaCombo.setTabIndex(tabIndex++);
precisionFieldSet.add(typesCollectionBotaCombo, new FormData(250, 0));
nbreEchantillonChp = new NumberField();
nbreEchantillonChp.setFieldLabel(i18nC.nbreEchantillon());
nbreEchantillonChp.setToolTip(i18nC.nbreEchantillonInfo());
nbreEchantillonChp.setFormat(NumberFormat.getFormat("#"));
precisionFieldSet.add(nbreEchantillonChp);
this.add(precisionFieldSet);
}
private static void creerStorePrecision() {
if (precisionStore == null) {
precisionStore = new ListStore<InterneValeur>();
precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, Mediateur.i18nC.precisionApproximatif()));
precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, Mediateur.i18nC.precisionExact()));
}
}
private void creerFieldsetConservation() {
FieldSet conservationFieldSet = new FieldSet();
conservationFieldSet.setHeadingHtml(i18nC.collectionTitreConservation());
conservationFieldSet.setCollapsible(true);
conservationFieldSet.collapse();
conservationFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
typePapierConservationChp = new ChampCaseACocher(i18nC.typePapierConservation(), "typePapier", true);
conservationFieldSet.add(typePapierConservationChp);
methodeConservationChp = new ChampCaseACocher(i18nC.methodeConservation(), "methodeRangement", true);
conservationFieldSet.add(methodeConservationChp);
this.add(conservationFieldSet);
}
private void creerFieldsetEtiquette() {
FieldSet etiquetteFieldSet = new FieldSet();
etiquetteFieldSet.setHeadingHtml(i18nC.collectionTitreEtiquette());
etiquetteFieldSet.setCollapsible(true);
etiquetteFieldSet.collapse();
etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
Text fixationPoucentLabel = new Text(i18nC.fixationPourcent());
etiquetteFieldSet.add(fixationPoucentLabel);
specimenFixationPourcentChp = new ChampSliderPourcentage(i18nC.specimenFixationPourcent());
etiquetteFieldSet.add(specimenFixationPourcentChp, new FormData(200, 0));
etiquetteFixationPourcentChp = new ChampSliderPourcentage(i18nC.etiquetteFixationPourcent());
etiquetteFieldSet.add(etiquetteFixationPourcentChp, new FormData(200, 0));
specimentMethodeFixationChp = new ChampCaseACocher(i18nC.specimenMethodeFixation(), "methodeFixation", true);
etiquetteFieldSet.add(specimentMethodeFixationChp);
etiquetteMethodeFixationSurSupportChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSupport(), "methodeFixation", true);
etiquetteFieldSet.add(etiquetteMethodeFixationSurSupportChp);
etiquetteMethodeFixationSurSpecimenChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSpecimen(), "methodeFixationSurSpecimen", true);
etiquetteFieldSet.add(etiquetteMethodeFixationSurSpecimenChp);
typeEcritureChp = new ChampCaseACocher(i18nC.typeEcriture(), "typeEcriture", false);
etiquetteFieldSet.add(typeEcritureChp);
this.add(etiquetteFieldSet);
}
private void creerFieldsetTraitement() {
FieldSet traitementFieldSet = new FieldSet();
traitementFieldSet.setHeadingHtml(i18nC.collectionTitreTraitement());
traitementFieldSet.setCollapsible(true);
traitementFieldSet.collapse();
traitementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
traitementCombo = new ChampComboBoxListeValeurs(i18nC.collectionTraitement(), "onpi");
traitementCombo.setTrie("id_valeur");
traitementFieldSet.add(traitementCombo, new FormData(300, 0));
poisonTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementPoison(), "poisonTraitement", true);
traitementFieldSet.add(poisonTraitementChp);
insecteTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementInsecte(), "insecteTraitement", true);
traitementFieldSet.add(insecteTraitementChp);
 
this.add(traitementFieldSet);
}
private void creerFieldsetTypesUniteEtat() {
FieldSet etatTypesUniteFieldSet = new FieldSet();
// Etat général et nombre d'échantillons (à changer dans l'i18n
etatTypesUniteFieldSet.setHeadingHtml(i18nC.collectionEtatGeneralEtNombreEchantillons());
etatTypesUniteFieldSet.setCollapsible(true);
etatTypesUniteFieldSet.collapse();
etatTypesUniteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
etatUniteRangementCombo = creerSimpleComboBonMauvaisEtat(i18nC.collectionUniteRangementEtatGeneral());
etatTypesUniteFieldSet.add(etatUniteRangementCombo, new FormData(300, 0));
// Liasses et cartons d'herbier
Label labelcartonsHerbiersFormat = new Label(i18nC.collectionCartonsHerbiers());
labelcartonsHerbiersFormat.setStyleName("labelChampNombreFormat");
nbCartonsHerbier = new ChampNombre();
nbCartonsHerbier.setStyleName("champNombreFormat");
nbCartonsHerbier.setWidth(55);
nbCartonsHerbier.setEmptyText(i18nC.collectionUniteNbre());
cartonsHerbierFormat = new TextField<String>();
cartonsHerbierFormat.setStyleName("champNombreFormat");
cartonsHerbierFormat.setEmptyText(i18nC.collectionUniteFormat());
HorizontalPanel conteneurCartonsHerbiers = new HorizontalPanel();
conteneurCartonsHerbiers.setBorderWidth(0);
conteneurCartonsHerbiers.add(labelcartonsHerbiersFormat);
conteneurCartonsHerbiers.add(nbCartonsHerbier);
conteneurCartonsHerbiers.add(cartonsHerbierFormat);
etatTypesUniteFieldSet.add(conteneurCartonsHerbiers);
Label labelLiasses = new Label(i18nC.collectionLiasses());
labelLiasses.setStyleName("labelChampNombreFormat");
nbLiasses = new ChampNombre();
nbLiasses.setStyleName("champNombreFormat");
nbLiasses.setWidth(55);
nbLiasses.setEmptyText(i18nC.collectionUniteNbre());
liassesFormat = new TextField<String>();
liassesFormat.setStyleName("champNombreFormat");
liassesFormat.setEmptyText(i18nC.collectionUniteFormat());
HorizontalPanel conteneurLiasses = new HorizontalPanel();
conteneurLiasses.setBorderWidth(0);
conteneurLiasses.add(labelLiasses);
conteneurLiasses.add(nbLiasses);
conteneurLiasses.add(liassesFormat);
etatTypesUniteFieldSet.add(conteneurLiasses);
autresUnitesRangement = new TextArea();
autresUnitesRangement.setStyleName("textAreaAutreUniteRangement");
autresUnitesRangement.setHeight(90);
autresUnitesRangement.setFieldLabel(i18nC.collectionAutreUnitesRangement());
etatTypesUniteFieldSet.add(autresUnitesRangement);
planchesHerbier = new ChampNombre();
planchesHerbier.setFieldLabel(i18nC.collectionNbPlanchesHerbier());
nbEspeces = new ChampNombre();
nbEspeces.setFieldLabel(i18nC.collectionNbEspeces());
etatTypesUniteFieldSet.add(planchesHerbier);
etatTypesUniteFieldSet.add(nbEspeces);
add(etatTypesUniteFieldSet);
 
etatGeneralCombo = creerSimpleComboBonMauvaisEtat(i18nC.collectionEtatGeneral());
etatTypesUniteFieldSet.add(etatGeneralCombo, new FormData(300, 0));
specimenDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationSpecimen(), 150, true);
specimenDegradationChp.initialiserType("specimenDegradation");
specimenDegradationChp.initialiserCombobox("niveauImportance");
etatTypesUniteFieldSet.add(specimenDegradationChp);
labelPresentationDegradationChp = new Text();
labelPresentationDegradationChp.setWidth("95%");
labelPresentationDegradationChp.setVisible(false);
presentationDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationPresentation(), 150, 200, true);
presentationDegradationChp.initialiserType("supportDegradation");
presentationDegradationChp.initialiserCombobox("niveauImportance");
presentationDegradationChp.getTypes().addListener(Events.Select,
new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
if (((Valeur)(be.getField().getValue())).get("id_valeur").equals("2310")) {
labelPresentationDegradationChp.setText(i18nC.degradationPresentationLabel());
labelPresentationDegradationChp.setVisible(true);
}
else {
labelPresentationDegradationChp.setText("");
labelPresentationDegradationChp.setVisible(false);
}
}
});
etatTypesUniteFieldSet.add(presentationDegradationChp);
etatTypesUniteFieldSet.add(labelPresentationDegradationChp);
determinationCombo = new ChampComboBoxListeValeurs(i18nC.collectionDetermination(), "niveauDetermination");
determinationCombo.setTrie("id_valeur");
etatTypesUniteFieldSet.add(determinationCombo, new FormData(450, 0));
this.add(etatTypesUniteFieldSet);
}
public void peupler() {
initialiserCollection();
if (collectionBotanique != null) {
typesCollectionBotaCombo.peupler(collectionBotanique.getType());
if (!UtilString.isEmpty(collectionBotanique.getNbreEchantillon())) {
nbreEchantillonChp.setValue(Integer.parseInt(collectionBotanique.getNbreEchantillon()));
}
if(!collectionBotanique.getNbCartonsHerbiers().isEmpty()) {
nbCartonsHerbier.setValue((Integer.parseInt(collectionBotanique.getNbCartonsHerbiers())));
}
cartonsHerbierFormat.setValue(collectionBotanique.getFormatCartonsHerbiers());
if(!collectionBotanique.getNbLiasses().isEmpty()) {
nbLiasses.setValue((Integer.parseInt(collectionBotanique.getNbLiasses())));
}
liassesFormat.setValue(collectionBotanique.getFormatLiasses());
autresUnitesRangement.setValue(collectionBotanique.getAutresUnitesRangement());
 
remplirSimpleCombo(etatUniteRangementCombo, collectionBotanique.getUniteRangementEtat());
if(!collectionBotanique.getNbPlanchesHerbiers().isEmpty()) {
planchesHerbier.setValue((Integer.parseInt(collectionBotanique.getNbPlanchesHerbiers())));
}
if(!collectionBotanique.getNbEspeces().isEmpty()) {
nbEspeces.setValue((Integer.parseInt(collectionBotanique.getNbEspeces())));
}
typePapierConservationChp.peupler(collectionBotanique.getConservationPapierType());
methodeConservationChp.peupler(collectionBotanique.getConservationMethode());
specimenFixationPourcentChp.peupler(collectionBotanique.getSpecimenFixationPourcent());
etiquetteFixationPourcentChp.peupler(collectionBotanique.getEtiquetteFixationPourcent());
specimentMethodeFixationChp.peupler(collectionBotanique.getSpecimenFixationMethode());
etiquetteMethodeFixationSurSupportChp.peupler(collectionBotanique.getEtiquetteFixationSupport());
etiquetteMethodeFixationSurSpecimenChp.peupler(collectionBotanique.getEtiquetteFixationSpecimen());
typeEcritureChp.peupler(collectionBotanique.getEtiquetteEcriture());
traitementCombo.peupler(collectionBotanique.getTraitement());
poisonTraitementChp.peupler(collectionBotanique.getTraitementPoison());
insecteTraitementChp.peupler(collectionBotanique.getTraitementInsecte());
remplirSimpleCombo(etatGeneralCombo, collectionBotanique.getEtatGeneral());
specimenDegradationChp.peupler(collectionBotanique.getDegradationSpecimen());
presentationDegradationChp.peupler(collectionBotanique.getDegradationPresentation());
determinationCombo.peupler(collectionBotanique.getDetermination());
}
}
public void collecter() {
initialiserCollection();
if (etreAccede()) {
collectionBotaniqueCollectee.setType(typesCollectionBotaCombo.getValeur());
if (nbreEchantillonChp.getValue() != null) {
collectionBotaniqueCollectee.setNbreEchantillon(Integer.toString(nbreEchantillonChp.getValue().intValue()));
}
collectionBotaniqueCollectee.setNbCartonsHerbiers(nbCartonsHerbier.getValue()+"");
collectionBotaniqueCollectee.setFormatCartonsHerbiers(cartonsHerbierFormat.getValue());
collectionBotaniqueCollectee.setNbLiasses(nbLiasses.getValue()+"");
collectionBotaniqueCollectee.setFormatLiasses(liassesFormat.getValue());
collectionBotaniqueCollectee.setAutresUnitesRangement(autresUnitesRangement.getValue());
collectionBotaniqueCollectee.setUniteRangementEtat(etatUniteRangementCombo.getValue().getCle());
collectionBotaniqueCollectee.setNbPlanchesHerbiers(planchesHerbier.getValue()+"");
collectionBotaniqueCollectee.setNbEspeces(nbEspeces.getValue()+"");
collectionBotaniqueCollectee.setConservationPapierType(typePapierConservationChp.getValeur());
collectionBotaniqueCollectee.setConservationMethode(methodeConservationChp.getValeur());
collectionBotaniqueCollectee.setSpecimenFixationPourcent(specimenFixationPourcentChp.getValeur());
collectionBotaniqueCollectee.setEtiquetteFixationPourcent(etiquetteFixationPourcentChp.getValeur());
collectionBotaniqueCollectee.setSpecimenFixationMethode(specimentMethodeFixationChp.getValeur());
collectionBotaniqueCollectee.setEtiquetteFixationSupport(etiquetteMethodeFixationSurSupportChp.getValeur());
collectionBotaniqueCollectee.setEtiquetteFixationSpecimen(etiquetteMethodeFixationSurSpecimenChp.getValeur());
collectionBotaniqueCollectee.setEtiquetteEcriture(typeEcritureChp.getValeur());
collectionBotaniqueCollectee.setTraitement(traitementCombo.getValeur());
collectionBotaniqueCollectee.setTraitementPoison(poisonTraitementChp.getValeur());
collectionBotaniqueCollectee.setTraitementInsecte(insecteTraitementChp.getValeur());
collectionBotaniqueCollectee.setEtatGeneral(etatGeneralCombo.getValue().getCle());
collectionBotaniqueCollectee.setDegradationSpecimen(specimenDegradationChp.getValeurs());
collectionBotaniqueCollectee.setDegradationPresentation(presentationDegradationChp.getValeurs());
collectionBotaniqueCollectee.setDetermination(determinationCombo.getValeur());
}
}
 
private void initialiserCollection() {
collection = ((CollectionForm) formulaire).collection;
if (collection != null) {
collectionBotanique = collection.getBotanique();
}
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee;
if (collectionCollectee != null) {
collectionBotaniqueCollectee = collectionCollectee.getBotanique();
}
}
public void remplirSimpleCombo(ComboBox<SimpleModelData> simpleCombo, String valeur) {
SimpleModelData selectionne = simpleCombo.getStore().findModel("cle", valeur);
simpleCombo.setValue(selectionne);
}
public ComboBox<SimpleModelData> creerSimpleComboBonMauvaisEtat(String label) {
ListStore<SimpleModelData> listeBonMauvaisEtat = OntologiesLocales.convertirVersListeStore(OntologiesLocales.getListeBonMauvaisEtat());
ComboBox<SimpleModelData> combo = new ComboBox<SimpleModelData>();
combo.setForceSelection(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.setFieldLabel(label);
combo.setDisplayField("valeur");
combo.setValueField("cle");
listeBonMauvaisEtat.sort("ordre", SortDir.ASC);
combo.setStore(listeBonMauvaisEtat);
return combo;
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
private void rafraichirValeurListe(ValeurListe listeValeurs) {
if (listeValeurs.getId().equals(config.getListeId("typeUniteRangement"))) {
Iterator<String> it = listeValeurs.keySet().iterator();
while (it.hasNext()) {
Valeur valeur = listeValeurs.get(it.next());
UniteRangement unite = new UniteRangement();
unite.setId(valeur.getId());
unite.setType(valeur.getNom());
unite.setTypeAutre(false);
uniteRangementGrille.getStore().add(unite);
}
} else if (listeValeurs.getId().equals(config.getListeId("typeUniteBase"))) {
Iterator<String> it = listeValeurs.keySet().iterator();
while (it.hasNext()) {
Valeur valeur = listeValeurs.get(it.next());
UniteBase unite = new UniteBase();
unite.setId(valeur.getId());
unite.setType(valeur.getNom());
unite.setTypeAutre(false);
uniteBaseGrille.getStore().add(unite);
}
} else {
Debug.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!");
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java
New file
0,0 → 1,134
package org.tela_botanica.client.vues.collection;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampCaseACocher;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.ChampSliderPourcentage;
import org.tela_botanica.client.modeles.OntologiesLocales;
import org.tela_botanica.client.modeles.SimpleModelData;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionBotanique;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
 
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.layout.FormData;
 
public class CollectionFormInventaire extends FormulaireOnglet {
 
public static final String ID = "inventaire";
private Collection collection = null;
private CollectionBotanique collectionBotanique = null;
private Collection collectionCollectee = null;
private CollectionBotanique collectionBotaniqueCollectee = null;
private ComboBox<SimpleModelData> existenceInventaireCombo = null;
private ComboBox<SimpleModelData> auteurInventaireCombo = null;
private ChampComboBoxListeValeurs formeInventaireCombo = null;
private TextArea infoInventaireChp = null;
private ChampCaseACocher digitalInventaireChp = null;
private ChampSliderPourcentage pourcentDigitalInventaireChp = null;
private ChampComboBoxListeValeurs etatInventaireCombo = null;
 
public CollectionFormInventaire(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setId(ID);
setText(Mediateur.i18nC.collectionInventaire());
int tabIndex = formulaireCourrant.tabIndex;
existenceInventaireCombo = creerSimpleComboOuiNonPeutEtre(i18nC.existenceInventaireCollection());
add(existenceInventaireCombo, new FormData(300, 0));
auteurInventaireCombo = creerSimpleComboOuiNonPeutEtre(i18nC.auteurInventaireCollection());
add(auteurInventaireCombo, new FormData(300, 0));
formeInventaireCombo = new ChampComboBoxListeValeurs(i18nC.formeInventaireCollection(), "inventaireForme", tabIndex++);
formeInventaireCombo.setTabIndex(tabIndex++);
add(formeInventaireCombo, new FormData(300, 0));
infoInventaireChp = new TextArea();
infoInventaireChp.setTabIndex(tabIndex++);
infoInventaireChp.setFieldLabel(i18nC.infoInventaireCollection());
add(infoInventaireChp, new FormData(550, 0));
digitalInventaireChp = new ChampCaseACocher(i18nC.digitalInventaireCollection(), "inventaireLogiciel", true);
add(digitalInventaireChp);
pourcentDigitalInventaireChp = new ChampSliderPourcentage(i18nC.pourcentDigitalInventaireCollection());
pourcentDigitalInventaireChp.setTabIndex(tabIndex++);
add(pourcentDigitalInventaireChp, new FormData(200, 0));
etatInventaireCombo = new ChampComboBoxListeValeurs(i18nC.etatInventaireCollection(), "inventaireEtat", tabIndex++);
etatInventaireCombo.setTabIndex(tabIndex++);
add(etatInventaireCombo, new FormData(300, 0));
}
public void peupler() {
initialiserCollection();
if (collectionBotanique != null) {
remplirSimpleCombo(existenceInventaireCombo, collectionBotanique.getInventaire());
remplirSimpleCombo(auteurInventaireCombo, collectionBotanique.getInventaireAuteur());
formeInventaireCombo.peupler(collectionBotanique.getInventaireForme());
infoInventaireChp.setValue(collectionBotanique.getInventaireInfo());
digitalInventaireChp.peupler(collectionBotanique.getInventaireDigital());
pourcentDigitalInventaireChp.peupler(collectionBotanique.getInventaireDigitalPourcent());
etatInventaireCombo.peupler(collectionBotanique.getInventaireEtat());
}
}
public void collecter() {
initialiserCollection();
if (etreAccede()) {
collectionBotaniqueCollectee.setInventaire(existenceInventaireCombo.getValue().getCle());
collectionBotaniqueCollectee.setInventaireAuteur(auteurInventaireCombo.getValue().getCle());
collectionBotaniqueCollectee.setInventaireForme(formeInventaireCombo.getValeur());
collectionBotaniqueCollectee.setInventaireInfo(infoInventaireChp.getValue());
collectionBotaniqueCollectee.setInventaireDigital(digitalInventaireChp.getValeur());
collectionBotaniqueCollectee.setInventaireDigitalPourcent(pourcentDigitalInventaireChp.getValeur());
collectionBotaniqueCollectee.setInventaireEtat(etatInventaireCombo.getValeur());
}
}
private void initialiserCollection() {
collection = ((CollectionForm) formulaire).collection;
if (collection != null) {
collectionBotanique = collection.getBotanique();
}
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee;
if (collectionCollectee != null) {
collectionBotaniqueCollectee = collectionCollectee.getBotanique();
}
}
public void rafraichir(Object nouvellesDonnees) {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
public void remplirSimpleCombo(ComboBox<SimpleModelData> simpleCombo, String valeur) {
SimpleModelData selectionne = simpleCombo.getStore().findModel("cle", valeur);
simpleCombo.setValue(selectionne);
}
public ComboBox<SimpleModelData> creerSimpleComboOuiNonPeutEtre(String label) {
ListStore<SimpleModelData> listeOuiNonPeutEtre = OntologiesLocales.convertirVersListeStore(OntologiesLocales.getListeOuiNonPeutEtre());
ComboBox<SimpleModelData> combo = new ComboBox<SimpleModelData>();
combo.setForceSelection(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.setFieldLabel(label);
combo.setDisplayField("valeur");
combo.setValueField("cle");
listeOuiNonPeutEtre.sort("ordre", SortDir.ASC);
combo.setStore(listeOuiNonPeutEtre);
return combo;
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java
New file
0,0 → 1,681
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.GrillePaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne;
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.vues.FenetreForm;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireBarreValidation;
import org.tela_botanica.client.vues.FormulaireOnglet;
import org.tela_botanica.client.vues.personne.PersonneForm;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FieldEvent;
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.Store;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Text;
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.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Validator;
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.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
 
public class CollectionFormPersonne extends FormulaireOnglet implements Rafraichissable {
public static final String ID = "personne";
private Collection collection = null;
private static int idGenere = 1;
private ContentPanel panneauPrincipal = null;
private ToolBar barreOutils = null;
private GrillePaginable<ModelData> grille;
private ComboBox<Valeur> typeRelationCombo = null;
private CollectionAPersonneListe personnesAjoutees = null;
private CollectionAPersonneListe personnesSupprimees = null;
private ChampComboBoxRechercheTempsReelPaginable personnesSaisisComboBox = null;
private ChampComboBoxRechercheTempsReelPaginable recherchePersonnesCombo = null;
private Button personnesBoutonSupprimer = null;
private Button personnesBoutonModifier = null;
private ListStore<Valeur> listeIon = null;
private FenetreForm fenetreFormulaire = null;
private Sequenceur sequenceur = new Sequenceur();
public CollectionFormPersonne(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setLayout(new FitLayout());
setScrollMode(Scroll.AUTO);
setId(ID);
setText(Mediateur.i18nC.collectionPersonne());
setStyleAttribute("padding", "0");
initialiser();
panneauPrincipal = creerPanneauContenantGrille();
barreOutils = creerBarreOutilsGrille();
panneauPrincipal.setTopComponent(barreOutils);
grille = creerGrille();
panneauPrincipal.add(grille);
mediateur.obtenirListeValeurEtRafraichir(this, "ion", sequenceur);
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonneCollection", sequenceur);
add(panneauPrincipal);
}
private void initialiser() {
// Remise à zéro des modification dans la liste des auteurs
idGenere = 1;
personnesAjoutees = new CollectionAPersonneListe();
personnesSupprimees = new CollectionAPersonneListe();
collection = ((CollectionForm) formulaire).collection;
}
private ContentPanel creerPanneauContenantGrille() {
ContentPanel panneau = new ContentPanel();
panneau.setHeadingHtml(i18nC.collectionPersonneTitre());
panneau.setIcon(Images.ICONES.table());
panneau.setLayout(new FitLayout());
panneau.setFrame(true);
panneau.setScrollMode(Scroll.AUTO);
return panneau;
}
 
private ToolBar creerBarreOutilsGrille() {
ToolBar barreOutils = new ToolBar();
personnesSaisisComboBox = creerComboBoxPersonnesSaisies();
barreOutils.add(personnesSaisisComboBox);
barreOutils.add(new Text(" ou "));
Button ajouterPersonneBouton = creerBoutonAjouter();
barreOutils.add(ajouterPersonneBouton);
barreOutils.add(new SeparatorToolItem());
personnesBoutonModifier = creerBoutonModifier();
barreOutils.add(personnesBoutonModifier);
barreOutils.add(new SeparatorToolItem());
personnesBoutonSupprimer = creerBoutonSupprimer();
barreOutils.add(personnesBoutonSupprimer);
barreOutils.add(new SeparatorToolItem());
Button rafraichirPersonneBouton = creerBoutonRafraichir();
barreOutils.add(rafraichirPersonneBouton);
return barreOutils;
}
 
private Button creerBoutonAjouter() {
Button bouton = new Button(i18nC.ajouter());
bouton.setIcon(Images.ICONES.vcardAjouter());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 
public void componentSelected(ButtonEvent ce) {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
fenetreFormulaire.show();
}
});
return bouton;
}
private Button creerBoutonModifier() {
Button bouton = new Button(i18nC.modifier());
bouton.setIcon(Images.ICONES.vcardModifier());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
CollectionAPersonne personneSaisiSelectionne = new CollectionAPersonne(grille.getSelection());
if (personneSaisiSelectionne == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne());
} else {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
fenetreFormulaire.show();
}
}
});
return bouton;
}
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
String personneId = null;
if (mode.equals(Formulaire.MODE_MODIFIER)) {
CollectionAPersonne personneSaisieSelectionnee = new CollectionAPersonne(grille.getSelection());
personneId = personneSaisieSelectionnee.getIdPersonne();
}
final FenetreForm fenetre = new FenetreForm("");
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
fenetre.add(formulaire);
return fenetre;
}
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, String personneId) {
PersonneForm formulaire = new PersonneForm(mediateur, personneId, this);
FormPanel panneauFormulaire = formulaire.getFormulaire();
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
panneauFormulaire.setHeaderVisible(false);
panneauFormulaire.setTopComponent(null);
 
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
panneauFormulaire.getBottomComponent().hide();
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulaire);
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
fenetre.setBottomComponent(barreValidation);
return formulaire;
}
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (formulaire.soumettreFormulaire()) {
fenetre.hide();
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
formulaire.soumettreFormulaire();
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fenetre.hide();
}
}
};
return ecouteur;
}
private Button creerBoutonSupprimer() {
Button bouton = new Button(i18nC.supprimer());
bouton.setIcon(Images.ICONES.vcardSupprimer());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
ModelData personneSaisiSelectionnee = grille.getSelection();
if (personneSaisiSelectionnee == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne());
} else {
supprimerDansGrille(personneSaisiSelectionnee);
}
}
});
return bouton;
}
private Button creerBoutonRafraichir() {
Button bouton = new Button(i18nC.rafraichir());
bouton.setIcon(Images.ICONES.rafraichir());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
actualiserGrille();
}
});
return bouton;
}
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPersonnesSaisies() {
ModelType modelTypePersonnes = new ModelType();
modelTypePersonnes.setRoot("personnes");
modelTypePersonnes.setTotalName("nbElements");
modelTypePersonnes.addField("cp_fmt_nom_complet");
modelTypePersonnes.addField("cp_id_personne");
modelTypePersonnes.addField("cp_nom");
modelTypePersonnes.addField("cp_prenom");
modelTypePersonnes.addField("cp_code_postal");
modelTypePersonnes.addField("cp_naissance_date");
modelTypePersonnes.addField("cp_naissance_lieu");
modelTypePersonnes.addField("cp_ce_deces");
modelTypePersonnes.addField("cp_deces_date");
modelTypePersonnes.addField("cp_deces_lieu");
String displayNamePersonnes = "cp_fmt_nom_complet";
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
recherchePersonnesCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
recherchePersonnesCombo.getCombo().setForceSelection(true);
recherchePersonnesCombo.getCombo().setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (recherchePersonnesCombo.getStore().findModel("cp_fmt_nom_complet", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
}
return retour;
}
});
recherchePersonnesCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if (personnesSaisisComboBox.getValeur() instanceof ModelData) {
Personne personneSaisiSelectionnee = new Personne(personnesSaisisComboBox.getValeur());
ajouterDansGrille(personneSaisiSelectionnee);
personnesSaisisComboBox.getCombo().setValue(null);
}
}
});
recherchePersonnesCombo.getCombo().setEmptyText("Rechercher et sélectionner une personne existante dans la base");
 
return recherchePersonnesCombo;
}
private void ajouterDansGrille(Personne personne) {
ajouterDansGrille(personne, null, 0);
}
private void ajouterDansGrille(Personne personne, String relation, int index) {
if (personne != null) {
CollectionAPersonne relationCollectionPersonne = new CollectionAPersonne();
relationCollectionPersonne.setPersonnePourGrillePaginable(personne);
relationCollectionPersonne.setIdPersonne(personne.getId());
relationCollectionPersonne.set("ccap_id_personne", personne.getId());
if (relation != null) {
relationCollectionPersonne.set("_role_", relation);
}
// Gestion de l'id de la collection
if (mode.equals(Formulaire.MODE_MODIFIER)) {
relationCollectionPersonne.setIdCollection(collection.getId());
}
relationCollectionPersonne.set("_etat_", aDonnee.ETAT_AJOUTE);
// FIXME besoin de ça ?
//corrigerChampsGrille(relationCollectionPersonne);
// Ajout à la grille
grille.getGrille().stopEditing();
grille.getGrille().getStore().insert(relationCollectionPersonne, index);
grille.getGrille().startEditing(index, 0);
grille.getGrille().getSelectionModel().select(index, false);
}
}
private void supprimerDansGrille(ModelData relationCollectionPersonne) {
CollectionAPersonne cap = new CollectionAPersonne(relationCollectionPersonne);
if (relationCollectionPersonne != null) {
// Ajout de la personne supprimée à la liste
if ((relationCollectionPersonne.get("_etat_") == null
|| relationCollectionPersonne.get("_etat_").equals("")
|| !relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
&& cap.getId() != null
&& !cap.getId().equals("")) {
personnesSupprimees.put("id"+idGenere++, cap);
}
grille.getStore().remove(relationCollectionPersonne);
}
}
 
private GrillePaginable<ModelData> creerGrille() {
// ModelType
ModelType modelTypeCollectionAPersonne = new ModelType();
modelTypeCollectionAPersonne.setRoot("collectionsAPersonne");
modelTypeCollectionAPersonne.setTotalName("nbElements");
modelTypeCollectionAPersonne.addField("cp_fmt_nom_complet");
modelTypeCollectionAPersonne.addField("cp_nom");
modelTypeCollectionAPersonne.addField("cp_prenom");
modelTypeCollectionAPersonne.addField("cp_code_postal");
modelTypeCollectionAPersonne.addField("cp_naissance_date");
modelTypeCollectionAPersonne.addField("cp_naissance_lieu");
modelTypeCollectionAPersonne.addField("cp_ce_deces");
modelTypeCollectionAPersonne.addField("cp_deces_date");
modelTypeCollectionAPersonne.addField("cp_deces_lieu");
modelTypeCollectionAPersonne.addField("ccap_id_collection");
modelTypeCollectionAPersonne.addField("ccap_id_personne");
modelTypeCollectionAPersonne.addField("ccap_id_role");
// Proxy
ProxyCollectionAPersonne<ModelData> proxyCollectionAPersonne = new ProxyCollectionAPersonne<ModelData>(null, collection.getId(), null);
 
// Colonnes
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
colonnes.add(new RowNumberer());
colonnes.add(creerColonneRole());
colonnes.add(new ColumnConfig("cp_fmt_nom_complet", i18nC.personneNomComplet(), 150));
colonnes.add(new ColumnConfig("cp_nom", i18nC.personneNom(), 75));
colonnes.add(new ColumnConfig("cp_prenom", i18nC.personnePrenom(), 75));
colonnes.add(new ColumnConfig("cp_naissance_date", i18nC.date(), 75));
colonnes.add(new ColumnConfig("cp_naissance_lieu", i18nC.lieu(), 100));
colonnes.add(creerColonneDeces());
colonnes.add(new ColumnConfig("cp_deces_date", i18nC.date(), 75));
colonnes.add(new ColumnConfig("cp_deces_lieu", i18nC.lieu(), 100));
// Modèle de colonnes
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
modeleDeColonnes.addHeaderGroup(0, 1, new HeaderGroupConfig(i18nC.personneIdentite(), 1, 4));
modeleDeColonnes.addHeaderGroup(0, 5, new HeaderGroupConfig(i18nC.personneNaissance(), 1, 2));
modeleDeColonnes.addHeaderGroup(0, 7, new HeaderGroupConfig(i18nC.personneDeces(), 1, 3));
HashMap<String, String> virtualFields = new HashMap<String, String>();
virtualFields.put("_role_", "ccap_id_role");
virtualFields.put("_etat_", "");
// Grille
GrillePaginable<ModelData> grillePaginable = new GrillePaginable<ModelData>(modelTypeCollectionAPersonne, virtualFields, proxyCollectionAPersonne, colonnes, modeleDeColonnes);
// Rajouter des écouteurs
grillePaginable.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
if (ce.getRecord().isModified("_role_") && ce.getModel().get("_etat_") == null || !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
}
}
});
return grillePaginable;
}
private ColumnConfig creerColonneRole() {
typeRelationCombo = new ComboBox<Valeur>();
typeRelationCombo.setForceSelection(true);
typeRelationCombo.setTriggerAction(TriggerAction.ALL);
typeRelationCombo.setDisplayField("nom");
typeRelationCombo.setStore(new ListStore<Valeur>());
typeRelationCombo.setEditable(false);
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE);
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire());
 
CellEditor editeurRelation = new CellEditor(typeRelationCombo) {
// Sert à retourner un ModelData à partir d'une String (la string est passée par le Renderer)
public Object preProcessValue(Object valeur) {
Valeur retour = null;
if (valeur != null ) {
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) {
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString());
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) {
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString());
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) {
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString());
}
}
return retour;
}
// Sert à retourner un String à Partir d'une Valeur
// en postProcess on remplace la valeur du champ par l'Id de la valeur au lieu de son Nom
public Object postProcessValue(Object valeur) {
String retour = null;
if (valeur != null ) {
if (valeur instanceof Valeur) {
Valeur valeurOntologie = (Valeur) valeur;
String id = valeurOntologie.getId();
retour = id;
}
}
return retour;
}
};
// Sert à afficher le nom du role au lieu de l'id
GridCellRenderer<ModelData> relationRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grille) {
// Gestion du texte afficher dans la cellule
String role = modele.get("_role_");
if (typeRelationCombo.getStore() != null && typeRelationCombo.getStore().getCount() > 0 && role.matches("[0-9]+")) {
role = typeRelationCombo.getStore().findModel("id_valeur", role).getNom();
}
return role;
}
};
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonneCollection(), 75);
typeRelationColonne.setEditor(editeurRelation);
typeRelationColonne.setRenderer(relationRendu);
return typeRelationColonne;
}
public ColumnConfig creerColonneDeces() {
GridCellRenderer<ModelData> decesRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
CollectionAPersonne cap = new CollectionAPersonne(modele);
String deces = cap.getPersonne().getDeces();
deces = deces.equals("0") ? "" : deces;
if (listeIon != null && cap.getPersonne().getDeces().matches("[0-9]+")) {
Valeur valeurDeces = listeIon.findModel("id_valeur", cap.getPersonne().getDeces());
if(valeurDeces != null) {
deces = valeurDeces.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) {
personnesBoutonSupprimer.enable();
personnesBoutonModifier.enable();
}
// Désactivation des boutons si la grille ne contient plus d'élément
if (grille.getStore().getCount() == 0) {
personnesBoutonSupprimer.disable();
personnesBoutonModifier.disable();
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
private void rafraichirValeurListe(ValeurListe listeValeurs) {
if (listeValeurs.getId().equals(config.getListeId("ion"))) {
listeIon = new ListStore<Valeur>();
listeIon.add(listeValeurs.toList());
} 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);
}
}
public void rafraichirInformation(Information info) {
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
}
String type = info.getType();
if (info.getType().equals("liste_collection_a_personne")) {
if (info.getDonnee(0) != null) {
collection.setPersonnesLiees((CollectionAPersonneListe) info.getDonnee(0));
}
} 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 if (type.equals("personne_modifiee")) {
if (info.getDonnee(0) != null) {
Personne personne = (Personne) info.getDonnee(0);
ModelData personneDansGrille = grille.getStore().findModel("ccap_id_personne", personne.getId());
int index = grille.getStore().indexOf(personneDansGrille);
grille.getStore().remove(personneDansGrille);
String role = "";
if(personneDansGrille != null) {
role = (String) personneDansGrille.get("_role_");
}
ajouterDansGrille(personne, role, index);
}
} else if (type.equals("personne_ajoutee")) {
if (info.getDonnee(0) != null) {
Personne personne = (Personne) info.getDonnee(0);
ajouterDansGrille(personne);
}
} else if (info.getType().equals("modif_collection_a_personne")) {
InfoLogger.display("Modification des personnes liées à la collection", info.toString());
} else if (info.getType().equals("suppression_collection_a_personne")) {
InfoLogger.display("Suppression des personnes liées à la collection", info.toString());
actualiserGrille();
} else if (info.getType().equals("ajout_collection_a_personne")) {
InfoLogger.display("Ajout des personnes liées à la collection", info.toString());
}
}
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++) {
if (grille.getStore().getAt(i).get("_role_").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() {
if (etreAccede()) {
int nbrePersonne = grille.getStore().getCount();
for (int i = 0; i < nbrePersonne; i++) {
CollectionAPersonne relationCollectionPersonne = new CollectionAPersonne(grille.getStore().getAt(i));
relationCollectionPersonne.set("_role_", grille.getStore().getAt(i).get("_role_"));
if (grille.getStore().getAt(i).get("_etat_") != null) {
if (grille.getStore().getAt(i).get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
personnesSupprimees.put("id"+idGenere++, relationCollectionPersonne);
CollectionAPersonne relationAAjouter = (CollectionAPersonne) relationCollectionPersonne.cloner(new CollectionAPersonne());
corrigerChampsGrille(relationAAjouter);// Nous modifions l'id_role
personnesAjoutees.put("id"+idGenere++, relationAAjouter);
}
if (grille.getStore().getAt(i).get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
corrigerChampsGrille(relationCollectionPersonne);// Nous modifions l'id_role
personnesAjoutees.put("id"+idGenere++, relationCollectionPersonne);
}
// Initialisation de la grille
grille.getStore().getAt(i).set("_etat_", "");
}
}
grille.getStore().commitChanges();
}
}
private void corrigerChampsGrille(CollectionAPersonne relationCollectionPersonne) {
String role = relationCollectionPersonne.get("_role_");
String champModele = "nom";
if (role.matches("[0-9]+")) {
champModele = "id_valeur";
}
 
if (typeRelationCombo.getStore().findModel(champModele, role) != null) {
String idRole = typeRelationCombo.getStore().findModel(champModele, role).getId();
relationCollectionPersonne.setIdRole(idRole);
}
}
 
public void soumettre() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
if (personnesAjoutees.size() == 0 && personnesSupprimees.size() == 0) {
//InfoLogger.display("Modification des personnes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
} else {
// 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 actualiserGrille() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerCollectionAPersonne(this, collection.getId(), null, null);
} else {
grille.getStore().removeAll();
layout();
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java
New file
0,0 → 1,621
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.GrillePaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPublication;
import org.tela_botanica.client.composants.pagination.ProxyPublications;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.vues.FenetreForm;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireBarreValidation;
import org.tela_botanica.client.vues.FormulaireOnglet;
import org.tela_botanica.client.vues.publication.PublicationForm;
 
import com.extjs.gxt.ui.client.core.XTemplate;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
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.Store;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Text;
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.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Validator;
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.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.RowExpander;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
 
public class CollectionFormPublication extends FormulaireOnglet implements Rafraichissable {
public static final String ID = "publication";
private Collection collection = null;
private static int idGenere = 1;
private ContentPanel panneauPrincipal = null;
private ToolBar barreOutils = null;
private GrillePaginable<ModelData> grille;
private CollectionAPublicationListe publicationsAjoutees = null;
private CollectionAPublicationListe publicationsSupprimees = null;
private CollectionAPublicationListe publicationsModifiees = null;
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null;
private Button publicationsBoutonSupprimer = null;
private Button publicationsBoutonModifier = null;
private FenetreForm fenetreFormulaire = null;
public boolean publicationsSontModifiees = false;
public CollectionFormPublication(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setId(ID);
setText(Mediateur.i18nC.collectionPublication());
setStyleAttribute("padding", "0");
initialiser();
panneauPrincipal = creerPanneauContenantGrille();
setLayout(new FitLayout());
barreOutils = creerBarreOutilsGrille();
panneauPrincipal.setTopComponent(barreOutils);
grille = creerGrille();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.add(grille);
add(panneauPrincipal);
}
private void initialiser() {
// Remise à zéro des modification dans la liste des auteurs
idGenere = 1;
publicationsAjoutees = new CollectionAPublicationListe();
publicationsSupprimees = new CollectionAPublicationListe();
publicationsModifiees = new CollectionAPublicationListe();
collection = ((CollectionForm) formulaire).collection;
}
private ContentPanel creerPanneauContenantGrille() {
ContentPanel panneau = new ContentPanel();
panneau.setHeadingHtml(i18nC.collectionPublicationTitre());
panneau.setIcon(Images.ICONES.table());
panneau.setLayout(new FitLayout());
panneau.setFrame(true);
return panneau;
}
 
private ToolBar creerBarreOutilsGrille() {
ToolBar barreOutils = new ToolBar();
 
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis();
barreOutils.add(publicationsSaisiesComboBox);
barreOutils.add(new Text(" ou "));
 
Button ajouterBouton = creerBoutonAjouter();
barreOutils.add(ajouterBouton);
barreOutils.add(new SeparatorToolItem());
publicationsBoutonModifier = creerBoutonModifier();
barreOutils.add(publicationsBoutonModifier);
barreOutils.add(new SeparatorToolItem());
publicationsBoutonSupprimer = creerBoutonSupprimer();
barreOutils.add(publicationsBoutonSupprimer);
barreOutils.add(new SeparatorToolItem());
 
return barreOutils;
}
 
private Button creerBoutonAjouter() {
Button bouton = new Button(i18nC.ajouter());
bouton.setIcon(Images.ICONES.vcardAjouter());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
fenetreFormulaire = creerFenetreModaleAvecFormulairePublication(Formulaire.MODE_AJOUTER);
fenetreFormulaire.show();
}
});
return bouton;
}
private Button creerBoutonModifier() {
Button bouton = new Button(i18nC.modifier());
bouton.setIcon(Images.ICONES.vcardModifier());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
ModelData publicationSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
if (publicationSaisieSelectionnee == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
} else {
fenetreFormulaire = creerFenetreModaleAvecFormulairePublication(Formulaire.MODE_MODIFIER);
fenetreFormulaire.show();
}
}
});
return bouton;
}
private FenetreForm creerFenetreModaleAvecFormulairePublication(String mode) {
String publicationId = null;
if (mode.equals(Formulaire.MODE_MODIFIER)) {
CollectionAPublication publicationSaisiSelectionne = new CollectionAPublication(grille.getGrille().getSelectionModel().getSelectedItem(), false);
publicationId = publicationSaisiSelectionne.getIdPublication();
}
final FenetreForm fenetre = new FenetreForm("");
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId);
fenetre.add(formulaire);
return fenetre;
}
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) {
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this);
FormPanel panneauFormulaire = formulairePublication.getFormulaire();
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
panneauFormulaire.setHeaderVisible(false);
panneauFormulaire.setTopComponent(null);
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
panneauFormulaire.getBottomComponent().hide();
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication);
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
fenetre.setBottomComponent(barreValidation);
return formulairePublication;
}
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (formulaire.soumettreFormulaire()) {
fenetre.hide();
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
formulaire.soumettreFormulaire();
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fenetre.hide();
}
}
};
return ecouteur;
}
private Button creerBoutonSupprimer() {
Button bouton = new Button(i18nC.supprimer());
bouton.setIcon(Images.ICONES.vcardSupprimer());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
List<ModelData> listeDonneesSelectionnees = grille.getGrille().getSelectionModel().getSelectedItems();
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
CollectionAPublication publicationSaisieSelectionnee = new CollectionAPublication(grille.getGrille().getSelectionModel().getSelectedItem(), false);
supprimerDansGrille(publicationSaisieSelectionnee, donneeSelectionnee);
}
}
});
return bouton;
}
 
private void actualiserGrille() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerCollectionAPublication(this, collection.getId(), null);
} else {
grille.getStore().removeAll();
layout();
}
}
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() {
ModelType modelTypePublications = new ModelType();
modelTypePublications.setRoot("publications");
modelTypePublications.setTotalName("nbElements");
modelTypePublications.addField("ccapu_id_collection");
modelTypePublications.addField("ccapu_id_publication");
modelTypePublications.addField("ccapu_source");
modelTypePublications.addField("cc_nom");
modelTypePublications.addField("cc_id_collection");
modelTypePublications.addField("cpu_id_publication");
modelTypePublications.addField("cpu_fmt_nom_complet");
modelTypePublications.addField("cpu_titre");
modelTypePublications.addField("cpu_nom");
modelTypePublications.addField("cpu_fmt_auteur");
modelTypePublications.addField("cpu_indication_nvt");
modelTypePublications.addField("cpu_truk_pages");
modelTypePublications.addField("cpu_fascicule");
modelTypePublications.addField("cpu_date_parution");
modelTypePublications.addField("cpu_ce_truk_editeur");
String displayNamePublications = "cpu_fmt_nom_complet";
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null);
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications);
publicationsCombo.getCombo().setTabIndex(tabIndex++);
publicationsCombo.getCombo().setForceSelection(true);
publicationsCombo.getCombo().setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
}
return retour;
}
});
publicationsCombo.getCombo().setEmptyText("Rechercher et sélectionner une publication existante dans la base");
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) {
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur(), false);
ajouterDansGrille(publicationSaisieSelectionne);
publicationsSaisiesComboBox.getCombo().setValue(null);
}
}
});
return publicationsCombo;
}
private void ajouterDansGrille(Publication publication) {
ajouterDansGrille(publication, 0);
}
private void ajouterDansGrille(Publication publication, int index) {
if (publication != null) {
CollectionAPublication publicationLiee = new CollectionAPublication(false);
publicationLiee.setPublication(publication);
publicationLiee.setIdPublication(publication.getId());
// Gestion de l'id de la collection
if (mode.equals(Formulaire.MODE_MODIFIER)) {
publicationLiee.setIdCollection(collection.getId());
}
// ajout au cache si nécessaire
if(!Publication.publisSaisiesModifieesCache.containsKey(publication.getId())) {
Publication.publisSaisiesModifieesCache.put(publication.getId(), publication);
}
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
grille.getGrille().stopEditing();
grille.getGrille().getStore().insert(publicationLiee, index);
grille.getGrille().startEditing(index, 0);
grille.getGrille().getSelectionModel().select(index, false);
}
}
private void supprimerDansGrille(CollectionAPublication publicationLiee, ModelData publicationLieeModele) {
if (publicationLiee != null) {
// Ajout de la personne supprimée à la liste
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
&& publicationLiee.getId() != null
&& !publicationLiee.getId().equals("")) {
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
}
// Suppression de l'enregistrement de la grille
grille.getStore().remove(publicationLieeModele);
}
}
private GrillePaginable<ModelData> creerGrille() {
GrillePaginable<ModelData> grillePublications = null;
// ModelType
ModelType modelTypeCollectionAPublication = new ModelType();
modelTypeCollectionAPublication.setRoot("collectionsAPublication");
modelTypeCollectionAPublication.setTotalName("nbElements");
modelTypeCollectionAPublication.addField("ccapu_id_collection");
modelTypeCollectionAPublication.addField("ccapu_id_publication");
modelTypeCollectionAPublication.addField("ccapu_source");
modelTypeCollectionAPublication.addField("ccapu_mark_licence");
modelTypeCollectionAPublication.addField("cpu_id_publication");
modelTypeCollectionAPublication.addField("cpu_fmt_auteur");
modelTypeCollectionAPublication.addField("cpu_titre");
modelTypeCollectionAPublication.addField("cpu_collection");
modelTypeCollectionAPublication.addField("cpu_ce_truk_editeur");
modelTypeCollectionAPublication.addField("cpu_date_parution");
modelTypeCollectionAPublication.addField("cpu_fascicule");
modelTypeCollectionAPublication.addField("cpu_truk_pages");
modelTypeCollectionAPublication.addField("cpu_indication_nvt");
// Proxy
ProxyCollectionAPublication<ModelData> proxyCollectionAPublication = new ProxyCollectionAPublication<ModelData>(null, collection.getId());
 
// Colonnes
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
RowNumberer numeroPlugin = new RowNumberer();
numeroPlugin.setHeaderHtml("#");
XTemplate infoTpl = XTemplate.create("<p>"+
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {cpu_fmt_auteur}<br />"+
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {cpu_titre}<br />"+
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {cpu_collection}<br />"+
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+
"</p>");
RowExpander expansionPlugin = new RowExpander();
expansionPlugin.setTemplate(infoTpl);
colonnes.add(expansionPlugin);
ColumnConfig sourceColonne = new ColumnConfig("ccapu_source", i18nC.collectionPublicationSource(), 60);
sourceColonne.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<ModelData> store, Grid<ModelData> grid) {
CheckBox cbSource = new CheckBox();
boolean source = model.get("ccapu_source") != null && model.get("ccapu_source").equals("1");
Publication publiFromCache = Publication.publisSaisiesModifieesCache.get((new CollectionAPublication(model, false)).getPublication().getId());
if(publiFromCache != null) {
source = publiFromCache.get("ccapu_source") != null && publiFromCache.get("ccapu_source").equals("1");
}
cbSource.setValue(source);
 
final Integer ligne = rowIndex;
final ModelData ceModele = model;
cbSource.addListener(Events.Change, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
String estSource = ((CheckBox)be.getSource()).getValue() ? "1" : "0";
ceModele.set("ccapu_source", estSource);
if (!(ceModele.get("_etat_") != null && ceModele.get("_etat_").equals(aDonnee.ETAT_AJOUTE))) {
ceModele.set("_etat_", aDonnee.ETAT_MODIFIE);
}
grille.getStore().commitChanges();
}
});
return cbSource;
}
});
colonnes.add(sourceColonne);
colonnes.add(numeroPlugin);
colonnes.add(new ColumnConfig("cpu_fmt_auteur", i18nC.publicationAuteurs(), 135));
colonnes.add(new ColumnConfig("cpu_titre", i18nC.publicationTitre(), 135));
colonnes.add(new ColumnConfig("cpu_collection", i18nC.publicationRevueCollection(), 100));
colonnes.add(creerColonneEditeur());
colonnes.add(creerColonneAnneePublication());
colonnes.add(new ColumnConfig("cpu_indication_nvt", i18nC.publicationNvt(), 75));
colonnes.add(new ColumnConfig("cpu_fascicule", i18nC.publicationFascicule(), 70));
colonnes.add(new ColumnConfig("cpu_truk_pages", i18nC.publicationPage(), 50));
HashMap<String, String> virtualFields = new HashMap<String, String>();
virtualFields.put("_editeur_", "cpu_ce_truk_editeur");
virtualFields.put("_annee_", "cpu_date_parution");
virtualFields.put("_etat_", "");
// Modele de selection
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info");
// Grille
grillePublications = new GrillePaginable<ModelData>(modelTypeCollectionAPublication, virtualFields, proxyCollectionAPublication, colonnes, modeleDeColonnes);
grillePublications.getGrille().setBorders(true);
grillePublications.getGrille().setSelectionModel(modeleDeSelection);
grillePublications.getGrille().addPlugin(expansionPlugin);
grillePublications.getGrille().addPlugin(numeroPlugin);
grillePublications.getGrille().getView().setForceFit(true);
grillePublications.getGrille().setAutoExpandColumn("titre");
grillePublications.getGrille().setStripeRows(true);
grillePublications.getGrille().setTrackMouseOver(true);
// Rajouter des écouteurs
grillePublications.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
actualiserEtatBoutonsBarreOutils();
}
});
grillePublications.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
actualiserEtatBoutonsBarreOutils();
}
});
return grillePublications;
}
private ColumnConfig creerColonneEditeur() {
GridCellRenderer<ModelData> editeurRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
String editeur = (new CollectionAPublication(model, false)).getPublication().getNomEditeur();
// Des fois l'éditeur est vide, là intervient le caché fabriqué dans publication
if(editeur.isEmpty() && Publication.publisSaisiesModifieesCache.containsKey((new CollectionAPublication(model, false)).getPublication().getId())) {
editeur = Publication.publisSaisiesModifieesCache.get((new CollectionAPublication(model, false)).getPublication().getId()).getNomEditeur();
}
model.set("_editeur_", editeur);
return editeur;
}
};
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 130);
editeurColonne.setRenderer(editeurRendu);
return editeurColonne;
}
private ColumnConfig creerColonneAnneePublication() {
GridCellRenderer<ModelData> datePublicationRendu = new GridCellRenderer<ModelData>() {
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
String annee = (new CollectionAPublication(model, false)).getPublication().getAnneeParution();
if(annee.isEmpty() && Publication.publisSaisiesModifieesCache.containsKey((new CollectionAPublication(model, false)).getPublication().getId())) {
annee = Publication.publisSaisiesModifieesCache.get((new CollectionAPublication(model, false)).getPublication().getId()).getAnneeParution();
}
model.set("_annee_", annee);
return annee;
}
};
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 40);
datePublicationColonne.setRenderer(datePublicationRendu);
return datePublicationColonne;
}
 
public void actualiserEtatBoutonsBarreOutils() {
// Activation des boutons si la grille contient un élément
if (grille.getStore().getCount() > 0) {
publicationsBoutonSupprimer.enable();
publicationsBoutonModifier.enable();
}
// Désactivation des boutons si la grille ne contient plus d'élément
if (grille.getStore().getCount() == 0) {
publicationsBoutonSupprimer.disable();
publicationsBoutonModifier.disable();
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
public void rafraichirInformation(Information info) {
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
}
String type = info.getType();
if (type.equals("liste_collection_a_publication")) {
if (info.getDonnee(0) != null) {
initialiser();
collection.setPublicationsLiees((CollectionAPublicationListe) 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 publications liées
// En mode AJOUT, il ne peut que y avoir des publications liées ajoutées
mediateur.ajouterCollectionAPublication(this, collectionId, publicationsAjoutees);
}
} else if (type.equals("publication_modifiee")) {
if (info.getDonnee(0) != null) {
Publication publication = (Publication) info.getDonnee(0);
ModelData publicationDansGrille = null;
publicationDansGrille = grille.getStore().findModel("cpu_id_publication", publication.getId());
publication.set("ccapu_source", publicationDansGrille.get("ccapu_source"));
int index = grille.getStore().indexOf(publicationDansGrille);
grille.getStore().remove(publicationDansGrille);
ajouterDansGrille(publication, index);
}
} else if (type.equals("publication_ajoutee")) {
if (info.getDonnee(0) != null) {
Publication publication = (Publication) info.getDonnee(0);
ajouterDansGrille(publication);
}
} else if (type.equals("suppression_collection_a_publication")) {
InfoLogger.display("Suppression des publications liées à la collection", info.toString());
} else if (type.equals("ajout_collection_a_publication")) {
InfoLogger.display("Ajout des publications liées à la collection", info.toString());
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null);
}
}
 
public void peupler() {
grille.getStore().removeAll();
grille.getStore().add(collection.getPublicationsLiees().toList());
layout();
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok());
}
 
public void collecter() {
if (etreAccede()) {
int nbrePublication = grille.getStore().getCount();
for (int i = 0; i < nbrePublication; i++) {
ModelData publicationLiee = grille.getStore().getAt(i);
CollectionAPublication cap = new CollectionAPublication(grille.getStore().getAt(i), false);
if (publicationLiee.get("_etat_") != null) {
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
publicationsModifiees.put(cap.getIdPublication(), cap);
}
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
publicationsAjoutees.put("id"+idGenere++, cap);
}
// Initialisation de la grille
publicationLiee.set("_etat_", "");
}
}
grille.getStore().commitChanges();
}
}
public void soumettre() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0 && publicationsModifiees.size() == 0) {
//InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
} else {
//Window.alert(publicationsAjoutees.size()+" | "+publicationsSupprimees.size()+" | "+publicationsModifiees.size());
publicationsSontModifiees = true;
// Ajout des relations CollectionAPublication
if (publicationsAjoutees.size() != 0) {
mediateur.ajouterCollectionAPublication(this, collection.getId(), publicationsAjoutees);
}
// Modification des relations CollectionAPublication
if (publicationsModifiees.size() != 0) {
mediateur.modifierCollectionAPublication(this, publicationsModifiees);
}
// Suppression des relations CollectionAPublication
if (publicationsSupprimees.size() != 0) {
mediateur.supprimerCollectionAPublication(this, publicationsSupprimees);
}
}
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java:r1136-1368
Merged /branches/v1.8-narince/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java:r1891-1892
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java
New file
0,0 → 1,278
package org.tela_botanica.client.vues.collection;
 
import java.util.HashMap;
import java.util.Iterator;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampCaseACocher;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.ChampSliderPourcentage;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionBotanique;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
 
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.layout.FormData;
 
public class CollectionFormContenu extends FormulaireOnglet implements Rafraichissable {
public static final String ID = "contenu";
private Collection collection = null;
private CollectionBotanique collectionBotanique = null;
private Collection collectionCollectee = null;
private CollectionBotanique collectionBotaniqueCollectee = null;
private ChampCaseACocher natureChp = null;
private TextArea specialiteChp = null;
private TextArea annotationClassementChp = null;
private ChampComboBoxListeValeurs etatClassementCombo = null;
private ChampComboBoxListeValeurs precisionDateCombo = null;
private ChampComboBoxListeValeurs precisionLocaliteCombo = null;
private TextArea etiquetteAnnotationChp = null;
private ChampComboBoxListeValeurs integreCollectionCombo = null;
private ChampComboBoxListeValeurs infoIntegreCollectionCombo = null;
private ChampSliderPourcentage auteurTitrePourcentChp;
private ChampSliderPourcentage famillePourcentChp;
private ChampSliderPourcentage genrePourcentChp;
private ChampSliderPourcentage spPourcentChp;
private ChampSliderPourcentage auteurSpPourcentChp;
private ChampSliderPourcentage localitePourcentChp;
private ChampSliderPourcentage datePourcentChp;
 
public CollectionFormContenu(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setId(ID);
setText(Mediateur.i18nC.collectionContenu());
creerFieldsetNature();
// TODO : réaliser un champ couverture géographique détaillé
creerFieldsetClassement();
creerFieldsetEtiquette();
creerFieldsetIntegration();
}
private void creerFieldsetNature() {
FieldSet natureFieldSet = new FieldSet();
natureFieldSet.setHeadingHtml(i18nC.collectionNatureTitre());
natureFieldSet.setCollapsible(true);
natureFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
natureChp = new ChampCaseACocher(i18nC.natureVegetaleContenu(), "natureVegetale", false);
natureFieldSet.add(natureChp);
specialiteChp = new TextArea();
specialiteChp.setFieldLabel(i18nC.specialiteCollection());
specialiteChp.setToolTip(i18nC.specialiteCollectionInfo());
natureFieldSet.add(specialiteChp, new FormData(550, 0));
add(natureFieldSet);
}
 
private void creerFieldsetClassement() {
FieldSet classementFieldSet = new FieldSet();
classementFieldSet.setHeadingHtml(i18nC.collectionClassementTitre());
classementFieldSet.setCollapsible(true);
classementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
 
etatClassementCombo = new ChampComboBoxListeValeurs(i18nC.etatClassementCollection(), "etatClassement", tabIndex++);
classementFieldSet.add(etatClassementCombo, new FormData(550, 0));
 
annotationClassementChp = new TextArea();
annotationClassementChp.setFieldLabel(i18nC.annotationClassementCollection());
classementFieldSet.add(annotationClassementChp, new FormData(550, 0));
Text infoClassement = new Text(i18nC.annotationClassementCollectionInfo());
classementFieldSet.add(infoClassement);
add(classementFieldSet);
}
private void creerFieldsetEtiquette() {
FieldSet etiquetteFieldSet = new FieldSet();
etiquetteFieldSet.setHeadingHtml(i18nC.collectionEtiquetteTitre());
etiquetteFieldSet.setCollapsible(true);
etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
Text renseignementPoucentLabel = new Text(i18nC.renseignementEtiquetteCollection());
renseignementPoucentLabel.setTagName("label");
renseignementPoucentLabel.setStyleName("x-form-item-label");
etiquetteFieldSet.add(renseignementPoucentLabel);
auteurTitrePourcentChp = new ChampSliderPourcentage(i18nC.auteurTitrePourcentCollection());
etiquetteFieldSet.add(auteurTitrePourcentChp, new FormData(200, 0));
famillePourcentChp = new ChampSliderPourcentage(i18nC.famillePourcentCollection());
etiquetteFieldSet.add(famillePourcentChp, new FormData(200, 0));
genrePourcentChp = new ChampSliderPourcentage(i18nC.genrePourcentCollection());
etiquetteFieldSet.add(genrePourcentChp, new FormData(200, 0));
spPourcentChp = new ChampSliderPourcentage(i18nC.spPourcentCollection());
etiquetteFieldSet.add(spPourcentChp, new FormData(200, 0));
auteurSpPourcentChp = new ChampSliderPourcentage(i18nC.auteurSpPourcentCollection());
etiquetteFieldSet.add(auteurSpPourcentChp, new FormData(200, 0));
localitePourcentChp = new ChampSliderPourcentage(i18nC.localitePourcentCollection());
etiquetteFieldSet.add(localitePourcentChp, new FormData(200, 0));
datePourcentChp = new ChampSliderPourcentage(i18nC.datePourcentCollection());
etiquetteFieldSet.add(datePourcentChp, new FormData(200, 0));
precisionLocaliteCombo = new ChampComboBoxListeValeurs(i18nC.precisionLocaliteCollection(), "onep", tabIndex++);
etiquetteFieldSet.add(precisionLocaliteCombo);
precisionDateCombo = new ChampComboBoxListeValeurs(i18nC.precisionDateCollection(), "onep", tabIndex++);
etiquetteFieldSet.add(precisionDateCombo);
 
etiquetteAnnotationChp = new TextArea();
etiquetteAnnotationChp.setFieldLabel(i18nC.etiquetteAnnotationCollection());
etiquetteAnnotationChp.setToolTip(i18nC.etiquetteAnnotationCollectionInfo());
etiquetteFieldSet.add(etiquetteAnnotationChp, new FormData(550, 0));
add(etiquetteFieldSet);
}
private String collecterEtiquetteRenseignement() {
String renseignement = "";
renseignement += creerTypeValeur("AT", auteurTitrePourcentChp.getValeur());
renseignement += creerTypeValeur("F", famillePourcentChp.getValeur());
renseignement += creerTypeValeur("G", genrePourcentChp.getValeur());
renseignement += creerTypeValeur("SP", spPourcentChp.getValeur());
renseignement += creerTypeValeur("ASP", auteurSpPourcentChp.getValeur());
renseignement += creerTypeValeur("L", localitePourcentChp.getValeur());
renseignement += creerTypeValeur("D", datePourcentChp.getValeur());
renseignement = renseignement.replaceFirst(aDonnee.SEPARATEUR_VALEURS+"$", "");
return renseignement;
}
private String creerTypeValeur(String type, String valeur) {
String retour = "";
if (!UtilString.isEmpty(valeur)) {
retour = type+aDonnee.SEPARATEUR_TYPE_VALEUR+valeur+aDonnee.SEPARATEUR_VALEURS;
}
return retour;
}
private void peuplerEtiquetteRenseignement(String valeurTruk) {
HashMap<String,String> infos = parserEtiquetteRenseignement(valeurTruk);
if (infos != null) {
Iterator<String> it = infos.keySet().iterator();
while (it.hasNext()) {
String cle = it.next();
if (cle.equals("AT")) {
auteurTitrePourcentChp.peupler(infos.get(cle));
} else if (cle.equals("F")) {
famillePourcentChp.peupler(infos.get(cle));
} else if (cle.equals("G")) {
genrePourcentChp.peupler(infos.get(cle));
} else if (cle.equals("SP")) {
spPourcentChp.peupler(infos.get(cle));
} else if (cle.equals("ASP")) {
auteurSpPourcentChp.peupler(infos.get(cle));
} else if (cle.equals("L")) {
localitePourcentChp.peupler(infos.get(cle));
} else if (cle.equals("D")) {
datePourcentChp.peupler(infos.get(cle));
}
}
}
}
public static HashMap<String,String> parserEtiquetteRenseignement(String valeurTruk) {
HashMap<String,String> infos = null;
if (!UtilString.isEmpty(valeurTruk)) {
infos = new HashMap<String,String>();
String[] pourcentages = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS));
for (int i = 0; i < pourcentages.length; i++) {
String[] pourcentageIdValeur = pourcentages[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR));
String id = pourcentageIdValeur[0];
String valeur = pourcentageIdValeur[1];
infos.put(id, valeur);
}
}
return infos;
}
private void creerFieldsetIntegration() {
FieldSet integrationFieldSet = new FieldSet();
integrationFieldSet.setHeadingHtml(i18nC.collectionIntegreeTitre());
integrationFieldSet.setCollapsible(true);
integrationFieldSet.setLayout(Formulaire.creerFormLayout(350, alignementLabelDefaut));
integreCollectionCombo = new ChampComboBoxListeValeurs(i18nC.integreCollection(), "onpi", tabIndex++);
integrationFieldSet.add(integreCollectionCombo);
infoIntegreCollectionCombo = new ChampComboBoxListeValeurs(i18nC.infoIntegreCollection(), "onp", tabIndex++);
integrationFieldSet.add(infoIntegreCollectionCombo);
Text infoIntegration = new Text(i18nC.infoIntegrationCollection());
integrationFieldSet.add(infoIntegration);
add(integrationFieldSet);
}
public void peupler() {
initialiserCollection();
if (collectionBotanique != null) {
natureChp.peupler(collectionBotanique.getNature());
specialiteChp.setValue(collectionBotanique.getSpecialite());
etatClassementCombo.peupler(collectionBotanique.getClassementEtat());
annotationClassementChp.setValue(collectionBotanique.getClassementAnnotation());
peuplerEtiquetteRenseignement(collectionBotanique.getEtiquetteRenseignement());
precisionLocaliteCombo.peupler(collectionBotanique.getPrecisionLocalite());
precisionDateCombo.peupler(collectionBotanique.getPrecisionDate());
etiquetteAnnotationChp.setValue(collectionBotanique.getAnnotationsDiverses());
integreCollectionCombo.peupler(collectionBotanique.getCollectionIntegre());
infoIntegreCollectionCombo.peupler(collectionBotanique.getCollectionIntegreInfo());
}
}
public void collecter() {
initialiserCollection();
if (etreAccede()) {
collectionBotaniqueCollectee.setNature(natureChp.getValeur());
collectionBotaniqueCollectee.setSpecialite(specialiteChp.getValue());
collectionBotaniqueCollectee.setClassementEtat(etatClassementCombo.getValeur());
collectionBotaniqueCollectee.setClassementAnnotation(annotationClassementChp.getValue());
collectionBotaniqueCollectee.setEtiquetteRenseignement(collecterEtiquetteRenseignement());
collectionBotaniqueCollectee.setPrecisionLocalite(precisionLocaliteCombo.getValeur());
collectionBotaniqueCollectee.setPrecisionDate(precisionDateCombo.getValeur());
collectionBotaniqueCollectee.setAnnotationsDiverses(etiquetteAnnotationChp.getValue());
collectionBotaniqueCollectee.setCollectionIntegre(integreCollectionCombo.getValeur());
collectionBotaniqueCollectee.setCollectionIntegreInfo(infoIntegreCollectionCombo.getValeur());
}
}
private void initialiserCollection() {
collection = ((CollectionForm) formulaire).collection;
if (collection != null) {
collectionBotanique = collection.getBotanique();
}
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee;
if (collectionCollectee != null) {
collectionBotaniqueCollectee = collectionCollectee.getBotanique();
}
}
public void rafraichir(Object nouvellesDonnees) {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionVue.java
New file
0,0 → 1,68
package org.tela_botanica.client.vues.collection;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.user.client.Window;
 
public class CollectionVue extends LayoutContainer implements Rafraichissable {
 
private Mediateur mediateur = null;
private CollectionListeVue listeCollectionPanneau = null;
private CollectionDetailVue detailCollectionPanneau = null;
 
private Sequenceur sequenceur = new Sequenceur();
public CollectionVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
BorderLayout layout = new BorderLayout();
layout.setEnableState(false);
setLayout(layout);
 
listeCollectionPanneau = new CollectionListeVue(mediateur);
add(listeCollectionPanneau, new BorderLayoutData(LayoutRegion.CENTER));
detailCollectionPanneau = new CollectionDetailVue(mediateur, sequenceur);
BorderLayoutData dispositionSud = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000);
dispositionSud.setSplit(true);
dispositionSud.setMargins(new Margins(5, 0, 0, 0));
add(detailCollectionPanneau, dispositionSud);
}
 
public void rafraichir(Object nouvellesDonnees) {
// Nous passons l'objet aux méthodes rafraichir des panneaux composant le panneau principal Structure
if (nouvellesDonnees instanceof Collection) {
detailCollectionPanneau.rafraichir(nouvellesDonnees);
} else if (nouvellesDonnees instanceof CollectionListe) {
listeCollectionPanneau.rafraichir(nouvellesDonnees);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("liste_collection_a_personne")
|| info.getType().equals("liste_collection_a_publication")
|| info.getType().equals("liste_collection_a_commentaire")) {
detailCollectionPanneau.rafraichir(nouvellesDonnees);
} else if (info.getType().equals("suppression_collection")) {
listeCollectionPanneau.rafraichir(nouvellesDonnees);
} else if (info.getType().equals("modif_collection")) {
listeCollectionPanneau.rafraichir(nouvellesDonnees);
} else if(info.getType().equals("collection_ajoutee")) {
mediateur.clicMenu(MenuApplicationId.COLLECTION);
}
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionVue.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java
New file
0,0 → 1,252
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Coel;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampFiltreRecherche;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionAsyncDao;
import org.tela_botanica.client.modeles.collection.CollectionListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
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;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.Window;
 
public class CollectionListeVue extends ContentPanel implements Rafraichissable {
private Mediateur mediateur = null;
private Constantes i18nC = null;
 
private Grid<Collection> grille = null;
private ListStore<Collection> store = null;
 
private Button modifier;
private Button supprimer;
private Button ajouter;
private BarrePaginationVue pagination = null;
private ChampFiltreRecherche champFiltreRecherche = null;
private int indexElementSelectionne = 0;
private Collection collectionSelectionnee = null;
public CollectionListeVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
setLayout(new FitLayout());
setHeaderVisible(false);
ToolBar toolBar = new ToolBar();
ajouter = new Button(i18nC.ajouter());
ajouter.setIcon(Images.ICONES.ajouter());
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
mediateur.clicAjouterCollection();
}
});
ajouter.setToolTip(i18nC.indicationCreerUneFiche()+" "+i18nC.collectionSingulier());
toolBar.add(ajouter);
 
modifier = new Button(i18nC.modifier());
modifier.setIcon(Images.ICONES.formModifier());
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
mediateur.clicModifierCollection(grille.getSelectionModel().getSelectedItems());
}
});
modifier.setToolTip(i18nC.indicationModifierUneFiche());
toolBar.add(modifier);
supprimer = new Button(i18nC.supprimer());
supprimer.setIcon(Images.ICONES.supprimer());
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
clicSupprimerCollection(grille.getSelectionModel().getSelectedItems());
}
});
supprimer.setToolTip(i18nC.indicationSupprimerUneFiche());
toolBar.add(supprimer);
setTopComponent(toolBar);
 
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
colonnes.add(new ColumnConfig("nom", i18nC.personneNom(), 300));
colonnes.add(new ColumnConfig("_structure_nom_", i18nC.structure(), 200));
colonnes.add(new ColumnConfig("_structure_ville_", i18nC.ville(), 150));
colonnes.get(1).setHidden(true);
ColumnModel modeleDeColonne = new ColumnModel(colonnes);
GridSelectionModel<Collection> modeleDeSelection = new GridSelectionModel<Collection>();
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Collection>() {
public void selectionChanged(SelectionChangedEvent<Collection> event) {
collectionSelectionnee = (Collection) event.getSelectedItem();
indexElementSelectionne = store.indexOf(collectionSelectionnee);
clicListe(collectionSelectionnee);
}
});
store = new ListStore<Collection>();
grille = new Grid<Collection>(store, modeleDeColonne);
grille.setWidth("100%");
grille.setAutoExpandColumn("nom");
grille.getView().setAutoFill(true);
grille.getView().setForceFit(true);
grille.setSelectionModel(modeleDeSelection);
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
grille.getSelectionModel().select(0, false);
}
});
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
modifier.fireEvent(Events.Select);
}
});
 
grille.addListener(Events.SortChange, new Listener<BaseEvent>() {
 
@Override
public void handleEvent(BaseEvent be) {
GridEvent ge = (GridEvent<Collection>) be;
// TODO rajouter un test sur le sort state pour trier par nom par défaut
String tri = ge.getSortInfo().getSortField();
if(tri.equals("_structure_ville_")) {
tri = "cs_ville";
} else {
tri = Collection.PREFIXE+"_"+tri;
}
CollectionAsyncDao.tri = tri+" "+ge.getSortInfo().getSortDir().toString();
pagination.changePage();
}
});
add(grille);
CollectionListe collectionListe = new CollectionListe();
champFiltreRecherche = new ChampFiltreRecherche(mediateur, toolBar, collectionListe);
// Définition de la barre de pagination
pagination = new BarrePaginationVue(collectionListe, mediateur, champFiltreRecherche);
setBottomComponent(pagination);
}
 
private void clicListe(Collection collection) {
if (collection != null && store.getCount() > 0) {
mediateur.clicListeCollection(collection);
}
}
 
private void clicSupprimerCollection(List<Collection> collectionsASupprimer) {
if (store.getCount() > 0) {
mediateur.clicSupprimerCollection(this, collectionsASupprimer);
}
}
private void gererEtatActivationBouton() {
int nbreElementDuMagazin = store.getCount();
ajouter.enable();
if (nbreElementDuMagazin == 0) {
supprimer.disable();
modifier.disable();
} else if (nbreElementDuMagazin > 0) {
modifier.enable();
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
supprimer.enable();
}
}
}
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof CollectionListe) {
CollectionListe collections = (CollectionListe) nouvellesDonnees;
 
pagination.setlistePaginable(collections);
int[] pt = collections.getPageTable();
pagination.rafraichir(collections.getPageTable());
champFiltreRecherche.setListePaginable(collections);
if (collections != null) {
List<Collection> liste = collections.toList();
store.removeAll();
store.add(liste);
mediateur.actualiserPanneauCentral();
}
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if (info.getType().equals("modif_collection")) {
// curieusement la suppression efface aussi l'index de l'élément
// car elle redéclenche l'évenement de selection (on le stocke donc temporairement)
int temporaire = indexElementSelectionne;
if(collectionSelectionnee != null) {
store.remove(collectionSelectionnee);
collectionSelectionnee = null;
}
Collection collecModifiee = (Collection)info.getDonnee(0);
// au cas ou le bouton appliquer aurait été cliqué avant de valider
store.remove(collecModifiee);
indexElementSelectionne = temporaire;
store.insert(collecModifiee, temporaire);
collectionSelectionnee = collecModifiee;
int indexElementSelectionne = store.indexOf(collectionSelectionnee);
grille.getSelectionModel().select(indexElementSelectionne, false);
grille.getView().focusRow(indexElementSelectionne);
clicListe(collectionSelectionnee);
} else if (info.getType().equals("suppression_collection")) {
// Affichage d'un message d'information
InfoLogger.display(i18nC.suppressionCollection(), info.toString().replaceAll("\n", "<br />"));
 
supprimerCollectionsSelectionnees();
gererEtatActivationBouton();
}
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
layout();
}
private void supprimerCollectionsSelectionnees() {
List<Collection> collectionsSelectionnees = grille.getSelectionModel().getSelectedItems();
Iterator<Collection> it = collectionsSelectionnees.iterator();
while (it.hasNext()) {
grille.getStore().remove(it.next());
}
layout(true);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java
New file
0,0 → 1,425
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
 
import org.tela_botanica.client.Coel;
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampCaseACocher;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.ChampMultiValeurs;
import org.tela_botanica.client.composants.ChampNombre;
import org.tela_botanica.client.composants.ConteneurMultiChamps;
import org.tela_botanica.client.composants.pagination.ProxyCollections;
import org.tela_botanica.client.composants.pagination.ProxyStructures;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilDate;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
 
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.HiddenField;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.ui.HorizontalPanel;
 
public class CollectionFormGeneral extends FormulaireOnglet implements Rafraichissable {
public static final String ID = "general";
private Collection collection = null;
private Collection collectionCollectee = null;
 
private HiddenField<String> idCollectionChp = null;
private ChampComboBoxRechercheTempsReelPaginable structuresCombo = null;
private ChampComboBoxRechercheTempsReelPaginable collectionsCombo = null;
private ChampNombre periodeConstitutionDebutChp = null;
private ChampNombre periodeConstitutionFinChp = null;
private ChampMultiValeurs lieuCouvertureChp = null;
 
private ChampComboBoxListeValeurs specimenTypeCombo = null;
private ChampComboBoxListeValeurs precisionTypeNbreCombo = null;
private NumberField nbreTypeChp = null;
private ChampComboBoxListeValeurs classementSpecimenTypeCombo = null;
private ChampComboBoxListeValeurs typeDepotCombo = null;
private TextField<String> coteChp = null;
private ChampMultiValeurs nomsAlternatifsChp = null;
private ChampMultiValeurs codesAlternatifsChp = null;
private TextArea descriptionChp = null;
private TextArea historiqueChp = null;
private ChampMultiValeurs urlsChp = null;
private Sequenceur sequenceur = new Sequenceur();
public CollectionFormGeneral(Formulaire formulaireCourrant) {
initialiserOnglet(formulaireCourrant);
setId(ID);
setText(Mediateur.i18nC.collectionGeneral());
creerChampsCache();
creerFieldsetLiaison();
creerFieldsetAdministratif();
creerFieldsetDescription();
creerFieldsetCouverture();
creerFieldsetType();
}
 
private void initialiserCollection() {
collection = ((CollectionForm) formulaire).collection;
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee;
}
private void creerChampsCache() {
// Champs cachés
idCollectionChp = new HiddenField<String>();
this.add(idCollectionChp);
}
private void creerFieldsetLiaison() {
FieldSet liaisonFieldSet = new FieldSet();
liaisonFieldSet.setHeadingHtml(i18nC.liaisonTitreCollection());
liaisonFieldSet.setCollapsible(true);
liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
//+-----------------------------------------------------------------------------------------------------------+
// Champ Structures
 
ModelType modelTypeStructures = new ModelType();
modelTypeStructures.setRoot("structures");
modelTypeStructures.setTotalName("nbElements");
modelTypeStructures.addField("cs_nom");
modelTypeStructures.addField("cs_id_structure");
String displayNameStructures = "cs_nom";
ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(null);
structuresCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
structuresCombo.setWidth(250, 600);
structuresCombo.getCombo().setTabIndex(tabIndex++);
structuresCombo.getCombo().setFieldLabel(i18nC.lienStructureCollection());
structuresCombo.getCombo().setForceSelection(true);
structuresCombo.getCombo().setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (structuresCombo.getStore().findModel("cs_nom", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
}
return retour;
}
});
 
liaisonFieldSet.add(structuresCombo, new FormData(600, 0));
//+-----------------------------------------------------------------------------------------------------------+
// Champ Collections
ModelType modelTypeCollections = new ModelType();
modelTypeCollections.setRoot("collections");
modelTypeCollections.setTotalName("nbElements");
modelTypeCollections.addField("cc_nom");
modelTypeCollections.addField("cc_id_collection");
modelTypeCollections.addField("cc_ce_mere");
String displayNameCollections = "cc_nom";
ProxyCollections<ModelData> proxyCollections = new ProxyCollections<ModelData>(null);
collectionsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyCollections, modelTypeCollections, displayNameCollections);
collectionsCombo.setWidth(250, 600);
collectionsCombo.getCombo().setTabIndex(tabIndex++);
collectionsCombo.getCombo().setFieldLabel(i18nC.lienMereCollection());
collectionsCombo.getCombo().setForceSelection(true);
collectionsCombo.getCombo().setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (collectionsCombo.getStore().findModel("cc_nom", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
}
return retour;
}
});
 
liaisonFieldSet.add(collectionsCombo, new FormData(600, 0));
this.add(liaisonFieldSet);
}
private void creerFieldsetAdministratif() {
// Fieldset ADMINISTRATIF
FieldSet administratifFieldSet = new FieldSet();
administratifFieldSet.setHeadingHtml(i18nC.collectionGeneralTitre());
administratifFieldSet.setCollapsible(true);
administratifFieldSet.collapse();
administratifFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
typeDepotCombo = new ChampComboBoxListeValeurs(i18nC.typeDepot(), "typeDepot", tabIndex++);
administratifFieldSet.add(typeDepotCombo);
coteChp = new TextField<String>();
coteChp.setTabIndex(tabIndex++);
coteChp.setFieldLabel(i18nC.cote());
administratifFieldSet.add(coteChp, new FormData(450, 0));
nomsAlternatifsChp = new ChampMultiValeurs(i18nC.intituleAlternatifCollection());
administratifFieldSet.add(nomsAlternatifsChp);
codesAlternatifsChp = new ChampMultiValeurs(i18nC.codeAlternatifCollection());
administratifFieldSet.add(codesAlternatifsChp);
this.add(administratifFieldSet);
}
private void creerFieldsetDescription() {
// Fieldset DESCRIPTION
FieldSet descriptionFieldSet = new FieldSet();
descriptionFieldSet.setHeadingHtml(i18nC.collectionDescriptionTitre());
descriptionFieldSet.setCollapsible(true);
descriptionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
 
descriptionChp = new TextArea();
descriptionChp.setFieldLabel(i18nC.description());
descriptionFieldSet.add(descriptionChp, new FormData(550, 0));
historiqueChp = new TextArea();
historiqueChp.setFieldLabel(i18nC.historique());
descriptionFieldSet.add(historiqueChp, new FormData(550, 0));
urlsChp = new ChampMultiValeurs(i18nC.urlsCollection());
descriptionFieldSet.add(urlsChp);
 
this.add(descriptionFieldSet);
}
private void creerFieldsetCouverture() {
FieldSet couvertureFieldSet = new FieldSet();
couvertureFieldSet.setHeadingHtml("Couvertures");
couvertureFieldSet.setCollapsible(true);
couvertureFieldSet.collapse();
couvertureFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
// à modifier
//periodeConstitutionChp = new ChampCaseACocher(i18nC.periodeConstitution(), "siecleNaturaliste", false);
//couvertureFieldSet.add(periodeConstitutionChp);
Label labelperiodeDebut = new Label(i18nC.periodeConstitutionDetailForm());
labelperiodeDebut.setStyleName("labelChampNombreFormat");
periodeConstitutionDebutChp = new ChampNombre();
periodeConstitutionDebutChp.setStyleName("champNombreFormat");
periodeConstitutionDebutChp.setWidth(55);
periodeConstitutionDebutChp.setEmptyText(i18nC.publicationDateParution());
periodeConstitutionFinChp = new ChampNombre();
periodeConstitutionFinChp.setStyleName("champNombreFormat");
periodeConstitutionFinChp.setWidth(55);
periodeConstitutionFinChp.setEmptyText(i18nC.publicationDateParution());
HorizontalPanel conteneurPeriode = new HorizontalPanel();
conteneurPeriode.setBorderWidth(0);
conteneurPeriode.add(labelperiodeDebut);
conteneurPeriode.add(periodeConstitutionDebutChp);
conteneurPeriode.add(periodeConstitutionFinChp);
couvertureFieldSet.add(conteneurPeriode);
lieuCouvertureChp = new ChampMultiValeurs(i18nC.lieuCouvertureCollection());
couvertureFieldSet.add(lieuCouvertureChp);
this.add(couvertureFieldSet);
}
 
private void creerFieldsetType() {
FieldSet typeFieldSet = new FieldSet();
typeFieldSet.setHeadingHtml("Spécimens «types»");
typeFieldSet.setCollapsible(true);
typeFieldSet.collapse();
typeFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
specimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.specimenTypeCollection(), "onpi", tabIndex++);
typeFieldSet.add(specimenTypeCombo);
ConteneurMultiChamps nbreTypeConteneur = new ConteneurMultiChamps(i18nC.nbreSpecimenTypeCollection());
nbreTypeChp = new NumberField();
nbreTypeChp.setFormat(NumberFormat.getFormat("#"));
nbreTypeConteneur.ajouterChamp(nbreTypeChp, new HBoxLayoutData(new Margins(0, 20, 0, 0)));
precisionTypeNbreCombo = new ChampComboBoxListeValeurs(null, "ea");
precisionTypeNbreCombo.setTrie("id_valeur");
precisionTypeNbreCombo.setEmptyText(i18nC.precisionNbreSpecimenTypeCollectionChpVide());
nbreTypeConteneur.ajouterChamp(precisionTypeNbreCombo);
typeFieldSet.add(nbreTypeConteneur);
classementSpecimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.classementSpecimenTypeCollection(), "typeClassement", tabIndex++);
typeFieldSet.add(classementSpecimenTypeCombo);
Text infoType = new Text(i18nC.specimenTypeCollectionInfo());
typeFieldSet.add(infoType);
this.add(typeFieldSet);
}
public void peupler() {
initialiserCollection();
if (collection != null) {
idCollectionChp.setValue(collection.getId());
setValeurComboStructures();
setValeurComboCollections();
typeDepotCombo.peupler(collection.getTypeDepot());
coteChp.setValue(collection.getCote());
nomsAlternatifsChp.peupler(collection.getNomAlternatif());
codesAlternatifsChp.peupler(collection.getCode());
descriptionChp.setValue(collection.getDescription());
historiqueChp.setValue(collection.getHistorique());
urlsChp.peupler(collection.getUrls());
if(!collection.getPeriodeConstitutionDebut().equals("")) {
periodeConstitutionDebutChp.setValue((Integer.parseInt(collection.getPeriodeConstitutionDebut())));
}
if(!collection.getPeriodeConstitutionFin().equals("")) {
periodeConstitutionFinChp.setValue((Integer.parseInt(collection.getPeriodeConstitutionFin())));
}
lieuCouvertureChp.peupler(collection.getCouvertureLieu());
specimenTypeCombo.peupler(collection.getSpecimenType());
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>();
return messages;
}
public void collecter() {
initialiserCollection();
// l'onglet collection est obligatoirement rempli lors d'un ajout
if (this.mode == Formulaire.MODE_AJOUTER || etreAccede()) {
collectionCollectee.setId(idCollectionChp.getValue());
collectionCollectee.setIdStructure(getValeurComboStructures());
collectionCollectee.setCollectionMereId(getValeurComboCollections());
collectionCollectee.setTypeDepot(typeDepotCombo.getValeur());
collectionCollectee.setCote(coteChp.getValue());
collectionCollectee.setNomAlternatif(nomsAlternatifsChp.getValeurs());
collectionCollectee.setCode(codesAlternatifsChp.getValeurs());
collectionCollectee.setDescription(descriptionChp.getValue());
collectionCollectee.setHistorique(historiqueChp.getValue());
collectionCollectee.setUrls(urlsChp.getValeurs());
 
collectionCollectee.setPeriodeConstitutionDebut("" + periodeConstitutionDebutChp.getValue());
collectionCollectee.setPeriodeConstitutionFin("" + periodeConstitutionFinChp.getValue());
collectionCollectee.setCouvertureLieu(lieuCouvertureChp.getValeurs());
collectionCollectee.setSpecimenType(specimenTypeCombo.getValeur());
if (nbreTypeChp.getValue() != null) {
collectionCollectee.setSpecimenTypeNbre(nbreTypeChp.getValue().toString());
}
collectionCollectee.setSpecimenTypeNbrePrecision(precisionTypeNbreCombo.getValeur());
collectionCollectee.setSpecimenTypeClassement(classementSpecimenTypeCombo.getValeur());
}
}
private String getValeurComboStructures() {
String valeur = "";
if (structuresCombo.getCombo().getValue() != null) {
Structure structure = new Structure(structuresCombo.getValeur());
valeur = structure.getId();
}
return valeur;
}
private void setValeurComboStructures() {
if (structuresCombo.getCombo().getStore() != null
&& collection != null
&& collection.getStructureNom() != null
&& !UtilString.isEmpty(collection.getStructureNom())) {
structuresCombo.chargerValeurInitiale(collection.getStructureNom(), "cs_nom");
} else {
structuresCombo.getCombo().setValue(null);
}
}
private String getValeurComboCollections() {
String valeur = "";
if (collectionsCombo.getCombo().getValue() != null) {
Collection collection = new Collection(collectionsCombo.getValeur());
valeur = collection.getId();
}
return valeur;
}
private void setValeurComboCollections() {
if (collectionsCombo.getCombo().getStore() != null
&& collection != null
&& collection.getCollectionMereNom() != null
&& !UtilString.isEmpty(collection.getCollectionMereNom())) {
collectionsCombo.chargerValeurInitiale(collection.getCollectionMereNom(), "cc_nom");
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
private void rafraichirValeurListe(ValeurListe listeValeurs) {
if (listeValeurs.getId().equals(config.getListeId("typeDepot"))) {
Formulaire.rafraichirComboBox(listeValeurs, typeDepotCombo);
} else {
Debug.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!");
}
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java:r11-933,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java
New file
0,0 → 1,972
package org.tela_botanica.client.vues.collection;
 
import java.util.HashMap;
import java.util.Iterator;
 
import org.tela_botanica.client.Coel;
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.OntologiesLocales;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe;
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe;
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe;
import org.tela_botanica.client.modeles.collection.CollectionBotanique;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.DetailVue;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 
public class CollectionDetailVue extends DetailVue implements Rafraichissable {
 
private Collection collection = null;
private boolean collectionChargementOk = false;
private boolean personnesLieesChargementOk = false;
private boolean publicationsLieesChargementOk = false;
private boolean commentairesLieesChargementOk = false;
private Structure structure = null;
 
private String enteteTpl = null;
private String generalTpl = null;
private String personneTpl = null;
private String tableauPersonnesLieesTpl = null;
private String lignePersonneLieeTpl = null;
private String publicationTpl = null;
private String tableauPublicationsLieesTpl = null;
private String lignePublicationLieeTpl = null;
private String descriptionTpl = null;
private String contenuTpl = null;
private String inventaireTpl = null;
private String commentaireTpl = null;
private String tableauCommentairesLieesTpl = null;
private String ligneCommentaireLieeTpl = null;
private ContentPanel panneauPrincipal = null;
private Html entete = null;
private TabPanel onglets = null;
private TabItem generalOnglet = null;
private TabItem personneOnglet = null;
private TabItem publicationOnglet = null;
private TabItem descriptionOnglet = null;
private TabItem contenuOnglet = null;
private TabItem inventaireOnglet = null;
private TabItem commentaireOnglet = null;
 
private Sequenceur sequenceur;
public CollectionDetailVue(Mediateur mediateurCourant, Sequenceur sequenceur) {
super(mediateurCourant);
this.sequenceur = sequenceur;
initialiserTousLesTpl();
chargerOntologie();
panneauPrincipal = new ContentPanel();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.setHeaderVisible(false);
panneauPrincipal.setBodyBorder(false);
entete = new Html();
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
panneauPrincipal.setTopComponent(entete);
onglets = new TabPanel();
onglets.setId(ComposantId.ZONE_DETAIL_CORPS);
onglets.setBodyBorder(false);
 
generalOnglet = new TabItem(i18nC.structureInfoGeneral());
generalOnglet.setLayout(new AnchorLayout());
generalOnglet.setScrollMode(Scroll.AUTO);
onglets.add(generalOnglet);
personneOnglet = new TabItem(i18nC.collectionPersonne());
personneOnglet.setLayout(new AnchorLayout());
personneOnglet.setScrollMode(Scroll.AUTO);
onglets.add(personneOnglet);
publicationOnglet = new TabItem(i18nC.collectionPublication());
publicationOnglet.setLayout(new AnchorLayout());
publicationOnglet.setScrollMode(Scroll.AUTO);
onglets.add(publicationOnglet);
descriptionOnglet = new TabItem(i18nC.collectionDescription());
descriptionOnglet.setLayout(new AnchorLayout());
descriptionOnglet.setScrollMode(Scroll.AUTO);
onglets.add(descriptionOnglet);
contenuOnglet = new TabItem(i18nC.collectionContenu());
contenuOnglet.setLayout(new AnchorLayout());
contenuOnglet.setScrollMode(Scroll.AUTO);
onglets.add(contenuOnglet);
inventaireOnglet = new TabItem(i18nC.collectionInventaire());
inventaireOnglet.setLayout(new AnchorLayout());
inventaireOnglet.setScrollMode(Scroll.AUTO);
onglets.add(inventaireOnglet);
commentaireOnglet = new TabItem(i18nC.collectionCommentaire());
commentaireOnglet.setLayout(new AnchorLayout());
commentaireOnglet.setScrollMode(Scroll.AUTO);
onglets.add(commentaireOnglet);
panneauPrincipal.add(onglets);
add(panneauPrincipal);
}
private void initialiserTousLesTpl() {
initialiserEnteteHtmlTpl();
initialiserGeneralTpl();
initialiserPersonneTpl();
initialiserTableauPersonnesLieesTpl();
initialiserLignePersonneLieeTpl();
initialiserPublicationTpl();
initialiserTableauPublicationsLieesTpl();
initialiserLignePublicationLieeTpl();
initialiserContenuTpl();
initialiserDescriptionTpl();
initialiserInventaireTpl();
initialiserCommentaireTpl();
initialiserTableauCommentairesLieesTpl();
initialiserLigneCommentaireLieeTpl();
}
private void initialiserEnteteHtmlTpl() {
enteteTpl =
"<div id='{css_id}'>"+
" <h1>{nom}</h1>"+
" <h2>{structure}<span class='{css_meta}'><br /> {i18n_id}:{id} - {guid}</span></h2>" +
"</div>";
}
private void initialiserGeneralTpl() {
generalTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_identification}</h2>"+
" <span class='{css_label}'>{i18n_nom_alternatif} :</span> {nom_alternatif}<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_depot} :</span> {type_depot}<br />"+
" <span class='{css_label}'>{i18n_code} :</span> {code}<br />"+
" <span class='{css_label}'>{i18n_cote} :</span> {cote}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_general_collection_titre}</h2>"+
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
" <span class='{css_label}'>{i18n_historique} :</span> {historique}<br />"+
" <span class='{css_label}'>{i18n_web} :</span> {web}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_couverture_collection_titre}</h2>"+
" <span class='{css_label}'>{i18n_couverture_geo} :</span> {couverture_geo}<br />"+
" <span class='{css_label}'>{i18n_periode} :</span> {periode}<br />"+
" </div>"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_specimen_type_titre}</h2>"+
" <span class='{css_label}'>{i18n_specimen_type_presence} :</span> {specimen_type_presence}<br />"+
" <span class='{css_label}'>{i18n_specimen_type_nombre} :</span> {specimen_type_nombre}<br />"+
" <span class='{css_label}'>{i18n_specimen_type_classement} :</span> {specimen_type_classement}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserPersonneTpl() {
personneTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_personne}</h2>"+
" {tableau_personnes_liees}"+
"</div>";
}
private void initialiserTableauPersonnesLieesTpl() {
tableauPersonnesLieesTpl =
"<table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_relation}</th>" +
" <th>{i18n_nom_complet}</th>" +
" <th>{i18n_nom}</th>" +
" <th>{i18n_prenom}</th>" +
" <th>{i18n_naissance_date}</th>" +
" <th>{i18n_naissance_lieu}</th>" +
" <th>{i18n_etre_decede}</th>" +
" <th>{i18n_deces_date}</th>" +
" <th>{i18n_deces_lieu}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLignePersonneLieeTpl() {
lignePersonneLieeTpl =
"<tr>"+
" <td>{relation}</td>"+
" <td>{nom_complet}</td>"+
" <td>{nom}</td>"+
" <td>{prenom}</td>"+
" <td>{naissance_date}</td>"+
" <td>{naissance_lieu}</td>"+
" <td>{etre_decede}</td>"+
" <td>{deces_date}</td>"+
" <td>{deces_lieu}</td>"+
"</tr>";
}
private void initialiserPublicationTpl() {
publicationTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_publication}</h2>"+
" {tableau_publications_liees}"+
"</div>";
}
private void initialiserTableauPublicationsLieesTpl() {
tableauPublicationsLieesTpl =
"<table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_auteur}</th>" +
" <th>{i18n_titre}</th>" +
" <th>{i18n_revue}</th>" +
" <th>{i18n_editeur}</th>" +
" <th>{i18n_annee}</th>" +
" <th>{i18n_nvt}</th>" +
" <th>{i18n_fascicule}</th>" +
" <th>{i18n_page}</th>" +
" <th>{i18n_source}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLignePublicationLieeTpl() {
lignePublicationLieeTpl =
"<tr>"+
" <td>{auteur}</td>"+
" <td>{titre}</td>"+
" <td>{revue}</td>"+
" <td>{editeur}</td>"+
" <td>{annee}</td>"+
" <td>{nvt}</td>"+
" <td>{fascicule}</td>"+
" <td>{page}</td>"+
" <td>{source}</td>"+
"</tr>";
}
private void initialiserDescriptionTpl() {
descriptionTpl =
"<div class='{css_corps}'>"+
" <div>"+
" <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 />"+
" <span class='{css_label}'>{i18n_etat_unite_rangement} :</span> {etat_unite_rangement}<br />"+
" <span class='{css_label}'>{i18n_collection_cartons_herbiers} :</span> {nb_cartons_herbier}<br />"+
" <span class='{css_label}'>{i18n_nb_liasses} :</span> {nb_liasses}<br />"+
" <span class='{css_label}'>{i18n_autres_unites_rangement} : </span>{autres_unites_rangement}<br />"+
" <span class='{css_label}'>{i18n_nb_planches_herbier} :</span> {nb_planches_herbier}<br />"+
" <span class='{css_label}'>{i18n_nb_especes} :</span> {nb_especes}<br />"+
" </div>"+
" <div>"+
" <h2>{i18n_titre_conservation}</h2>"+
" <span class='{css_label}'>{i18n_type_papier} :</span> {type_papier}<br />"+
" <span class='{css_label}'>{i18n_conservation_methode} :</span> {conservation_methode}<br />"+
" </div>"+
" <div>"+
" <h2>{i18n_titre_etiquette}</h2>"+
" <span class='{css_label}'>{i18n_specimen_fixation_pourcent} :</span> {specimen_fixation_pourcent}<br />"+
" <span class='{css_label}'>{i18n_etiquette_fixation_pourcent} :</span> {etiquette_fixation_pourcent}<br />"+
" <span class='{css_label}'>{i18n_specimen_fixation_methode} :</span> {specimen_fixation_methode}<br />"+
" <span class='{css_label}'>{i18n_etiquette_fixation_methode_support} :</span> {etiquette_fixation_methode_support}<br />"+
" <span class='{css_label}'>{i18n_etiquette_fixation_methode_specimen} :</span> {etiquette_fixation_methode_specimen}<br />"+
" <span class='{css_label}'>{i18n_etiquette_type_ecriture} :</span> {etiquette_type_ecriture}<br />"+
" </div>"+
" <div>"+
" <h2>{i18n_titre_traitement}</h2>"+
" <span class='{css_label}'>{i18n_traitement} :</span> {traitement}<br />"+
" <span class='{css_label}'>{i18n_traitement_poison} :</span> {traitement_poison}<br />"+
" <span class='{css_label}'>{i18n_traitement_insecte} :</span> {traitement_insecte}<br />"+
" </div>"+
" <div>"+
" <h2>{i18n_titre_etat_degradation}</h2>"+
" <span class='{css_label}'>{i18n_etat_general} :</span> {etat_general}<br />"+
" <span class='{css_label}'>{i18n_degradation_specimen} :</span> {degradation_specimen}<br />"+
" <span class='{css_label}'>{i18n_degradation_presentation} :</span> {degradation_presentation}<br />"+
" <span class='{css_label}'>{i18n_determination} :</span> {determination}<br />"+
" </div>"+
"</div>";
}
private void initialiserContenuTpl() {
contenuTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_nature}</h2>"+
" <span class='{css_label}'>{i18n_nature} :</span> {nature}<br />"+
" <span class='{css_label}'>{i18n_specialite} :</span> {specialite}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_etiquette}</h2>"+
" <span class='{css_label}'>{i18n_etiquette_renseignement} :</span> {etiquette_renseignement}<br />"+
" <span class='{css_label}'>{i18n_precision_localite} :</span> {precision_localite}<br />"+
" <span class='{css_label}'>{i18n_precision_date} :</span> {precision_date}<br />"+
" <span class='{css_label}'>{i18n_etiquette_annotation} :</span> {etiquette_annotation}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_classement}</h2>"+
" <span class='{css_label}'>{i18n_classement_etat} :</span> {classement_etat}<br />"+
" <span class='{css_label}'>{i18n_classement} :</span> {classement}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_integree}</h2>"+
" <span class='{css_label}'>{i18n_collection_integration} :</span> {collection_integration}<br />"+
" <span class='{css_label}'>{i18n_collection_integration_info} :</span> {collection_integration_info}<br />"+
" </div>"+
"</div>";
}
private void initialiserInventaireTpl() {
inventaireTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_inventaire}</h2>"+
" <span class='{css_label}'>{i18n_existence} :</span> {existence}<br />"+
" <span class='{css_label}'>{i18n_participation_auteur} :</span> {participation_auteur}<br />"+
" <span class='{css_label}'>{i18n_forme} :</span> {forme}<br />"+
" <span class='{css_label}'>{i18n_info} :</span> {info}<br />"+
" <span class='{css_label}'>{i18n_digital} :</span> {digital}<br />"+
" <span class='{css_label}'>{i18n_digital_pourcent} :</span> {digital_pourcent}<br />"+
" <span class='{css_label}'>{i18n_etat} :</span> {etat}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
"</div>";
}
private void initialiserCommentaireTpl() {
commentaireTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_commentaire}</h2>"+
" {tableau_commentaires_liees}"+
"</div>";
}
private void initialiserTableauCommentairesLieesTpl() {
tableauCommentairesLieesTpl =
"<table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_type}</th>" +
" <th>{i18n_titre}</th>" +
" <th>{i18n_ponderation}</th>" +
" <th>{i18n_public}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLigneCommentaireLieeTpl() {
ligneCommentaireLieeTpl =
"<tr>"+
" <td>{type}</td>"+
" <td>{titre}</td>"+
" <td>{ponderation}</td>"+
" <td>{public}</td>"+
"</tr>"+
"<tr>"+
" <td colspan='4'>{texte}</td>"+
"</tr>";
}
private void chargerOntologie() {
String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot", "groupementPrincipe",
"realisationBut", "onpi", "ea", "typeClassement", "relationPersonneCollection", "ion",
"typeUniteRangement", "etat", "typeUniteBase", "typePapier", "methodeRangement", "methodeFixation",
"methodeFixationSurSpecimen", "typeEcriture", "poisonTraitement", "insecteTraitement", "specimenDegradation",
"niveauImportance", "supportDegradation", "niveauDetermination", "natureVegetale", "siecleNaturaliste",
"dateDebut", "dateFin", "etat", "onep", "onp", "inventaireForme", "inventaireLogiciel", "inventaireEtat",
"etatClassement", "typeCommentaireCollection"};
lancerChargementListesValeurs(listesCodes, sequenceur);
sequenceur.enfilerRafraichissement(this, new Information("ontologie_chargee"));
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Collection) {
collection = (Collection) nouvellesDonnees;
collectionChargementOk = true;
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
receptionerListeValeurs(listeValeursReceptionnee);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("liste_collection_a_personne")) {
lierCollectionAPersonne((CollectionAPersonneListe) info.getDonnee(0));
} else if (info.getType().equals("liste_collection_a_publication")) {
lierCollectionAPublication((CollectionAPublicationListe) info.getDonnee(0));
} else if (info.getType().equals("liste_collection_a_commentaire")) {
lierCollectionACommentaire((CollectionACommentaireListe) info.getDonnee(0));
} else if (info.getType().equals("ontologie_chargee")) {
ontologieChargementOk = true;
}
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
if (avoirDonneesChargees()) {
afficherDetail();
}
}
protected void lierCollectionAPersonne(CollectionAPersonneListe personnes) {
collection.setPersonnesLiees(personnes);
personnesLieesChargementOk = true;
}
protected void lierCollectionAPublication(CollectionAPublicationListe publications) {
collection.setPublicationsLiees(publications);
publicationsLieesChargementOk = true;
}
protected void lierCollectionACommentaire(CollectionACommentaireListe commentaires) {
collection.setCommentairesLiees(commentaires);
commentairesLieesChargementOk = true;
}
private boolean avoirDonneesChargees() {
boolean ok = false;
if (collectionChargementOk && ontologieChargementOk && personnesLieesChargementOk && publicationsLieesChargementOk && commentairesLieesChargementOk) {
ok = true;
}
return ok;
}
private void afficherDetail() {
if (collection != null) {
afficherEntete();
afficherIdentification();
afficherPersonne();
afficherPublication();
afficherDescription();
afficherContenu();
afficherInventaire();
afficherCommentaire();
}
layout();
}
private void afficherEntete() {
Params enteteParams = new Params();
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
enteteParams.set("css_meta", ComposantClass.META);
enteteParams.set("i18n_id", i18nC.id());
enteteParams.set("nom", collection.getNom());
enteteParams.set("structure", collection.getStructureNom());
enteteParams.set("id", collection.getId());
enteteParams.set("guid", collection.getGuid());
String eHtml = Format.substitute(enteteTpl, enteteParams);
entete.getElement().setInnerHTML(eHtml);
}
private void afficherIdentification() {
Params generalParams = new Params();
generalParams.set("i18n_titre_identification", i18nC.titreAdministratif());
generalParams.set("i18n_nom_alternatif", i18nC.intituleAlternatifCollection());
generalParams.set("i18n_mere", i18nC.collectionMere());
generalParams.set("i18n_type_ncd", i18nC.typeCollectionNcd());
generalParams.set("i18n_type_depot", i18nC.typeDepot());
generalParams.set("i18n_code", i18nC.codeAlternatifCollection());
generalParams.set("i18n_cote", i18nC.cote());
generalParams.set("i18n_general_collection_titre", i18nC.collectionGeneralTitre());
generalParams.set("i18n_description", i18nC.description());
generalParams.set("i18n_historique", i18nC.historique());
generalParams.set("i18n_web", i18nC.siteWeb());
generalParams.set("i18n_couverture_collection_titre", i18nC.collectionCouvertureTitre());
generalParams.set("i18n_couverture_geo", i18nC.couvertureGeo());
generalParams.set("i18n_periode", i18nC.periodeConstitutionDetail());
String periode = "";
if (!collection.getPeriodeConstitutionDebut().equals("0")) {
periode = collection.getPeriodeConstitutionDebut();
}
if (!collection.getPeriodeConstitutionFin().equals("0")) {
periode += " - "+collection.getPeriodeConstitutionFin();
}
generalParams.set("periode", periode);
generalParams.set("i18n_specimen_type_titre", i18nC.collectionSpecimenTypeTitre());
generalParams.set("i18n_specimen_type_presence", i18nC.specimenTypeCollectionDetail());
generalParams.set("i18n_specimen_type_nombre", i18nC.nbreSpecimenTypeCollectionDetail());
generalParams.set("i18n_specimen_type_classement", i18nC.classementSpecimenTypeCollectionDetail());
String nomAlternatif = construireTxtTruck(collection.getNomAlternatif());
String typeNcd = construireTxtListeOntologie(collection.getTypeNcd());
String typeDepot = construireTxtListeOntologie(collection.getTypeDepot());
String code = construireTxtTruck(collection.getCode());
String urls = construireTxtTruck(collection.getUrls(), false);
String couvertureGeo = construireTxtTruck(collection.getCouvertureLieu());
String specimenTypePresence = construireTxtListeOntologie(collection.getSpecimenType());
String specimenTypeNombrePrecision = construireTxtListeOntologie(collection.getSpecimenTypeNbrePrecision());
String specimenTypeNombre = "";
if (!collection.getSpecimenTypeNbre().equals("0") && !collection.getSpecimenTypeNbre().equals("")) {
specimenTypeNombre = collection.getSpecimenTypeNbre()+" ("+specimenTypeNombrePrecision+")";
}
String specimenTypeClassement = construireTxtListeOntologie(collection.getSpecimenTypeClassement());
generalParams.set("nom_alternatif", nomAlternatif);
generalParams.set("mere", collection.getCollectionMereNom());
generalParams.set("type_ncd", typeNcd);
generalParams.set("type_depot", typeDepot);
generalParams.set("code", code);
generalParams.set("cote", collection.getCote());
generalParams.set("description", collection.getDescription());
generalParams.set("historique", collection.getHistorique());
generalParams.set("web", urls);
generalParams.set("couverture_geo", couvertureGeo);
generalParams.set("specimen_type_presence", specimenTypePresence);
generalParams.set("specimen_type_nombre", specimenTypeNombre);
generalParams.set("specimen_type_classement", specimenTypeClassement);
afficherOnglet(generalTpl, generalParams, generalOnglet);
}
private void afficherPersonne() {
String tableauPersonneHtml = "";
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) {
tableauPersonneHtml = construireTableauPersonnesLiees();
}
Params personneParams = new Params();
personneParams.set("i18n_titre_personne", i18nC.collectionPersonneTitre());
personneParams.set("tableau_personnes_liees", tableauPersonneHtml);
afficherOnglet(personneTpl, personneParams, personneOnglet);
}
private String construireTableauPersonnesLiees() {
Params contenuParams = new Params();
contenuParams.set("i18n_relation", i18nC.typeRelationPersonneCollection());
contenuParams.set("i18n_nom_complet", i18nC.personneNomComplet());
contenuParams.set("i18n_prenom", i18nC.personnePrenom());
contenuParams.set("i18n_nom", i18nC.personneNom());
contenuParams.set("i18n_naissance_date", i18nC.personneDateNaissance());
contenuParams.set("i18n_naissance_lieu", i18nC.personneLieuNaissance());
contenuParams.set("i18n_etre_decede", i18nC.personneDeces());
contenuParams.set("i18n_deces_date", i18nC.personneDateDeces());
contenuParams.set("i18n_deces_lieu", i18nC.personneLieuDeces());
String lignesPersonnel = "";
if (collection.getPersonnesLiees() != null) {
Iterator<String> it = collection.getPersonnesLiees().keySet().iterator();
while (it.hasNext()) {
CollectionAPersonne relationCollectionAPersonne = collection.getPersonnesLiees().get(it.next());
Personne personne = relationCollectionAPersonne.getPersonne();
String relation = construireTxtListeOntologie(relationCollectionAPersonne.getIdRole());
String etreDecede = construireTxtListeOntologie(personne.getDeces());
Params ligneParams = new Params();
ligneParams.set("relation", relation);
ligneParams.set("nom_complet", personne.getNomComplet());
ligneParams.set("nom", personne.getNom());
ligneParams.set("prenom", personne.getPrenom());
ligneParams.set("naissance_date", personne.getNaissanceDate());
ligneParams.set("naissance_lieu", personne.getNaissanceLieu());
ligneParams.set("etre_decede", etreDecede);
ligneParams.set("deces_date", personne.getDecesDate());
ligneParams.set("deces_lieu", personne.getDecesLieu());
lignesPersonnel += Format.substitute(lignePersonneLieeTpl, ligneParams);
}
}
String cHtml = i18nC.nonRenseigne();
if (!UtilString.isEmpty(lignesPersonnel)) {
contenuParams.set("lignes", lignesPersonnel);
cHtml = Format.substitute(tableauPersonnesLieesTpl, contenuParams);
}
return cHtml;
}
private void afficherPublication() {
Params publicationParams = new Params();
publicationParams.set("i18n_titre_publication", i18nC.collectionPublicationTitre());
String tableauPublicationHtml = "";
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) {
tableauPublicationHtml = construireTableauPublicationsLiees();
}
publicationParams.set("tableau_publications_liees", tableauPublicationHtml);
afficherOnglet(publicationTpl, publicationParams, publicationOnglet);
}
private String construireTableauPublicationsLiees() {
Params contenuParams = new Params();
contenuParams.set("i18n_auteur", i18nC.publicationAuteurs());
contenuParams.set("i18n_titre", i18nC.publicationTitre());
contenuParams.set("i18n_revue", i18nC.publicationRevueCollection());
contenuParams.set("i18n_editeur", i18nC.publicationEditeur());
contenuParams.set("i18n_annee", i18nC.publicationDateParution());
contenuParams.set("i18n_nvt", i18nC.publicationNvt());
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule());
contenuParams.set("i18n_page", i18nC.publicationPage());
contenuParams.set("i18n_source", i18nC.collectionPublicationSource());
String lignesPublication = "";
if (collection.getPublicationsLiees() != null) {
Iterator<String> it = collection.getPublicationsLiees().keySet().iterator();
while (it.hasNext()) {
CollectionAPublication relationCollectionAPublication = collection.getPublicationsLiees().get(it.next());
Publication publication = relationCollectionAPublication.getPublication();
Params ligneParams = new Params();
ligneParams.set("auteur", publication.getAuteur());
ligneParams.set("titre", publication.getTitre());
ligneParams.set("revue", publication.getCollection());
ligneParams.set("editeur", publication.getNomEditeur());
ligneParams.set("annee", publication.getAnneeParution());
ligneParams.set("nvt", publication.getIndicationNvt());
ligneParams.set("fascicule", publication.getFascicule());
ligneParams.set("page", publication.getPages());
ligneParams.set("source", relationCollectionAPublication.getSource() == "1" ? i18nC.oui() : i18nC.non());
lignesPublication += Format.substitute(lignePublicationLieeTpl, ligneParams);
}
}
 
String cHtml = i18nC.nonRenseigne();
if (!UtilString.isEmpty(lignesPublication)) {
contenuParams.set("lignes", lignesPublication);
cHtml = Format.substitute(tableauPublicationsLieesTpl, contenuParams);
}
return cHtml;
}
private void afficherDescription() {
Params descriptionParams = new Params();
descriptionParams.set("i18n_titre_description", i18nC.collectionEtatGeneralEtNombreEchantillons());
descriptionParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique());
descriptionParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon());
descriptionParams.set("i18n_titre_unite_rangement", i18nC.collectionUniteRangementTitre());
descriptionParams.set("i18n_etat_unite_rangement", i18nC.collectionUniteRangementEtatGeneralDetail());
descriptionParams.set("i18n_titre_unite_base", i18nC.collectionUniteBaseTitre());
descriptionParams.set("i18n_titre_conservation", i18nC.collectionTitreConservation());
descriptionParams.set("i18n_type_papier", i18nC.typePapierConservationDetail());
descriptionParams.set("i18n_conservation_methode", i18nC.methodeConservationDetail());
descriptionParams.set("i18n_titre_etiquette", i18nC.collectionTitreEtiquette());
descriptionParams.set("i18n_specimen_fixation_pourcent", i18nC.specimenFixationPourcent());
descriptionParams.set("i18n_etiquette_fixation_pourcent", i18nC.etiquetteFixationPourcent());
descriptionParams.set("i18n_specimen_fixation_methode", i18nC.specimenMethodeFixationDetail());
descriptionParams.set("i18n_etiquette_fixation_methode_support", i18nC.etiquetteMethodeFixationSurSupportDetail());
descriptionParams.set("i18n_etiquette_fixation_methode_specimen", i18nC.etiquetteMethodeFixationSurSpecimenDetail());
descriptionParams.set("i18n_etiquette_type_ecriture", i18nC.typeEcritureDetail());
descriptionParams.set("i18n_titre_traitement", i18nC.collectionTitreTraitement());
descriptionParams.set("i18n_traitement", i18nC.collectionTraitementDetail());
descriptionParams.set("i18n_traitement_poison", i18nC.collectionTraitementPoisonDetail());
descriptionParams.set("i18n_traitement_insecte", i18nC.collectionTraitementInsecteDetail());
descriptionParams.set("i18n_titre_etat_degradation", i18nC.collectionTitreEtatEtDegradation());
descriptionParams.set("i18n_etat_general", i18nC.collectionEtatGeneralDetail());
descriptionParams.set("i18n_degradation_specimen", i18nC.degradationSpecimenDetail());
descriptionParams.set("i18n_degradation_presentation", i18nC.degradationPresentationDetail());
descriptionParams.set("i18n_determination", i18nC.collectionDeterminationDetail());
String typeBota = construireTxtListeOntologie(collection.getBotanique().getType());
descriptionParams.set("type_botanique", typeBota);
descriptionParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon());
CollectionBotanique collectionBotanique = collection.getBotanique();
descriptionParams.set("i18n_collection_cartons_herbiers", i18nC.collectionCartonsHerbiers());
descriptionParams.set("i18n_nb_liasses", i18nC.collectionLiasses());
descriptionParams.set("i18n_autres_unites_rangement", i18nC.collectionAutreUnitesRangement());
String cartonsHerbiers = collectionBotanique.getNbCartonsHerbiers();
if(!collectionBotanique.getNbCartonsHerbiers().trim().isEmpty() &&
! collectionBotanique.getFormatCartonsHerbiers().trim().isEmpty()) {
cartonsHerbiers += " - "+i18nC.format()+": ";
}
cartonsHerbiers += collectionBotanique.getFormatCartonsHerbiers();
descriptionParams.set("nb_cartons_herbier", cartonsHerbiers);
String liasses = collectionBotanique.getNbLiasses();
if(!collectionBotanique.getNbLiasses().trim().isEmpty() &&
! collectionBotanique.getFormatLiasses().trim().isEmpty()) {
liasses += " - "+i18nC.format()+": ";
}
liasses += collectionBotanique.getFormatLiasses();
descriptionParams.set("nb_liasses", liasses);
 
descriptionParams.set("autres_unites_rangement", collectionBotanique.getAutresUnitesRangement().replaceAll("\r\n|\r|\n", ", "));
 
String etatUniteRangement = collectionBotanique.getUniteRangementEtat();
String[] ontoValEtatUniteRangement = OntologiesLocales.getListeBonMauvaisEtat().get(etatUniteRangement);
String eur = etatUniteRangement;
if (ontoValEtatUniteRangement != null && ontoValEtatUniteRangement.length > 0) {
eur = ontoValEtatUniteRangement[0];
Coel.LogVersFirebug("ontoValEtatUniteRangement[0]: " + eur);
}
descriptionParams.set("etat_unite_rangement", eur);
descriptionParams.set("i18n_nb_planches_herbier", i18nC.collectionNbPlanchesHerbier());
descriptionParams.set("i18n_nb_especes", i18nC.collectionNbEspeces());
descriptionParams.set("nb_planches_herbier", collectionBotanique.getNbPlanchesHerbiers());
descriptionParams.set("nb_especes", collectionBotanique.getNbEspeces());
String typePapier = construireTxtListeOntologie(collectionBotanique.getConservationPapierType());
String conservationMethode = construireTxtListeOntologie(collectionBotanique.getConservationMethode());
descriptionParams.set("type_papier", typePapier);
descriptionParams.set("conservation_methode", conservationMethode);
String specimenFixationMethode = construireTxtListeOntologie(collectionBotanique.getSpecimenFixationMethode());
String etiquetteFixationMethodeSupport = construireTxtListeOntologie(collectionBotanique.getEtiquetteFixationSupport());
String etiquetteFixationMethodeSpecimen = construireTxtListeOntologie(collectionBotanique.getEtiquetteFixationSpecimen());
String etiquetteTypeEcriture = construireTxtListeOntologie(collectionBotanique.getEtiquetteEcriture());
descriptionParams.set("specimen_fixation_pourcent", collectionBotanique.getSpecimenFixationPourcent());
descriptionParams.set("etiquette_fixation_pourcent", collectionBotanique.getEtiquetteFixationPourcent());
descriptionParams.set("specimen_fixation_methode", specimenFixationMethode);
descriptionParams.set("etiquette_fixation_methode_support", etiquetteFixationMethodeSupport);
descriptionParams.set("etiquette_fixation_methode_specimen", etiquetteFixationMethodeSpecimen);
descriptionParams.set("etiquette_type_ecriture", etiquetteTypeEcriture);
String traitement = construireTxtListeOntologie(collectionBotanique.getTraitement());
String traitementPoison = construireTxtListeOntologie(collectionBotanique.getTraitementPoison());
String traitementInsecte = construireTxtListeOntologie(collectionBotanique.getTraitementInsecte());
descriptionParams.set("traitement", traitement);
descriptionParams.set("traitement_poison", traitementPoison);
descriptionParams.set("traitement_insecte", traitementInsecte);
 
String etatGeneral = collectionBotanique.getEtatGeneral();
boolean valeurEstOntologie = false;
boolean typeEstOntologie = true;
boolean donneeEstOntologie = true;
String degradationSpecimen = construireTxtListeOntologie(collectionBotanique.getDegradationSpecimen(), valeurEstOntologie, typeEstOntologie, donneeEstOntologie);
String degradationPresentation = construireTxtListeOntologie(collectionBotanique.getDegradationPresentation(), valeurEstOntologie, typeEstOntologie, donneeEstOntologie);
String determination = construireTxtListeOntologie(collectionBotanique.getDetermination());
 
String[] ontoVal2 = OntologiesLocales.getListeBonMauvaisEtat().get(etatGeneral);
//Coel.LogVersFirebug("ontoval2: " + ontoVal2);
String eg = etatGeneral;
if (ontoVal2 != null && ontoVal2.length > 0) {
//Coel.LogVersFirebug("ontoval2[0]: " + ontoVal2[0]);
eg = ontoVal2[0];
}
descriptionParams.set("etat_general", eg);
 
descriptionParams.set("degradation_specimen", degradationSpecimen);
descriptionParams.set("degradation_presentation", degradationPresentation);
descriptionParams.set("determination", determination);
afficherOnglet(descriptionTpl, descriptionParams, descriptionOnglet);
}
private void afficherContenu() {
Params contenuParams = new Params();
contenuParams.set("i18n_titre_nature", i18nC.collectionNatureTitre());
contenuParams.set("i18n_nature", i18nC.natureVegetaleContenuDetail());
contenuParams.set("i18n_specialite", i18nC.specialiteCollectionDetail());
contenuParams.set("i18n_titre_classement", i18nC.collectionClassementTitre());
contenuParams.set("i18n_classement_etat", i18nC.etatClassementCollectionDetail());
contenuParams.set("i18n_classement", i18nC.annotationClassementCollectionDetail());
contenuParams.set("i18n_titre_etiquette", i18nC.collectionEtiquetteTitre());
contenuParams.set("i18n_etiquette_renseignement", i18nC.etiquetteRenseignementDetail());
contenuParams.set("i18n_precision_localite", i18nC.precisionLocaliteDetail());
contenuParams.set("i18n_precision_date", i18nC.precisionDateDetail());
contenuParams.set("i18n_etiquette_annotation", i18nC.etiquetteAnnotationDetail());
contenuParams.set("i18n_titre_integree", i18nC.collectionIntegreeTitre());
contenuParams.set("i18n_collection_integration", i18nC.integreCollectionDetail());
contenuParams.set("i18n_collection_integration_info", i18nC.infoIntegreCollectionDetail());
CollectionBotanique collectionBotanique = collection.getBotanique();
String nature = construireTxtListeOntologie(collectionBotanique.getNature());
contenuParams.set("nature", nature);
contenuParams.set("specialite", collectionBotanique.getSpecialite());
String classementEtat = construireTxtListeOntologie(collectionBotanique.getClassementEtat());
contenuParams.set("classement_etat", classementEtat);
contenuParams.set("classement", collectionBotanique.getClassementAnnotation());
String etiquetteRenseignements = "";
HashMap<String,String> infos = CollectionFormContenu.parserEtiquetteRenseignement(collectionBotanique.getEtiquetteRenseignement());
if (infos != null) {
Iterator<String> it = infos.keySet().iterator();
while (it.hasNext()) {
String cle = it.next();
if (cle.equals("AT")) {
etiquetteRenseignements += i18nC.etiquetteAuteurCollection();
} else if (cle.equals("F")) {
etiquetteRenseignements += i18nC.etiquetteFamille();
} else if (cle.equals("G")) {
etiquetteRenseignements += i18nC.etiquetteGenre();
} else if (cle.equals("SP")) {
etiquetteRenseignements += i18nC.etiquetteSp();
} else if (cle.equals("ASP")) {
etiquetteRenseignements += i18nC.etiquetteAuteurSp();
} else if (cle.equals("L")) {
etiquetteRenseignements += i18nC.etiquetteLocalite();
} else if (cle.equals("D")) {
etiquetteRenseignements += i18nC.etiquetteDateRecolte();
} else {
etiquetteRenseignements += i18nC.inconnue();
}
if (it.hasNext()) etiquetteRenseignements += ": "+infos.get(cle)+"%, ";
else etiquetteRenseignements += ": "+infos.get(cle)+"%.";
}
}
String precisionLocalite = construireTxtListeOntologie(collectionBotanique.getPrecisionLocalite());
String precisionDate = construireTxtListeOntologie(collectionBotanique.getPrecisionDate());
contenuParams.set("etiquette_renseignement", etiquetteRenseignements);
contenuParams.set("precision_localite", precisionLocalite);
contenuParams.set("precision_date", precisionDate);
contenuParams.set("etiquette_annotation", collectionBotanique.getAnnotationsDiverses());
String collectionIntegration = construireTxtListeOntologie(collectionBotanique.getCollectionIntegre());
String collectionIntegrationInfo = construireTxtListeOntologie(collectionBotanique.getCollectionIntegreInfo());
contenuParams.set("collection_integration", collectionIntegration);
contenuParams.set("collection_integration_info", collectionIntegrationInfo);
afficherOnglet(contenuTpl, contenuParams, contenuOnglet);
}
private void afficherInventaire() {
Params inventaireParams = new Params();
inventaireParams.set("i18n_titre_inventaire", i18nC.collectionInventaireTitre());
inventaireParams.set("i18n_existence", i18nC.existenceInventaireCollectionDetail());
inventaireParams.set("i18n_participation_auteur", i18nC.auteurInventaireCollectionDetail());
inventaireParams.set("i18n_forme", i18nC.formeInventaireCollectionDetail());
inventaireParams.set("i18n_info", i18nC.infoInventaireCollectionDetail());
inventaireParams.set("i18n_digital", i18nC.digitalInventaireCollectionDetail());
inventaireParams.set("i18n_digital_pourcent", i18nC.pourcentDigitalInventaireCollectionDetail());
inventaireParams.set("i18n_etat", i18nC.etatInventaireCollectionDetail());
//DELETEME inventaireParams.set("i18n_type_donnee", i18nC.typeDonneeInventaireCollectionDetail());
CollectionBotanique collectionBotanique = collection.getBotanique();
String existence = OntologiesLocales.getValeurOntologie(OntologiesLocales.getListeOuiNonPeutEtre(), collectionBotanique.getInventaire());
String participationAuteur = OntologiesLocales.getValeurOntologie(OntologiesLocales.getListeOuiNonPeutEtre(), collectionBotanique.getInventaireAuteur());
String forme = construireTxtListeOntologie(collectionBotanique.getInventaireForme());
String digital = construireTxtListeOntologie(collectionBotanique.getInventaireDigital());
String digitalPourcent = collectionBotanique.getInventaireDigitalPourcent()+"%";
String etat = construireTxtListeOntologie(collectionBotanique.getInventaireEtat());
inventaireParams.set("existence", existence);
inventaireParams.set("participation_auteur", participationAuteur);
inventaireParams.set("forme", forme);
inventaireParams.set("info", collectionBotanique.getInventaireInfo());
inventaireParams.set("digital", digital);
inventaireParams.set("digital_pourcent", digitalPourcent);
inventaireParams.set("etat", etat);
afficherOnglet(inventaireTpl, inventaireParams, inventaireOnglet);
}
private void afficherCommentaire() {
String tableauCommentaireHtml = "";
if (collection.getCommentairesLiees() != null && collection.getCommentairesLiees().size() > 0) {
tableauCommentaireHtml = construireTableauCommentairesLiees();
}
Params personneParams = new Params();
personneParams.set("i18n_titre_commentaire", i18nC.collectionCommentaireTitre());
personneParams.set("tableau_commentaires_liees", tableauCommentaireHtml);
afficherOnglet(commentaireTpl, personneParams, commentaireOnglet);
}
private String construireTableauCommentairesLiees() {
Params contenuParams = new Params();
contenuParams.set("i18n_type", i18nC.commentaireType());
contenuParams.set("i18n_titre", i18nC.commentaireTitre());
contenuParams.set("i18n_texte", i18nC.commentaireTexte());
contenuParams.set("i18n_ponderation", i18nC.commentairePonderation());
contenuParams.set("i18n_public", i18nC.commentairePublic());
String lignesCommentaire = "";
if (collection.getCommentairesLiees() != null) {
Iterator<String> it = collection.getCommentairesLiees().keySet().iterator();
while (it.hasNext()) {
CollectionACommentaire relationCollectionACommentaire = collection.getCommentairesLiees().get(it.next());
Commentaire commentaire = relationCollectionACommentaire.getCommentaire();
String type = construireTxtListeOntologie(relationCollectionACommentaire.getType());
String acces = (commentaire.etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
Params ligneParams = new Params();
ligneParams.set("type", type);
ligneParams.set("titre", commentaire.getTitre());
ligneParams.set("texte", commentaire.getTexte());
ligneParams.set("ponderation", commentaire.getPonderation()+"/100");
ligneParams.set("public", acces);
lignesCommentaire += Format.substitute(ligneCommentaireLieeTpl, ligneParams);
}
}
String cHtml = i18nC.nonRenseigne();
if (!UtilString.isEmpty(lignesCommentaire)) {
contenuParams.set("lignes", lignesCommentaire);
cHtml = Format.substitute(tableauCommentairesLieesTpl, contenuParams);
}
return cHtml;
}
protected String getNomStructure() {
String nomStructure = "";
if (structure != null) {
nomStructure = structure.getNom();
} else {
nomStructure = collection.getIdStructure();
}
return nomStructure;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java:r11-933,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection/CollectionForm.java
New file
0,0 → 1,418
package org.tela_botanica.client.vues.collection;
 
import java.util.ArrayList;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.interfaces.Rafraichissable;
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.modeles.collection.Collection;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilArray;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.structure.StructureForm;
 
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
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.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.google.gwt.user.client.Window;
 
public class CollectionForm extends Formulaire implements Rafraichissable {
 
protected Collection collection = null;
protected Collection collectionCollectee = null;
 
private ChampComboBoxListeValeurs typesCollectionCombo = null;
private TabPanel onglets = null;
private CollectionFormGeneral generalOnglet = null;
private CollectionFormPersonne personneOnglet = null;
private CollectionFormPublication publicationOnglet = null;
private CollectionFormDescription descriptionOnglet = null;
private CollectionFormContenu contenuOnglet = null;
private CollectionFormInventaire inventaireOnglet = null;
private CollectionFormCommentaire commentaireOnglet = null;
private TextField<String> nomChp = null;
private Sequenceur sequenceur = new Sequenceur();
public CollectionForm(Mediateur mediateurCourrant, String collectionId) {
initialiserCollectionForm(mediateurCourrant, collectionId);
}
private void initialiserCollectionForm(Mediateur mediateurCourrant, String collectionId) {
collection = new Collection();
collection.setId(collectionId);
String modeDeCreation = (UtilString.isEmpty(collection.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION);
genererTitreFormulaire();
creerOnglets();
creerFieldsetPrincipal();
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
mediateurCourrant.selectionnerCollection(this, collectionId, null, sequenceur);
mediateurCourrant.selectionnerCollectionAPersonne(this, collectionId, null, sequenceur);
//mediateurCourrant.selectionnerCollectionAPublication(this, collectionId, sequenceur);
//mediateurCourrant.selectionnerCollectionACommentaire(this, collectionId, sequenceur);
}
}
private void genererTitreFormulaire() {
String titre = i18nC.collectionTitreFormAjout();
if (mode.equals(Formulaire.MODE_MODIFIER)) {
titre = i18nC.collectionTitreFormModif();
if (collection != null) {
titre += " - "+i18nC.id()+": "+collection.getId();
}
}
panneauFormulaire.setHeadingHtml(titre);
}
private void creerFieldsetPrincipal() {
FieldSet principalFieldSet = new FieldSet();
principalFieldSet.setHeadingHtml("Info");
principalFieldSet.setCollapsible(true);
principalFieldSet.setLayout(Formulaire.creerFormLayout(150, LabelAlign.LEFT));
nomChp = new TextField<String>();
nomChp.setTabIndex(tabIndex++);
nomChp.setFieldLabel(i18nC.nomCollection());
nomChp.setAllowBlank(false);
nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
nomChp.getMessages().setBlankText(i18nC.champObligatoire());
principalFieldSet.add(nomChp, new FormData(450, 0));
Listener<BaseEvent> ecouteurTypeCollection = new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
Valeur valeur = typesCollectionCombo.getValue();
// Gestion des onglets en fonction du type de collection
mediateur.activerChargement(this, "Chargement des onglets");
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) {
activerOngletsHerbier();
} else {
activerOngletsDefaut();
}
mediateur.desactiverChargement(this);
}
};
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++);
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER);
typesCollectionCombo.addStyleName(ComposantClass.OBLIGATOIRE);
typesCollectionCombo.addListener(Events.Change, ecouteurTypeCollection);
typesCollectionCombo.addListener(Events.Select, ecouteurTypeCollection);
typesCollectionCombo.addListener(Events.Valid, creerEcouteurChampObligatoire());
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0));
typesCollectionCombo.fireEvent(Events.Select);
panneauFormulaire.setTopComponent(principalFieldSet);
}
private void activerOngletsDefaut() {
if (onglets.findItem(CollectionFormGeneral.ID, false) == null) {
onglets.add(generalOnglet);
}
if (onglets.findItem(CollectionFormPersonne.ID, false) == null) {
onglets.add(personneOnglet);
}
if (onglets.findItem(CollectionFormPublication.ID, false) != null) {
onglets.remove(publicationOnglet);
}
if (onglets.findItem(CollectionFormDescription.ID, false) != null) {
onglets.remove(descriptionOnglet);
}
if (onglets.findItem(CollectionFormContenu.ID, false) != null) {
onglets.remove(contenuOnglet);
}
if (onglets.findItem(CollectionFormInventaire.ID, false) != null) {
onglets.remove(inventaireOnglet);
}
if (onglets.findItem(CollectionFormCommentaire.ID, false) != null) {
onglets.remove(commentaireOnglet);
}
panneauFormulaire.layout();
}
 
private void activerOngletsHerbier() {
if (onglets.findItem(CollectionFormGeneral.ID, false) == null) {
onglets.add(generalOnglet);
}
if (onglets.findItem(CollectionFormPersonne.ID, false) == null) {
onglets.add(personneOnglet);
}
if (onglets.findItem(CollectionFormPublication.ID, false) == null) {
onglets.add(publicationOnglet);
}
if (onglets.findItem(CollectionFormDescription.ID, false) == null) {
onglets.add(descriptionOnglet);
}
if (onglets.findItem(CollectionFormContenu.ID, false) == null) {
onglets.add(contenuOnglet);
}
if (onglets.findItem(CollectionFormInventaire.ID, false) == null) {
onglets.add(inventaireOnglet);
}
if (onglets.findItem(CollectionFormCommentaire.ID, false) == null) {
onglets.add(commentaireOnglet);
}
panneauFormulaire.layout();
}
private void creerOnglets() {
onglets = new TabPanel();
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner)
onglets.setHeight("100%");
// Onlget formulaire GENERAL
onglets.add(creerOngletGeneral());
// Onlget formulaire AUTEUR
onglets.add(creerOngletPersonne());
// Onlget formulaire PUBLICATION
onglets.add(creerOngletPublication());
// Onlget formulaire DESCRIPTION
onglets.add(creerOngletDescription());
// Onlget formulaire CONTENU
onglets.add(creerOngletContenu());
// Onlget formulaire INVENTAIRE
onglets.add(creerOngletInventaire());
// Onlget formulaire COMMENTAIRE
onglets.add(creerOngletCommentaire());
// Sélection de l'onglet par défaut
onglets.setSelection(generalOnglet);
panneauFormulaire.add(onglets);
}
private TabItem creerOngletGeneral() {
generalOnglet = new CollectionFormGeneral(this);
return generalOnglet;
}
private TabItem creerOngletPersonne() {
personneOnglet = new CollectionFormPersonne(this);
return personneOnglet;
}
private TabItem creerOngletPublication() {
publicationOnglet = new CollectionFormPublication(this);
return publicationOnglet;
}
private TabItem creerOngletDescription() {
descriptionOnglet = new CollectionFormDescription(this);
return descriptionOnglet;
}
private TabItem creerOngletContenu() {
contenuOnglet = new CollectionFormContenu(this);
return contenuOnglet;
}
private TabItem creerOngletInventaire() {
inventaireOnglet = new CollectionFormInventaire(this);
return inventaireOnglet;
}
private TabItem creerOngletCommentaire() {
commentaireOnglet = new CollectionFormCommentaire(this);
return commentaireOnglet;
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
controlerFermeture();
}
 
private void rafraichirInformation(Information info) {
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
Debug.log("MESSAGES:\n"+info.getMessages().toString());
}
String infoType = info.getType();
if (infoType.equals("modif_collection")) {
InfoLogger.display("Modification d'une collection", info.toString());
repandreRafraichissement();
} else if (infoType.equals("selection_collection")) {
InfoLogger.display("Modification d'une collection", info.toString());
if (info.getDonnee(0) != null) {
collection = (Collection) info.getDonnee(0);
}
peupler();
genererTitreFormulaire();
} else if (infoType.equals("ajout_collection")) {
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
String collectionId = (String) info.getDonnee(0);
InfoLogger.display("Ajout d'une collection", "La collection '"+collectionId+"' a bien été ajoutée");
collection.setId(collectionId);
// 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);
commentaireOnglet.rafraichir(info);
this.mode = MODE_MODIFIER;
} else {
InfoLogger.display("Ajout d'une collection", info.toString());
}
} else if (infoType.equals("liste_collection_a_personne")) {
personneOnglet.rafraichir(info);
} else if (infoType.equals("liste_collection_a_publication")) {
publicationOnglet.rafraichir(info);
} else if (infoType.equals("liste_collection_a_commentaire")) {
commentaireOnglet.rafraichir(info);
}
}
private void peupler() {
if (collection != null) {
nomChp.setValue(collection.getNom());
typesCollectionCombo.peupler(collection.getTypeNcd());
peuplerOnglets();
}
}
 
private void peuplerOnglets() {
generalOnglet.peupler();
descriptionOnglet.peupler();
contenuOnglet.peupler();
inventaireOnglet.peupler();
commentaireOnglet.peupler();
}
 
public boolean soumettreFormulaire() {
// Vérification de la validité des champs du formulaire
boolean formulaireValide = verifierFormulaire();
 
if (formulaireValide) {
// Collecte des données du formulaire
Collection collectionAEnregistrer = collecterCollection();
if (mode.equals(MODE_AJOUTER)) {
mediateur.ajouterCollection(this, collectionAEnregistrer);
} else if (mode.equals(MODE_MODIFIER)) {
if (collectionAEnregistrer == null) {
//InfoLogger.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
this.controlerFermeture();
} else {
mediateur.modifierCollection(this, collectionAEnregistrer);
}
}
soumettreOnglets();
}
return formulaireValide;
}
private void soumettreOnglets() {
personneOnglet.soumettre();
publicationOnglet.soumettre();
commentaireOnglet.soumettre();
}
private Collection collecterCollection() {
collectionCollectee = (Collection) collection.cloner(new Collection());
this.collecter();
collecterOnglets();
Collection collectionARetourner = null;
if (!collectionCollectee.comparer(collection) ||
!collectionCollectee.getBotanique().comparer(collection.getBotanique()) ||
publicationOnglet.publicationsSontModifiees) {
collectionARetourner = collection = collectionCollectee;
publicationOnglet.publicationsSontModifiees = false;
}
return collectionARetourner;
}
private void collecter() {
collectionCollectee.setNom(nomChp.getValue());
collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId());
}
 
private void collecterOnglets() {
generalOnglet.collecter();
personneOnglet.collecter();
publicationOnglet.collecter();
descriptionOnglet.collecter();
contenuOnglet.collecter();
inventaireOnglet.collecter();
commentaireOnglet.collecter();
}
 
public 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("")
|| (mode.equals(MODE_MODIFIER) && collection != null && 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("")) {
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;
}
private void repandreRafraichissement() {
if (vueExterneARafraichirApresValidation != null) {
String type = "modif_collection";
if (mode.equals(Formulaire.MODE_AJOUTER)) {
type = "ajout_collection";
}
Information info = new Information(type);
info.setDonnee(0, collection);
vueExterneARafraichirApresValidation.rafraichir(info);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/collection/CollectionForm.java:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionForm.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionForm.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/collection
New file
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/collection:r11-933,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection:r1136-1291
Merged /branches/v1.8-narince/src/org/tela_botanica/client/vues/collection:r1891-1892
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/FenetreForm.java
New file
0,0 → 1,30
package org.tela_botanica.client.vues;
 
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
 
public class FenetreForm extends Window {
 
public FenetreForm(String titre) {
int hauteur = (int) Math.ceil(com.google.gwt.user.client.Window.getClientHeight() * .8);
int largeur = (int) Math.ceil(com.google.gwt.user.client.Window.getClientWidth() * .8);
setSize(largeur, hauteur);
setPlain(true);
setModal(true);
setBlinkModal(true);
setHeadingHtml(titre);
setLayout(new FitLayout());
setOnEsc(false);
}
public void setTailleFenetre(double ratioParRapportAEcran) {
int hauteur = (int) Math.ceil(com.google.gwt.user.client.Window.getClientHeight() * ratioParRapportAEcran);
int largeur = (int) Math.ceil(com.google.gwt.user.client.Window.getClientWidth() * ratioParRapportAEcran);
setSize(largeur, hauteur);
}
public void setTailleFenetre(int hauteur, int largeur) {
setSize(largeur, hauteur);
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/FenetreForm.java:r11-702,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/FenetreForm.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/FenetreForm.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/FormulaireOnglet.java
New file
0,0 → 1,81
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.i18n.ErrorMessages;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.synchronisation.Sequenceur;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
 
public abstract class FormulaireOnglet extends TabItem implements Rafraichissable {
protected Formulaire formulaire = null;
protected Mediateur mediateur = null;
protected Constantes i18nC = null;
protected ErrorMessages i18nM = null;
protected Configuration config = null;
protected String mode = null;
protected int tabIndex = 100;
protected static LabelAlign alignementLabelDefaut = LabelAlign.LEFT;
protected static int largeurLabelDefaut = 250;
public FormulaireOnglet() {
parametrer(this);
addListener(Events.Select, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
setAcces(true);
actualiser();
}
});
}
public static void parametrer(TabItem onglet) {
FormLayout layout = new FormLayout();
layout.setLabelWidth(largeurLabelDefaut);
layout.setLabelAlign(alignementLabelDefaut);
onglet.setLayout(layout);
onglet.setStyleAttribute("padding", "10px");
onglet.setScrollMode(Scroll.AUTO);
onglet.setData("acces", false);
}
 
protected void initialiserOnglet(Formulaire formulaireCourrant) {
formulaire = formulaireCourrant;
mediateur = formulaire.mediateur;
i18nC = Mediateur.i18nC;
i18nM = Mediateur.i18nM;
config = (Configuration) Registry.get(RegistreId.CONFIG);
mode = formulaire.mode;
tabIndex = formulaire.tabIndex;
}
public void actualiser() {
layout();
}
public void setAcces(boolean acces) {
this.setData("acces", acces);
}
public boolean etreAccede() {
boolean acces = false;
if (isAttached()) {
acces = this.getData("acces");
}
return acces;
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/FormulaireOnglet.java:r11-686,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/FormulaireOnglet.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/FormulaireOnglet.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureFormConservation.java
New file
0,0 → 1,562
package org.tela_botanica.client.vues.structure;
 
import java.util.ArrayList;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.structure.StructureConservation;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
 
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
 
public class StructureFormConservation extends FormulaireOnglet implements Rafraichissable {
 
private StructureConservation conservation = null;
private CheckBoxGroup localStockageTrukCacGrpChp = null;
private LayoutContainer localStockageTrukCp = null;
private CheckBoxGroup meubleStockageTrukCacGrpChp = null;
private LayoutContainer meubleStockageTrukCp = null;
private CheckBoxGroup parametreStockageTrukCacGrpChp = null;
private LayoutContainer parametreStockageTrukCp = null;
private LayoutContainer collectionAutreTrukCp = null;
private CheckBoxGroup collectionAutreTrukCacGrpChp = null;
private CheckBoxGroup opRestauTrukCacGrpChp = null;
private LayoutContainer opRestauTrukCp = null;
private CheckBoxGroup autreMaterielTrukCacGrpChp = null;
private LayoutContainer autreMaterielTrukCp = null;
private RadioGroup formationMarkRGrpChp = null;
private RadioGroup interetFormationMarkRGrpChp = null;
private RadioGroup collectionCommuneMarkRGrpChp = null;
private RadioGroup accesControleMarkRGrpChp = null;
private RadioGroup restaurationMarkRGrpChp = null;
private RadioGroup traitementMarkRGrpChp = null;
private RadioGroup collectionAcquisitionMarkRGrpChp = null;
private RadioGroup echantillonAcquisitionMarkRGrpChp = null;
private LayoutContainer traitementTrukCp = null;
private CheckBoxGroup traitementTrukCacGrpChp = null;
private LayoutContainer poisonTraitementTrukCp = null;
private LayoutContainer insecteTraitementTrukCp = null;
private CheckBoxGroup insecteTraitementTrukCacGrpChp = null;
private CheckBoxGroup poisonTraitementTrukCacGrpChp = null;
private TextField<String> formationChp = null;
private RadioGroup materielConservationCeRGrpChp = null;
private LayoutContainer materielConservationCp = null;
private RadioGroup traitementAcquisitionMarkRGrpChp = null;
private LabelField traitementAcquisitionMarkLabel = null;
private TextField<String> localStockageAutreChp = null;
private TextField<String> meubleStockageAutreChp = null;
private TextField<String> parametreStockageAutreChp = null;
private TextField<String> collectionAutreAutreChp = null;
private TextField<String> opRestauAutreChp = null;
private TextField<String> autreMaterielAutreChp = null;
private TextField<String> traitementAutreChp = null;
private TextField<String> poisonTraitementAutreChp = null;
private TextField<String> insecteTraitementAutreChp = null;
private String ID = "conservation";
private Formulaire formulaireCourant = null;
private Mediateur mediateur = null;
private Sequenceur sequenceur = null;
public StructureFormConservation(Mediateur mediateur, Formulaire formulaireCourant, Sequenceur sequenceur) {
initialiserOnglet(formulaireCourant);
this.mediateur = mediateur;
this.formulaireCourant = formulaireCourant;
this.sequenceur = sequenceur;
setId(ID);
setText(Mediateur.i18nC.structureInfoConservation());
FormulaireOnglet.parametrer(this);
this.setLayout(Formulaire.creerFormLayout(650, LabelAlign.TOP));
Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
peupler();
layout();
}
};
this.addListener(Events.Select, ecouteurSelection);
formationMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("formation_mark", "ouiNon");
formationMarkRGrpChp.setFieldLabel("Le personnel s'occupant des collections a-t-il suivi des formations en conservation ?");
this.add(formationMarkRGrpChp);
formationChp = new TextArea();
formationChp.hide();
formationChp.addListener(Events.Hide, new Listener<BaseEvent>() {
 
public void handleEvent(BaseEvent be) {
((TextArea) be.getSource()).setValue("");
}
});
formationChp.setFieldLabel("Si oui, lesquelles ?");
this.add(formationChp);
interetFormationMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("interet_formation_mark", "ouiNon");
interetFormationMarkRGrpChp.setFieldLabel("Seriez vous intéressé par une formation à la conservation et à la restauration d'herbier ?");
interetFormationMarkRGrpChp.setHeight(35);
this.add(interetFormationMarkRGrpChp);
localStockageTrukCacGrpChp = new CheckBoxGroup();
localStockageTrukCacGrpChp.setFieldLabel("Avez vous des locaux spécifiques de stockage des collections botaniques ?");
localStockageTrukCp = Formulaire.creerChoixMultipleCp();
this.add(localStockageTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "localStockage", sequenceur);
meubleStockageTrukCp = Formulaire.creerChoixMultipleCp();
meubleStockageTrukCacGrpChp = new CheckBoxGroup();
meubleStockageTrukCacGrpChp.setFieldLabel("Avez vous des meubles spécifiques au stockage des collections botaniques ?");
this.add(meubleStockageTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "meubleStockage", sequenceur);
parametreStockageTrukCp = Formulaire.creerChoixMultipleCp();
parametreStockageTrukCacGrpChp = new CheckBoxGroup();
parametreStockageTrukCacGrpChp.setFieldLabel("Quels paramètres maîtrisez vous ?");
this.add(parametreStockageTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "parametreStockage", sequenceur);
collectionCommuneMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("collection_commune_mark", "ouiNon");
collectionCommuneMarkRGrpChp.setFieldLabel("Les collections botaniques sont-elles conservées avec d'autres collections dans les mêmes locaux (problème de conservation en commun) ?");
this.add(collectionCommuneMarkRGrpChp);
collectionAutreTrukCp = Formulaire.creerChoixMultipleCp();
collectionAutreTrukCacGrpChp = new CheckBoxGroup();
collectionAutreTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");
collectionAutreTrukCp.hide();
this.add(collectionAutreTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "autreCollection", sequenceur);
accesControleMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("mark_acces_controle", "ouiNon");
accesControleMarkRGrpChp.setFieldLabel("L'accès à vos collections botanique est-il contrôlé (ex. : manipulation réservées à des personnes compétentes) ?");
this.add(accesControleMarkRGrpChp);
restaurationMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("restauration_mark", "ouiNon");
restaurationMarkRGrpChp.setFieldLabel("Effectuez vous des opérations de restauration ou de remise en état de vos collections botaniques ?");
this.add(restaurationMarkRGrpChp);
opRestauTrukCp = Formulaire.creerChoixMultipleCp();
opRestauTrukCacGrpChp = new CheckBoxGroup();
opRestauTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");
opRestauTrukCp.hide();
this.add(opRestauTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "opRestau", sequenceur);
// Création d'un ContentPanel vide et du groupe de bouton radio
// Le groupe de bouton radio recevra les boutons au moment de la réception des données (rafraichir()) et ser à ce moment là ajouter au ContenetPanel
materielConservationCp = Formulaire.creerChoixMultipleCp();
this.add(materielConservationCp);
materielConservationCeRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("materiel_conservation_ce", "onep");
materielConservationCeRGrpChp.setFieldLabel("Utilisez vous du matériel de conservation ?");
materielConservationCeRGrpChp.setToolTip(new ToolTipConfig("Matériel de conservation", "matériel spécialisé pour la conservation des archives ou du patrimoine fragile. Ce matériel possède des propriétés mécaniques et chimiques qui font qu'il résiste dans le temps et que sa dégradation n'entraîne pas de dommages sur le matériel qu'il aide à conserver. Exemples : papier neutre, papier gommé, etc..."));
mediateur.obtenirListeValeurEtRafraichir(this, "onep", sequenceur);
autreMaterielTrukCp = Formulaire.creerChoixMultipleCp();
autreMaterielTrukCacGrpChp = new CheckBoxGroup();
autreMaterielTrukCacGrpChp.setFieldLabel("Si non, qu'utilisez vous comme matériel ?");
autreMaterielTrukCp.hide();
this.add(autreMaterielTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "autreMateriel", sequenceur);
traitementMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("traitement_mark", "ouiNon");
traitementMarkRGrpChp.setFieldLabel("Réalisez vous actuellement des traitements globaux contre les insectes ?");
this.add(traitementMarkRGrpChp);
traitementTrukCp = Formulaire.creerChoixMultipleCp();
traitementTrukCp.hide();
traitementTrukCacGrpChp = new CheckBoxGroup();
traitementTrukCacGrpChp.setFieldLabel("Si oui, lesquels ?");
this.add(traitementTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "insecteTraitement", sequenceur);
collectionAcquisitionMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("collection_acquisition_mark", "ouiNon");
collectionAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, vos collections botaniques s'accroissent-elles de nouvelles acquisitions ?");
this.add(collectionAcquisitionMarkRGrpChp);
echantillonAcquisitionMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("echantillon_acquisition_mark", "ouiNon");
echantillonAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, mettez vous en herbier de nouveaux échantillons ?");
this.add(echantillonAcquisitionMarkRGrpChp);
 
traitementAcquisitionMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("traitement_acquisition_mark", "ouiNon");
traitementAcquisitionMarkRGrpChp.hide();
traitementAcquisitionMarkRGrpChp.setFieldLabel("Si oui, faites-vous un traitement contre les insectes avant l'intégration dans vos collections ?");
this.add(traitementAcquisitionMarkRGrpChp);
traitementAcquisitionMarkLabel = new LabelField();
traitementAcquisitionMarkLabel.hide();
traitementAcquisitionMarkLabel.setFieldLabel("Si oui, lesquels ?");
this.add(traitementAcquisitionMarkLabel);
poisonTraitementTrukCp = Formulaire.creerChoixMultipleCp();
poisonTraitementTrukCp.hide();
poisonTraitementTrukCacGrpChp = new CheckBoxGroup();
poisonTraitementTrukCacGrpChp.setFieldLabel("Empoisonnement");
poisonTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;");
poisonTraitementTrukCacGrpChp.setLabelSeparator("");
this.add(poisonTraitementTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "poisonTraitement", sequenceur);
insecteTraitementTrukCp = Formulaire.creerChoixMultipleCp();
insecteTraitementTrukCp.hide();
insecteTraitementTrukCacGrpChp = new CheckBoxGroup();
insecteTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;");
insecteTraitementTrukCacGrpChp.setLabelSeparator("");
insecteTraitementTrukCacGrpChp.setFieldLabel("Désinsectisation");
this.add(insecteTraitementTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "insecteTraitement", sequenceur);
this.add(new Html("<br />"));
}
@Override
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
}
}
public void rafraichirInformation(Information info) {
if (info.getDonnee(1) != null) {
conservation = (StructureConservation) info.getDonnee(1);
peupler();
}
}
public void rafraichirValeurListe(ValeurListe listeValeurs) {
List<Valeur> liste = listeValeurs.toList();
if (listeValeurs.getId().equals(config.getListeId("localStockage"))) {
localStockageAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(localStockageTrukCp, localStockageTrukCacGrpChp, listeValeurs, localStockageAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("meubleStockage"))) {
meubleStockageAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(meubleStockageTrukCp, meubleStockageTrukCacGrpChp, listeValeurs, meubleStockageAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("parametreStockage"))) {
parametreStockageAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(parametreStockageTrukCp, parametreStockageTrukCacGrpChp, listeValeurs, parametreStockageAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("autreCollection"))) {
if (collectionAutreTrukCp != null && collectionAutreTrukCp.getItemByItemId("collectionAutreTrukCacGrpChp") == null) {
collectionAutreTrukCacGrpChp.setId("collectionAutreTrukCacGrpChp");
collectionAutreAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(collectionAutreTrukCp, collectionAutreTrukCacGrpChp, listeValeurs, collectionAutreAutreChp);
}
}
if (listeValeurs.getId().equals(config.getListeId("opRestau"))) {
opRestauAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(opRestauTrukCp, opRestauTrukCacGrpChp, listeValeurs, opRestauAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("onep"))) {
formulaireCourant.creerChoixUniqueBoutonRadio(materielConservationCeRGrpChp, Formulaire.trierListeOuiNonEnPartie(listeValeurs));
materielConservationCp.add(materielConservationCeRGrpChp);
materielConservationCp.layout();
}
if (listeValeurs.getId().equals(config.getListeId("autreMateriel"))) {
autreMaterielAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(autreMaterielTrukCp, autreMaterielTrukCacGrpChp, listeValeurs, autreMaterielAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("poisonTraitement"))) {
poisonTraitementAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(poisonTraitementTrukCp, poisonTraitementTrukCacGrpChp, listeValeurs, poisonTraitementAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("insecteTraitement"))) {
if (traitementTrukCp != null && traitementTrukCp.getItemByItemId("traitementTrukCacGrpChp") == null) {
traitementTrukCacGrpChp.setId("traitementTrukCacGrpChp");
traitementAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(traitementTrukCp, traitementTrukCacGrpChp, listeValeurs, traitementAutreChp);
}
if (insecteTraitementTrukCp != null && insecteTraitementTrukCp.getItemByItemId("insecteTraitementTrukCacGrpChp") == null) {
insecteTraitementTrukCacGrpChp.setId("insecteTraitementTrukCacGrpChp");
insecteTraitementAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(insecteTraitementTrukCp, insecteTraitementTrukCacGrpChp, listeValeurs, insecteTraitementAutreChp);
}
}
}
private void initialiserConservation() {
conservation = ((StructureForm)formulaireCourant).conservation;
}
public StructureConservation collecter() {
if(conservation == null) {
initialiserConservation();
}
StructureConservation conservationARetourner = null;
if (this.getData("acces").equals(true)) {
// Création de l'objet
StructureConservation conservationCollectee = (StructureConservation) conservation.cloner(new StructureConservation());
// FORMATION
conservationCollectee.setFormation(formationMarkRGrpChp.getValue() == null ?
null :
formationMarkRGrpChp.getValue().getValueAttribute());
 
// FORMATION INFO
conservationCollectee.setFormationInfo(formationChp.getValue());
// FORMATION INTERET
conservationCollectee.setFormationInteret(interetFormationMarkRGrpChp.getValue() == null ?
null :
interetFormationMarkRGrpChp.getValue().getValueAttribute());
// STOCKAGE LOCAL
conservationCollectee.setStockageLocal(creerChaineDenormalisee(localStockageTrukCacGrpChp.getValues()));
conservationCollectee.setStockageLocal("AUTRE", localStockageAutreChp.getValue());
// STOCKAGE MEUBLE
conservationCollectee.setStockageMeuble(creerChaineDenormalisee(meubleStockageTrukCacGrpChp.getValues()));
conservationCollectee.setStockageMeuble("AUTRE", meubleStockageAutreChp.getValue());
// STOCKAGE PAREMETRE
conservationCollectee.setStockageParametre(creerChaineDenormalisee(parametreStockageTrukCacGrpChp.getValues()));
conservationCollectee.setStockageParametre("AUTRE", parametreStockageAutreChp.getValue());
// COLLECTION COMMUNE
if (collectionCommuneMarkRGrpChp.getValue() != null) {
conservationCollectee.setCollectionCommune(collectionCommuneMarkRGrpChp.getValue().getValueAttribute());
}
// COLLECTION AUTRE
conservationCollectee.setCollectionAutre(creerChaineDenormalisee(collectionAutreTrukCacGrpChp.getValues()));
conservationCollectee.setCollectionAutre("AUTRE", collectionAutreAutreChp.getValue());
// ACCÈS CONTROLÉ
if (accesControleMarkRGrpChp.getValue() != null) {
conservationCollectee.setAccesControle(accesControleMarkRGrpChp.getValue().getValueAttribute());
}
// RESTAURATION
if (restaurationMarkRGrpChp.getValue() != null) {
conservationCollectee.setRestauration(restaurationMarkRGrpChp.getValue().getValueAttribute());
}
// RESTAURATION OPÉRATION
conservationCollectee.setRestaurationOperation(creerChaineDenormalisee(opRestauTrukCacGrpChp.getValues()));
conservationCollectee.setRestaurationOperation("AUTRE", opRestauAutreChp.getValue());
// MATERIEL CONSERVATION
if (materielConservationCeRGrpChp.getValue() != null) {
conservationCollectee.setMaterielConservation(materielConservationCeRGrpChp.getValue().getValueAttribute());
 
// MATERIEL AUTRE
conservationCollectee.setMaterielAutre(creerChaineDenormalisee(autreMaterielTrukCacGrpChp.getValues()));
conservationCollectee.setMaterielAutre("AUTRE", autreMaterielAutreChp.getValue());
}
// TRAITEMENT
if (traitementMarkRGrpChp.getValue() != null) {
conservationCollectee.setTraitement(traitementMarkRGrpChp.getValue().getValueAttribute());
}
// TRAIEMENTS
conservationCollectee.setTraitements(creerChaineDenormalisee(traitementTrukCacGrpChp.getValues()));
conservationCollectee.setTraitements("AUTRE", traitementAutreChp.getValue());
// ACQUISITION COLLECTION
if (collectionAcquisitionMarkRGrpChp.getValue() != null) {
conservationCollectee.setAcquisitionCollection(collectionAcquisitionMarkRGrpChp.getValue().getValueAttribute());
}
// ACQUISITION ECHANTILLON
if (echantillonAcquisitionMarkRGrpChp.getValue() != null) {
conservationCollectee.setAcquisitionEchantillon(echantillonAcquisitionMarkRGrpChp.getValue().getValueAttribute());
}
// ACQUISITION TRAITEMENT
if (traitementAcquisitionMarkRGrpChp.getValue() != null) {
conservationCollectee.setAcquisitionTraitement(traitementAcquisitionMarkRGrpChp.getValue().getValueAttribute());
}
// ACQUISITION TRAITEMENT POISON
conservationCollectee.setAcquisitionTraitementPoison(creerChaineDenormalisee(poisonTraitementTrukCacGrpChp.getValues()));
conservationCollectee.setAcquisitionTraitementPoison("AUTRE", poisonTraitementAutreChp.getValue());
// ACQUISITION TRAITEMENT INSECTE
conservationCollectee.setAcquisitionTraitementInsecte(creerChaineDenormalisee(insecteTraitementTrukCacGrpChp.getValues()));
conservationCollectee.setAcquisitionTraitementInsecte("AUTRE", insecteTraitementAutreChp.getValue());
// Retour de l'objet
if (!conservationCollectee.comparer(conservation)) {
GWT.log("Collecte différent de Retour", null);
conservationARetourner = conservation = conservationCollectee;
}
}
return conservationARetourner;
}
private String creerChaineDenormalisee(List<CheckBox> liste) {
return ((StructureForm)formulaireCourant).creerChaineDenormalisee(liste);
}
private void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) {
((StructureForm)formulaireCourant).peuplerCasesACocher(donnees, groupeCac, champAutre);
}
private void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) {
((StructureForm)formulaireCourant).peuplerBoutonsRadio(valeur, groupeBr);
}
public void afficherChampSupplementaires(Radio radioBtn) {
//GWT.log("Nom btn : "+radioBtn.getName()+" - Nom group : "+radioBtn.getGroup().getName(), null);
// Valeur du bouton radio déclenchant l'affichage des composants cachés
String valeurPourAfficher = "oui";
// Construction de la liste des composants à afficher/cacher
String radioGroupeNom = radioBtn.getGroup().getName();
ArrayList<Object> composants = new ArrayList<Object>();
if (radioGroupeNom.equals("formation_mark_grp")) {
composants.add(formationChp);
} else if (radioGroupeNom.equals("collection_commune_mark_grp")) {
composants.add(collectionAutreTrukCp);
} else if (radioGroupeNom.equals("restauration_mark_grp")) {
composants.add(opRestauTrukCp);
} else if (radioGroupeNom.equals("traitement_mark_grp")) {
composants.add(traitementTrukCp);
} else if (radioGroupeNom.equals("echantillon_acquisition_mark_grp")) {
composants.add(traitementAcquisitionMarkRGrpChp);
} else if (radioGroupeNom.equals("traitement_acquisition_mark_grp")) {
composants.add(traitementAcquisitionMarkLabel);
composants.add(poisonTraitementTrukCp);
composants.add(insecteTraitementTrukCp);
} else if (radioGroupeNom.equals("materiel_conservation_ce_grp")) {
composants.add(autreMaterielTrukCp);
valeurPourAfficher = "non";
}
// Nous affichons/cachons les composant de la liste
final int nbreComposants = composants.size();
//GWT.log("Id : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax, null);
//Window.alert("Radio grp nom : "+radioGroupeNom+" - Id btn : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax);
for (int i = 0; i < nbreComposants; i++) {
// En fonction du type de bouton cliquer, on affiche ou cache les champs
String type = radioBtn.getBoxLabel().toLowerCase();
//GWT.log(type, null);
if (radioBtn.getValue() == true) {
if (type.equals(valeurPourAfficher)) {
((Component) composants.get(i)).show();
} else {
((Component) composants.get(i)).hide();
}
}
// Si on a à faire à un ContentPanel, on l'actualise pour déclencher l'affichage
if (composants.get(i) instanceof ContentPanel) {
((ContentPanel) composants.get(i)).layout();
}
}
}
public void peupler() {
if(conservation == null) {
initialiserConservation();
}
if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
// Indique que l'onglet a pu être modifié pour la méthode collecter...
this.setData("acces", true);
// Initialisation de l'objet Structure
conservation = new StructureConservation();
}
if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && conservation != null) {
// FORMATION
// Bouton oui, à toujours l'index 0, mais dans le modèle, value == 0
// donc ^ 1, car 0 ^ 1 = 1 et 1 ^ 1 = 0
if(conservation.getFormation() != null) {
((Radio) formationMarkRGrpChp.get(conservation.getFormation() ^ 1)).setValue(true);
}
 
// FORMATION INFO
formationChp.setValue(conservation.getFormationInfo());
// FORMATION INTERET
if(conservation.getFormationInteret() != null) {
((Radio) interetFormationMarkRGrpChp.get(conservation.getFormationInteret() ^ 1)).setValue(true);
}
// STOCKAGE LOCAL
peuplerCasesACocher(conservation.getStockageLocal(), localStockageTrukCacGrpChp,localStockageAutreChp);
// STOCKAGE MEUBLE
peuplerCasesACocher(conservation.getStockageMeuble(), meubleStockageTrukCacGrpChp, meubleStockageAutreChp);
// STOCKAGE PAREMETRE
peuplerCasesACocher(conservation.getStockageParametre(), parametreStockageTrukCacGrpChp, parametreStockageAutreChp);
// COLLECTION COMMUNE
if(conservation.getCollectionCommune() != null) {
((Radio) collectionCommuneMarkRGrpChp.get(conservation.getCollectionCommune() ^ 1)).setValue(true);
}
// COLLECTION AUTRE
peuplerCasesACocher(conservation.getCollectionAutre(), collectionAutreTrukCacGrpChp, collectionAutreAutreChp);
// ACCÈS CONTROLÉ
if(conservation.getAccesControle() != null) {
((Radio) accesControleMarkRGrpChp.get(conservation.getAccesControle() ^ 1)).setValue(true);
}
// RESTAURATION
if(conservation.getRestauration() != null) {
((Radio) restaurationMarkRGrpChp.get(conservation.getRestauration() ^ 1)).setValue(true);
}
// RESTAURATION OPÉRATION
peuplerCasesACocher(conservation.getRestaurationOperation(), opRestauTrukCacGrpChp, opRestauAutreChp);
// MATERIEL CONSERVATION
peuplerBoutonsRadio(conservation.getMaterielConservation(), materielConservationCeRGrpChp);
// MATERIEL AUTRE
peuplerCasesACocher(conservation.getMaterielAutre(), autreMaterielTrukCacGrpChp, autreMaterielAutreChp);
// TRAITEMENT
if(conservation.getTraitement() != null) {
((Radio) traitementMarkRGrpChp.get(conservation.getTraitement() ^ 1)).setValue(true);
}
// TRAITEMENTS
peuplerCasesACocher(conservation.getTraitements(), traitementTrukCacGrpChp, traitementAutreChp);
// ACQUISITION COLLECTION
if(conservation.getAcquisitionCollection() != null) {
((Radio) collectionAcquisitionMarkRGrpChp.get(conservation.getAcquisitionCollection() ^ 1)).setValue(true);
}
// ACQUISITION ECHANTILLON
if(conservation.getAcquisitionEchantillon() != null) {
((Radio) echantillonAcquisitionMarkRGrpChp.get(conservation.getAcquisitionEchantillon() ^ 1)).setValue(true);
}
// ACQUISITION TRAITEMENT
((Radio) traitementAcquisitionMarkRGrpChp.get((conservation.getAcquisitionTraitement().equals("1") ? 0 : 1))).setValue(true);
// ACQUISITION TRAITEMENT POISON
peuplerCasesACocher(conservation.getAcquisitionTraitementPoison(), poisonTraitementTrukCacGrpChp, poisonTraitementAutreChp);
// ACQUISITION TRAITEMENT INSECTE
peuplerCasesACocher(conservation.getAcquisitionTraitementInsecte(), insecteTraitementTrukCacGrpChp, insecteTraitementAutreChp);
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
this.setData("acces", true);
}
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureFormValorisation.java
New file
0,0 → 1,401
package org.tela_botanica.client.vues.structure;
 
import java.util.ArrayList;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.structure.StructureValorisation;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
 
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FormData;
 
public class StructureFormValorisation extends FormulaireOnglet implements Rafraichissable {
 
private StructureValorisation valorisation = null;
private LayoutContainer autreCollectionTrukCp = null;
private TextField<String> typeRechercheAutreChp = null;
private CheckBoxGroup autreCollectionTrukCacGrpChp = null;
private LayoutContainer provenanceRechercheTrukCp = null;
private CheckBoxGroup provenanceRechercheTrukCacGrpChp = null;
private CheckBoxGroup typeRechercheTrukCacGrpChp = null;
private LayoutContainer typeRechercheTrukCp = null;
private TextField<String> futureActionChp = null;
private TextField<String> sansMotifAccesChp = null;
private TextField<String> avecMotifAccesChp = null;
private TextField<String> autreCollectionAutreChp = null;
private TextField<String> actionAutreChp = null;
private TextField<String> provenanceRechercheAutreChp = null;
private RadioGroup actionMarkRGrpChp = null;
private LayoutContainer actionTrukCp = null;
private CheckBoxGroup actionTrukCacGrpChp = null;
private RadioGroup futureActionMarkRGrpChp = null;
private RadioGroup rechercheMarkRGrpChp = null;
private RadioGroup sansMotifAccesMarkRGrpChp = null;
private RadioGroup avecMotifAccesMarkRGrpChp = null;
private TextField<String> publicationChp = null;
private String ID = "valorisation";
private Mediateur mediateur = null;
private Formulaire formulaireCourant = null;
private Sequenceur sequenceur = null;
public StructureFormValorisation(Mediateur mediateur, Formulaire formulaireCourant, Sequenceur sequenceur) {
this.mediateur = mediateur;
this.formulaireCourant = formulaireCourant;
this.sequenceur = sequenceur;
initialiserOnglet(formulaireCourant);
setId(ID);
setText(Mediateur.i18nC.structureInfoValorisation());
FormulaireOnglet.parametrer(this);
this.setLayout(Formulaire.creerFormLayout(650, LabelAlign.TOP));
Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
peupler();
layout();
}
};
this.addListener(Events.Select, ecouteurSelection);
actionMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("action_mark", "ouiNon");
actionMarkRGrpChp.setFieldLabel("Avez-vous réalisé des actions de valorisation de vos collections botaniques ou avez-vous été sollicités pour la valorisation de ces collections ?");
this.add(actionMarkRGrpChp);
actionTrukCp = Formulaire.creerChoixMultipleCp();
actionTrukCp.hide();
actionTrukCacGrpChp = new CheckBoxGroup();
actionTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");
this.add(actionTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "actionValorisation", sequenceur);
mediateur.obtenirListeValeurEtRafraichir(this, "statut", sequenceur);
publicationChp = new TextArea();
publicationChp.setFieldLabel("Quelques titres des ouvrages, articles scientifiques, ...");
this.add(publicationChp, new FormData(550, 0));
autreCollectionTrukCp = Formulaire.creerChoixMultipleCp();
autreCollectionTrukCacGrpChp = new CheckBoxGroup();
autreCollectionTrukCacGrpChp.setFieldLabel("L'organisme dispose-t-il d'autres collections (permettant une valorisation pluridisciplinaire) ?");
this.add(autreCollectionTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "autreCollection", sequenceur);
futureActionMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("future_action_mark", "ouiNon");
futureActionMarkRGrpChp.setFieldLabel("Envisagez vous des actions de valorisation dans le cadre de votre politique culturelle ?");
this.add(futureActionMarkRGrpChp);
futureActionChp = new TextArea();
futureActionChp.setFieldLabel("Si oui, lesquelles ?");
futureActionChp.hide();
futureActionChp.addListener(Events.Hide, new Listener<BaseEvent>() {
 
public void handleEvent(BaseEvent be) {
((TextArea) be.getSource()).setValue("");
}
});
this.add(futureActionChp, new FormData(550, 0));
rechercheMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("recherche_mark", "ouiNon");
rechercheMarkRGrpChp.setFieldLabel("Vos collections botaniques sont-elles utilisées pour des recherches scientifiques ?");
this.add(rechercheMarkRGrpChp);
provenanceRechercheTrukCp = Formulaire.creerChoixMultipleCp();
provenanceRechercheTrukCp.hide();
provenanceRechercheTrukCacGrpChp = new CheckBoxGroup();
provenanceRechercheTrukCacGrpChp.setFieldLabel("Si oui, par des chercheurs (professionnels ou amateurs) de quelle provenance ?");
this.add(provenanceRechercheTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "continentEtFr", sequenceur);
typeRechercheTrukCp = Formulaire.creerChoixMultipleCp();
typeRechercheTrukCp.hide();
typeRechercheTrukCacGrpChp = new CheckBoxGroup();
typeRechercheTrukCacGrpChp.setFieldLabel("Et pour quelles recherches ?");
this.add(typeRechercheTrukCp);
mediateur.obtenirListeValeurEtRafraichir(this, "typeRecherche", sequenceur);
sansMotifAccesMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("sans_motif_acces_mark", "ouiNon");
sansMotifAccesMarkRGrpChp.setFieldLabel("Peut-on consulter vos collections botaniques sans motif de recherches scientifiques ?");
this.add(sansMotifAccesMarkRGrpChp);
this.add(sansMotifAccesChp = new TextArea(), new FormData(550, 0));
sansMotifAccesChp.hide();
sansMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() {
 
public void handleEvent(BaseEvent be) {
((TextArea) be.getSource()).setValue("");
}
});
sansMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les consulter ?");
avecMotifAccesMarkRGrpChp = formulaireCourant.creerChoixUniqueRadioGroupe("avec_motif_acces_mark", "ouiNon");
avecMotifAccesMarkRGrpChp.setFieldLabel("Peut-on visiter vos collections botaniques avec des objectifs de recherches scientifiques ?");
this.add(avecMotifAccesMarkRGrpChp);
this.add(avecMotifAccesChp = new TextArea(), new FormData(550, 0));
avecMotifAccesChp.hide();
avecMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() {
 
public void handleEvent(BaseEvent be) {
((TextArea) be.getSource()).setValue("");
}
});
avecMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les visiter ?");
}
public void peupler() {
if(valorisation == null) {
initialiserValorisation();
}
if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
// Indique que l'onglet a pu être modifié pour la méthode collecter...
setData("acces", true);
// Initialisation de l'objet Structure
valorisation = new StructureValorisation();
}
if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && valorisation != null) {
// ACTION :
//TODO : check below:
if(valorisation.getAction() != null) {
((Radio) actionMarkRGrpChp.get(valorisation.getAction() ^ 1)).setValue(true);
}
// ACTION INFO
peuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp);
// PUBLICATION
publicationChp.setValue(valorisation.getPublication());
// COLLECTION AUTRE
peuplerCasesACocher(valorisation.getCollectionAutre(), autreCollectionTrukCacGrpChp, autreCollectionAutreChp);
// ACTION FUTURE
if(valorisation.getActionFuture() != null) {
((Radio) futureActionMarkRGrpChp.get(valorisation.getActionFuture() ^ 1)).setValue(true);
}
// ACTION FUTURE INFO
futureActionChp.setValue(valorisation.getActionFutureInfo());
// RECHERCHE
if(valorisation.getRecherche() != null) {
((Radio) rechercheMarkRGrpChp.get(valorisation.getRecherche() ^ 1)).setValue(true);
}
// RECHERCHE PROVENANCE
peuplerCasesACocher(valorisation.getRechercheProvenance(), provenanceRechercheTrukCacGrpChp, provenanceRechercheAutreChp);
// RECHERCHE TYPE
peuplerCasesACocher(valorisation.getRechercheType(), typeRechercheTrukCacGrpChp, typeRechercheAutreChp);
// ACCÈS SANS MOTIF
if(valorisation.getAccesSansMotif() != null) {
((Radio) sansMotifAccesMarkRGrpChp.get(valorisation.getAccesSansMotif() ^ 1)).setValue(true);
}
// ACCÈS SANS MOTIF INFO
sansMotifAccesChp.setValue(valorisation.getAccesSansMotifInfo());
// VISITE AVEC MOTIF
if(valorisation.getVisiteAvecMotif() != null) {
((Radio) avecMotifAccesMarkRGrpChp.get(valorisation.getVisiteAvecMotif() ^ 1)).setValue(true);
}
// VISITE AVEC MOTIF INFO
avecMotifAccesChp.setValue(valorisation.getVisiteAvecMotifInfo());
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
this.setData("acces", true);
}
}
private String creerChaineDenormalisee(List<CheckBox> liste) {
return ((StructureForm)formulaireCourant).creerChaineDenormalisee(liste);
}
private void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) {
((StructureForm)formulaireCourant).peuplerCasesACocher(donnees, groupeCac, champAutre);
}
private void initialiserValorisation() {
valorisation = ((StructureForm)formulaireCourant).valorisation;
}
 
public StructureValorisation collecter() {
if(valorisation == null) {
initialiserValorisation();
}
StructureValorisation valorisationARetourner = null;
if (getData("acces").equals(true)) {
// Création de l'objet
StructureValorisation valorisationCollectee = (StructureValorisation) valorisation.cloner(new StructureValorisation());
// ACTION
if (actionMarkRGrpChp.getValue() != null) {
valorisationCollectee.setAction(actionMarkRGrpChp.getValue().getValueAttribute());
}
// ACTION INFO
valorisationCollectee.setActionInfo(creerChaineDenormalisee(actionTrukCacGrpChp.getValues()));
valorisationCollectee.setActionInfo("AUTRE", actionAutreChp.getValue());
// PUBLICATION
valorisationCollectee.setPublication(publicationChp.getValue());
// COLLECTION AUTRE
valorisationCollectee.setCollectionAutre(creerChaineDenormalisee(autreCollectionTrukCacGrpChp.getValues()));
valorisationCollectee.setCollectionAutre("AUTRE", autreCollectionAutreChp.getValue());
// ACTION FUTURE
if (futureActionMarkRGrpChp.getValue() != null) {
valorisationCollectee.setActionFuture(futureActionMarkRGrpChp.getValue().getValueAttribute());
}
// ACTION FUTURE INFO
valorisationCollectee.setActionFutureInfo(futureActionChp.getValue());
// RECHERCHE
if (rechercheMarkRGrpChp.getValue() != null) {
valorisationCollectee.setRecherche(rechercheMarkRGrpChp.getValue().getValueAttribute());
 
// RECHERCHE PROVENANCE
valorisationCollectee.setRechercheProvenance(creerChaineDenormalisee(provenanceRechercheTrukCacGrpChp.getValues()));
valorisationCollectee.setRechercheProvenance("AUTRE", provenanceRechercheAutreChp.getValue());
// RECHERCHE TYPE
valorisationCollectee.setRechercheType(creerChaineDenormalisee(typeRechercheTrukCacGrpChp.getValues()));
valorisationCollectee.setRechercheType("AUTRE", typeRechercheAutreChp.getValue());
}
// ACCÈS SANS MOTIF
if (sansMotifAccesMarkRGrpChp.getValue() != null) {
valorisationCollectee.setAccesSansMotif(sansMotifAccesMarkRGrpChp.getValue().getValueAttribute());
}
// ACCÈS SANS MOTIF INFO
valorisationCollectee.setAccesSansMotifInfo(sansMotifAccesChp.getValue());
// VISITE AVEC MOTIF
if (avecMotifAccesMarkRGrpChp.getValue() != null) {
valorisationCollectee.setVisiteAvecMotif(avecMotifAccesMarkRGrpChp.getValue().getValueAttribute());
}
// VISITE AVEC MOTIF INFO
valorisationCollectee.setVisiteAvecMotifInfo(avecMotifAccesChp.getValue());
// Retour de l'objet
if (!valorisationCollectee.comparer(valorisation)) {
valorisationARetourner = valorisation = valorisationCollectee;
}
}
return valorisationARetourner;
}
 
@Override
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
}
}
public void rafraichirInformation(Information info) {
if (info.getDonnee(2) != null) {
valorisation = (StructureValorisation) info.getDonnee(2);
if (valorisation != null) {
peupler();
}
}
}
private void rafraichirValeurListe(ValeurListe listeValeurs) {
List<Valeur> liste = listeValeurs.toList();
if (listeValeurs.getId().equals(config.getListeId("autreCollection"))) {
if (autreCollectionTrukCp != null && autreCollectionTrukCp.getItemByItemId("autreCollectionTrukCacGrpChp") == null) {
autreCollectionTrukCacGrpChp.setId("autreCollectionTrukCacGrpChp");
autreCollectionAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(autreCollectionTrukCp, autreCollectionTrukCacGrpChp, listeValeurs, autreCollectionAutreChp);
}
}
if (listeValeurs.getId().equals(config.getListeId("actionValorisation"))) {
actionAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(actionTrukCp, actionTrukCacGrpChp, listeValeurs, actionAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("continentEtFr"))) {
provenanceRechercheAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(provenanceRechercheTrukCp, provenanceRechercheTrukCacGrpChp, listeValeurs, provenanceRechercheAutreChp);
}
if (listeValeurs.getId().equals(config.getListeId("typeRecherche"))) {
typeRechercheAutreChp = new TextField<String>();
Formulaire.creerChoixMultipleCac(typeRechercheTrukCp, typeRechercheTrukCacGrpChp, listeValeurs, typeRechercheAutreChp);
}
}
 
public void afficherChampSupplementaire(Radio radioBtn) {
//GWT.log("Nom btn : "+radioBtn.getName()+" - Nom group : "+radioBtn.getGroup().getName(), null);
// Valeur du bouton radio déclenchant l'affichage des composants cachés
String valeurPourAfficher = "oui";
// Construction de la liste des composants à afficher/cacher
String radioGroupeNom = radioBtn.getGroup().getName();
ArrayList<Object> composants = new ArrayList<Object>();
if (radioGroupeNom.equals("action_mark_grp")) {
composants.add(actionTrukCp);
} else if (radioGroupeNom.equals("future_action_mark_grp")) {
composants.add(futureActionChp);
} else if (radioGroupeNom.equals("sans_motif_acces_mark_grp")) {
composants.add(sansMotifAccesChp);
} else if (radioGroupeNom.equals("avec_motif_acces_mark_grp")) {
composants.add(avecMotifAccesChp);
} else if (radioGroupeNom.equals("recherche_mark_grp")) {
composants.add(provenanceRechercheTrukCp);
composants.add(typeRechercheTrukCp);
}
// Nous affichons/cachons les composant de la liste
final int nbreComposants = composants.size();
//GWT.log("Id : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax, null);
//Window.alert("Radio grp nom : "+radioGroupeNom+" - Id btn : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax);
for (int i = 0; i < nbreComposants; i++) {
// En fonction du type de bouton cliquer, on affiche ou cache les champs
String type = radioBtn.getBoxLabel().toLowerCase();
//GWT.log(type, null);
if (radioBtn.getValue() == true) {
if (type.equals(valeurPourAfficher)) {
((Component) composants.get(i)).show();
} else {
((Component) composants.get(i)).hide();
}
}
// Si on a à faire à un ContentPanel, on l'actualise pour déclencher l'affichage
if (composants.get(i) instanceof ContentPanel) {
((ContentPanel) composants.get(i)).layout();
}
}
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureVue.java
New file
0,0 → 1,65
package org.tela_botanica.client.vues.structure;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
 
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.core.client.GWT;
 
public class StructureVue extends LayoutContainer implements Rafraichissable {
 
private Mediateur mediateur = null;
private StructureListeVue panneauInstitutionListe = null;
private StructureDetailVue panneauInstitutionDetail = null;
 
private Sequenceur sequenceur = new Sequenceur();
public StructureVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
BorderLayout layout = new BorderLayout();
layout.setEnableState(false);
setLayout(layout);
 
panneauInstitutionListe = new StructureListeVue(mediateur);
add(panneauInstitutionListe, new BorderLayoutData(LayoutRegion.CENTER));
 
panneauInstitutionDetail = new StructureDetailVue(mediateur, sequenceur);
BorderLayoutData dispositionSud = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000);
dispositionSud.setSplit(true);
dispositionSud.setMargins(new Margins(5, 0, 0, 0));
add(panneauInstitutionDetail, dispositionSud);
}
 
public void rafraichir(Object nouvellesDonnees) {
// Nous passons l'objet aux méthodes rafraichir des panneaux composant le panneau principal Structure
if (nouvellesDonnees instanceof Structure) {
panneauInstitutionDetail.rafraichir(nouvellesDonnees);
} else if (nouvellesDonnees instanceof StructureListe) {
panneauInstitutionListe.rafraichir(nouvellesDonnees);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("liste_structure_a_personne")) {
panneauInstitutionDetail.rafraichir(nouvellesDonnees);
} else if(info.getType().equals("structure_ajoutee")) {
mediateur.clicMenu(MenuApplicationId.STRUCTURE);
} else if (info.getType().equals("liste_collection_a_structure")) {
panneauInstitutionDetail.rafraichir(nouvellesDonnees);
} else {
panneauInstitutionListe.rafraichir(nouvellesDonnees);
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/structure/StructureVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/structure/StructureVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureListeVue.java
New file
0,0 → 1,247
package org.tela_botanica.client.vues.structure;
 
import java.util.ArrayList;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampFiltreRecherche;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationListe;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureAsyncDao;
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;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
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 {
private Mediateur mediateur = null;
private Constantes i18nC = null;
 
private Grid<Structure> grille = null;
private ListStore<Structure> store = null;
private Button modifier;
private Button supprimer;
private Button ajouter;
private ChampFiltreRecherche champFiltreRecherche = null;
private BarrePaginationVue pagination = null;
private int indexElementSelectionne = 0;
private Structure structureSelectionnee = null;
 
public StructureListeVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = mediateur.i18nC;
setHeaderVisible(false);
setLayout(new FitLayout());
ToolBar toolBar = new ToolBar();
ajouter = new Button(i18nC.ajouter());
ajouter.setIcon(Images.ICONES.ajouter());
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
mediateur.clicAjouterStructure();
}
});
ajouter.setToolTip(i18nC.indicationCreerUneFiche()+" "+i18nC.structureSingulier());
toolBar.add(ajouter);
 
modifier = new Button(i18nC.modifier());
modifier.setIcon(Images.ICONES.formModifier());
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
mediateur.clicModifierStructure(grille.getSelectionModel().getSelectedItems());
}
});
modifier.setToolTip(i18nC.indicationModifierUneFiche());
toolBar.add(modifier);
supprimer = new Button(i18nC.supprimer());
supprimer.setIcon(Images.ICONES.supprimer());
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
clicSupprimerStructure(grille.getSelectionModel().getSelectedItems());
}
});
supprimer.setToolTip(i18nC.indicationSupprimerUneFiche());
toolBar.add(supprimer);
 
setTopComponent(toolBar);
 
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
colonnes.add(new ColumnConfig("ville", "Ville", 150));
colonnes.add(new ColumnConfig("nom", "Nom", 450));
ColumnModel modeleDeColonne = new ColumnModel(colonnes);
GridSelectionModel<Structure> modeleDeSelection = new GridSelectionModel<Structure>();
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Structure>() {
public void selectionChanged(SelectionChangedEvent<Structure> event) {
if((Structure) event.getSelectedItem() != null) {
structureSelectionnee = (Structure) event.getSelectedItem();
indexElementSelectionne = store.indexOf(structureSelectionnee);
clicListe(structureSelectionnee);
}
}
});
store = new ListStore<Structure>();
 
grille = new Grid<Structure>(store, modeleDeColonne);
grille.setWidth("100%");
grille.setAutoExpandColumn("nom");
grille.getView().setAutoFill(true);
grille.getView().setForceFit(true);
grille.setSelectionModel(modeleDeSelection);
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
grille.getSelectionModel().select(0, false);
}
});
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
modifier.fireEvent(Events.Select);
}
});
grille.addListener(Events.SortChange, new Listener<BaseEvent>() {
 
@Override
public void handleEvent(BaseEvent be) {
GridEvent ge = (GridEvent<Structure>) be;
// TODO rajouter un test sur le sort state pour trier par nom par défaut
String tri = ge.getSortInfo().getSortField();
StructureAsyncDao.tri = Structure.PREFIXE+"_"+tri+" "+ge.getSortInfo().getSortDir().toString();
pagination.changePage();
}
});
add(grille);
StructureListe structureListe = new StructureListe();
champFiltreRecherche = new ChampFiltreRecherche(mediateurCourant, toolBar, structureListe);
// Définition de la barre de pagination
pagination = new BarrePaginationVue(structureListe, mediateur, champFiltreRecherche);
setBottomComponent(pagination);
}
 
private void clicListe(Structure structure) {
if (structure != null && store.getCount() > 0) {
mediateur.clicListeStructure(structure);
}
}
private void clicSupprimerStructure(List<Structure> structuresASupprimer) {
mediateur.clicSupprimerStructure(this, structuresASupprimer);
}
 
private void gererEtatActivationBouton() {
int nbreElementDuMagazin = store.getCount();
if (nbreElementDuMagazin == 0) {
supprimer.disable();
modifier.disable();
} else if (nbreElementDuMagazin > 0) {
modifier.enable();
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
supprimer.enable();
}
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof StructureListe) {
StructureListe structures = (StructureListe) nouvellesDonnees;
champFiltreRecherche.setListePaginable(structures);
pagination.setlistePaginable(structures);
pagination.rafraichir(structures.getPageTable());
if (structures != null) {
List<Structure> liste = structures.toList();
store.removeAll();
store.add(liste);
 
gererEtatActivationBouton();
mediateur.actualiserPanneauCentral();
grille.fireEvent(Events.ViewReady);
}
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("suppression_structure")) {
// Affichage d'un message d'information
InfoLogger.display(i18nC.suppressionStructure(), info.toString().replaceAll("\n", "<br />"));
List<Structure> selectionStructure = grille.getSelectionModel().getSelectedItems();
if (info.toString().replaceAll("\n", "").equals("OK")) {
mediateur.supprimerStructureAPersonne(this, selectionStructure);
}
// Suppression des structures sélectionnées de la grille
final int taille = selectionStructure.size();
for (int i = 0; i < taille; i++) {
store.remove(selectionStructure.get(i));
}
gererEtatActivationBouton();
} else if(info.getType().equals("structure_modifiee")) {
Structure structureModifiee = (Structure)info.getDonnee(0);
if(structureSelectionnee != null && structureModifiee != null) {
if(structureSelectionnee.getId().equals(structureModifiee.getId())) {
store.remove(indexElementSelectionne);
} else {
structureSelectionnee = null;
}
// au cas ou le bouton appliquer aurait été cliqué avant de valider
store.remove(structureModifiee);
store.insert(structureModifiee, indexElementSelectionne);
structureSelectionnee = structureModifiee;
int indexElementSelectionne = store.indexOf(structureSelectionnee);
grille.getSelectionModel().select(indexElementSelectionne, false);
grille.getView().focusRow(indexElementSelectionne);
clicListe(structureSelectionnee);
}
} else if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if (info.getType().equals("suppression_structure_a_personne")) {
// Affichage d'un message d'information
InfoLogger.display(i18nC.suppressionStructureAPersonne(), info.toString().replaceAll("\n", "<br />"));
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
layout();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureListeVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/structure/StructureListeVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/structure/StructureListeVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureDetailVue.java
New file
0,0 → 1,769
package org.tela_botanica.client.vues.structure;
 
import java.util.Iterator;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.collection.CollectionAStructure;
import org.tela_botanica.client.modeles.collection.CollectionAStructureListe;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
import org.tela_botanica.client.modeles.structure.StructureConservation;
import org.tela_botanica.client.modeles.structure.StructureValorisation;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.vues.DetailVue;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
 
public class StructureDetailVue extends DetailVue implements Rafraichissable {
 
private String enteteTpl = null;
private String identificationTpl = null;
private String personnelTpl = null;
private String tableauPersonnelTpl = null;
private String lignePersonnelTpl = null;
private String conservationTpl = null;
private String traitementConservationTpl = null;
private String valorisationTpl = null;
private String typeTraitementConservationTpl = null;
private String rechercheValorisationTpl = null;
private String collectionTpl = null;
private String ligneCollectionTpl = null;
private String tableauCollectionTpl = null;
private Structure structure = null;
private boolean structureChargementOk = false;
private StructureAPersonneListe personnel = null;
private boolean personnelChargementOk = false;
private StructureValorisation valorisation = null;
private StructureConservation conservation = null;
private CollectionAStructureListe collection = null;
private boolean collectionChargementOk = false;
private ContentPanel panneauPrincipal = null;
private Html entete = null;
private TabPanel onglets = null;
private TabItem identificationOnglet = null;
private TabItem personnelOnglet = null;
private TabItem collectionOnglet = null;
private TabItem conservationOnglet = null;
private TabItem valorisationOnglet = null;
private Sequenceur sequenceur;
public StructureDetailVue(Mediateur mediateurCourant, Sequenceur sequenceur) {
super(mediateurCourant);
this.sequenceur = sequenceur;
initialiserTousLesTpl();
chargerOntologie();
panneauPrincipal = new ContentPanel();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.setHeaderVisible(false);
panneauPrincipal.setBodyBorder(false);
entete = new Html();
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
panneauPrincipal.setTopComponent(entete);
onglets = new TabPanel();
onglets.setId(ComposantId.ZONE_DETAIL_CORPS);
onglets.setBodyBorder(false);
identificationOnglet = new TabItem(i18nC.structureInfoGeneral());
identificationOnglet.setLayout(new AnchorLayout());
identificationOnglet.setScrollMode(Scroll.AUTO);
onglets.add(identificationOnglet);
personnelOnglet = new TabItem(i18nC.structureInfoPersonnel());
personnelOnglet.setLayout(new AnchorLayout());
personnelOnglet.setScrollMode(Scroll.AUTO);
onglets.add(personnelOnglet);
collectionOnglet = new TabItem(i18nC.structureInfoCollection());
collectionOnglet.setLayout(new AnchorLayout());
collectionOnglet.setScrollMode(Scroll.AUTO);
onglets.add(collectionOnglet);
conservationOnglet = new TabItem(i18nC.structureInfoConservation());
conservationOnglet.setLayout(new AnchorLayout());
conservationOnglet.setScrollMode(Scroll.AUTO);
onglets.add(conservationOnglet);
valorisationOnglet = new TabItem(i18nC.structureInfoValorisation());
valorisationOnglet.setLayout(new AnchorLayout());
valorisationOnglet.setScrollMode(Scroll.AUTO);
onglets.add(valorisationOnglet);
panneauPrincipal.add(onglets);
add(panneauPrincipal);
}
 
private void chargerOntologie() {
String[] listesCodes = {"stpr", "stpu", "pays", "statut", "fonction", "localStockage", "meubleStockage",
"parametreStockage", "autreCollection", "onep", "opRestau", "autreMateriel", "poisonTraitement",
"insecteTraitement", "actionValorisation", "continentEtFr", "typeRecherche"};
lancerChargementListesValeurs(listesCodes, this.sequenceur);
sequenceur.enfilerRafraichissement(this, new Information("ontologie_chargee"));
}
 
private void afficherDetailInstitution() {
if (structure != null) {
personnel = structure.getPersonnel();
valorisation = structure.getValorisation();
conservation = structure.getConservation();
afficherEntete();
afficherIdentification();
if (personnel != null) {
afficherPersonnel();
}
if (conservation != null) {
afficherConservation();
}
if (valorisation != null) {
afficherValorisation();
}
if (collection != null) {
afficherCollection();
}
}
layout();
}
private void afficherEntete() {
Params enteteParams = new Params();
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
enteteParams.set("css_meta", ComposantClass.META);
enteteParams.set("i18n_id", i18nC.id());
enteteParams.set("nom", structure.getNom());
enteteParams.set("ville", structure.getVille());
enteteParams.set("id", structure.getId());
enteteParams.set("guid", structure.getGuid());
String eHtml = Format.substitute(enteteTpl, enteteParams);
entete.getElement().setInnerHTML(eHtml);
}
private void afficherIdentification() {
Params identificationParams = new Params();
identificationParams.set("i18n_titre_administratif", i18nC.titreAdministratif());
identificationParams.set("i18n_acronyme", i18nC.acronyme());
identificationParams.set("i18n_statut", i18nC.statut());
identificationParams.set("i18n_date_fondation", i18nC.dateFondation());
identificationParams.set("i18n_nbre_personnel", i18nC.nbrePersonnel());
identificationParams.set("i18n_titre_description", i18nC.description());
identificationParams.set("i18n_description", i18nC.description());
identificationParams.set("i18n_acces", i18nC.acces());
identificationParams.set("i18n_usage", i18nC.usage());
identificationParams.set("i18n_titre_adresse", i18nC.adresse());
identificationParams.set("i18n_adresse", i18nC.adresse());
identificationParams.set("i18n_cp", i18nC.codePostal());
identificationParams.set("i18n_ville", i18nC.ville());
identificationParams.set("i18n_pays", i18nC.pays());
identificationParams.set("i18n_latitude", i18nC.latitude());
identificationParams.set("i18n_longitude", i18nC.longitude());
identificationParams.set("i18n_titre_communication", i18nC.titreCommunication());
identificationParams.set("i18n_tel", i18nC.telephone());
identificationParams.set("i18n_fax", i18nC.FAX());
identificationParams.set("i18n_courriel", i18nC.courriel());
identificationParams.set("i18n_web", i18nC.siteWeb());
 
String acronyme = construireTxtTruck(structure.getIdAlternatif());
String typePrive = construireTxtListeOntologie(structure.getTypePrive());
String typePublic = construireTxtListeOntologie(structure.getTypePublic());
String pays = construireTxtListeOntologie(structure.getPays());
String web = construireTxtTruck(structure.getUrl(), false);
String latitude = structure.getLatitude();
String longitude = structure.getLongitude();
String latitudeLongitude = (!longitude.equals("") && !latitude.equals("")) ? latitude+" / "+longitude : "";
identificationParams.set("acronyme", acronyme);
identificationParams.set("statut", typePrive+typePublic);
String dateFondation = structure.getAnneOuDateFondationFormatLong();
dateFondation = dateFondation.equals("0000") ? "" : dateFondation;
identificationParams.set("date_fondation", dateFondation);
identificationParams.set("nbre_personnel", structure.getNbrePersonne() != null ? structure.getNbrePersonne() : "");
identificationParams.set("description", structure.getDescription());
identificationParams.set("acces", structure.getConditionAcces());
identificationParams.set("usage", structure.getConditionUsage());
identificationParams.set("adresse", structure.getAdresse());
identificationParams.set("cp", structure.getCodePostal());
identificationParams.set("ville", structure.getVille());
identificationParams.set("pays", pays);
identificationParams.set("latitude_longitude", latitudeLongitude);
identificationParams.set("tel", structure.getTelephoneFixe());
identificationParams.set("fax", structure.getFax());
identificationParams.set("courriel", structure.getCourriel());
identificationParams.set("web", web);
afficherOnglet(identificationTpl, identificationParams, identificationOnglet);
}
private void afficherPersonnel() {
String tableauPersonnelHtml = "";
if (personnel.size() > 0) {
tableauPersonnelHtml = construireTableauDuPersonnel();
}
Params personnelParams = new Params();
personnelParams.set("i18n_titre_personnel", i18nC.titrePersonnel());
personnelParams.set("i18n_nbre_personnel_collection", i18nC.nbrePersonnelCollection());
personnelParams.set("nbre_personnel_collection", personnel.size());
personnelParams.set("tableau_personnel", tableauPersonnelHtml);
afficherOnglet(personnelTpl, personnelParams, personnelOnglet);
}
private String construireTableauDuPersonnel() {
Params contenuParams = new Params();
contenuParams.set("i18n_titre_membre", i18nC.titreMembre());
contenuParams.set("i18n_fonction", i18nC.fonction());
contenuParams.set("i18n_prenom", i18nC.personnePrenom());
contenuParams.set("i18n_nom", i18nC.personneNom());
contenuParams.set("i18n_tel", i18nC.FIX());
contenuParams.set("i18n_fax", i18nC.FAX());
contenuParams.set("i18n_courriel", i18nC.courrielPrincipal());
contenuParams.set("i18n_statut", i18nC.statut());
contenuParams.set("i18n_tps_w", i18nC.tpsTravail());
contenuParams.set("i18n_specialite", i18nC.specialite());
contenuParams.set("i18n_contact", i18nC.boolContact());
String lignesPersonnel = "";
Iterator<String> it = personnel.keySet().iterator();
while (it.hasNext()) {
StructureAPersonne personne = personnel.get(it.next());
Params ligneParams = new Params();
String fonction = construireTxtListeOntologie(personne.getFonction());
String statut = construireTxtListeOntologie(personne.getStatut());
String contact = formaterOuiNon(personne.getContact());
ligneParams.set("fonction", fonction);
ligneParams.set("prenom", personne.getPrenom());
ligneParams.set("nom", personne.getNom());
ligneParams.set("tel_fix", personne.getTelephoneFixe());
ligneParams.set("tel_fax", personne.getFax());
ligneParams.set("courriel", personne.getCourriel());
ligneParams.set("statut", statut);
ligneParams.set("tps_w", personne.getBotaTravailHebdoTps());
ligneParams.set("specialite", personne.afficherSpecialite());
ligneParams.set("contact", contact);
lignesPersonnel += Format.substitute(lignePersonnelTpl, ligneParams);
}
contenuParams.set("lignes", lignesPersonnel);
String cHtml = Format.substitute(tableauPersonnelTpl, contenuParams);
return cHtml;
}
private void afficherConservation() {
Params conservationParams = new Params();
conservationParams.set("i18n_titre_conservation_personnel", i18nC.titreConservationPersonnel());
conservationParams.set("i18n_formation", i18nC.formation());
conservationParams.set("i18n_formation_interet", i18nC.formationInteret());
conservationParams.set("i18n_titre_local", i18nC.titreLocal());
conservationParams.set("i18n_local_specifique", i18nC.localSpecifique());
conservationParams.set("i18n_meuble_specifique", i18nC.meubleSpecifique());
conservationParams.set("i18n_local_parametre", i18nC.localParametre());
conservationParams.set("i18n_conservation_en_commun", i18nC.conservationEnCommun());
conservationParams.set("i18n_acces_controle", i18nC.accesControle());
conservationParams.set("i18n_titre_operation", i18nC.titreOperation());
conservationParams.set("i18n_restauration", i18nC.restauration());
conservationParams.set("i18n_materiel_conservation", i18nC.materielConservation());
conservationParams.set("i18n_traitement", i18nC.traitement());
conservationParams.set("i18n_titre_acquisition", i18nC.titreAcquisition());
conservationParams.set("i18n_acquisition_collection", i18nC.acquisitionCollection());
conservationParams.set("i18n_acquisition_echantillon", i18nC.acquisitionEchantillon());
conservationParams.set("formation", formaterOuiNon(conservation.getFormation()));
conservationParams.set("formation_info", formaterSautDeLigne(conservation.getFormationInfo()));
conservationParams.set("formation_interet", formaterOuiNon(conservation.getFormationInteret()));
conservationParams.set("meuble_specifique", conservation.getStockageMeuble());
String chaineAAnalyser = conservation.getStockageLocal();
String chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("local_specifique", chaineAAfficher);
chaineAAnalyser = conservation.getStockageMeuble();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("meuble_specifique", chaineAAfficher);
chaineAAnalyser = conservation.getStockageParametre();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("local_parametre", chaineAAfficher);
conservationParams.set("conservation_en_commun", formaterOuiNon(conservation.getCollectionCommune()));
chaineAAnalyser = conservation.getCollectionAutre();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("collection_autre", formaterParenthese(chaineAAfficher));
conservationParams.set("acces_controle", formaterOuiNon(conservation.getAccesControle()));
conservationParams.set("restauration", formaterOuiNon(conservation.getRestauration()));
chaineAAnalyser = conservation.getRestaurationOperation();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("restauration_operation", formaterParenthese(chaineAAfficher));
chaineAAnalyser = conservation.getMaterielConservation();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("materiel_conservation", chaineAAfficher);
chaineAAnalyser = conservation.getMaterielAutre();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("materiel_autre", formaterParenthese(chaineAAfficher));
conservationParams.set("traitement", formaterOuiNon(conservation.getTraitement()));
chaineAAnalyser = conservation.getTraitements();
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser);
conservationParams.set("traitements", formaterParenthese(chaineAAfficher));
conservationParams.set("acquisition_collection", formaterOuiNon(conservation.getAcquisitionCollection()));
conservationParams.set("acquisition_echantillon", formaterOuiNon(conservation.getAcquisitionEchantillon()));
conservationParams.set("acquisition_traitement_info", construireTraitement());
afficherOnglet(conservationTpl, conservationParams, conservationOnglet);
}
private String construireTraitement() {
String cHtml = "";
Integer echantillon = conservation.getAcquisitionEchantillon();
if (echantillon != null && echantillon.intValue() == 1) {
Params traitementConservationParams = new Params();
traitementConservationParams.set("i18n_acquisition_traitement", i18nC.acquisitionTraitement());
traitementConservationParams.set("acquisition_traitement", formaterOuiNon(conservation.getAcquisitionTraitement()));
traitementConservationParams.set("acquisition_traitement_type_info", construireTraitementType());
cHtml = Format.substitute(traitementConservationTpl, traitementConservationParams);
}
return cHtml;
}
private String construireTraitementType() {
String cHtml = "";
String traitement = conservation.getAcquisitionTraitement();
if (traitement.equals("1")) {
Params typeTraitementParams = new Params();
typeTraitementParams.set("i18n_acquisition_traitement_insecte", i18nC.acquisitionTraitementInsecte());
typeTraitementParams.set("i18n_acquisition_traitement_poison", i18nC.acquisitionTraitementPoison());
String acquisitionTraitementInsecte = construireTxtListeOntologie(conservation.getAcquisitionTraitementInsecte());
typeTraitementParams.set("acquisition_traitement_insecte", acquisitionTraitementInsecte);
String acquisitionTraitementPoison = construireTxtListeOntologie(conservation.getAcquisitionTraitementPoison());
typeTraitementParams.set("acquisition_traitement_poison", acquisitionTraitementPoison);
cHtml = Format.substitute(typeTraitementConservationTpl, typeTraitementParams);
}
return cHtml;
}
private void afficherValorisation() {
Params valorisationParams = new Params();
valorisationParams.set("i18n_titre_action_valorisation", i18nC.titreActionValorisation());
valorisationParams.set("i18n_action", i18nC.action());
valorisationParams.set("i18n_action_publication", i18nC.actionPublication());
valorisationParams.set("i18n_collection_autre", i18nC.collectionAutre());
valorisationParams.set("i18n_action_future", i18nC.actionFuture());
valorisationParams.set("action", formaterOuiNon(valorisation.getAction()));
String actionInfo = construireTxtListeOntologie(valorisation.getActionInfo());
valorisationParams.set("action_info", formaterParenthese(actionInfo));
valorisationParams.set("action_publication", valorisation.getPublication());
String collectionAutre = construireTxtListeOntologie(valorisation.getCollectionAutre());
valorisationParams.set("collection_autre", collectionAutre);
valorisationParams.set("action_future", formaterOuiNon(valorisation.getActionFuture()));
valorisationParams.set("action_future_info", formaterParenthese(valorisation.getActionFutureInfo()));
 
valorisationParams.set("i18n_titre_recherche_scientifique", i18nC.titreRechercherScientifique());
valorisationParams.set("i18n_recherche", i18nC.recherche());
valorisationParams.set("recherche", formaterOuiNon(valorisation.getRecherche()));
valorisationParams.set("recherche_info", construireRecherche());
valorisationParams.set("i18n_titre_acces_usage", i18nC.titreAccesUsage());
valorisationParams.set("i18n_acces", i18nC.acces());
valorisationParams.set("i18n_visite", i18nC.visite());
valorisationParams.set("acces", formaterOuiNon(valorisation.getAccesSansMotif()));
valorisationParams.set("acces_info", formaterParenthese(valorisation.getAccesSansMotifInfo()));
valorisationParams.set("visite", formaterOuiNon(valorisation.getVisiteAvecMotif()));
valorisationParams.set("visite_info", formaterParenthese(valorisation.getVisiteAvecMotifInfo()));
afficherOnglet(valorisationTpl, valorisationParams, valorisationOnglet);
}
private String construireRecherche() {
String cHtml = "";
Integer recherche = valorisation.getRecherche();
if (recherche != null && recherche.intValue() == 1) {
Params rechercheParams = new Params();
rechercheParams.set("i18n_recherche_provenance", i18nC.rechercheProvenance());
rechercheParams.set("i18n_recherche_type", i18nC.rechercheType());
String rechercheProvenance = construireTxtListeOntologie(valorisation.getRechercheProvenance());
rechercheParams.set("recherche_provenance", rechercheProvenance);
String rechercheType = construireTxtListeOntologie(valorisation.getRechercheType());
rechercheParams.set("recherche_type", rechercheType);
cHtml = Format.substitute(rechercheValorisationTpl, rechercheParams);
}
return cHtml;
}
private void afficherCollection() {
Params collectionParams = new Params();
collectionParams.set("i18n_titre_collection", i18nC.structureInfoCollection());
collectionParams.set("i18n_indication_collection", i18nC.structureIndicationCollection());
collectionParams.set("i18n_indication_lien_collection", i18nC.structureIndicationLienCollection());
collectionParams.set("css_indication_titre_petit", ComposantClass.INDICATION_TITRE_PETIT);
String guidTpl = ((Configuration) Registry.get(RegistreId.CONFIG)).getUrl("consultationCollectionsLieesStructures");
String guid = guidTpl.replace("{str_id}", structure.getId());
collectionParams.set("guid_structure", guid);
String tableauCollectionHtml = "";
if (collection.size() > 0) {
tableauCollectionHtml = construireTableauCollection();
}
collectionParams.set("tableau_collection", tableauCollectionHtml);
afficherOnglet(collectionTpl, collectionParams, collectionOnglet);
}
private String construireTableauCollection() {
Params contenuParams = new Params();
String lignesCollection = "";
contenuParams.set("i18n_nom_collection", i18nC.nomCollection());
contenuParams.set("i18n_id_collection", i18nC.id());
contenuParams.set("i18n_lien_collection", i18nC.structureLienCollection());
contenuParams.set("css_largeur_colonne_id", ComposantClass.LARGEUR_COLONNE_ID);
String guidTpl = ((Configuration) Registry.get(RegistreId.CONFIG)).getUrl("consultationCollections");
Iterator<String> it = collection.keySet().iterator();
while (it.hasNext()) {
CollectionAStructure collectionCourante = collection.get(it.next());
Params ligneParams = new Params();
String guidCollection = guidTpl.replace("{col_id}", collectionCourante.getIdCollection());
ligneParams.set("guid_structure", guidCollection);
ligneParams.set("id_collection", collectionCourante.getIdCollection());
ligneParams.set("nom_collection", collectionCourante.getNom());
ligneParams.set("lien_collection", guidCollection);
lignesCollection += Format.substitute(ligneCollectionTpl, ligneParams);
}
contenuParams.set("lignes", lignesCollection);
String cHtml = Format.substitute(tableauCollectionTpl, contenuParams);
return cHtml;
}
private void initialiserTousLesTpl() {
initialiserEnteteTpl();
initialiserIdentificationTpl();
initialiserPersonnelTpl();
initialiserTableauPersonnelTpl();
initialiserLignePersonnelTpl();
initialiserConservationTpl();
initialiserTraitementConservationTpl();
initialiserTypeTraitementConservationTpl();
initialiserValorisationTpl();
initialiserRechercheValorisationTpl();
initialiserCollectionTpl();
initialiserTableauCollectionTpl();
initialiserLigneCollectionTpl();
}
private void initialiserEnteteTpl() {
enteteTpl =
"<div id='{css_id}'>"+
" <h1>{nom}</h1>"+
" <h2>{ville}<span class='{css_meta}'> <br /> {i18n_id}:{id} - {guid}</span></h2>" +
" " +
"</div>";
}
private void initialiserIdentificationTpl() {
identificationTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_administratif}</h2>"+
" <span class='{css_label}'>{i18n_acronyme} :</span> {acronyme}<br />"+
" <span class='{css_label}'>{i18n_statut} :</span> {statut}<br />"+
" <span class='{css_label}'>{i18n_date_fondation} :</span> {date_fondation}<br />"+
" <span class='{css_label}'>{i18n_nbre_personnel} :</span> {nbre_personnel}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_description}</h2>"+
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
" <span class='{css_label}'>{i18n_acces} :</span> {acces}<br />"+
" <span class='{css_label}'>{i18n_usage} :</span> {usage}<br />"+
" </div>"+
" <hr class='{css_clear}'/>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_adresse}</h2>"+
" <span class='{css_label}'>{i18n_adresse} :</span> {adresse}<br />" +
" <span class='{css_label}'>{i18n_cp} :</span> {cp}<br />" +
" <span class='{css_label}'>{i18n_ville} :</span> {ville}<br />" +
" <span class='{css_label}'>{i18n_pays} :</span> {pays}<br />" +
" <span class='{css_label}'>{i18n_latitude} / {i18n_longitude} :</span> {latitude_longitude}<br />" +
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_communication}</h2>"+
" <span class='{css_label}'>{i18n_tel} :</span> {tel}<br />"+
" <span class='{css_label}'>{i18n_fax} :</span> {fax}<br />"+
" <span class='{css_label}'>{i18n_courriel} :</span> {courriel}<br />"+
" <span class='{css_label}'>{i18n_web} :</span> {web}<br />"+
" </div>"+
"</div>";
}
private void initialiserPersonnelTpl() {
personnelTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_personnel}</h2>"+
" <p><span class='{css_label}'>{i18n_nbre_personnel_collection} :</span> {nbre_personnel_collection}</p>"+
" {tableau_personnel}"+
"</div>";
}
private void initialiserTableauPersonnelTpl() {
tableauPersonnelTpl =
"<h3>{i18n_titre_membre}</h3>"+
"<table>"+
" <thead>"+
" <tr>" +
" <th>{i18n_fonction}</th>" +
" <th>{i18n_prenom}</th>" +
" <th>{i18n_nom}</th>" +
" <th>{i18n_tel}</th>" +
" <th>{i18n_fax}</th>" +
" <th>{i18n_courriel}</th>" +
" <th>{i18n_statut}</th>" +
" <th>{i18n_tps_w}</th>" +
" <th>{i18n_specialite}</th>" +
" <th>{i18n_contact}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLignePersonnelTpl() {
lignePersonnelTpl =
"<tr>"+
" <td>{fonction}</td>"+
" <td>{prenom}</td>"+
" <td>{nom}</td>"+
" <td>{tel_fix}</td>" +
" <td>{tel_fax}</td>" +
" <td>{courriel}</td>" +
" <td>{statut}</td>" +
" <td>{tps_w}</td>" +
" <td>{specialite}</td>" +
" <td>{contact}</td>" +
"</tr>";
}
private void initialiserConservationTpl() {
conservationTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_conservation_personnel}</h2>"+
" <span class='{css_label}'>{i18n_formation} :</span> {formation}<br />"+
" {formation_info}<br />"+
" <span class='{css_label}'>{i18n_formation_interet} :</span> {formation_interet}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_local}</h2>"+
" <span class='{css_label}'>{i18n_local_specifique} :</span> {local_specifique}<br />"+
" <span class='{css_label}'>{i18n_meuble_specifique} :</span> {meuble_specifique}<br />"+
" <span class='{css_label}'>{i18n_local_parametre} :</span> {local_parametre}<br />"+
" <span class='{css_label}'>{i18n_conservation_en_commun} :</span> {conservation_en_commun} {collection_autre}<br />"+
" <span class='{css_label}'>{i18n_acces_controle} :</span> {acces_controle}<br />"+
" </div>"+
" <hr class='{css_clear}'Window/>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_operation}</h2>"+
" <span class='{css_label}'>{i18n_restauration} :</span> {restauration} {restauration_operation}<br />"+
" <span class='{css_label}'>{i18n_materiel_conservation} :</span> {materiel_conservation} {materiel_autre}<br />"+
" <span class='{css_label}'>{i18n_traitement} :</span> {traitement} {traitements}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_acquisition}</h2>"+
" <span class='{css_label}'>{i18n_acquisition_collection} :</span> {acquisition_collection}<br />"+
" <span class='{css_label}'>{i18n_acquisition_echantillon} :</span> {acquisition_echantillon}<br />"+
" {acquisition_traitement_info}" +
" </div>"+
"</div>";
}
private void initialiserTraitementConservationTpl() {
traitementConservationTpl =
"<span class='{css_indentation} {css_label}'>{i18n_acquisition_traitement} :</span> {acquisition_traitement}<br />"+
" <div class='{css_indentation}'>"+
" {acquisition_traitement_type_info}"+
" </div>";
}
private void initialiserTypeTraitementConservationTpl() {
typeTraitementConservationTpl =
"<span class='{css_indentation} {css_label}'>{i18n_acquisition_traitement_insecte} :</span> {acquisition_traitement_insecte}<br />"+
"<span class='{css_indentation} {css_label}'>{i18n_acquisition_traitement_poison} :</span> {acquisition_traitement_poison}<br />";
}
private void initialiserValorisationTpl() {
valorisationTpl =
"<div class='{css_corps}'>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_action_valorisation}</h2>"+
" <span class='{css_label}'>{i18n_action} :</span> {action} {action_info}<br />"+
" <span class='{css_label}'>{i18n_action_publication} :</span> {action_publication}<br />"+
" <span class='{css_label}'>{i18n_collection_autre} :</span> {collection_autre}<br />"+
" <span class='{css_label}'>{i18n_action_future} :</span> {action_future} {action_future_info}<br />"+
" </div>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_recherche_scientifique}</h2>"+
" <span class='{css_label}'>{i18n_recherche} :</span> {recherche}<br />"+
" {recherche_info}"+
" </div>"+
" <hr class='{css_clear}'/>"+
" <div class='{css_fieldset}'>"+
" <h2>{i18n_titre_acces_usage}</h2>"+
" <span class='{css_label}'>{i18n_visite} :</span> {visite} {visite_info}<br />"+
" <span class='{css_label}'>{i18n_acces} :</span> {acces} {acces_info}<br />"+
" </div>"+
"</div>";
}
private void initialiserRechercheValorisationTpl() {
rechercheValorisationTpl =
"<span class='{css_indentation} {css_label}'>{i18n_recherche_provenance} :</span> {recherche_provenance}<br />"+
"<span class='{css_indentation} {css_label}'>{i18n_recherche_type} :</span> {recherche_type}<br />";
}
private void initialiserCollectionTpl() {
collectionTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_collection} (<span class='{css_label} {css_indication_titre_petit}'>{i18n_indication_collection}</span>)</h2>"+
" {tableau_collection}"+
" <p> "+
" <a href=\"{guid_structure}\" class=\"{css_indication_titre_petit}\" target=\"_blank\">{i18n_indication_lien_collection}</a>"+
" </p>"+
"</div>";
}
private void initialiserTableauCollectionTpl() {
tableauCollectionTpl =
"<table>"+
" <thead>"+
" <tr>" +
" <th class=\"{css_largeur_colonne_id}\">{i18n_id_collection}</th>" +
" <th>{i18n_nom_collection}</th>" +
" <th>{i18n_lien_collection}</th>" +
" </tr>"+
" </thead>"+
" <tbody>"+
" {lignes}"+
" </tbody>"+
"</table>";
}
private void initialiserLigneCollectionTpl() {
ligneCollectionTpl =
"<tr>"+
" <td>{id_collection}</td>"+
" <td>{nom_collection}</td>"+
" <td><a href=\"{lien_collection}\" target=\"_blank\">{lien_collection}</a></td>"+
"</tr>";
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Structure) {
structure = (Structure) nouvellesDonnees;
structureChargementOk = true;
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
receptionerListeValeurs(listeValeursReceptionnee);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("liste_structure_a_personne")) {
allouerPersonnelAStructure((StructureAPersonneListe) info.getDonnee(0));
personnelChargementOk = true;
} else if (info.getType().equals("liste_collection_a_structure")) {
allouerCollectionAStructure((CollectionAStructureListe) info.getDonnee(0));
collectionChargementOk = true;
} else if (info.getType().equals("ontologie_chargee")) {
ontologieChargementOk = true;
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
if (avoirDonneesChargees()) {
afficherDetailInstitution();
}
}
private void allouerCollectionAStructure(CollectionAStructureListe donnee) {
collection = donnee;
}
 
protected void allouerPersonnelAStructure(StructureAPersonneListe personnel) {
structure.setPersonnel(personnel);
}
private boolean avoirDonneesChargees() {
boolean ok = false;
if (structureChargementOk && personnelChargementOk && ontologieChargementOk) {
ok = true;
}
return ok;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureDetailVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/structure/StructureDetailVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/structure/StructureDetailVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureForm.java
New file
0,0 → 1,488
package org.tela_botanica.client.vues.structure;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.GrillePaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne;
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
import org.tela_botanica.client.composants.pagination.ProxyStructureAPersonne;
import org.tela_botanica.client.composants.pagination.ProxyValeur;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.InterneValeur;
import org.tela_botanica.client.modeles.InterneValeurListe;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneListe;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
import org.tela_botanica.client.modeles.structure.StructureConservation;
import org.tela_botanica.client.modeles.structure.StructureValorisation;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.UtilArray;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.structure.StructureFormPersonne.EtatPersonnelStructure;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
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.Component;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.HiddenField;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
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.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Window;
 
public class StructureForm extends Formulaire implements Rafraichissable {
private TabPanel onglets = null;
private StructureFormIdentification identificationOnglet = null;
private StructureFormPersonne personnelOnglet = null;
private StructureFormConservation conservationOnglet = null;
private StructureFormValorisation valorisationOnglet = null;
// Onglet IDENTIFICATION
public Structure identification = null;
 
// Onglet PERSONNEL
// Vide suite à refactoring
// Onglet CONSERVATION
public StructureConservation conservation = null;
// Onglet VALORISATION
public StructureValorisation valorisation = null;
private Sequenceur sequenceur;
public Structure structure = null;
public Rafraichissable vueExterneARafraichirApresValidation = null;
public StructureForm(Mediateur mediateurCourrant, String modeDeCreation, Sequenceur sequenceur) {
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.STRUCTURE);
this.sequenceur = sequenceur;
// Ajout du titre
panneauFormulaire.setHeadingHtml(i18nC.titreAjoutFormStructurePanneau());
// Création des onglets
onglets = creerOnglets();
// Ajout des onglets au formulaire général
panneauFormulaire.add(onglets);
}
protected TabPanel creerOnglets() {
TabPanel ongletsStructure = new TabPanel();
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner)
ongletsStructure.setHeight("100%");
// Onlget formulaire IDENTIFICATION
ongletsStructure.add(creerOngletIdentification());
// Onlget formulaire PERSONNEL
ongletsStructure.add(creerOngletPersonnel());
// Onlget formulaire CONSERVATION
ongletsStructure.add(creerOngletConservation());
// Onlget formulaire VALORISATION
ongletsStructure.add(creerOngletValorisation());
// Sélection de l'onglet par défaut
//ongletsStructure(personnelOnglet);
return ongletsStructure;
}
private void repandreRafraichissement() {
if (vueExterneARafraichirApresValidation != null) {
String type = "structure_modifiee";
if (mode.equals(Formulaire.MODE_AJOUTER)) {
type = "structure_ajoutee";
}
Information info = new Information(type);
info.setDonnee(0, structure);
vueExterneARafraichirApresValidation.rafraichir(info);
}
}
public boolean soumettreFormulaire() {
// Vérification de la validité des champs du formulaire
boolean fomulaireValide = verifierFormulaire();
Structure identification = collecterStructureIdentification();
if(identification != null) {
structure = identification;
} else {
structure = this.identification;
}
 
structure.setConservation(this.conservation);
structure.setValorisation(this.valorisation);
if (fomulaireValide) {
// Collecte des données du formulaire
StructureConservation conservation = collecterStructureConservation();
StructureValorisation valorisation = collecterStructureValorisation();
if(conservation != null) {
structure.setConservation(conservation);
}
if(valorisation != null) {
structure.setValorisation(valorisation);
}
EtatPersonnelStructure etatPersonnel = personnelOnglet.collecter();
structure.setPersonnel(etatPersonnel.personnel);
structure.setConservation(conservation);
structure.setValorisation(valorisation);
if (mode.equals(MODE_AJOUTER)) {
// Ajout des informations sur la Structure
mediateur.ajouterStructure(this, structure, conservation, valorisation);
// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
// Voir la méthode rafraichir().
} else if (mode.equals(MODE_MODIFIER)) {
// Modification des informations sur la Structure
if (structure == null && conservation == null && valorisation == null) {
//InfoLogger.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
} else {
mediateur.modifierStructure(this, structure.getId(), structure, conservation, valorisation);
}
if (etatPersonnel.personnelModifie.size() == 0 && etatPersonnel.personnelAjoute.size() == 0 && etatPersonnel.personnelSupprime.size() == 0) {
//InfoLogger.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
} else {
if (etatPersonnel.personnelModifie.size() != 0) {
personnelOnglet.incrementerDecompteRafraichissementPersonnel();
mediateur.modifierStructureAPersonne(this, etatPersonnel.personnelModifie);
}
// Ajout des relations StructureAPersonne
if (etatPersonnel.personnelAjoute.size() != 0) {
personnelOnglet.incrementerDecompteRafraichissementPersonnel();
mediateur.ajouterStructureAPersonne(this, structure.getId(), etatPersonnel.personnelAjoute);
}
// Suppression des relations StructureAPersonne
if (etatPersonnel.personnelSupprime.size() != 0) {
personnelOnglet.incrementerDecompteRafraichissementPersonnel();
mediateur.supprimerStructureAPersonne(this, etatPersonnel.personnelSupprime);
}
}
}
}
return fomulaireValide;
}
public boolean verifierFormulaire() {
ArrayList<String> messages = new ArrayList<String>();
messages.addAll(verifierOnglets());
// Affichage des messages d'alerte
if (messages.size() != 0) {
String[] a = {};
a = messages.toArray(a);
MessageBox.alert("Erreurs de saisies", UtilArray.implode(a, "\n\n"), null);
return false;
}
return true;
}
private ArrayList<String> verifierOnglets() {
ArrayList<String> messages = new ArrayList<String>();
messages.addAll(identificationOnglet.verifier());
messages.addAll(personnelOnglet.verifier());
return messages;
}
private StructureValorisation collecterStructureValorisation() {
return valorisationOnglet.collecter();
}
private void peuplerStructureValorisation() {
valorisationOnglet.peupler();
}
private StructureConservation collecterStructureConservation() {
return conservationOnglet.collecter();
}
private void peuplerStructureConservation() {
conservationOnglet.peupler();
}
private Structure collecterStructureIdentification() {
Structure structureARetourner = identificationOnglet.collecter();
return structureARetourner;
}
private TabItem creerOngletValorisation() {
valorisationOnglet = new StructureFormValorisation(mediateur, this, sequenceur);
return valorisationOnglet;
}
private TabItem creerOngletConservation() {
conservationOnglet = new StructureFormConservation(mediateur, this, sequenceur);
return conservationOnglet;
}
private EtatPersonnelStructure collecterStructurePersonnel() {
return personnelOnglet.collecter();
}
private void peuplerStructurePersonnel(StructureAPersonneListe personnel) {
personnelOnglet.peupler(personnel);
}
private TabItem creerOngletPersonnel() {
personnelOnglet = new StructureFormPersonne(this, mediateur);
return personnelOnglet;
}
private TabItem creerOngletIdentification() {
identificationOnglet = new StructureFormIdentification(this);
return identificationOnglet;
}
public void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) {
String[] valeurs = donnees.split(";;");
for (int i = 0; i < valeurs.length; i++) {
if (valeurs[i].startsWith("AUTRE##")) {
champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", ""));
} else {
//TODO : check : List<CheckBox> cases = groupeCac.getAll();
List<Field<?>> cases = groupeCac.getAll();
for (int j = 0; j < cases.size(); j++) {
if (cases.get(j).getId().equals("val-"+valeurs[i])) {
((CheckBox) cases.get(j)).setValue(true);
}
}
}
}
}
public void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) {
//List<Radio> boutons = groupeBr.getAll();
List<Field<?>> boutons = groupeBr.getAll();
String id = valeur+"_"+groupeBr.getName().replace("_grp", "");
for (int i = 0; i < boutons.size(); i++) {
if (boutons.get(i).getId().equals(id)) {
((Radio) boutons.get(i)).setValue(true);
}
}
}
public String creerChaineDenormalisee(List<CheckBox> liste) {
String identifiants = "";
if (liste != null) {
int taille = liste.size();
for (int i = 0; i < taille; i++) {
CheckBox cac = liste.get(i);
if (cac.isEnabled()) {
identifiants = identifiants.concat(";;"+cac.getData("id"));
}
}
identifiants.replaceFirst("^;;", "");
}
return identifiants;
}
public void afficherChampSupplementaire(Radio radioBtn) {
valorisationOnglet.afficherChampSupplementaire(radioBtn) ;
conservationOnglet.afficherChampSupplementaires(radioBtn);
}
public void rafraichir(Object nouvellesDonnees) {
try {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
if(!info.getType().equals("selection_structure") && !info.getType().equals("selection_structure")) {
repandreRafraichissement();
}
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
} catch (Exception e) {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e);
}
controlerFermeture();
}
public void rafraichirInformation(Information info) {
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
}
if (info.getType().equals("modif_structure")) {
InfoLogger.display("Modification d'une institution", info.toString());
Structure structureMaj = (Structure)(info.getDonnee(0));
if(structureMaj != null) {
// TRUE uniquement si la modification a retourné un objet JSON pour mise à jour
// (contenant les coordonnées générées, cf r1673)
structure.setLatitude(structureMaj.getLatitude());
structure.setLongitude(structureMaj.getLongitude());
}
controlerFermeture();
} else if (info.getType().equals("ajout_structure")) {
if (info.getDonnee(0) != null && ( info.getDonnee(0) instanceof String || info.getDonnee(0) instanceof Object) ) {
this.mode = MODE_MODIFIER;
String structureId;
 
if(info.getDonnee(0) instanceof String) {
structureId = (String) info.getDonnee(0);
}
else {
// le backend renvoie un objet si longitude et latitude ont
// été générés
Structure structureMaj = (Structure)(info.getDonnee(0));
// structureMaj == null ? erreur horriblement impensable
structure.setLatitude(structureMaj.getLatitude());
structure.setLongitude(structureMaj.getLongitude());
structureId = structureMaj.getId();
}
 
structure.setId(structureId);
identification = structure;
identificationOnglet.rafraichir(info);
personnelOnglet.rafraichir(info);
conservationOnglet.rafraichir(info);
valorisationOnglet.rafraichir(info);
InfoLogger.display("Ajout d'une Institution", "L'intitution '"+structureId+"' a bien été ajoutée");
} else {
InfoLogger.display("Ajout d'une Institution", info.toString());
}
} else if (info.getType().equals("modif_structure_a_personne")) {
InfoLogger.display("Modification du Personnel", info.toString());
personnelOnglet.rafraichir(info);
} else if (info.getType().equals("suppression_structure_a_personne")) {
InfoLogger.display("Suppression du Personnel", info.toString());
personnelOnglet.rafraichir(info);
} else if (info.getType().equals("ajout_structure_a_personne")) {
InfoLogger.display("Ajout du Personnel", info.toString());
personnelOnglet.rafraichir(info);
} else if (info.getType().equals("selection_structure")) {
InfoLogger.display("Modification d'une institution", info.toString());
String titre = i18nC.titreModifFormStructurePanneau();
if (info.getDonnee(0) != null) {
identification = (Structure)info.getDonnee(0);
identificationOnglet.rafraichir(info);
// Composition du titre
titre += " - ID : "+identification.getId();
}
if (info.getDonnee(1) != null) {
conservation = (StructureConservation)info.getDonnee(1);
conservationOnglet.rafraichir(info);
}
if (info.getDonnee(2) != null) {
valorisation = (StructureValorisation)info.getDonnee(2);
valorisationOnglet.rafraichir(info);
}
} else if (info.getType().equals("liste_structure_a_personne")) {
personnelOnglet.rafraichir(info);
}
}
public void rafraichirValeurListe(ValeurListe listeValeurs) {
List<Valeur> liste = listeValeurs.toList();
 
// Test pour savoir si la liste contient des éléments
if (liste.size() > 0) {
identificationOnglet.rafraichir(listeValeurs);
personnelOnglet.rafraichir(listeValeurs);
conservationOnglet.rafraichir(listeValeurs);
valorisationOnglet.rafraichir(listeValeurs);
//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
} else {
GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
}
}
 
public String getIdIdentification() {
return identification.getId();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureForm.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/structure/StructureForm.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/structure/StructureForm.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureFormIdentification.java
New file
0,0 → 1,757
package org.tela_botanica.client.vues.structure;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.ChampNombre;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyValeur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.InterneValeur;
import org.tela_botanica.client.modeles.InterneValeurListe;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
import org.tela_botanica.client.modeles.structure.StructureConservation;
import org.tela_botanica.client.modeles.structure.StructureValorisation;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireOnglet;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.HiddenField;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Window;
 
public class StructureFormIdentification extends FormulaireOnglet implements Rafraichissable {
public TabItem personnelOnglet;
public TabItem conservationOnglet;
public TabItem valorisationOnglet;
public HiddenField<String> idStructureChp;
public Structure identification;
public ListStore<Valeur> magazinLstpr;
public ComboBox<Valeur> comboLstpr;
public ListStore<Valeur> magazinLstpu;
public ComboBox<Valeur> comboLstpu;
public ComboBox<InterneValeur> comboAcronyme;
public TextField<String> ihChp;
public TextField<String> mnhnChp;
public ComboBox<InterneValeur> comboTypeStructure;
public TextField<String> nomStructureChp;
public TextField<String> dateFondationChp;
public TextArea descriptionChp;
public TextArea conditionAccesChp;
public TextArea conditionUsageChp;
public TextArea adrChp;
public TextField<String> cpChp;
public TextField<String> villeChp;
public ListStore<Valeur> magazinPays;
public ChampComboBoxRechercheTempsReelPaginable comboPays;
public TextField<String> latitudeChp;
public TextField<String> longitudeChp;
public TextField<String> telChp;
public TextField<String> faxChp;
public TextField<String> emailChp;
public TextField<String> urlChp;
public StructureAPersonneListe personnel;
public StructureAPersonneListe personnelAjoute;
public StructureAPersonneListe personnelModifie;
public StructureAPersonneListe personnelSupprime;
public NumberField nbreTotalPersonneStructureChp;
public EditorGrid<StructureAPersonne> grillePersonnel;
public ListStore<StructureAPersonne> personnelGrilleMagazin;
public StructureConservation conservation;
public RadioGroup formationMarkRGrpChp;
public RadioGroup interetFormationMarkRGrpChp;
public RadioGroup collectionCommuneMarkRGrpChp;
public RadioGroup accesControleMarkRGrpChp;
public RadioGroup restaurationMarkRGrpChp;
public RadioGroup traitementMarkRGrpChp;
public RadioGroup collectionAcquisitionMarkRGrpChp;
public RadioGroup echantillonAcquisitionMarkRGrpChp;
public TextField<String> localStockageAutreChp;
public TextField<String> meubleStockageAutreChp;
public TextField<String> parametreStockageAutreChp;
public TextField<String> collectionAutreAutreChp;
public TextField<String> autreCollectionAutreChp;
public TextField<String> opRestauAutreChp;
public TextField<String> autreMaterielAutreChp;
public TextField<String> poisonTraitementAutreChp;
public TextField<String> traitementAutreChp;
public TextField<String> insecteTraitementAutreChp;
public TextField<String> actionAutreChp;
public TextField<String> provenanceRechercheAutreChp;
public TextField<String> typeRechercheAutreChp;
public CheckBoxGroup localStockageTrukCacGrpChp;
public LayoutContainer localStockageTrukCp;
public CheckBoxGroup meubleStockageTrukCacGrpChp;
public LayoutContainer meubleStockageTrukCp;
public CheckBoxGroup parametreStockageTrukCacGrpChp;
public LayoutContainer parametreStockageTrukCp;
public LayoutContainer collectionAutreTrukCp;
public CheckBoxGroup collectionAutreTrukCacGrpChp;
public CheckBoxGroup opRestauTrukCacGrpChp;
public LayoutContainer opRestauTrukCp;
public CheckBoxGroup autreMaterielTrukCacGrpChp;
public LayoutContainer autreMaterielTrukCp;
public LayoutContainer traitementTrukCp;
public CheckBoxGroup traitementTrukCacGrpChp;
public LayoutContainer poisonTraitementTrukCp;
public LayoutContainer insecteTraitementTrukCp;
public CheckBoxGroup insecteTraitementTrukCacGrpChp;
public CheckBoxGroup poisonTraitementTrukCacGrpChp;
public LayoutContainer autreCollectionTrukCp;
public CheckBoxGroup autreCollectionTrukCacGrpChp;
public LayoutContainer provenanceRechercheTrukCp;
public CheckBoxGroup provenanceRechercheTrukCacGrpChp;
public CheckBoxGroup typeRechercheTrukCacGrpChp;
public LayoutContainer typeRechercheTrukCp;
public TextField<String> futureActionChp;
public TextField<String> sansMotifAccesChp;
public TextField<String> avecMotifAccesChp;
public TextField<String> formationChp;
public RadioGroup traitementAcquisitionMarkRGrpChp;
public LabelField traitementAcquisitionMarkLabel;
public RadioGroup materielConservationCeRGrpChp;
public StructureValorisation valorisation;
public RadioGroup actionMarkRGrpChp;
public LayoutContainer actionTrukCp;
public CheckBoxGroup actionTrukCacGrpChp;
public RadioGroup futureActionMarkRGrpChp;
public RadioGroup rechercheMarkRGrpChp;
public RadioGroup sansMotifAccesMarkRGrpChp;
public RadioGroup avecMotifAccesMarkRGrpChp;
public TextField<String> publicationChp;
public LayoutContainer materielConservationCp;
public ListStore<Personne> personneExistanteMagazin;
public ChampComboBoxRechercheTempsReelPaginable personneExistanteCombo;
public Button supprimerPersonnelBtn;
public CellEditor fonctionEditor;
public List<Valeur> fonctionsListe;
public Sequenceur sequenceur;
public Structure structure;
public Rafraichissable vueExterneARafraichirApresValidation;
private String ID = "identification";
Formulaire formulaireCourant;
public StructureFormIdentification(Formulaire formulaireCourant) {
initialiserOnglet(formulaireCourant);
setLayout(new FitLayout());
setId(ID);
setText(Mediateur.i18nC.structureInfoGeneral());
setStyleAttribute("padding", "0");
this.formulaireCourant = formulaireCourant;
//+-----------------------------------------------------------------------------------------------------------+
//+-----------------------------------------------------------------------------------------------------------+
// Champs cachés
idStructureChp = new HiddenField<String>();
//+-----------------------------------------------------------------------------------------------------------+
// Fieldset IDENTITÉ
FieldSet fieldSetIdentite = new FieldSet();
fieldSetIdentite.setHeadingHtml("Identité");
fieldSetIdentite.setCollapsible(true);
fieldSetIdentite.setLayout(Formulaire.creerFormLayout(120, LabelAlign.LEFT));
fieldSetIdentite.setAutoHeight(true);
nomStructureChp = new TextField<String>();
nomStructureChp.setTabIndex(tabIndex++);
nomStructureChp.setFieldLabel("Nom de la structure");
nomStructureChp.setAllowBlank(false);
nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire.");
nomStructureChp.addStyleName(ComposantClass.OBLIGATOIRE);
nomStructureChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
fieldSetIdentite.add(nomStructureChp, new FormData(450, 0));
// Création du sous-formulaire : Acronyme
LayoutContainer ligne = new LayoutContainer();
ligne.setLayout(new ColumnLayout());
ligne.setSize(600, -1);
LayoutContainer gauche = new LayoutContainer();
gauche.setLayout(Formulaire.creerFormLayout(120, LabelAlign.LEFT));
LayoutContainer droite = new LayoutContainer();
droite.setLayout(Formulaire.creerFormLayout(10, LabelAlign.LEFT));
ListStore<InterneValeur> acronymes = new ListStore<InterneValeur>();
acronymes.add(InterneValeurListe.getTypeAcronyme());
comboAcronyme = new ComboBox<InterneValeur>();
comboAcronyme.setTabIndex(tabIndex++);
comboAcronyme.setEmptyText("Sélectioner un type d'acronyme...");
comboAcronyme.setFieldLabel("Type d'acronyme");
comboAcronyme.setDisplayField("nom");
comboAcronyme.setStore(acronymes);
comboAcronyme.setEditable(false);
comboAcronyme.setTypeAhead(true);
comboAcronyme.setTriggerAction(TriggerAction.ALL);
comboAcronyme.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {
@Override
public void selectionChanged(SelectionChangedEvent<InterneValeur> se) {
String acronymeAbr = se.getSelectedItem().getAbr();
if (acronymeAbr.equals("IH")) {
mnhnChp.hide();
ihChp.show();
} else if (acronymeAbr.equals("MNHN")) {
ihChp.hide();
mnhnChp.show();
} else if (acronymeAbr.equals("")) {
ihChp.hide();
mnhnChp.hide();
comboAcronyme.clearSelections();
}
}
});
gauche.add(comboAcronyme, new FormData("95%"));
ihChp = new TextField<String>();
ihChp.setTabIndex(tabIndex++);
ihChp.setLabelSeparator("");
ihChp.setToolTip("Index Herbariorum : herbier de plus de 5000 échantillons");
ihChp.hide();
droite.add(ihChp, new FormData("95%"));
mnhnChp = new TextField<String>();
mnhnChp.setTabIndex(tabIndex++);
mnhnChp.setLabelSeparator("");
mnhnChp.setToolTip("Acronyme MNHN : herbier de moins de 5000 échantillons");
mnhnChp.hide();
droite.add(mnhnChp, new FormData("95%"));
ligne.add(gauche, new ColumnData(.5));
ligne.add(droite, new ColumnData(.5));
fieldSetIdentite.add(ligne);
// Création du sous-formulaire : Type de Structure
LayoutContainer ligneTs = new LayoutContainer();
ligneTs.setLayout(new ColumnLayout());
ligneTs.setSize(600, -1);
LayoutContainer gaucheTs = new LayoutContainer();
gaucheTs.setLayout(Formulaire.creerFormLayout(120, LabelAlign.LEFT));
LayoutContainer droiteTs = new LayoutContainer();
droiteTs.setLayout(Formulaire.creerFormLayout(10, LabelAlign.LEFT));
ListStore<InterneValeur> typesStructure = new ListStore<InterneValeur>();
typesStructure.add(InterneValeurListe.getTypeStructure());
comboTypeStructure = new ComboBox<InterneValeur>();
comboTypeStructure.setTabIndex(tabIndex++);
comboTypeStructure.setEmptyText("Sélectioner un type de structure...");
comboTypeStructure.setFieldLabel("Statut des structures");
comboTypeStructure.setDisplayField("nom");
comboTypeStructure.setStore(typesStructure);
comboTypeStructure.setEditable(false);
comboTypeStructure.setTypeAhead(true);
comboTypeStructure.setTriggerAction(TriggerAction.ALL);
comboTypeStructure.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {
@Override
public void selectionChanged(SelectionChangedEvent<InterneValeur> se) {
String typeAbr = se.getSelectedItem().getAbr();
if (typeAbr.equals("stpu")) {
comboLstpr.hide();
comboLstpu.show();
} else if (typeAbr.equals("stpr")) {
comboLstpu.hide();
comboLstpr.show();
} else if (typeAbr.equals("")) {
comboLstpr.hide();
comboLstpu.hide();
comboTypeStructure.clearSelections();
}
}
});
gaucheTs.add(comboTypeStructure, new FormData("95%"));
magazinLstpu = new ListStore<Valeur>();
comboLstpu = new ComboBox<Valeur>();
comboLstpu.setTabIndex(tabIndex++);
//comboLstpu.setFieldLabel("Statut des structures publiques");
comboLstpu.setLabelSeparator("");
comboLstpu.setDisplayField("nom");
comboLstpu.setEditable(false);
comboLstpu.setTriggerAction(TriggerAction.ALL);
comboLstpu.setStore(magazinLstpu);
comboLstpu.hide();
droiteTs.add(comboLstpu, new FormData("95%"));
mediateur.obtenirListeValeurEtRafraichir(this, "stpu", sequenceur);
magazinLstpr = new ListStore<Valeur>();
comboLstpr = new ComboBox<Valeur>();
comboLstpr.setTabIndex(tabIndex++);
//comboLstpr.setFieldLabel("Statut des structures privées");
comboLstpr.setLabelSeparator("");
comboLstpr.setDisplayField("nom");
comboLstpr.setEditable(false);
comboLstpr.setTriggerAction(TriggerAction.ALL);
comboLstpr.setStore(magazinLstpr);
comboLstpr.hide();
droiteTs.add(comboLstpr, new FormData("95%"));
mediateur.obtenirListeValeurEtRafraichir(this, "stpr", sequenceur);
ligneTs.add(gaucheTs, new ColumnData(0.5));
ligneTs.add(droiteTs, new ColumnData(0.5));
fieldSetIdentite.add(ligneTs);
dateFondationChp = new TextField();
dateFondationChp.setTabIndex(tabIndex++);
dateFondationChp.setFieldLabel("Date de fondation");
fieldSetIdentite.add(dateFondationChp);
nbreTotalPersonneStructureChp = new NumberField();
nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personnes travaillant dans l'institution");
nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#"));
nbreTotalPersonneStructureChp.setToolTip(i18nC.champNumerique());
nbreTotalPersonneStructureChp.setAllowDecimals(false);
nbreTotalPersonneStructureChp.setAllowNegative(false);
nbreTotalPersonneStructureChp.setEmptyText("");
fieldSetIdentite.add(nbreTotalPersonneStructureChp);
 
this.add(fieldSetIdentite);
//+-----------------------------------------------------------------------------------------------------------+
// Fieldset ADRESSE
LayoutContainer principalFdAdresse = new LayoutContainer();
principalFdAdresse.setLayout(new ColumnLayout());
principalFdAdresse.setSize(1050, -1);
LayoutContainer gaucheFdAdresse = new LayoutContainer();
gaucheFdAdresse.setLayout(Formulaire.creerFormLayout(null, LabelAlign.LEFT));
LayoutContainer droiteFdAdresse = new LayoutContainer();
droiteFdAdresse.setLayout(Formulaire.creerFormLayout(100, LabelAlign.LEFT));
droiteFdAdresse.setWidth(700);
FieldSet fieldSetAdresse = new FieldSet();
fieldSetAdresse.setHeadingHtml("Adresse");
fieldSetAdresse.setCollapsible(true);
fieldSetAdresse.setLayout(Formulaire.creerFormLayout(null, LabelAlign.LEFT));
adrChp = new TextArea();
adrChp.setTabIndex(tabIndex++);
adrChp.setFieldLabel("Adresse (Nom du batiment, rue...)");
fieldSetAdresse.add(adrChp, new FormData(550, 0));
cpChp = new TextField<String>();
cpChp.setTabIndex(tabIndex++);
cpChp.setFieldLabel("Code postal");
gaucheFdAdresse.add(cpChp, new FormData("95%"));
villeChp = new TextField<String>();
villeChp.setTabIndex(tabIndex++);
villeChp.setFieldLabel("Ville");
gaucheFdAdresse.add(villeChp, new FormData("95%"));
ModelType modelTypesPays = new ModelType();
modelTypesPays.setRoot("valeurs");
modelTypesPays.setTotalName("nbElements");
modelTypesPays.addField("cmlv_nom");
modelTypesPays.addField("cmlv_id_valeur");
modelTypesPays.addField("cmlv_abreviation");
modelTypesPays.addField("cmlv_description");
String displayNamePays = "cmlv_nom";
String nomListeTypes = "pays";
ProxyValeur<ModelData> proxyPays = new ProxyValeur<ModelData>(nomListeTypes, null);
comboPays = new ChampComboBoxRechercheTempsReelPaginable(proxyPays, modelTypesPays, displayNamePays);
comboPays.setWidth(100,500);
comboPays.getCombo().setTabIndex(tabIndex++);
comboPays.getCombo().setFieldLabel("Pays");
comboPays.getCombo().setForceSelection(true);
comboPays.getCombo().setTemplate(getTemplatePays());
droiteFdAdresse.add(comboPays, new FormData("95%"));
latitudeChp = new TextField<String>();
latitudeChp.setRegex(Pattern.latitude);
latitudeChp.setToolTip("Format : nombre décimal positif ou négatif de 0 à 90.");
latitudeChp.getMessages().setRegexText("La valeur saisie n'est pas une latitude valide. Exemples de latitude : -45,302010 ou 45.252423 ou 25,16.");
latitudeChp.setTabIndex(tabIndex++);
latitudeChp.setFieldLabel("Latitude (Nord)");
gaucheFdAdresse.add(latitudeChp, new FormData("95%"));
longitudeChp = new TextField<String>();
longitudeChp.setRegex(Pattern.longitude);
longitudeChp.setToolTip("Format : nombre décimal positif ou négatif de 0 à 180.");
longitudeChp.getMessages().setRegexText("La valeur saisie n'est pas une longitude valide. Exemples de longitude : -150,302010 ou 150.252423 ou 25,16.");
longitudeChp.setTabIndex(tabIndex++);
longitudeChp.setFieldLabel("Longitude (Est)");
droiteFdAdresse.add(longitudeChp, new FormData("95%"));
principalFdAdresse.add(gaucheFdAdresse, new ColumnData(.5));
principalFdAdresse.add(droiteFdAdresse, new ColumnData(.5));
fieldSetAdresse.add(principalFdAdresse);
this.add(fieldSetAdresse);
//+-----------------------------------------------------------------------------------------------------------+
// Fieldset TÉLÉPHONE et EMAIL
LayoutContainer principalFdTelMail = new LayoutContainer();
principalFdTelMail.setLayout(new ColumnLayout());
principalFdTelMail.setSize(700, -1);
LayoutContainer gaucheFdTelMail = new LayoutContainer();
gaucheFdTelMail.setLayout(Formulaire.creerFormLayout(60, LabelAlign.LEFT));
LayoutContainer droiteFdTelMail = new LayoutContainer();
droiteFdTelMail.setLayout(Formulaire.creerFormLayout(60, LabelAlign.LEFT));
FieldSet fieldSetTelMail = new FieldSet();
fieldSetTelMail.setHeadingHtml("Communication");
fieldSetTelMail.setCollapsible(true);
fieldSetTelMail.setLayout(Formulaire.creerFormLayout(null, LabelAlign.LEFT));
telChp = new TextField<String>();
telChp.setTabIndex(tabIndex++);
telChp.setFieldLabel("Téléphone");
gaucheFdTelMail.add(telChp, new FormData("95%"));
faxChp = new TextField<String>();
faxChp.setTabIndex(tabIndex++);
faxChp.setFieldLabel("Fax");
droiteFdTelMail.add(faxChp, new FormData("95%"));
emailChp = new TextField<String>();
emailChp.setTabIndex(tabIndex++);
emailChp.setFieldLabel("Courriel");
emailChp.setToolTip("Saisir le courriel de l'organisation, pas de courriel individuel. Ex. : accueil@organisation.org");
gaucheFdTelMail.add(emailChp, new FormData("95%"));
urlChp = new TextField<String>();
urlChp.setTabIndex(tabIndex++);
urlChp.setFieldLabel("Site web");
droiteFdTelMail.add(urlChp, new FormData("95%"));
principalFdTelMail.add(gaucheFdTelMail, new ColumnData(.5));
principalFdTelMail.add(droiteFdTelMail, new ColumnData(.5));
fieldSetTelMail.add(principalFdTelMail);
this.add(fieldSetTelMail);
//+-----------------------------------------------------------------------------------------------------------+
// Fieldset DESCRIPTION
FieldSet fieldSetDescription = new FieldSet();
fieldSetDescription.setHeadingHtml("Description");
fieldSetDescription.setCollapsible(true);
fieldSetDescription.setLayout(Formulaire.creerFormLayout(120, LabelAlign.LEFT));
descriptionChp = new TextArea();
descriptionChp.setTabIndex(tabIndex++);
descriptionChp.setFieldLabel("Description");
fieldSetDescription.add(descriptionChp, new FormData(550, 0));
conditionAccesChp = new TextArea();
conditionAccesChp.setTabIndex(tabIndex++);
conditionAccesChp.setFieldLabel("Conditions d'accès");
fieldSetDescription.add(conditionAccesChp, new FormData(550, 0));
conditionUsageChp = new TextArea();
conditionUsageChp.setTabIndex(tabIndex++);
conditionUsageChp.setFieldLabel("Conditions d'usage");
fieldSetDescription.add(conditionUsageChp, new FormData(550, 0));
this.add(fieldSetDescription);
}
private native String getTemplatePays() /*-{
return [
'<tpl for=".">',
'<div class="x-combo-list-item">{cmlv_nom} ({cmlv_abreviation})</div>',
'</tpl>'
].join("");
}-*/;
public void peuplerIdSurRetourAjout() {
initialiserIdentification();
idStructureChp.setValue(identification.getId());
nomStructureChp.setValue(identification.getNom());
}
public void peupler() {
if(identification == null) {
initialiserIdentification();
}
if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
// Indique que l'ongleta pu être modifié pour la méthode collecter...
this.setData("acces", true);
// Initialisation de l'objet Structure
identification = new Structure();
}
 
if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && identification != null && getData("acces").equals(false)) {
idStructureChp.setValue(identification.getId());
nomStructureChp.setValue(identification.getNom());
if (!identification.getIdAlternatif().isEmpty()) {
String[] acronyme = identification.getIdAlternatif().split("##");
//#436 : Ne pas afficher "null"
if (UtilString.isEmpty(acronyme[1]) || acronyme[1].equals("null")) {
acronyme[1] = "";
}
if (acronyme[0].matches("^IH$")) {
comboAcronyme.setValue(InterneValeurListe.getTypeAcronymeIH());
ihChp.setValue(acronyme[1]);
} else if (acronyme[0].matches("^MNHN$")) {
comboAcronyme.setValue(InterneValeurListe.getTypeAcronymeMNHN());
mnhnChp.setValue(acronyme[1]);
}
}
if (!identification.getTypePrive().isEmpty()) {
if (identification.getTypePrive().matches("^[0-9]+$")) {
comboTypeStructure.setValue(InterneValeurListe.getTypePrivee());
comboLstpr.setValue(comboLstpr.getStore().findModel("id_valeur", identification.getTypePrive()));
}
} else if (!identification.getTypePublic().isEmpty()) {
if (identification.getTypePublic().matches("^[0-9]+$")) {
comboTypeStructure.setValue(InterneValeurListe.getTypePublique());
comboLstpu.setValue(comboLstpu.getStore().findModel("id_valeur", identification.getTypePublic()));
}
}
String dateFondation = identification.getAnneeOuDateFondation();
dateFondationChp.setValue(dateFondation);
descriptionChp.setValue(identification.getDescription());
conditionAccesChp.setValue(identification.getConditionAcces());
conditionUsageChp.setValue(identification.getConditionUsage());
adrChp.setValue(identification.getAdresse());
cpChp.setValue(identification.getCodePostal());
villeChp.setValue(identification.getVille());
 
if (identification.getPays().matches("^[0-9]+$")) {
comboPays.chargerValeurInitiale(identification.getPays(), "cmlv_id_valeur");
} else {
comboPays.getCombo().setRawValue(identification.getPays());
}
latitudeChp.setValue(identification.getLatitude());
longitudeChp.setValue(identification.getLongitude());
telChp.setValue(identification.getTelephoneFixe());
faxChp.setValue(identification.getFax());
emailChp.setValue(identification.getCourriel());
urlChp.setValue(identification.getUrl("WEB"));
nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne());
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
this.setData("acces", true);
}
}
private void initialiserIdentification() {
identification = ((StructureForm)formulaireCourant).identification;
}
 
public Structure collecter() {
peupler();
Structure structureARetourner = null;
if (this.getData("acces").equals(true)) {
if(identification == null) {
initialiserIdentification();
}
Structure structureCollectee = (Structure) identification.cloner(new Structure());
structureCollectee.setId(idStructureChp.getValue());
structureCollectee.setNom(nomStructureChp.getValue());
// Récupération de l'acronyme (= identifiant alternatif)
structureCollectee.setIdAlternatif(null);
if (comboAcronyme.getValue() != null) {
String typeAcronyme = comboAcronyme.getValue().getAbr();
if (typeAcronyme == "IH") {
structureCollectee.setIdAlternatif(typeAcronyme+"##"+ihChp.getValue());
} else if (typeAcronyme == "MNHN") {
structureCollectee.setIdAlternatif(typeAcronyme+"##"+mnhnChp.getValue());
}
}
// Récupération statut de la structure
structureCollectee.setTypePublic(null);
structureCollectee.setTypePrive(null);
if (comboTypeStructure.getValue() != null) {
String typeStructure = comboTypeStructure.getValue().getAbr();
if (typeStructure == "stpu" && comboLstpu.getValue() != null) {
structureCollectee.setTypePublic(comboLstpu.getValue().getId());
} else if (typeStructure == "stpr" && comboLstpr.getValue() != null) {
structureCollectee.setTypePrive(comboLstpr.getValue().getId());
}
}
String valeurDateFondation = dateFondationChp.getValue();
if (!UtilString.isEmpty(valeurDateFondation)) {
if (valeurDateFondation.matches("\\d{2}/\\d{2}/\\d{4}")) {
Date dateFondation = DateTimeFormat.getFormat("dd/MM/yyyy").parse(valeurDateFondation);
structureCollectee.setDateFondation(dateFondation);
} else if (valeurDateFondation.matches("\\d{4}")) {
structureCollectee.setDateFondation(valeurDateFondation + "-00-00");
}
}
structureCollectee.setDescription(descriptionChp.getValue());
structureCollectee.setConditionAcces(conditionAccesChp.getValue());
structureCollectee.setConditionUsage(conditionUsageChp.getValue());
structureCollectee.setAdresse(adrChp.getValue());
structureCollectee.setCodePostal(cpChp.getValue());
structureCollectee.setVille(villeChp.getValue());
structureCollectee.setPays(null);
if (comboPays.getCombo().getValue() != null) {
structureCollectee.setPays(new Valeur(comboPays.getValeur()).getId());
} else if (comboPays.getCombo().getRawValue() != "") {
structureCollectee.setPays(comboPays.getCombo().getRawValue());
}
structureCollectee.setLatitude(latitudeChp.getValue());
structureCollectee.setLongitude(longitudeChp.getValue());
structureCollectee.setTelephoneFixe(telChp.getValue());
structureCollectee.setFax(faxChp.getValue());
structureCollectee.setCourriel(emailChp.getValue());
structureCollectee.setUrl(Structure.URL_SITE, urlChp.getValue());
structureCollectee.setNbrePersonne(nbreTotalPersonneStructureChp.getValue());
structureARetourner = identification = structureCollectee;
} else {
 
}
return structureARetourner;
}
 
@Override
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
public void rafraichirInformation(Information info) {
if (info.getType().equals("ajout_structure")) {
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
String structureId = (String) info.getDonnee(0);
identification.setId(structureId);
this.setData("acces", false);
peupler();
} else {
InfoLogger.display("Ajout d'une Institution", info.toString());
}
} else if (info.getType().equals("selection_structure")) {
InfoLogger.display("Modification d'une institution", info.toString());
String titre = i18nC.titreModifFormStructurePanneau();
if (info.getDonnee(0) != null) {
try {
identification = (Structure) info.getDonnee(0);
setAcces(false);
peupler();
} catch(Exception e) {
GWT.log("Problème de cast. "+info.getDonnee(0)+" ne peut être casté en Structure", e);
}
// Composition du titre
titre += " - ID : "+identification.getId();
}
}
}
private void rafraichirValeurListe(ValeurListe listeValeurs) {
List<Valeur> liste = listeValeurs.toList();
 
// Test pour savoir si la liste contient des éléments
if (liste.size() > 0) {
if (listeValeurs.getId().equals(config.getListeId("stpr"))) {
magazinLstpr.removeAll();
magazinLstpr.add(liste);
comboLstpr.setStore(magazinLstpr);
}
if (listeValeurs.getId().equals(config.getListeId("stpu"))) {
magazinLstpu.removeAll();
magazinLstpu.add(liste);
comboLstpu.setStore(magazinLstpu);
}
}
}
 
public Collection<? extends String> verifier() {
ArrayList<String> messages = new ArrayList<String>();
// Vérification des infos sur le nom de la structure
if ( (this.getData("acces").equals(true) && nomStructureChp.getValue() == null) ||
(this.getData("acces").equals(true) && nomStructureChp.getValue().equals("")) ||
(this.getData("acces").equals(false) && identification.getNom().equals(""))) {
messages.add("Veuillez indiquez un nom à l'institution.");
}
//Vérification de la date de fondation
String valeurDateFondation = dateFondationChp.getValue();
if (!UtilString.isEmpty(valeurDateFondation) && (!valeurDateFondation.matches("\\d{2}/\\d{2}/\\d{4}") &&
!valeurDateFondation.matches("\\d{4}"))) {
messages.add("La date de fondation n'est pas au format jj/MM/AAAA ou AAAA");
}
return messages;
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure/StructureFormPersonne.java
New file
0,0 → 1,789
package org.tela_botanica.client.vues.structure;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.FenetreForm;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireBarreValidation;
import org.tela_botanica.client.vues.FormulaireOnglet;
import org.tela_botanica.client.vues.personne.PersonneForm;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
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;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.Text;
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.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
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.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Window;
 
public class StructureFormPersonne extends FormulaireOnglet implements Rafraichissable {
private StructureAPersonneListe personnel = null;
private StructureAPersonneListe personnelAjoute = null;
private StructureAPersonneListe personnelModifie = null;
private StructureAPersonneListe personnelSupprime = null;
private NumberField nbreTotalPersonneStructureChp = null;
private EditorGrid<StructureAPersonne> grillePersonnel = null;
private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
public ListStore<Valeur> fonctionsMagazin;
public ComboBox<Valeur> fonctionsCombo;
public ListStore<Valeur> magazinLiStatut;
public ComboBox<Valeur> comboLiStatut;
private ListStore<Personne> personneExistanteMagazin = null;
private ChampComboBoxRechercheTempsReelPaginable personneExistanteCombo = null;
private Button supprimerPersonnelBtn = null;
private CellEditor fonctionEditor = null;
private List<Valeur> fonctionsListe = null;
private String ID = "personnel";
private Formulaire formulaireCourant = null;
private int decompteRafraichissementPersonnel;
private FenetreForm fenetreFormulaire = null;
private Sequenceur sequenceur = null;
final class EtatPersonnelStructure {
public StructureAPersonneListe personnelModifie;
public StructureAPersonneListe personnelAjoute;
public StructureAPersonneListe personnelSupprime;
public StructureAPersonneListe personnel;
}
 
public StructureFormPersonne(Formulaire formulaireCourant, Mediateur mediateur) {
initialiserOnglet(formulaireCourant);
this.formulaireCourant = formulaireCourant;
// Création des objets contenant les manipulations de la grille
personnelModifie = new StructureAPersonneListe();
personnelAjoute = new StructureAPersonneListe();
personnelSupprime = new StructureAPersonneListe();
setId(ID);
setText(Mediateur.i18nC.personneSingulier());
FormulaireOnglet.parametrer(this);
this.setLayout(Formulaire.creerFormLayout(400, LabelAlign.LEFT));
this.setStyleAttribute("padding", "0");
this.addListener(Events.Select, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
setData("acces", true);
 
// Rafraichissement du contenu de la grille du personnel
if (StructureFormPersonne.this.formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
rafraichirPersonnel();
}
}
});
ContentPanel cp = new ContentPanel();
cp.setHeadingHtml("Personnes travaillant sur les collections");
cp.setIcon(Images.ICONES.table());
cp.setScrollMode(Scroll.AUTO);
cp.setLayout(new FitLayout());
//cp.setWidth(1250);
//cp.setHeight("100%");
cp.setFrame(true);
personnelGrilleMagazin = new ListStore<StructureAPersonne>();
personnelGrilleMagazin.setMonitorChanges(true);
personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() {
public void handleEvent(StoreEvent<StructureAPersonne> ce) {
// Activation du bouton supprimer si la grille contient un élément
if (grillePersonnel.getStore().getCount() > 0) {
supprimerPersonnelBtn.enable();
}
}
});
RowNumberer r = new RowNumberer();
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
 
GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>();
configs.add(r);
ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150);
fonctionsMagazin = new ListStore<Valeur>();
fonctionsCombo = new ComboBox<Valeur>();
fonctionsCombo.setTriggerAction(TriggerAction.ALL);
fonctionsCombo.setEditable(true);
fonctionsCombo.setDisplayField("nom");
fonctionsCombo.setStore(fonctionsMagazin);
mediateur.obtenirListeValeurEtRafraichir(this, "fonction", sequenceur);
fonctionEditor = new CellEditor(fonctionsCombo) {
@Override
public Object preProcessValue(Object valeur) {
Valeur retour = null;
if (valeur != null) {
String chaineTransmise = (String) valeur;
if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
fonctionsMagazin.add(fonctionsListe);
}
if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) {
retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise);
} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) {
retour = fonctionsMagazin.findModel("nom", chaineTransmise);
} else {
retour = new Valeur("", chaineTransmise, "", "");
}
}
return retour;
}
@Override
public Object postProcessValue(Object valeur) {
String retour = "";
Valeur fonctionTrouvee = null;
if (valeur == null) {
String valeurBrute = this.getField().getRawValue();
if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
fonctionsMagazin.add(fonctionsListe);
}
if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) {
fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute);
} else {
retour = valeurBrute;
}
} else if (valeur instanceof Valeur) {
fonctionTrouvee = (Valeur) valeur;
}
if (fonctionTrouvee != null) {
retour = fonctionTrouvee.getNom();
}
return retour;
}
};
column.setEditor(fonctionEditor);
configs.add(column);
column = new ColumnConfig("prenom", "Prénom", 100);
configs.add(column);
column = new ColumnConfig("nom", "Nom", 100);
configs.add(column);
 
column = new ColumnConfig("tel_fix", "Téléphone", 100);
configs.add(column);
 
column = new ColumnConfig("tel_fax", "Fax", 100);
configs.add(column);
column = new ColumnConfig("courriel", "Courriel principal", 200);
configs.add(column);
magazinLiStatut = new ListStore<Valeur>();
magazinLiStatut.add(new ArrayList<Valeur>());
comboLiStatut = new ComboBox<Valeur>();
comboLiStatut.setTriggerAction(TriggerAction.ALL);
comboLiStatut.setEditable(false);
comboLiStatut.disableTextSelection(true);
comboLiStatut.setDisplayField("nom");
comboLiStatut.setStore(magazinLiStatut);
mediateur.obtenirListeValeurEtRafraichir(this, "statut", sequenceur);
CellEditor statutEditor = new CellEditor(comboLiStatut) {
@Override
public Object preProcessValue(Object value) {
if (value == null) {
return value;
}
return comboLiStatut.getStore().findModel("nom", (String) value);
}
@Override
public Object postProcessValue(Object value) {
if (value == null) {
return value;
}
return ((Valeur) value).get("nom");
}
};
column = new ColumnConfig("statut", "Statut", 100);
column.setEditor(statutEditor);
configs.add(column);
column = new ColumnConfig("travail", "Travail hebdo (%)", 100);
column.setNumberFormat(NumberFormat.getFormat("##"));
NumberField tpsWChp = new NumberField();
tpsWChp.setFormat(NumberFormat.getFormat("##"));
tpsWChp.setToolTip("Ce champ doit contenir un nombre");
column.setEditor(new CellEditor(tpsWChp));
configs.add(column);
column = new ColumnConfig("specialite", "Spécialité botanique principale", 150);
configs.add(column);
CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
configs.add(checkColumn);
ToolBar toolBar = new ToolBar();
personneExistanteMagazin = new ListStore<Personne>();
personneExistanteMagazin.add(new ArrayList<Personne>());
ModelType modelTypePersonnes = new ModelType();
modelTypePersonnes.setRoot("personnes");
modelTypePersonnes.setTotalName("nbElements");
modelTypePersonnes.addField("cp_fmt_nom_complet");
modelTypePersonnes.addField("cp_nom");
modelTypePersonnes.addField("cp_prenom");
modelTypePersonnes.addField("cp_truk_courriel");
modelTypePersonnes.addField("cp_truk_telephone");
modelTypePersonnes.addField("cp_ce_truk_specialite");
modelTypePersonnes.addField("cp_id_personne");
String displayNamePersonnes = "cp_fmt_nom_complet";
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
personneExistanteCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
personneExistanteCombo.getCombo().setEmptyText("Rechercher et sélectionner une personne existante dans la base");
// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar
//> CHECK
toolBar.add(personneExistanteCombo);
personneExistanteCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if (personneExistanteCombo.getValeur() instanceof ModelData) {
Personne personneExistante = new Personne(personneExistanteCombo.getValeur());
StructureAPersonne membreDuPersonnel = new StructureAPersonne(personneExistante, "", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
ajouterMembreAGrillePersonnel(membreDuPersonnel);
personneExistanteCombo.getCombo().setValue(null);
}
}
});
 
toolBar.add(new Text(" ou "));
Button ajouterPersonnelBtn = creerBoutonAjouter();
toolBar.add(ajouterPersonnelBtn);
toolBar.add(new SeparatorToolItem());
Button modifierPersonnelBtn = creerBoutonModifier();
toolBar.add(modifierPersonnelBtn);
toolBar.add(new SeparatorToolItem());
supprimerPersonnelBtn = new Button("Supprimer");
supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer());
supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
if (personne != null) {
// Ajout de la personne supprimée à la liste
if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
personnelSupprime.put(personne.getId(), personne);
}
// Suppression de l'enregistrement de la grille
grillePersonnel.getStore().remove(personne);
// Désactivation du bouton supprimer si la grille contient plus d'élément
if (grillePersonnel.getStore().getCount() == 0) {
//TODO : check : Item -> component
ce.getComponent().disable();
}
}
}
});
toolBar.add(supprimerPersonnelBtn);
toolBar.add(new SeparatorToolItem());
Button rafraichirPersonnelBtn = new Button("Rafraichir");
rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
rafraichirPersonnel();
}
});
toolBar.add(rafraichirPersonnelBtn);
toolBar.add(new SeparatorToolItem());
cp.setTopComponent(toolBar);
 
ColumnModel cm = new ColumnModel(configs);
grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);
//grillePersonnel.setHeight("100%");
grillePersonnel.setAutoHeight(true);
grillePersonnel.setBorders(true);
grillePersonnel.setSelectionModel(sm);
grillePersonnel.addPlugin(checkColumn);
grillePersonnel.addPlugin(r);
grillePersonnel.getView().setForceFit(true);
grillePersonnel.setAutoExpandColumn("specialite");
grillePersonnel.setStripeRows(true);
grillePersonnel.setTrackMouseOver(true);
personnelGrilleMagazin.addListener(Store.Update, new Listener<StoreEvent<StructureAPersonne>>() {
public void handleEvent(StoreEvent<StructureAPersonne> ce) {
StructureAPersonne structureAPersonne = ce.getModel();
String etat = structureAPersonne.get("etat");
if ((etat==null || !etat.equals(aDonnee.ETAT_AJOUTE)) && structureAPersonne!=null && !UtilString.isEmpty(structureAPersonne.getId())) {
ce.getModel().set("etat", aDonnee.ETAT_MODIFIE);
}
}
});
cp.add(grillePersonnel);
this.add(cp);
this.setAutoHeight(true);
}
private Button creerBoutonAjouter() {
Button bouton = new Button(i18nC.ajouter());
bouton.setIcon(Images.ICONES.vcardAjouter());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
fenetreFormulaire.show();
}
});
return bouton;
}
private Button creerBoutonModifier() {
Button bouton = new Button(i18nC.modifier());
bouton.setIcon(Images.ICONES.vcardModifier());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String IdpersonneSaisieSelectionnee = (grillePersonnel.getSelectionModel().getSelectedItem()).getIdPersonne();
if (IdpersonneSaisieSelectionnee == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne());
} else {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
fenetreFormulaire.show();
}
}
});
return bouton;
}
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
String personneId = null;
if (mode.equals(Formulaire.MODE_MODIFIER)) {
personneId = (grillePersonnel.getSelectionModel().getSelectedItem()).getIdPersonne();
}
final FenetreForm fenetre = new FenetreForm("");
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
fenetre.add(formulaire);
return fenetre;
}
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
panneauFormulaire.setHeaderVisible(false);
panneauFormulaire.setTopComponent(null);
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
panneauFormulaire.getBottomComponent().hide();
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
fenetre.setBottomComponent(barreValidation);
return formulairePersonne;
}
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (formulaire.soumettreFormulaire()) {
fenetre.hide();
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
formulaire.soumettreFormulaire();
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fenetre.hide();
}
}
};
return ecouteur;
}
public Collection<? extends String> verifier() {
ArrayList<String> messages = new ArrayList<String>();
// Vérification du Personnel
if (getData("acces").equals(true)) {
String personnelNumero = "";
int nbrePersonne = personnelGrilleMagazin.getCount();
for (int i = 0; i < nbrePersonne; i++) {
StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
if (personne.getNom().equals("") || personne.getPrenom().equals("")) {
personnelNumero += (i != 0 ? ", " : "")+(i+1);
}
}
if (!personnelNumero.equals("")) {
messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero);
}
}
return messages;
}
 
@Override
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
rafraichirValeurListe(listeValeurs);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
rafraichirInformation(info);
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
public void rafraichirInformation(Information info) {
if (info.getType().equals("ajout_structure")) {
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
String structureId = (String) info.getDonnee(0);
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel
mediateur.ajouterStructureAPersonne(this, structureId, getPersonnelAjoute());
}
} else if (info.getType().equals("modif_structure_a_personne")) {
InfoLogger.display("Modification du Personnel", info.toString());
testerLancementRafraichirPersonnel();
} else if (info.getType().equals("suppression_structure_a_personne")) {
InfoLogger.display("Suppression du Personnel", info.toString());
testerLancementRafraichirPersonnel();
} else if (info.getType().equals("ajout_structure_a_personne")) {
InfoLogger.display("Ajout du Personnel", info.toString());
testerLancementRafraichirPersonnel();
} else if (info.getType().equals("liste_structure_a_personne")) {
if (info.getDonnee(0) != null) {
StructureAPersonneListe personnel = (StructureAPersonneListe) info.getDonnee(0);
peupler(personnel);
layout();
InfoLogger.display("Chargement du Personnel", "ok");
}
} else if (info.getType().equals("personne_modifiee")) {
if (info.getDonnee(0) != null) {
Personne personne = (Personne) info.getDonnee(0);
StructureAPersonne personneDansGrille = grillePersonnel.getStore().findModel("id_personne", personne.getId());
StructureAPersonne personneDansGrilleModif = new StructureAPersonne(personne, personneDansGrille.getFonction(), personneDansGrille.getIdRole(), personneDansGrille.getIdEtat());
int index = grillePersonnel.getStore().indexOf(personneDansGrille);
grillePersonnel.getStore().remove(personneDansGrille);
grillePersonnel.getStore().insert(personneDansGrilleModif, index);
personnelModifie.put(personne.getId()+"", personneDansGrilleModif);
}
} else if (info.getType().equals("personne_ajoutee")) {
if (info.getDonnee(0) != null) {
Personne personne = (Personne) info.getDonnee(0);
StructureAPersonne structAPersonne = new StructureAPersonne(personne,"",StructureAPersonne.ROLE_EQUIPE, "");
Structure structure = ((StructureForm) formulaire).identification;
structAPersonne.setIdStructure(structure.getId());
personnelAjoute.put(personne.getId(), structAPersonne);
ajouterMembreAGrillePersonnel(structAPersonne);
}
}
}
public void rafraichirValeurListe(ValeurListe listeValeurs) {
List<Valeur> liste = listeValeurs.toList();
if (listeValeurs.getId().equals(config.getListeId("statut"))) {
magazinLiStatut.removeAll();
magazinLiStatut.add(liste);
comboLiStatut.setStore(magazinLiStatut);
}
if (listeValeurs.getId().equals(config.getListeId("fonction"))) {
// FIXME : le store ne contient pas tout le temps les données, chose étrange.
// On stocke donc les données dans une variables de la classe pour recharger le store si besoin.
fonctionsListe = liste;
fonctionsMagazin.removeAll();
fonctionsMagazin.add(liste);
fonctionsCombo.setStore(fonctionsMagazin);
}
}
 
public EtatPersonnelStructure collecter() {
StructureForm formulaire = (StructureForm)formulaireCourant;
if (getData("acces").equals(true)) {
personnelGrilleMagazin.commitChanges();
int nbrePersonne = personnelGrilleMagazin.getCount();
for (int i = 0; i < nbrePersonne; i++) {
StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
// Seules les lignes ajoutées ou modifiées sont prises en compte.
Record record = personnelGrilleMagazin.getRecord(personne);
if (personnelGrilleMagazin.getModifiedRecords().contains(record) == true
|| (personne.get("etat") != null && (personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE) || personne.get("etat").equals(StructureAPersonne.ETAT_MODIFIE)) )) {
// Gestion de l'id de la structure
if (mode.equals("MODIF")) {
personne.setIdStructure(getIdIdentification());
}
// Gestion de la fonction
String fonction = personne.get("fonction");
if (fonction != null && !fonction.equals("")) {
Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction);
if (valeurRecherche != null) {
personne.setFonction(valeurRecherche.getId());
} else {
personne.setFonction("AUTRE", fonction);
}
} else {
personne.setFonction("");
}
 
// Gestion du nom complet
String nomComplet = personne.getPrenom()+" "+personne.getNom();
personne.setNomComplet(nomComplet);
// Gestion de la notion de "contact"
personne.setContact(false);
if (personne.get("contact").equals(true)) {
personne.setContact(true);
}
// Gestion du statut
String statut = personne.get("statut");
if (statut != null && !statut.equals("")) {
Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut);
if (valeurRecherche != null) {
personne.setStatut(valeurRecherche.getId());
} else {
personne.setStatut("AUTRE", statut);
}
} else {
personne.setStatut("");
}
// Gestion du temps de travail
String personneTravail = "";
if(personne.get("travail") != null) {
personneTravail = personne.get("travail").toString();
}
personne.setBotaTravailHebdoTps(personneTravail);
// Gestion du téléphone
String telephoneFixe = personne.get("tel_fix");
personne.setTelephoneFixe(telephoneFixe);
// Gestion du fax
String fax = personne.get("tel_fax");
personne.setFax(fax);
// Gestion du courriel
String courriel = personne.get("courriel");
personne.setCourriel(courriel);
// Gestion de la spécialité
String specialite = personne.get("specialite");
personne.setSpecialite(specialite);
// On met à faux le décès
personne.setDeces(Personne.ETRE_VIVANT);
// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)
if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) { // Une personne ajoutée
personnelAjoute.put(""+i, personne);
} else {// Une personne modifiée
personnelModifie.put(personne.getId(), personne);
}
} else {
GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null);
}
}
}
EtatPersonnelStructure etatPersonnel = new EtatPersonnelStructure();
etatPersonnel.personnelAjoute = personnelAjoute;
etatPersonnel.personnelModifie = personnelModifie;
etatPersonnel.personnelSupprime = personnelSupprime;
// Remise à zéro des modification dans la liste du personnel
personnelModifie = new StructureAPersonneListe();
personnelAjoute = new StructureAPersonneListe();
personnelSupprime = new StructureAPersonneListe();
return etatPersonnel;
}
 
public void peupler(StructureAPersonneListe personnel) {
//this.personnel = personnel;
if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && personnel != null) {
ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
String index = it.next();
// Gestion de la fonction
if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {
if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) {
personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
}
} else {
personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
}
// Gestion de la notion de "contact"
personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
// Gestion du statut
if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
} else {
personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", ""));
}
// Gestion de la specialite
if (((String) personnel.get(index).getSpecialite()).matches("^[0-9]+$")) {
// Author : Cyprien
// TODO
// Ici faire un combobox ?
// ...
} else {
personnel.get(index).set("specialite", personnel.get(index).getSpecialite().replaceFirst("AUTRE##", ""));
}
// Gestion du temps de travail
String tps = personnel.get(index).getBotaTravailHebdoTps();
personnel.get(index).set("travail", (tps.matches("^[0-9]+$") ? Integer.parseInt(tps) : 0));
personnes.add(personnel.get(index));
}
personnelGrilleMagazin.removeAll();
personnelGrilleMagazin.add(personnes);
// Remise à zéro des modification dans la liste du personnel
personnelModifie = new StructureAPersonneListe();
personnelAjoute = new StructureAPersonneListe();
personnelSupprime = new StructureAPersonneListe();
// Nous vidons la variable personnel une fois qu'elle a remplie la grille
personnel = null;
}
}
public StructureAPersonneListe getPersonnelAjoute() {
return personnelAjoute;
}
private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) {
grillePersonnel.stopEditing();
personnelGrilleMagazin.insert(personnel, 0);
grillePersonnel.startEditing(0, 0);
}
public void testerLancementRafraichirPersonnel() {
decompteRafraichissementPersonnel--;
if (decompteRafraichissementPersonnel <= 0) {
// Nous rechargeons la liste du Personnel
rafraichirPersonnel();
}
}
private void rafraichirPersonnel() {
decompteRafraichissementPersonnel = 0;
if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER)) {
initialiserGrillePersonnelEnModification();
} else if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
initialiserGrillePersonnelEnAjout();
}
}
private void rafraichirPersonneExistante(String nom) {
mediateur.selectionnerPersonneParNomComplet(this, nom+"%", null);
}
public void incrementerDecompteRafraichissementPersonnel() {
decompteRafraichissementPersonnel++;
}
private void initialiserGrillePersonnelEnAjout() {
personnelGrilleMagazin.removeAll();
layout();
}
private String getIdIdentification() {
return ((StructureForm)formulaireCourant).getIdIdentification();
}
private void initialiserGrillePersonnelEnModification() {
mediateur.selectionnerStructureAPersonne(this, getIdIdentification(), StructureAPersonne.ROLE_EQUIPE, null);
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/structure
New file
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure:r1136-1291
Merged /trunk/src/org/tela_botanica/client/vues/structure:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/structure:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/DetailVue.java
New file
0,0 → 1,292
package org.tela_botanica.client.vues;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Analytics;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
 
public abstract class DetailVue extends LayoutContainer implements Rafraichissable {
 
protected Mediateur mediateur = null;
protected Constantes i18nC = null;
 
protected HashMap<String, Valeur> ontologie = null;
protected boolean ontologieChargementOk = false;
private HashMap<Integer, String> ontologiesEnAttenteDeReception = null;
protected String sautLigneTpl = null;
public DetailVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
initialiserSautLigneTpl();
ontologie = new HashMap<String, Valeur>();
ontologieChargementOk = false;
ontologiesEnAttenteDeReception = new HashMap<Integer, String>();
setLayout(new FitLayout());
setBorders(false);
setScrollMode(Scroll.AUTO);
}
private void initialiserSautLigneTpl() {
sautLigneTpl = "<br />\n";
}
protected String construireTxtTruck(String chaineAAnalyser) {
return construireTxtTruck(chaineAAnalyser, true);
}
protected String construireTxtTruck(String chaineAAnalyser, boolean ucFirst) {
ArrayList<String> termes = new ArrayList<String>();
if ((chaineAAnalyser != null) && (!chaineAAnalyser.trim().equals(""))) {
String[] valeurs = chaineAAnalyser.split(aDonnee.SEPARATEUR_VALEURS);
int nbreValeurs = valeurs.length;
if (nbreValeurs > 0) {
for (int i = 0; i < nbreValeurs; i++) {
String valeur = valeurs[i];
String valeurFormatee = formaterValeurTruck(valeur);
termes.add(valeurFormatee);
}
}
}
String chaineARetourner = formaterTableauDeTxt(termes, ucFirst);
return chaineARetourner;
}
private String formaterValeurTruck(String valeur) {
String chaineARetourner = "";
if (valeur.matches("^[^#]+##[^$]+$")) {
String[] cleValeur = valeur.split(aDonnee.SEPARATEUR_TYPE_VALEUR);
chaineARetourner = (UtilString.isEmpty(cleValeur[1]) || cleValeur[1].equals("null") ? aDonnee.VALEUR_NULL : cleValeur[1]) +" "+formaterParenthese(cleValeur[0]);
} else if (!valeur.equals("")) {
chaineARetourner = valeur;
} else {
GWT.log("Valeur truck posant problème :"+valeur, null);
}
return chaineARetourner;
}
protected String formaterParenthese(String chaineAAfficher) {
if (!chaineAAfficher.equals("")) {
chaineAAfficher = "("+chaineAAfficher+")";
}
return chaineAAfficher;
}
protected String formaterTableauDeTxt(ArrayList<String> tableauDeTxt, boolean ucFirst) {
String chaineAAfficher = "";
int tailleDuTableau = tableauDeTxt.size();
if (tailleDuTableau > 0) {
int indexAvtDernier = tailleDuTableau - 1;
for (int i = 0; i < tailleDuTableau; i++) {
String mot = tableauDeTxt.get(i);
if (i != indexAvtDernier) {
chaineAAfficher += mot+", ";
} else {
chaineAAfficher += nettoyerPointFinal(mot)+".";
}
}
}
if (ucFirst) return UtilString.ucFirst(chaineAAfficher);
else return chaineAAfficher;
}
protected String nettoyerPointFinal(String mot) {
mot = mot.replaceAll("[.]$", "");
return mot;
}
protected String formaterContenu(String template, Params parametres) {
String cHtml = Format.substitute(template, parametres);
Params cssParams = new Params();
cssParams.set("css_lien_ext", ComposantClass.LIEN_EXTERNE);
cssParams.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU);
cssParams.set("css_label", ComposantClass.LABEL);
cssParams.set("css_indentation", ComposantClass.INDENTATION);
cssParams.set("css_fieldset", ComposantClass.FIELDSET);
cssParams.set("css_clear", ComposantClass.CLEAR);
cHtml = Format.substitute(cHtml, cssParams);
return cHtml;
}
protected void afficherOnglet(String template, Params parametres, TabItem onglet) {
String cHtml = formaterContenu(template, parametres);
HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml);
onglet.removeAll();
onglet.add(corpsConteneurDuHtml);
}
protected String formaterAutre(String chaineAAfficher) {
if (!chaineAAfficher.equals("")) {
chaineAAfficher = " ["+i18nC.autres()+" : "+chaineAAfficher+"]";
}
return chaineAAfficher;
}
protected String formaterOuiNon(String chaineAFormater) {
String txtARetourner = "";
if (chaineAFormater.equals("0")) {
txtARetourner = i18nC.non();
} else if (chaineAFormater.equals("1")) {
txtARetourner = i18nC.oui();
}
return txtARetourner;
}
 
protected String formaterOuiNon(Integer intAFormater) {
if(intAFormater == null) return "";
if(intAFormater.intValue() == 0) return i18nC.non();
if(intAFormater.intValue() == 1) return i18nC.oui();
return "";
}
protected String formaterSautDeLigne(String chaineAFormater) {
String txtARetourner = chaineAFormater.replaceAll("\n", sautLigneTpl);
return txtARetourner;
}
protected void lancerChargementListesValeurs(String[] listesCodes) {
lancerChargementListesValeurs(listesCodes, null);
}
protected void lancerChargementListesValeurs(String[] listesCodes, Sequenceur sequenceur) {
Configuration configuration = (Configuration) Registry.get(RegistreId.CONFIG);
for (int i = 0; i < listesCodes.length ; i++) {
String code = listesCodes[i];
ontologiesEnAttenteDeReception.put(configuration.getListeId(code), code);
mediateur.obtenirListeValeurEtRafraichir(this, code, sequenceur);
}
}
protected void receptionerListeValeurs(ValeurListe listeValeursReceptionnee) {
mettreAJourOntologieEnAttenteDeReception(listeValeursReceptionnee);
ajouterListeValeursAOntologie(listeValeursReceptionnee);
}
protected void mettreAJourOntologieEnAttenteDeReception(ValeurListe listeValeursReceptionnee) {
ontologiesEnAttenteDeReception.remove(listeValeursReceptionnee.getId());
}
protected void ajouterListeValeursAOntologie(ValeurListe listeValeursReceptionnee) {
Iterator<String> it = listeValeursReceptionnee.keySet().iterator();
while (it.hasNext()) {
String cle = it.next();
Valeur valeur = listeValeursReceptionnee.get(cle);
if (valeur != null) {
ontologie.put(cle, valeur);
}
}
}
public String construireTxtListeOntologie(String chaineAAnalyser) {
return construireTxtListeOntologie(chaineAAnalyser, true, true, false);
}
public String construireTxtListeOntologie(String chaineAAnalyser, boolean valeurEstOntologie, boolean typeEstOntologie, boolean donneeEstOntologie) {
ArrayList<String> termes = new ArrayList<String>();
ArrayList<String> autres = new ArrayList<String>();
chaineAAnalyser = chaineAAnalyser.trim();
if (!UtilString.isEmpty(chaineAAnalyser)) {
String[] valeurs = chaineAAnalyser.split(aDonnee.SEPARATEUR_VALEURS);
int nbreValeurs = valeurs.length;
if (nbreValeurs > 0) {
for (int i = 0; i < nbreValeurs; i++) {
String valeur = valeurs[i];
// VALEUR SANS TYPE
// La valeur sans type est une entrée de l'ontologie
if (valeurEstOntologie && valeur.matches("^[0-9]+$")) {
if (valeur.equals("0")) {
valeur = "";
} else if (ontologie != null) {
Valeur valeurOntologie = ontologie.get(valeur);
if (valeurOntologie != null) {
valeur = valeurOntologie.getNom();
}
}
}
// VALEUR AVEC TYPE
// Type : AUTRE
String valeurTypeAutre = aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR;
if (valeur.matches("^"+valeurTypeAutre+".*$")) {
String txtAutre = valeur.replaceFirst("^"+valeurTypeAutre, "");
if (!txtAutre.equals("")) {
autres.add(txtAutre);
}
valeur = "";
}
// Type correspondant à une entrée de l'ontologie
if (typeEstOntologie) {
String valeurTypeOntologie = "[0-9]+"+aDonnee.SEPARATEUR_TYPE_VALEUR;
if (valeur.matches("^"+valeurTypeOntologie+".+$")) {
String type = valeur.substring(0, valeur.indexOf(aDonnee.SEPARATEUR_TYPE_VALEUR));
if (ontologie != null && ontologie.get(type) != null) {
Valeur valeurOntologie = ontologie.get(type);
valeur = valeur.replaceFirst("^"+type, valeurOntologie.getNom()+": ");
}
}
}
// Donnée correspondant à une entrée de l'ontologie
if (donneeEstOntologie) {
String donneeOntologie = aDonnee.SEPARATEUR_TYPE_VALEUR+"[0-9]+";
if (valeur.matches("^.+"+donneeOntologie+"$")) {
String donnee = valeur.substring(valeur.indexOf(aDonnee.SEPARATEUR_TYPE_VALEUR), valeur.length());
donnee = donnee.replaceFirst("^"+aDonnee.SEPARATEUR_TYPE_VALEUR, "");
if (ontologie != null && ontologie.get(donnee) != null) {
Valeur valeurOntologie = ontologie.get(donnee);
valeur = valeur.replaceFirst(donnee+"$", valeurOntologie.getNom());
}
}
}
// Nettoyage final
valeur = valeur.replaceFirst(aDonnee.SEPARATEUR_TYPE_VALEUR, "");
if (!UtilString.isEmpty(valeur)) {
termes.add(valeur);
}
}
}
}
String chaineTermes = formaterTableauDeTxt(termes, true);
String chaineAutres = formaterTableauDeTxt(autres, true);
String chaineARetourner = chaineTermes+formaterAutre(chaineAutres);
return chaineARetourner;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/DetailVue.java:r1136-1368
Merged /branches/v1.6-muscardin/src/org/tela_botanica/client/vues/DetailVue.java:r1816-1817
Merged /trunk/src/org/tela_botanica/client/vues/DetailVue.java:r11-452,929-935,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/DetailVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/FenetreJournal.java
New file
0,0 → 1,103
package org.tela_botanica.client.vues;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Valeur;
 
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.core.XTemplate;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.InfoConfig;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
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.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.Dictionary;
 
public class FenetreJournal extends Dialog implements Rafraichissable{
 
private int id = 0;
private EditorGrid<Valeur> grille;
//private int nbLogs = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbLogs"));
private ListStore<Valeur> store;
public FenetreJournal(Mediateur mediateur) {
this.setHeadingHtml(mediateur.i18nC.titreJournal());
this.setWidth(500);
this.setHeight(500);
setLayout(new FitLayout());
// Définition des colomnes de la grille:
RowNumberer numeroPlugin = new RowNumberer();
numeroPlugin.setHeaderHtml("#");
XTemplate infoTpl = XTemplate.create("<p>"+
"<b>" + mediateur.i18nC.heureMessage() + " : </b>{heure}<br />" +
"<b>" + mediateur.i18nC.message() + " : </b>{description}<br />" +
"</p>");
RowExpander expansionPlugin = new RowExpander();
expansionPlugin.setTemplate(infoTpl);
List<ColumnConfig> lstColumns = new ArrayList<ColumnConfig>();
lstColumns.add(expansionPlugin);
lstColumns.add(new ColumnConfig("nom", mediateur.i18nC.publicationTitre(), 200));
lstColumns.add(new ColumnConfig("description", mediateur.i18nC.message() , 400));
 
ColumnModel modeleColonnes = new ColumnModel(lstColumns);
store = new ListStore<Valeur>();
grille = new EditorGrid<Valeur>(store, modeleColonnes);
grille.addPlugin(expansionPlugin);
grille.setAutoExpandColumn("description");
grille.getView().setAutoFill(true);
grille.getView().setForceFit(true);
store.sort("id", SortDir.DESC);
add(grille);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof InfoConfig) {
InfoConfig info = (InfoConfig) nouvellesDonnees;
id++;
Valeur v = new Valeur(String.valueOf(id), info.titleHtml, null, info.html);
v.set("heure", getDate());
store.add(v);
//if (store.getModels().size() > nbLogs) {
//store.remove(store.getAt(nbLogs));
//}
}
}
public String getDate() {
Date date = new Date();
return String.valueOf(DateTimeFormat.getFormat("HH:mm:ss").format(date));
}
protected void createButtons() {
//Pas de boutons, merci
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/FenetreJournal.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/FenetreJournal.java:r11-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/FenetreJournal.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/commentaire/CommentaireVue.java
New file
0,0 → 1,52
package org.tela_botanica.client.vues.commentaire;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
 
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
 
public class CommentaireVue extends LayoutContainer implements Rafraichissable {
private Mediateur mediateur = null;
private CommentaireListeVue panneauListe;
private CommentaireDetailVue panneauDetail;
public CommentaireVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
BorderLayout layout = new BorderLayout();
layout.setEnableState(false);
setLayout(layout);
 
panneauListe = new CommentaireListeVue(mediateur);
add(panneauListe, new BorderLayoutData(LayoutRegion.CENTER));
 
panneauDetail = new CommentaireDetailVue(mediateur);
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000);
southData.setSplit(true);
southData.setMargins(new Margins(5, 0, 0, 0));
add(panneauDetail, southData);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Commentaire) {
panneauDetail.rafraichir(nouvellesDonnees);
} else if (nouvellesDonnees instanceof CommentaireListe) {
panneauListe.rafraichir(nouvellesDonnees);
mediateur.desactiverChargement(this);
} else if (nouvellesDonnees instanceof Information) {
panneauListe.rafraichir(nouvellesDonnees);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/commentaire/CommentaireVue.java:r11-984,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/commentaire/CommentaireVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/commentaire/CommentaireListeVue.java
New file
0,0 → 1,366
package org.tela_botanica.client.vues.commentaire;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampFiltreRecherche;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
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;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.GroupingStore;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.util.Util;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.button.Button;
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.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
import com.extjs.gxt.ui.client.widget.grid.GroupingView;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.menu.Menu;
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 CommentaireListeVue extends ContentPanel implements Rafraichissable {
 
private Mediateur mediateur = null;
private Constantes i18nC = null;
 
private Grid<Commentaire> grille = null;
private GroupingStore<Commentaire> store = null;
private ColumnModel modeleDesColonnes = null;
private Button ajouter;
private Button modifier;
private Button supprimer;
private BarrePaginationVue pagination = null;
private ChampFiltreRecherche champFiltreRecherche = null;
private CommentaireListe commentaires = null;
protected boolean commentairesChargementOk = false;
protected HashMap<String, Valeur> ontologie = null;
protected boolean ontologieChargementOk = false;
private int indexElementSelectionne = 0;
private Commentaire commentaireSelectionne = null;
public CommentaireListeVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
setLayout(new FitLayout());
setHeaderVisible(false);
// Gestion de l'ontologie
ontologie = new HashMap<String, Valeur>();
mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection", null);
// Gestion de la barre d'outil
ToolBar toolBar = new ToolBar();
ajouter = new Button(i18nC.ajouter());
ajouter.setIcon(Images.ICONES.ajouter());
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
mediateur.clicAjouterCommentaire();
}
});
ajouter.setToolTip(i18nC.indicationCreerUneFiche()+" "+i18nC.commentaireSingulier());
toolBar.add(ajouter);
 
modifier = new Button(i18nC.modifier());
modifier.setIcon(Images.ICONES.formModifier());
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
mediateur.clicModifierCommentaire(grille.getSelectionModel().getSelectedItems());
}
});
modifier.setToolTip(i18nC.indicationModifierUneFiche());
toolBar.add(modifier);
supprimer = new Button(i18nC.supprimer());
supprimer.setIcon(Images.ICONES.supprimer());
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
mediateur.clicSupprimerCommentaire(grille.getSelectionModel().getSelectedItems());
}
});
supprimer.setToolTip(i18nC.indicationSupprimerUneFiche());
toolBar.add(supprimer);
setTopComponent(toolBar);
 
// Gestion de la grille
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
colonnes.add(new ColumnConfig("_collection_nom_", i18nC.commentaireCollection(), 150));
colonnes.add(creerColonneType());
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150));
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 30));
colonnes.add(creerColonneAcces());
modeleDesColonnes = new ColumnModel(colonnes);
 
GridSelectionModel<Commentaire> modeleDeSelection = new GridSelectionModel<Commentaire>();
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Commentaire>() {
public void selectionChanged(SelectionChangedEvent<Commentaire> event) {
commentaireSelectionne = (Commentaire) event.getSelectedItem();
indexElementSelectionne = store.indexOf(commentaireSelectionne);
clicListe(commentaireSelectionne);
}
});
store = new GroupingStore<Commentaire>();
store.groupBy("_collection_nom_");
store.setRemoteGroup(false);
GroupingView vueDeGroupe = new GroupingView();
vueDeGroupe.setShowGroupedColumn(false);
vueDeGroupe.setForceFit(true);
vueDeGroupe.setAutoFill(true);
vueDeGroupe.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
String f = modeleDesColonnes.getColumnById(data.field).getHeaderHtml();
String l = data.models.size() == 1 ? i18nC.commentaireSingulier() : i18nC.commentairePluriel();
if (Util.isEmptyString(data.group)) return f + ": aucune (" + data.models.size() + " " + l + ")";
else return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
}
});
grille = new Grid<Commentaire>(store, modeleDesColonnes);
grille.setView(vueDeGroupe);
grille.setWidth("100%");
grille.setAutoExpandColumn("_titre_");
grille.setSelectionModel(modeleDeSelection);
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
grille.getSelectionModel().select(0, false);
}
});
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be) {
modifier.fireEvent(Events.Select);
}
});
// @TODO marche pas à cause des méta machin de merde
/*grille.addListener(Events.SortChange, new Listener<BaseEvent>() {
 
@Override
public void handleEvent(BaseEvent be) {
GridEvent ge = (GridEvent<Commentaire>) be;
// TODO rajouter un test sur le sort state pour trier par nom par défaut
String tri = ge.getSortInfo().getSortField();
if(tri.equals("fmt_nom_complet")) {
tri = "nom";
}
CommentaireAsyncDao.tri = Commentaire.PREFIXE+"_"+tri+" "+ge.getSortInfo().getSortDir().toString();
pagination.changePage();
}
});*/
add(grille);
CommentaireListe commentaireListe = new CommentaireListe();
champFiltreRecherche = new ChampFiltreRecherche(mediateur, toolBar, commentaireListe);
// Définition de la barre de pagination
pagination = new BarrePaginationVue(commentaireListe, mediateur, champFiltreRecherche);
setBottomComponent(pagination);
}
private ColumnConfig creerColonneType() {
GridCellRenderer<Commentaire> typeRendu = new GridCellRenderer<Commentaire>() {
public String render(Commentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Commentaire> store, Grid<Commentaire> grid) {
// FIXME : créer une classe Ontologie qui mixe le code ci-dessous et tout ce qui concerne l'ontologie dans DetailVue
String type = "";
String[] valeurs = model.getCollectionACommentaire().getType().split(aDonnee.SEPARATEUR_VALEURS);
int nbreValeurs = valeurs.length;
int indexAvtDernier = nbreValeurs - 1;
if (nbreValeurs > 0) {
for (int i = 0; i < nbreValeurs; i++) {
String valeur = valeurs[i];
if (valeur.matches("^[0-9]+$")) {
if (valeur.equals("0")) {
valeur = "";
} else if (ontologie != null) {
Valeur valeurOntologie = ontologie.get(valeur);
if (valeurOntologie != null) {
valeur = valeurOntologie.getNom();
}
}
}
if (i != indexAvtDernier) {
type += valeur+", ";
} else {
type += valeur;
}
}
}
model.set("_type_", type);
return type;
}
};
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100);
typeColonne.setRenderer(typeRendu);
return typeColonne;
}
private ColumnConfig creerColonneAcces() {
GridCellRenderer<Commentaire> accesRendu = new GridCellRenderer<Commentaire>() {
public String render(Commentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Commentaire> store, Grid<Commentaire> grid) {
String acces = (model.etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee());
model.set("_public_", acces);
return acces;
}
};
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30);
accesColonne.setRenderer(accesRendu);
return accesColonne;
}
private void clicListe(Commentaire commentaire) {
if (commentaire != null && store.getCount() > 0) {
mediateur.clicListeCommentaire(commentaire);
}
}
 
private void gererEtatActivationBouton() {
int nbreElementDuMagazin = store.getCount();
ajouter.enable();
if (nbreElementDuMagazin <= 0) {
supprimer.disable();
modifier.disable();
} else if (nbreElementDuMagazin > 0) {
modifier.enable();
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
supprimer.enable();
}
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof CommentaireListe) {
commentaires = (CommentaireListe) nouvellesDonnees;
champFiltreRecherche.setListePaginable(commentaires);
pagination.setlistePaginable(commentaires);
pagination.rafraichir(commentaires.getPageTable());
commentairesChargementOk = true;
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
Iterator<String> it = listeValeursReceptionnee.keySet().iterator();
while (it.hasNext()) {
String cle = it.next();
Valeur valeur = listeValeursReceptionnee.get(cle);
if (valeur != null) {
ontologie.put(cle, valeur);
}
}
ontologieChargementOk = true;
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if (info.getType().equals("suppression_commentaire")) {
String message = info.toString();
if (info.getDonnee(0) != null) {
message = (String) info.getDonnee(0);
}
InfoLogger.display(i18nC.commentaireTitreSuppression(), message);
supprimerCommentairesSelectionnees();
gererEtatActivationBouton();
} else if (info.getType().equals("commentaire_modifiee")) {
// GXT c'est pourri et la grille ne prend en compte les modifications
// du store, donc en attendant, on recharge tout, comme pour la suppression
/*Commentaire commModifie = (Commentaire)info.getDonnee(0);
store.remove(indexElementSelectionne);
store.insert(commModifie, indexElementSelectionne);
grille.reconfigure(store, modeleDesColonnes);
grille.repaint();*/
mediateur.clicMenu(MenuApplicationId.COMMENTAIRE);
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
if (etrePretAAfficherListe()) {
chargerListe();
}
layout();
}
private boolean etrePretAAfficherListe() {
boolean ok = false;
if (commentairesChargementOk && ontologieChargementOk) {
ok = true;
}
return ok;
}
private void chargerListe() {
if (commentaires != null) {
List<Commentaire> liste = commentaires.toList();
store.removeAll();
store.add(liste);
mediateur.actualiserPanneauCentral();
}
}
private void supprimerCommentairesSelectionnees() {
// FIXME : le code ci-dessous ne marche pas avec la GroupingView, nous utilisons le rechargement du menu à la place
/*
List<Commentaire> commentairesSelectionnees = grille.getSelectionModel().getSelectedItems();
Iterator<Commentaire> it = commentairesSelectionnees.iterator();
while (it.hasNext()) {
Commentaire commentaireASupprimer = it.next();
Debug.log(commentaireASupprimer.getId());
grille.getStore().remove(commentaireASupprimer);
}
layout(true);
*/
mediateur.clicMenu(MenuApplicationId.COMMENTAIRE);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireListeVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/commentaire/CommentaireListeVue.java:r11-984,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/commentaire/CommentaireListeVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/commentaire/CommentaireDetailVue.java
New file
0,0 → 1,154
package org.tela_botanica.client.vues.commentaire;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.vues.DetailVue;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
 
public class CommentaireDetailVue extends DetailVue implements Rafraichissable {
private String enteteTpl = null;
private String contenuTpl = null;
private ContentPanel panneauPrincipal = null;
private Html entete = null;
private Html contenu = null;
private Commentaire commentaire = null;
private boolean commentaireChargementOk = false;
 
public CommentaireDetailVue(Mediateur mediateurCourant) {
super(mediateurCourant);
initialiserTousLesTpl();
chargerOntologie();
panneauPrincipal = new ContentPanel();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.setHeaderVisible(false);
panneauPrincipal.setBodyBorder(false);
panneauPrincipal.setScrollMode(Scroll.AUTO);
entete = new Html();
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
panneauPrincipal.setTopComponent(entete);
contenu = new Html();
panneauPrincipal.add(contenu);
add(panneauPrincipal);
}
 
private void initialiserTousLesTpl() {
initialiserEnteteHtmlTpl();
initialiserGeneralTpl();
}
private void initialiserEnteteHtmlTpl() {
enteteTpl =
"<div id='{css_id}'>"+
" <h1>{titre}</h1>"+
" <h2>{collection}<span class='{css_meta}'><br /> {i18n_id}:{id} - {guid}</span></h2>" +
"</div>";
}
private void initialiserGeneralTpl() {
contenuTpl =
"<div class='{css_corps}'>"+
" <span class='{css_label}'>{i18n_type} :</span> {type}<br />"+
" <span class='{css_label}'>{i18n_public} :</span> {public}<br />"+
" <span class='{css_label}'>{i18n_ponderation} :</span> {ponderation}<br />"+
" <span class='{css_label}'>{i18n_texte} :</span>"+
" {texte}"+
"</div>";
}
private void chargerOntologie() {
String[] listesCodes = {"typeCommentaireCollection"};
lancerChargementListesValeurs(listesCodes);
}
public void afficherDetail() {
if (commentaire != null) {
afficherEntete();
afficherDetailCommentaire();
}
layout();
}
private void afficherEntete() {
Params enteteParams = new Params();
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
enteteParams.set("css_meta", ComposantClass.META);
enteteParams.set("i18n_id", i18nC.id());
enteteParams.set("collection", commentaire.getCollection().getNom());
enteteParams.set("titre", commentaire.getTitre());
enteteParams.set("id", commentaire.getId());
enteteParams.set("guid", getGuid());
String eHtml = Format.substitute(enteteTpl, enteteParams);
entete.getElement().setInnerHTML(eHtml);
}
public String getGuid() {
String guid = "URN:tela-botanica.org:";
guid += "com"+commentaire.getId();
return guid;
}
public void afficherDetailCommentaire() {
Params contenuParams = new Params();
contenuParams.set("i18n_type", i18nC.commentaireType());
contenuParams.set("i18n_public", i18nC.commentairePublic());
contenuParams.set("i18n_ponderation", i18nC.commentairePonderation());
contenuParams.set("i18n_texte", i18nC.commentaireTexte());
String type = construireTxtListeOntologie(commentaire.getCollectionACommentaire().getType());
contenuParams.set("type", type);
contenuParams.set("ponderation", commentaire.getPonderation());
contenuParams.set("public", (commentaire.etrePublic() ? "public" : "privé"));
contenuParams.set("texte", commentaire.getTexte());
String gHtml = formaterContenu(contenuTpl, contenuParams);
contenu.getElement().setInnerHTML(gHtml);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Commentaire) {
commentaire = (Commentaire) nouvellesDonnees;
commentaireChargementOk = true;
} else if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
receptionerListeValeurs(listeValeursReceptionnee);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
if (avoirDonneesChargees()) {
afficherDetail();
}
}
private boolean avoirDonneesChargees() {
boolean ok = false;
if (commentaireChargementOk) {
ok = true;
}
return ok;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/commentaire/CommentaireDetailVue.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireDetailVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/commentaire/CommentaireDetailVue.java:r11-984,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/commentaire/CommentaireForm.java
New file
0,0 → 1,256
package org.tela_botanica.client.vues.commentaire;
 
import java.util.ArrayList;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.ChampSliderPourcentage;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.commentaire.Commentaire;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilArray;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.Formulaire;
 
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.user.client.Window;
 
 
public class CommentaireForm extends Formulaire implements Rafraichissable {
private Commentaire commentaire;
 
private TextField<String> titreChp;
private TextArea texteChp;
private ChampSliderPourcentage ponderationChp;
private CheckBox publicChp;
private static boolean formulaireValideOk = false;
private static boolean commentaireValideOk = false;
private Sequenceur sequenceur = new Sequenceur();
 
public CommentaireForm(Mediateur mediateurCourrant, String commentaireId) {
initialiserCommentaireForm(mediateurCourrant, commentaireId);
}
 
public CommentaireForm(Mediateur mediateurCourrant, String commentaireId, Rafraichissable vueARafraichirApresValidation) {
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
initialiserCommentaireForm(mediateurCourrant, commentaireId);
}
private void initialiserCommentaireForm(Mediateur mediateurCourrant, String commentaireId) {
initialiserValidation();
commentaire = new Commentaire();
commentaire.setId(commentaireId);
String modeDeCreation = (UtilString.isEmpty(commentaire.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COMMENTAIRE);
panneauFormulaire.setLayout(new FormLayout());
genererTitreFormulaire();
creerChamps();
 
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerCommentaire(this, commentaireId, null);
}
}
private void genererTitreFormulaire() {
String titre = i18nC.commentaireTitreFormAjout();
if (mode.equals(Formulaire.MODE_MODIFIER)) {
titre = i18nC.commentaireTitreFormModif();
if (commentaire != null) {
titre += " - "+i18nC.id()+": "+commentaire.getId();
}
}
panneauFormulaire.setHeadingHtml(titre);
}
private void creerChamps() {
titreChp = new TextField<String>();
titreChp.setFieldLabel(i18nC.commentaireTitre());
titreChp.setAllowBlank(false);
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
titreChp.addListener(Events.Invalid, creerEcouteurChampObligatoire());
panneauFormulaire.add(titreChp, new FormData(450, 0));
texteChp = new TextArea();
texteChp.setFieldLabel(i18nC.commentaireTexte());
panneauFormulaire.add(texteChp, new FormData(450, 250));
ponderationChp = new ChampSliderPourcentage(i18nC.commentairePonderation());
panneauFormulaire.add(ponderationChp, new FormData(450, 0));
publicChp = new CheckBox();
publicChp.setFieldLabel(i18nC.donneePublic());
panneauFormulaire.add(publicChp, new FormData(50, 0));
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Commentaire) {
// Si on a reçu les details d'une publication
rafraichirCommentaire((Commentaire) nouvellesDonnees);
} else if (nouvellesDonnees instanceof Information) {
rafraichirInformation((Information) nouvellesDonnees);
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
if (etreValide()) {
initialiserValidation();
repandreRafraichissement();
controlerFermeture();
}
}
private void rafraichirCommentaire(Commentaire commentaireRecu) {
commentaire = commentaireRecu;
peuplerFormulaire();
genererTitreFormulaire();
}
private void rafraichirInformation(Information info) {
// Gestion des messages d'erreur
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
Debug.log("MESSAGES:\n"+info.getMessages().toString());
}
// Gestion des actions
String type = info.getType();
if (type.equals("ajout_commentaire") || type.equals("modif_commentaire")) {
commentaireValideOk = true;
}
if (info.getType().equals("ajout_commentaire")) {
String noteId = (String) info.getDonnee(0);
commentaire.setId(noteId);
this.mode = MODE_MODIFIER;
}
// Gestion des messages
if (info.getType().equals("modif_commentaire")) {
InfoLogger.display("Modification d'une note", info.toString());
} else if (info.getType().equals("ajout_commentaire")) {
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
String noteId = (String) info.getDonnee(0);
InfoLogger.display("Ajout d'une note", "La note '"+noteId+"' a bien été ajoutée");
} else {
InfoLogger.display("Ajout d'une note", info.toString());
}
}
}
 
private Boolean etreValide() {
Boolean valide = false;
if (formulaireValideOk && commentaireValideOk) {
valide = true;
}
return valide;
}
private void initialiserValidation() {
formulaireValideOk = false;
commentaireValideOk = false;
}
private void repandreRafraichissement() {
if (vueExterneARafraichirApresValidation != null) {
String type = "commentaire_modifiee";
if (mode.equals(Formulaire.MODE_AJOUTER)) {
type = "commentaire_ajoutee";
}
Information info = new Information(type);
info.setDonnee(0, commentaire);
vueExterneARafraichirApresValidation.rafraichir(info);
}
}
public boolean soumettreFormulaire() {
formulaireValideOk = verifierFormulaire();
if (formulaireValideOk) {
soumettreCommentaire();
}
return formulaireValideOk;
}
private void soumettreCommentaire() {
Commentaire commentaireCollectee = collecterCommentaire();
if (commentaireCollectee != null) {
if (mode.equals(Formulaire.MODE_AJOUTER)) {
mediateur.ajouterCommentaire(this, commentaireCollectee);
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.modifierCommentaire(this, commentaireCollectee);
}
} else {
if(clicBoutonvalidation) {
fermerFormulaire();
}
}
}
public boolean verifierFormulaire() {
boolean valide = true;
ArrayList<String> messages = new ArrayList<String>();
String titre = titreChp.getValue();
if (titre == null || titre.equals("")) {
messages.add(i18nC.commentaireMessageTitre());
}
if (messages.size() != 0) {
String[] tableauDeMessages = {};
tableauDeMessages = messages.toArray(tableauDeMessages);
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
valide = false;
}
return valide;
}
private void peuplerFormulaire() {
titreChp.setValue(commentaire.getTitre());
texteChp.setValue(commentaire.getTexte());
ponderationChp.peupler(commentaire.getPonderation());
boolean acces = (commentaire.etrePublic() ? true : false);
publicChp.setValue(acces);
}
private Commentaire collecterCommentaire() {
Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
String titre = titreChp.getValue();
commentaireCollectee.setTitre(titre);
String texte = texteChp.getValue();
commentaireCollectee.setTexte(texte);
String ponderation = ponderationChp.getValeur();
commentaireCollectee.setPonderation(ponderation);
String acces = (publicChp.getValue() ? "1" : "0");
commentaireCollectee.setPublic(acces);
Commentaire commentaireARetourner = null;
if (!commentaireCollectee.comparer(commentaire)) {
commentaireARetourner = commentaire = commentaireCollectee;
}
return commentaireARetourner;
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/commentaire/CommentaireForm.java:r11-984,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/commentaire/CommentaireForm.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireForm.java:r1136-1368
Added: svn:executable
+*
\ No newline at end of property
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/commentaire
New file
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire:r1136-1291
Merged /trunk/src/org/tela_botanica/client/vues/commentaire:r11-984,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/commentaire:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/MenuVue.java
New file
0,0 → 1,79
package org.tela_botanica.client.vues;
 
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.modeles.Menu;
import org.tela_botanica.client.modeles.MenuApplicationId;
 
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.user.client.Window;
 
public class MenuVue extends ContentPanel {
 
private Mediateur mediateur = null;
private Constantes i18nC = null;
private TreePanel<Menu> arbreMenus;
private TreeStore<Menu> menuStore;
public MenuVue(Mediateur mediateurCourrant) {
mediateur = mediateurCourrant;
i18nC = Mediateur.i18nC;
setHeadingHtml(i18nC.titreMenu());
setLayout(new FitLayout());
setLayoutOnChange(true);
construireMenu();
afficherMenu();
}
 
private void construireMenu() {
menuStore = new TreeStore<Menu>();
Menu accueilMenu = new Menu(i18nC.menuAccueil(), MenuApplicationId.ACCUEIL);
Menu menuInstitution = new Menu(i18nC.menuStructure(), MenuApplicationId.STRUCTURE);
Menu menuCollections = new Menu(i18nC.menuCollection(), MenuApplicationId.COLLECTION);
Menu menuPersonnes = new Menu(i18nC.menuPersonne(), MenuApplicationId.PERSONNE);
Menu menuPublications = new Menu(i18nC.menuPublication(), MenuApplicationId.PUBLICATION);
Menu menuCommentaires = new Menu(i18nC.menuCommentaire(), MenuApplicationId.COMMENTAIRE);
menuStore.add(accueilMenu, false);
menuStore.add(accueilMenu, menuInstitution, true);
menuStore.add(accueilMenu, menuCollections, true);
menuStore.add(accueilMenu, menuPersonnes, true);
menuStore.add(accueilMenu, menuPublications, true);
menuStore.add(accueilMenu, menuCommentaires, true);
}
private void afficherMenu() {
arbreMenus = new TreePanel<Menu>(menuStore);
arbreMenus.getStyle().setNodeCloseIcon(null);
arbreMenus.getStyle().setNodeOpenIcon(null);
arbreMenus.setDisplayProperty("nom");
arbreMenus.setHeight("100%");
arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
public void handleEvent(TreePanelEvent<Menu> tpe) {
Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem();
mediateur.clicMenu(menuCourant.getCode());
}
});
add(arbreMenus);
arbreMenus.setAutoExpand(true);
}
public void selectionMenu(String code) {
arbreMenus.getSelectionModel().select(menuStore.findModel("code", code), false);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/MenuVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/MenuVue.java:r11-443,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/MenuVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/accueil/StatistiquesVue.java
New file
0,0 → 1,301
package org.tela_botanica.client.vues.accueil;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeMap;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.TabPanelEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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;
import com.extjs.gxt.ui.client.widget.custom.Portal;
import com.extjs.gxt.ui.client.widget.custom.Portlet;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.Node;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.xml.client.XMLParser;
 
public class StatistiquesVue extends LayoutContainer implements Rafraichissable {
private Mediateur mediateur = null;
private Constantes i18nC = null;
private static Portal portail = null;
private static boolean enregistrementEnCours = false;
private ContentPanel panneauPrincipalPortail = new ContentPanel();
public StatistiquesVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
setLayout(new FitLayout());
panneauPrincipalPortail = new ContentPanel();
panneauPrincipalPortail.setLayout(new FitLayout());
panneauPrincipalPortail.setHeaderVisible(false);
panneauPrincipalPortail.setBorders(false);
final ToolBar barreOutils = new ToolBar();
Button ajouter = new Button(i18nC.ajouter());
ajouter.setIcon(Images.ICONES.ajouter());
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
ajouterPortlet();
}
});
ajouter.setToolTip(i18nC.indicationAjouterStatistiqueAccueil());
barreOutils.add(ajouter);
Button enregistrer = new Button("Enregistrer");
enregistrer.setIcon(Images.ICONES.appliquer());
enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
if (enregistrementEnCours == false) {
enregistrerParametres();
} else {
InfoLogger.display(i18nC.accueilEnregistrement(), i18nC.accueilEnregistrementEnCours());
}
}
});
enregistrer.setToolTip(i18nC.indicationEnregistrerAccueil());
barreOutils.add(enregistrer);
panneauPrincipalPortail.setTopComponent(barreOutils);
portail = creerPortail();
ajouterPortletsDefaut();
Utilisateur utilisateur = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateur();
if(utilisateur.isIdentifie()) {
chargerParametres();
}
panneauPrincipalPortail.add(portail);
add(panneauPrincipalPortail);
mediateur.desactiverChargement(this);
}
private Portal creerPortail() {
final Portal portail = new Portal(3);
portail.setBorders(true);
portail.addListener(Events.Render, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
portail.setStyleAttribute("backgroundColor", "white");
}
});
portail.setShadow(true);
portail.setColumnWidth(0, .33);
portail.setColumnWidth(1, .33);
portail.setColumnWidth(2, .33);
return portail;
}
// INFO: Les items d'une classse portal correspondent aux colonnes. Pour vider une Portal, il faut donc vider les éléments de chaque item du Portal.
private void viderPortail() {
portail.getItem(0).removeAll();
portail.getItem(1).removeAll();
portail.getItem(2).removeAll();
}
private void chargerParametres() {
viderPortail();
Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre());
NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil");
int nbreAccueilNoeud = listeAccueilNoeud.getLength();
 
// Récupération du noeud accueil
Node accueilNoeud = null;
if (nbreAccueilNoeud == 0) {
ajouterPortletsDefaut();
} else if (nbreAccueilNoeud == 1) {
accueilNoeud = listeAccueilNoeud.item(0);
NodeList listeAppletteNoeud = accueilNoeud.getChildNodes();
// un noeud de type vide indique que l'utilisateur a explicité effacé les applettes de la page d'accueil
if(listeAppletteNoeud.getLength() > 0 && !listeAppletteNoeud.item(0).getNodeName().equals("vide")) {
portail.removeAll();
// Lecture des noeuds "applette"
int nbreAppletteNoeud = listeAppletteNoeud.getLength();
TreeMap<String, HashMap<String, String>> tableApplettes = new TreeMap<String, HashMap<String, String>>();
for (int i = 0; i < nbreAppletteNoeud ; i++) {
Element appletteNoeud = (Element) listeAppletteNoeud.item(i);
int colonne = Integer.parseInt(appletteNoeud.getAttribute("colonne"));
int index = Integer.parseInt(appletteNoeud.getAttribute("index"));
HashMap<String, String> infoApplette = new HashMap<String, String>();
infoApplette.put("reduite", appletteNoeud.getAttribute("reduite"));
infoApplette.put("epingle", appletteNoeud.getAttribute("epingle"));
infoApplette.put("type", appletteNoeud.getAttribute("type"));
infoApplette.put("colonne", appletteNoeud.getAttribute("colonne"));
infoApplette.put("index", appletteNoeud.getAttribute("index"));
infoApplette.put("contenu", appletteNoeud.getAttribute("contenu"));
tableApplettes.put(colonne+"-"+index, infoApplette);
}
Iterator<String> it = tableApplettes.keySet().iterator();
while (it.hasNext()) {
String id = it.next();
HashMap<String, String> infoApplette = tableApplettes.get(id);
boolean reduite = (infoApplette.get("reduite") != null && infoApplette.get("reduite").equals("true")) ? true : false;
boolean epingle = (infoApplette.get("epingle") != null && infoApplette.get("epingle").equals("true")) ? true : false;
int index = Integer.parseInt(infoApplette.get("index"));
int colonne = Integer.parseInt(infoApplette.get("colonne"));
ajouterPortlet(reduite, epingle, infoApplette.get("type"), colonne, index, infoApplette.get("contenu"));
}
} else if(listeAppletteNoeud.getLength() == 0) {
ajouterPortletsDefaut();
}
}
layout();
}
private void enregistrerParametres() {
ArrayList<Portlet> applettes = getPortlets();
Iterator<Portlet> it = applettes.iterator();
Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre());
NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil");
int nbreAccueilNoeud = listeAccueilNoeud.getLength();
 
// Suppression des noeuds "accueil" existant car il ne devrait y en avoir qu'un
if (nbreAccueilNoeud > 1) {
for (int i = 0; i < nbreAccueilNoeud ; i++) {
paramXml.getDocumentElement().removeChild(listeAccueilNoeud.item(i));
}
nbreAccueilNoeud = 0;
}
// Création du nouveau noeud accueil
Node accueilNoeud = null;
Element accueilElement = paramXml.createElement("accueil");
if (nbreAccueilNoeud == 0) {
accueilNoeud = paramXml.getDocumentElement().appendChild(accueilElement);
} else if (nbreAccueilNoeud == 1) {
accueilNoeud = listeAccueilNoeud.item(0);
paramXml.getDocumentElement().replaceChild(accueilElement, accueilNoeud);
accueilNoeud = paramXml.getElementsByTagName("accueil").item(0);
}
// si il existe des applettes ouvertes
if(it.hasNext()) {
// Ajout des noeuds "applette" au noeud "accueil"
while (it.hasNext()) {
Portlet applette = it.next();
String reduite = (applette.isCollapsed() ? "true" : "false");
String epingle = (applette.isPinned() ? "true" : "false");
String index = Integer.toString(portail.getPortletIndex(applette));
String colonne = Integer.toString(portail.getPortletColumn(applette));
String contenu = applette.getData("contenu");
Element appletteElement = paramXml.createElement("applette");
appletteElement.setAttribute("reduite", reduite);
appletteElement.setAttribute("epingle", epingle);
appletteElement.setAttribute("type", "statistique");
appletteElement.setAttribute("colonne", colonne);
appletteElement.setAttribute("index", index);
appletteElement.setAttribute("contenu", contenu);
accueilNoeud.appendChild(appletteElement);
}
} else {
// sinon ajout d'un noeud vide
Element videElement = paramXml.createElement("vide");
accueilNoeud.appendChild(videElement);
}
enregistrementEnCours = true;
mediateur.getUtilisateur().setParametre(paramXml.toString());
mediateur.modifierUtilisateur();
}
private ArrayList<Portlet> getPortlets() {
ArrayList<Portlet> applettes = new ArrayList<Portlet>();
for (int i = 0; i < 3; i++) {
int nbreApplette = portail.getItem(i).getItemCount();
if (nbreApplette > 0) {
for (int j = 0; j < nbreApplette; j++) {
applettes.add((Portlet) portail.getItem(i).getItem(j));
}
}
}
return applettes;
}
private void ajouterPortlet() {
ajouterPortlet(false, false, "statistique", 0, 0, null);
}
private void ajouterPortlet(boolean reduite, boolean epingle, String type, int colonne, int index, String contenu) {
Applette applette = null;
if (type.equals("statistique")) {
applette = new AppletteStatistique(mediateur, contenu);
}
if (reduite) {
applette.collapse();
}
portail.insert(applette, index, colonne);
applette.setEpingler(epingle);
layout();
}
private void ajouterPortletsDefaut() {
//TODO créer une énum des différents types de portlet puis faire une boucle
// dessus
Applette applette = new AppletteStatistique(mediateur, "NombreDonnees");
portail.insert(applette, 0, 0);
applette.setEpingler(true);
applette = new AppletteStatistique(mediateur, "MesDonnees");
portail.insert(applette, 0, 1);
applette = new AppletteStatistique(mediateur, "TypeDepot");
portail.insert(applette, 0, 2);
applette = new AppletteStatistique(mediateur, "NombreCollectionParStructure");
portail.insert(applette, 1, 0);
layout();
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
String type = info.getType();
if (type.equals("maj_utilisateur")) {
if (enregistrementEnCours == true) {
enregistrementEnCours = false;
InfoLogger.display(i18nC.accueilEnregistrement(), i18nC.accueilEnregistrementSucces());
} else {
chargerParametres();
InfoLogger.display(i18nC.accueil(), i18nC.accueilChargementSucces());
}
}
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/accueil/AccueilVue.java
New file
0,0 → 1,64
package org.tela_botanica.client.vues.accueil;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeMap;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.TabPanelEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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;
import com.extjs.gxt.ui.client.widget.custom.Portal;
import com.extjs.gxt.ui.client.widget.custom.Portlet;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.Node;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.xml.client.XMLParser;
 
public class AccueilVue extends LayoutContainer implements Rafraichissable {
private Mediateur mediateur = null;
private Constantes i18nC = null;
private static Widget tutoriel = null;
public AccueilVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
setLayout(new FitLayout());
setBorders(false);
tutoriel = new AccueilTutorielVue(mediateur);
add(tutoriel);
mediateur.desactiverChargement(this);
}
 
@Override
public void rafraichir(Object nouvellesDonnees) {
// TODO Auto-generated method stub
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/accueil/AccueilTutorielVue.java
New file
0,0 → 1,130
package org.tela_botanica.client.vues.accueil;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Menu;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.Print;
 
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.custom.Portlet;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.Request;
import org.tela_botanica.client.http.RequestBuilderWithCredentials;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.regexp.shared.MatchResult;
import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
 
public class AccueilTutorielVue extends LayoutContainer {
 
private static final String SERVICE_NOM = "CoelAide";
private static final String PAGE_A_OUVRIR_CODE = "AideCOELTutoriel";
private static Menu pagePrincipale = null;
private static Menu menuAOuvrirParDefaut = null;
 
private ContentPanel contenuPanneau = null;
private HtmlContainer conteneurDuHtml;
private LayoutContainer entetePanneau;
public AccueilTutorielVue(Mediateur mediateur) {
setLayout(new FitLayout());
creerPanneauContenu();
chargerPageParDefaut();
}
private void chargerPageParDefaut() {
String serviceUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
String defautPageUrl = serviceUrl+SERVICE_NOM+"/"+PAGE_A_OUVRIR_CODE+"/";
chargerPageAide(defautPageUrl);
}
 
private void creerPanneauContenu() {
contenuPanneau = new ContentPanel();
contenuPanneau.setScrollMode(Scroll.AUTO);
contenuPanneau.setHeaderVisible(false);
contenuPanneau.setLayout(new FitLayout());
add(contenuPanneau);
}
private void chargerPageAide(String url) {
conteneurDuHtml = new HtmlContainer() {
public void onBrowserEvent(Event e) {
// Nous vérifions que l'évenement est un clic et qu'il a lieu sur un lien
if (e.getTypeInt() == Event.ONCLICK && e.getEventTarget().toString().startsWith("<a href=\"http://")) {
e.preventDefault();
String urlPageCliquee = extraireLien(e.getEventTarget().toString());
if(urlPageCliquee != null) {
chargerPageAide(urlPageCliquee);
}
} else {
GWT.log("Event target:"+e.getEventTarget().toString()+" - type :"+e.getTypeInt()+"="+Event.ONCLICK, null);
}
}
};
conteneurDuHtml.setId(ComposantId.PANNEAU_TUTORIEL);
 
conteneurDuHtml.sinkEvents(Event.ONCLICK);
conteneurDuHtml.setUrl(url);
conteneurDuHtml.recalculate();
contenuPanneau.removeAll();
contenuPanneau.add(conteneurDuHtml);
contenuPanneau.layout();
conteneurDuHtml.setStyleAttribute("padding-left", "5px");
conteneurDuHtml.setStyleAttribute("padding-top", "5px");
}
public String extraireLien(String str) {
String lien = null;
RegExp regExp = RegExp.compile("href=\"(.*?)\"");
MatchResult matcher = regExp.exec(str);
boolean matchOK = (matcher != null);
if (matchOK) {
//TODO plus de vérifications
lien = matcher.getGroup(1);
}
return lien;
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/accueil/Applette.java
New file
0,0 → 1,86
package org.tela_botanica.client.vues.accueil;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.IconButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.button.ToolButton;
import com.extjs.gxt.ui.client.widget.custom.Portlet;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 
abstract public class Applette extends Portlet {
protected Mediateur mediateur = null;
private ToolButton epingleBouton = null;
private ToolButton configurationBouton = null;
private ToolButton fermetureBouton = null;
protected void initialiserApplette(Mediateur mediateurCourrant) {
initialiserApplette(mediateurCourrant, null);
}
protected void initialiserApplette(Mediateur mediateurCourrant, String titre) {
mediateur = mediateurCourrant;
setLayout(new FitLayout());
setHeight(250);
setCollapsible(true);
setAnimCollapse(true);
setScrollMode(Scroll.AUTO);
setTitre(titre);
configurationBouton = new ToolButton("x-tool-gear");
getHeader().addTool(configurationBouton);
epingleBouton = getBoutonEpingle();
getHeader().addTool(epingleBouton);
fermetureBouton = getBoutonFermeture();
getHeader().addTool(fermetureBouton);
}
private ToolButton getBoutonEpingle() {
ToolButton bouton = new ToolButton("x-tool-pin", new SelectionListener<IconButtonEvent>() {
@Override
public void componentSelected(IconButtonEvent ce) {
setEpingler(!isPinned());
}
});
return bouton;
}
private ToolButton getBoutonFermeture() {
ToolButton bouton = new ToolButton("x-tool-close", new SelectionListener<IconButtonEvent>() {
@Override
public void componentSelected(IconButtonEvent ce) {
removeFromParent();
}
});
return bouton;
}
public void setTitre(String titre) {
if (titre != null) {
setHeadingHtml(titre);
}
}
public void setEpingler(boolean epingler) {
if (epingler) {
epingleBouton.setStyleName("x-tool-unpin x-tool");
setPinned(true);
} else {
epingleBouton.setStyleName("x-tool-pin x-tool");
setPinned(false);
}
Debug.log("epingleBouton.getStyleName() = "+epingleBouton.getStyleName());
layout();
}
protected void ajouterConfigurationListener(SelectionListener<IconButtonEvent> configurationListener) {
configurationBouton.addSelectionListener(configurationListener);
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/accueil/AppletteStatistique.java
New file
0,0 → 1,107
package org.tela_botanica.client.vues.accueil;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.modeles.InterneValeur;
import org.tela_botanica.client.vues.Formulaire;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.IconButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.WindowEvent;
import com.extjs.gxt.ui.client.event.WindowListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 
public class AppletteStatistique extends Applette {
private String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
 
public AppletteStatistique(Mediateur mediateurCourrant) {
initialiserAppletteStatistique(mediateurCourrant, null);
}
public AppletteStatistique(Mediateur mediateurCourrant, String contenu) {
initialiserAppletteStatistique(mediateurCourrant, contenu);
}
private void initialiserAppletteStatistique(Mediateur mediateurCourrant, String contenu) {
String titre = "Statistiques des collections";
initialiserApplette(mediateurCourrant, titre);
SelectionListener<IconButtonEvent> configurationListener = new SelectionListener<IconButtonEvent>() {
@Override
public void componentSelected(IconButtonEvent ce) {
ContentPanel panneau = new ContentPanel();
panneau.setHeaderVisible(false);
panneau.setLayout(Formulaire.creerFormLayout(350, LabelAlign.TOP));
ListStore<InterneValeur> appletteStore = new ListStore<InterneValeur>();
appletteStore.add(new InterneValeur("NombreDonnees", "Nombre de données"));
appletteStore.add(new InterneValeur("MesDonnees", "Ma participation"));
appletteStore.add(new InterneValeur("TypeDepot", "Types de dépôt des collections"));
appletteStore.add(new InterneValeur("NombreCollectionParStructure", "Nombre de collections par institution"));
final ComboBox<InterneValeur> applettesCombo = new ComboBox<InterneValeur>();
applettesCombo.setFieldLabel("Veuillez sélectionner le type d'applette");
applettesCombo.setForceSelection(true);
applettesCombo.setTriggerAction(TriggerAction.ALL);
applettesCombo.setDisplayField("nom");
applettesCombo.setStore(appletteStore);
applettesCombo.setEditable(false);
applettesCombo.setWidth(300);
panneau.add(applettesCombo);
final Dialog configurationFenetre = new Dialog();
configurationFenetre.setHeadingHtml("Configuration de l'applette");
configurationFenetre.setButtons(Dialog.OK);
configurationFenetre.setSize(350, 150);
configurationFenetre.setPlain(true);
configurationFenetre.setModal(true);
configurationFenetre.setBlinkModal(true);
configurationFenetre.setLayout(new FitLayout());
configurationFenetre.setHideOnButtonClick(true);
configurationFenetre.addWindowListener(new WindowListener(){
public void windowHide(WindowEvent we) {
String abreviation = applettesCombo.getValue().getAbr();
attribuerContenu(abreviation);
}
});
configurationFenetre.add(panneau);
configurationFenetre.show();
}
};
ajouterConfigurationListener(configurationListener);
attribuerContenu(contenu);
}
 
private void attribuerContenu(String abreviation) {
if (abreviation == null) {
abreviation = "NombreDonnees";
}
setData("contenu", abreviation);
String url = baseUrl+"CoelStatistique/"+abreviation;
if (abreviation.equals("MesDonnees")) {
url += "/"+mediateur.getUtilisateurId();
}
HtmlContainer conteneurHtml = new HtmlContainer();
conteneurHtml.setUrl(url);
conteneurHtml.recalculate();
removeAll();
add(conteneurHtml);
layout();
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/accueil
New file
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/accueil:r1136-1291
Merged /trunk/src/org/tela_botanica/client/vues/accueil:r11-911,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/accueil:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/BarrePaginationVue.java
New file
0,0 → 1,435
package org.tela_botanica.client.vues;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.i18n.ErrorMessages;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.ListePaginable;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.composants.ChampFiltreRecherche;
 
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.store.StoreListener;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
import com.extjs.gxt.ui.client.widget.form.SimpleComboValue;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
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 {
 
private Mediateur mediateur = null;
private Constantes i18nC = null;
private ErrorMessages i18nM = null;
public int valeur = 0;
private ListePaginable listePaginable = null;
private Button prevPage, suivPage, premierePage, dernierePage, rafraichir;
private int pageCourante, nbElement = 0;
private int taillePage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage"));
private int pageTotale = 1;
private Text page, surTotalPage, afficherNbElem, nbElemParPage, intervalleElements;
private NumberField champPage = new NumberField();
private SimpleComboBox<Integer> selecteurTaillePage = new SimpleComboBox<Integer>();
private LinkedList<Integer> intervallePages = new LinkedList<Integer>();
private ListStore storeIntervalle = new ListStore() ;
private String labelElement;
private int taillePageDefaut = 50;
 
private ChampFiltreRecherche champFiltreRecherche = null;
 
public ListePaginable getlistePaginable() {
return listePaginable;
}
public void setlistePaginable(ListePaginable listePaginable) {
this.listePaginable = listePaginable;
}
/***************************************************************************
* constructeur sans argument (privé car ne doit pas être utilisé)
*/
@SuppressWarnings("unused")
private BarrePaginationVue() {
super();
}
 
/**
* constructeur avec paramètres
*
* @param im
* le médiateur à associer à la barre
*/
public BarrePaginationVue(ListePaginable listePaginableCourante, Mediateur mediateurCourant) {
super();
listePaginable = listePaginableCourante;
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
i18nM = Mediateur.i18nM;
intervallePages.add(10);
intervallePages.add(20);
intervallePages.add(50);
intervallePages.add(100);
intervallePages.add(200);
premierePage = new Button();
premierePage.setIcon(Images.ICONES.resultsetFirst());
add(premierePage);
prevPage = new Button();
prevPage.setIcon(Images.ICONES.resultsetPrevious());
add(prevPage);
add(new SeparatorToolItem());
page = new Text(i18nC.page());
page.setStyleAttribute("padding", "0 5px 0 5px");
add(page);
champPage.setValue(pageCourante+1);
champPage.setAllowDecimals(false);
champPage.setAllowNegative(false);
champPage.setStyleAttribute("text-align","right");
champPage.setWidth(30);
add(champPage);
surTotalPage = new Text(i18nC.sur() + " " + pageTotale);
surTotalPage.setStyleAttribute("padding-left", "5px");
add(surTotalPage);
//Séparation
add(new SeparatorToolItem());
suivPage = new Button();
suivPage.setIcon(Images.ICONES.resultsetNext());
add(suivPage);
dernierePage = new Button();
dernierePage.setIcon(Images.ICONES.resultsetLast());
add(dernierePage);
 
//Séparation
add(new SeparatorToolItem());
rafraichir = new Button();
rafraichir.setIcon(Images.ICONES.rafraichir());
add(rafraichir);
//Séparation
add(new SeparatorToolItem());
afficherNbElem = new Text(i18nC.afficher());
afficherNbElem.setStyleAttribute("padding", "0 5px 0 5px");
add(afficherNbElem);
 
// Attention l'appel à setTriggerAction avec ALL est indispensable
// pour éviter un bug lors de la selection de la taille de page par défaut
selecteurTaillePage.setTriggerAction(TriggerAction.ALL);
selecteurTaillePage.setLazyRender(false);
selecteurTaillePage.setWidth("40px");
setIntervallesPages();
add(selecteurTaillePage);
labelElement = i18nC.elements();
nbElemParPage = new Text(labelElement+" "+i18nC.parPage());
nbElemParPage.setStyleAttribute("padding-left", "5px");
add(nbElemParPage);
//Séparation
add(new SeparatorToolItem());
intervalleElements = new Text(i18nM.elementsAffiches(UtilString.ucFirst(labelElement),
pageCourante * taillePage, (pageCourante + 1) * taillePage, nbElement));
add(intervalleElements);
// on ajoute les différents listeners
ajouterListeners();
}
 
public BarrePaginationVue(ListePaginable listePaginableCourante, Mediateur mediateurCourant, ChampFiltreRecherche champFiltreRechercheCourant) {
this(listePaginableCourante, mediateurCourant);
champFiltreRecherche = champFiltreRechercheCourant;
}
/**
* Texte nommant les elements pagines (Images, Observation, truc, machin etc...).
* @param label
*/
public void setLabelElement(String label) {
this.labelElement = label;
nbElemParPage.setText(labelElement + " par page ");
intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement),
pageCourante * taillePage, (pageCourante + 1) * taillePage, nbElement));
}
 
public void setTaillePageParDefaut(int taille) {
this.taillePageDefaut = taille;
selecteurTaillePage.setRawValue(""+taillePageDefaut);
}
public void setIntervallesPages() {
if (!intervallePages.contains(taillePage)) {
intervallePages.add(taillePage);
}
Iterator<Integer> itIntervallePages = intervallePages.iterator();
while (itIntervallePages.hasNext()) {
Integer intervalle = itIntervallePages.next();
selecteurTaillePage.add(intervalle);
}
 
selecteurTaillePage.setSimpleValue(taillePage);
}
/**
* Change l'état de la barre de pagination a actif ou inactif
* @param etat actif ou inactif
*/
private void changerEtatBarre(boolean etat) {
premierePage.setEnabled(etat);
prevPage.setEnabled(etat);
suivPage.setEnabled(etat);
dernierePage.setEnabled(etat);
champPage.setEnabled(etat);
selecteurTaillePage.setEnabled(etat);
page.setEnabled(etat);
surTotalPage.setEnabled(etat);
afficherNbElem.setEnabled(etat);
nbElemParPage.setEnabled(etat);
}
/**
* ajoute les différents listeners nécessaires au bon fonctionnement des
* éléments de la barre de pagination
*/
@SuppressWarnings("unchecked")
private void ajouterListeners() {
premierePage.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
pageCourante = 0;
rafraichirNumeroPage();
changePage();
}
});
// boutons suivants et précédents
prevPage.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
// si la page courante n'est pas la première
if (pageCourante > 0) {
// on décrémente la page courante de 1
pageCourante--;
// on rafraichit l'affichage
rafraichirNumeroPage();
changePage();
}
}
});
 
suivPage.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
// si la page courante n'est pas la dernière
if (pageCourante < pageTotale - 1) {
// on incrémente la page courante de 1
pageCourante++;
// on rafraichit l'affichage
rafraichirNumeroPage();
changePage();
}
}
});
dernierePage.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
pageCourante = pageTotale;
rafraichirNumeroPage();
changePage();
}
});
rafraichir.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
changePage();
}
});
 
champPage.addKeyListener(new KeyListener() {
public void componentKeyUp(ComponentEvent ce) {
// on teste si la touche entrée a été pressée
if (ce.getKeyCode() == KeyCodes.KEY_ENTER) {
int nouvellePage = champPage.getValue().intValue();
 
// on verifie s'il est nécessaire de changer de page
// et si la nouvelle est comprise dans l'intervalle des
// pages existantes (0..pageTotale)
if (nouvellePage != pageCourante + 1 && nouvellePage > 0
&& nouvellePage <= pageTotale) {
// le cas échéant, on charge la nouvelle page et on
// notifie le médiateur
changerPageCourante(nouvellePage - 1);
changePage();
} else {
// sinon on reaffiche l'ancien numero de page sans rien changer
rafraichirNumeroPage();
champPage.focus();
}
}
}
});
 
// listener pour la selection dans la combobox
selecteurTaillePage.addSelectionChangedListener(new SelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
SimpleComboBox comboBox = (SimpleComboBox) e.getSource();
String nouvelleTaillePageString = comboBox.getRawValue();
int nouvelleTaillePage = Integer.parseInt(nouvelleTaillePageString);
changerTaillePage(nouvelleTaillePage);
rafraichirNumeroPage();
}
});
}
 
public void changePage() {
// si notre barre de pagination n'a pas été initialisée
// avec un filtre de recherche, contentons-nous de changer de page
// Attention, car tous les webservice ne supporte pas un segment d'URI "null" (500)
if(champFiltreRecherche == null || champFiltreRecherche.getFiltreValue() == null) {
// et on notifie le médiateur de l'évenement
listePaginable.changerNumeroPage(pageCourante);
} else {
// autrement nous pouvons changer de page *tout en conservant* le filtre de recherche,
// charge au modèle de cette liste d'avoir implémenté correctement filtrerParNomEtPage()
listePaginable.filtrerParNomEtPage(champFiltreRecherche.getFiltreValue(), pageCourante);
}
}
 
/**
* Met à jour les affichage sur les numéros de pages et d'intervalle
* d'éléments à partir des variables de classes
*/
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(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), 0,0,0));
} 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(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(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage,
nbElement, nbElement));
}
}
}
 
/**
* Met à jour la page en cours
*
* @param nouvellePageCourante
* la nouvelle page en cours
*/
public void changerPageCourante(int nouvellePageCourante) {
pageCourante = nouvellePageCourante;
}
 
/**
* Envoie au médiateur une demande pour modifier la taille de la page (qui
* va à son tour faire les modifications nécessaires)
*
* @param nouvelleTaillePage
* la nouvelle taille de page (élement appartenant au tableau
* renvoyé par getNbPages())
*/
public void changerTaillePage(int nouvelleTaillePage) {
if (nouvelleTaillePage != taillePage) {
listePaginable.changerTaillePage(nouvelleTaillePage);
}
}
 
/**
* Selectionne la valeur correspond à celle passée en paramètre dans la
* combobox (si elle existe)
*
* @param nouvelleTaillePage
* la nouvelle taille de page
*/
public void selectionnerTaillePage(int nouvelleTaillePage) {
selecteurTaillePage.setRawValue("" + nouvelleTaillePage);
}
public void allerALaDernierePage() {
changerPageCourante(pageTotale);
changePage();
}
 
public void rafraichir(Object nouvelleDonnees) {
// si on reçoit un tableau de int
if (nouvelleDonnees instanceof int[]) {
int[] page = (int[]) nouvelleDonnees;
// le premier élement est le nombre de pages totales
pageTotale = page[0];
// le second la page en cours
pageCourante = page[1];
// le troisième la taille de la page
taillePage = page[2];
// et le dernier le nombre total d'éléments
nbElement = page[3];
// si la page courante dépasse la page totale (cas normalement
// improbable car géré en amont)
// on met le numéro de page à la page courante -1 (car la page
// courante est comptée à partir
// de zéro)
if (pageCourante >= pageTotale && pageCourante != 0) {
pageCourante = pageTotale - 1;
// le cas échéant on en notifie le médiateur
changePage();
}
}
 
// enfin on rafraichit les informations affichées à partir des nouvelles
// variables de classes mises à jour
rafraichirNumeroPage();
layout();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/BarrePaginationVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/BarrePaginationVue.java:r11-593,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/BarrePaginationVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/publication/PublicationDetailVue.java
New file
0,0 → 1,155
package org.tela_botanica.client.vues.publication;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.vues.DetailVue;
 
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
 
public class PublicationDetailVue extends DetailVue implements Rafraichissable {
private String enteteTpl = null;
private String contenuTpl = null;
private ContentPanel panneauPrincipal = null;
private Html entete = null;
private Html contenu = null;
private Publication publication = null;
private boolean publicationChargementOk = false;
 
public PublicationDetailVue(Mediateur mediateurCourant) {
super(mediateurCourant);
initialiserTousLesTpl();
panneauPrincipal = new ContentPanel();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.setHeaderVisible(false);
panneauPrincipal.setBodyBorder(false);
entete = new Html();
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
panneauPrincipal.setTopComponent(entete);
contenu = new Html();
panneauPrincipal.add(contenu);
add(panneauPrincipal);
}
 
private void initialiserTousLesTpl() {
initialiserEnteteHtmlTpl();
initialiserGeneralTpl();
}
private void initialiserEnteteHtmlTpl() {
enteteTpl =
"<div id='{css_id}'>"+
" <h1>{titre}</h1>"+
" <h2>{auteurs} ({annee})<span class='{css_meta}'><br /> {i18n_id}:{id} - {guid}</span></h2>" +
"</div>";
}
private void initialiserGeneralTpl() {
contenuTpl =
"<div class='{css_corps}'>"+
" <span class='{css_label}'>{i18n_nom_complet} :</span> {nom_complet}<br />"+
" <span class='{css_label}'>{i18n_auteurs} :</span> {auteurs}<br />"+
" <span class='{css_label}'>{i18n_titre} :</span> {titre}<br />"+
" <span class='{css_label}'>{i18n_collection} :</span> {collection}<br />"+
" <span class='{css_label}'>{i18n_editeur} :</span> {editeur}<br />"+
" <span class='{css_label}'>{i18n_annee} :</span> {annee}<br />"+
" <span class='{css_label}'>{i18n_nvt} :</span> {nvt}<br />"+
" <span class='{css_label}'>{i18n_fascicule} :</span> {fascicule}<br />"+
" <span class='{css_label}'>{i18n_pages} :</span> {pages}<br />"+
"</div>";
}
public void afficherDetail() {
if (publication != null) {
afficherEntete();
afficherDetailPublication();
}
layout();
}
private void afficherEntete() {
Params enteteParams = new Params();
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
enteteParams.set("css_meta", ComposantClass.META);
enteteParams.set("i18n_id", i18nC.id());
enteteParams.set("titre", publication.getTitre());
enteteParams.set("auteurs", publication.getAuteur());
enteteParams.set("annee", publication.getAnneeParution());
enteteParams.set("id", publication.getId());
enteteParams.set("guid", getGuid());
 
String eHtml = Format.substitute(enteteTpl, enteteParams);
entete.getElement().setInnerHTML(eHtml);
}
public String getGuid() {
String guid = "URN:tela-botanica.org:";
guid += "pub"+publication.getId();
return guid;
}
public void afficherDetailPublication() {
Params contenuParams = new Params();
contenuParams.set("i18n_nom_complet", i18nC.publicationNomComplet());
contenuParams.set("i18n_auteurs", i18nC.publicationAuteurs());
contenuParams.set("i18n_titre", i18nC.publicationTitre());
contenuParams.set("i18n_collection", i18nC.publicationRevueCollection());
contenuParams.set("i18n_editeur", i18nC.publicationEditeur());
contenuParams.set("i18n_annee", i18nC.publicationDateParution());
contenuParams.set("i18n_nvt", i18nC.publicationNvt());
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule());
contenuParams.set("i18n_pages", i18nC.publicationPage());
contenuParams.set("nom_complet", publication.getNomComplet());
contenuParams.set("auteurs", publication.getAuteur());
contenuParams.set("titre", publication.getTitre());
contenuParams.set("collection", publication.getCollection());
contenuParams.set("editeur", publication.getNomEditeur());
contenuParams.set("annee", publication.getAnneeParution());
contenuParams.set("nvt", publication.getIndicationNvt());
contenuParams.set("fascicule", publication.getFascicule());
contenuParams.set("pages", publication.getPages());
String gHtml = formaterContenu(contenuTpl, contenuParams);
contenu.getElement().setInnerHTML(gHtml);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Publication) {
publication = (Publication) nouvellesDonnees;
publicationChargementOk = true;
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
if (avoirDonneesChargees()) {
afficherDetail();
}
}
private boolean avoirDonneesChargees() {
boolean ok = false;
if (publicationChargementOk) {
ok = true;
}
return ok;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationDetailVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/publication/PublicationDetailVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/publication/PublicationDetailVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/publication/PublicationForm.java
New file
0,0 → 1,1257
package org.tela_botanica.client.vues.publication;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.GrillePaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
import org.tela_botanica.client.composants.pagination.ProxyPersonnesAPublication;
import org.tela_botanica.client.composants.pagination.ProxyStructures;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.MenuApplicationId;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Log;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.UtilArray;
import org.tela_botanica.client.util.UtilString;
import org.tela_botanica.client.vues.FenetreForm;
import org.tela_botanica.client.vues.Formulaire;
import org.tela_botanica.client.vues.FormulaireBarreValidation;
import org.tela_botanica.client.vues.personne.PersonneForm;
 
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.LoadEvent;
import com.extjs.gxt.ui.client.data.Loader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.Text;
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.Field;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
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 PublicationForm extends Formulaire implements Rafraichissable {
//-------------//
// ATTRIBUTS //
//-------------//
/** Publication **/
// on se sert d'un objet Publication lorsque l'on est en mode MODIFIER
private Publication publication;
// on se sert de l'identifiant d'une publication lorsque l'on est en mode AJOUTER
private String publicationId = null;
/** Auteurs **/
private PublicationAPersonneListe auteursInitialListe = null;
private PublicationAPersonneListe auteursAjoutes = null;
private PublicationAPersonneListe auteursSupprimes = null;
private PublicationAPersonneListe auteursModifies = null;
private ContentPanel auteursFieldset = null;
private FieldSet generalitesFieldset = null;
private TextField<String> titreChp = null;
private TextField<String> collectionChp = null;
private TextField<String> uriChp = null;
private FieldSet editionFieldset = null;
private ChampComboBoxRechercheTempsReelPaginable editeurCombobox = null;
private TextField<String> datePublicationChp = null;
private TextField<String> tomeChp = null;
private TextField<String> fasciculeChp = null;
private TextField<String> pagesChp = null;
private LayoutContainer zoneHaut, zoneBas;
private ToolBar barreOutils = null;
private GrillePaginable<ModelData> grilleAuteurs;
private ChampComboBoxRechercheTempsReelPaginable personnesSaisiesComboBox = null;
private Button personnesBoutonSupprimer = null;
private Button personnesBoutonModifier = null;
private Button boutonAuteurUp = null;
private Button boutonAuteurDown = null;
private FenetreForm fenetreFormulaire = null;
private Sequenceur sequenceur;
private String modeDeCreation = null;
boolean changeOrderMarker = false;
private Label infosAuteurFmt = null;
private ContentPanel infosAuteursNonPresentsPanel = null;
//+----------------------------------------------------------------------------------------------------------------+
// Constructeurs
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
initialiserPublicationForm(mediateurCourrant, publicationId);
}
 
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
initialiserPublicationForm(mediateurCourrant, publicationId);
}
 
//+----------------------------------------------------------------------------------------------------------------+
// Initialisation
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
sequenceur = new Sequenceur();
publication = new Publication();
publication.setId(publicationId);
this.publicationId = publicationId;
auteursInitialListe = new PublicationAPersonneListe();
initialiserAuteurs(); // Crée les listes d'auteurs ajoutés et supprimés
// Si 'publicationId' est vide alors on est en mode "AJOUTER", sinon on est en mode "MODIFIER"
modeDeCreation = (UtilString.isEmpty(publicationId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
panneauFormulaire.setLayout(new RowLayout());
panneauFormulaire.setStyleAttribute("padding", "0");
panneauFormulaire.setHeight(600);
zoneHaut = new LayoutContainer(new FitLayout());
zoneBas = new LayoutContainer(new FlowLayout());
panneauFormulaire.add(zoneHaut, new RowData(0.99, 0.45));
panneauFormulaire.add(zoneBas, new RowData(0.99, 0.55));
panneauFormulaire.setScrollMode(Scroll.AUTO);
genererTitreFormulaire();
creerZoneAuteurs();
zoneHaut.add(auteursFieldset);
creerZoneGeneralites();
zoneBas.add(generalitesFieldset);
creerZoneEdition();
zoneBas.add(editionFieldset);
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
mediateurCourrant.selectionnerPublication(this, publicationId, sequenceur);
sequenceur.enfilerRafraichissement(this, new Information("chargement_modifier_ok"));
}
}
 
private void initialiserAuteurs() {
auteursAjoutes = new PublicationAPersonneListe();
auteursSupprimes = new PublicationAPersonneListe();
auteursModifies = new PublicationAPersonneListe();
}
//+----------------------------------------------------------------------------------------------------------------+
// User Interface
private ToolBar creerBarreOutilsGrille() {
ToolBar barreOutils = new ToolBar();
creerComboBoxPersonnesSaisies();
barreOutils.add(personnesSaisiesComboBox);
personnesSaisiesComboBox.getCombo().setEmptyText("Rechercher et sélectionner une personne existante dans la base");
barreOutils.add(new Text(" ou "));
Button ajouterBouton = creerBoutonAjouter();
barreOutils.add(ajouterBouton);
barreOutils.add(new SeparatorToolItem());
personnesBoutonModifier = creerBoutonModifier();
barreOutils.add(personnesBoutonModifier);
barreOutils.add(new SeparatorToolItem());
personnesBoutonSupprimer = creerBoutonSupprimer();
barreOutils.add(personnesBoutonSupprimer);
barreOutils.add(new SeparatorToolItem());
Button rafraichirBouton = creerBoutonRafraichir();
barreOutils.add(rafraichirBouton);
barreOutils.add(new SeparatorToolItem());
barreOutils.add(new Text(i18nC.deplacerAuteur()));
boutonAuteurUp = creerBoutonAuteurUp();
barreOutils.add(boutonAuteurUp);
boutonAuteurDown = creerBoutonAuteurDown();
barreOutils.add(boutonAuteurDown);
return barreOutils;
}
public void actualiserEtatBoutonsBarreOutils() {
// Activation des boutons si la grille contient un élément
if (grilleAuteurs.getStore().getCount() > 0) {
personnesBoutonSupprimer.enable();
personnesBoutonModifier.enable();
}
// Désactivation des boutons si la grille ne contient plus d'élément
if (grilleAuteurs.getStore().getCount() == 0) {
personnesBoutonSupprimer.disable();
personnesBoutonModifier.disable();
}
}
private Button creerBoutonAuteurUp() {
Button bouton = new Button();
bouton.setIcon(Images.ICONES.arrowUp());
bouton.setEnabled(false);
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
if (grilleAuteurs.getGrille().getSelectionModel().getSelectedItem() != null) {
mettreAJourOrdreAuteur(-1);
}
}
});
return bouton;
}
private Button creerBoutonAuteurDown() {
Button bouton = new Button();
bouton.setIcon(Images.ICONES.arrowDown());
bouton.setEnabled(false);
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
if (grilleAuteurs.getSelectionModel().getSelectedItem() != null) {
mettreAJourOrdreAuteur(+1);
}
}
});
return bouton;
}
private void formaterOrdreAuteurs() {
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
Iterator<ModelData> itAuteurs = auteurs.iterator();
while (itAuteurs.hasNext()) {
ModelData selection = itAuteurs.next();
PublicationAPersonne pap = new PublicationAPersonne(selection, false);
String ordre = String.valueOf(grilleAuteurs.getStore().indexOf(selection) + 1);
if (pap.getOrdreAuteurs() != ordre) {
selection.set("_ordre_", ordre);
grilleAuteurs.getStore().update(selection);
pap.setOrdreAuteurs(ordre);
auteursModifies.put(pap.getId(), pap);
}
}
}
private void mettreAJourOrdreAuteur(int monterOuDescendre) {
ModelData publiAPersonneSelectionnee = grilleAuteurs.getSelectionModel().getSelectedItem();
int index = grilleAuteurs.getStore().indexOf(publiAPersonneSelectionnee);
int nouvelIndex = index + monterOuDescendre;
if (verifierOrdreAuteur(nouvelIndex)) {
// le marqueur suivant est obligatoire sinon les évènements liés au magasin se
// déclenchent et posent problème
changeOrderMarker = true;
int indexAPermuter = index + monterOuDescendre;
ModelData publiAPersonneSwitch = grilleAuteurs.getStore().getAt(indexAPermuter);
String ordreAPermuter = String.valueOf((indexAPermuter + 1) - monterOuDescendre);
publiAPersonneSwitch.set("_ordre_", ordreAPermuter);
grilleAuteurs.getStore().update(publiAPersonneSwitch);
PublicationAPersonne papSwitch = new PublicationAPersonne(publiAPersonneSwitch, false);
papSwitch.setOrdreAuteurs(ordreAPermuter);
auteursModifies.put(papSwitch.getId(), papSwitch);
 
grilleAuteurs.getStore().remove(publiAPersonneSelectionnee);
String nouvelOrdre = String.valueOf((index + 1) + monterOuDescendre);
publiAPersonneSelectionnee.set("_ordre_", nouvelOrdre);
grilleAuteurs.getStore().insert(publiAPersonneSelectionnee, nouvelIndex);
PublicationAPersonne papSelectionnee = new PublicationAPersonne(publiAPersonneSelectionnee, false);
papSelectionnee.setOrdreAuteurs(nouvelOrdre);
auteursModifies.put(papSelectionnee.getId(), papSelectionnee);
changeOrderMarker = false;
grilleAuteurs.getSelectionModel().select(nouvelIndex, false);
}
}
private boolean verifierOrdreAuteur(int nouvelIndex) {
int nbrElement = grilleAuteurs.getStore().getCount();
boolean ok = true;
if (nouvelIndex < 0 || nouvelIndex >= nbrElement) {
ok = false;
}
return ok;
}
private void activerBoutonsOrdreAuteur() {
ModelData papSelectionnee = grilleAuteurs.getGrille().getSelectionModel().getSelectedItem();
int index = grilleAuteurs.getStore().indexOf(papSelectionnee);
if (index >= 1) {
boutonAuteurUp.setEnabled(true);
} else {
boutonAuteurUp.setEnabled(false);
}
if ((index+1) < grilleAuteurs.getStore().getCount()) {
boutonAuteurDown.setEnabled(true);
} else {
boutonAuteurDown.setEnabled(false);
}
}
private Button creerBoutonAjouter() {
Button bouton = new Button(i18nC.ajouter());
bouton.setIcon(Images.ICONES.vcardAjouter());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
fenetreFormulaire.show();
}
});
return bouton;
}
private Button creerBoutonModifier() {
Button bouton = new Button(i18nC.modifier());
bouton.setIcon(Images.ICONES.vcardModifier());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
if (personneSaisieSelectionnee == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
} else {
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
fenetreFormulaire.show();
}
}
});
return bouton;
}
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
String personneId = null;
if (mode.equals(Formulaire.MODE_MODIFIER)) {
Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
personneId = personneSaisieSelectionnee.getId();
}
final FenetreForm fenetre = new FenetreForm("");
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
fenetre.add(formulaire);
return fenetre;
}
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
panneauFormulaire.setHeaderVisible(false);
panneauFormulaire.setTopComponent(null);
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
panneauFormulaire.getBottomComponent().hide();
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
fenetre.setBottomComponent(barreValidation);
return formulairePersonne;
}
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String code = ((Button) ce.getComponent()).getData("code");
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
if (formulaire.soumettreFormulaire()) {
fenetre.hide();
}
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
formulaire.soumettreFormulaire();
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
fenetre.hide();
}
}
};
return ecouteur;
}
private Button creerBoutonSupprimer() {
Button bouton = new Button(i18nC.supprimer());
bouton.setIcon(Images.ICONES.vcardSupprimer());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
supprimerDansGrille();
}
});
return bouton;
}
private Button creerBoutonRafraichir() {
Button bouton = new Button(i18nC.rafraichir());
bouton.setIcon(Images.ICONES.rafraichir());
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
actualiserGrille();
}
});
return bouton;
}
private void actualiserGrille() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
// FIXME : c'est la merde
grilleAuteurs.reload();
} else {
grilleAuteurs.getStore().removeAll();
layout();
}
}
private void creerComboBoxPersonnesSaisies() {
ModelType modelTypePersonnes = new ModelType();
modelTypePersonnes.setRoot("personnes");
modelTypePersonnes.setTotalName("nbElements");
modelTypePersonnes.addField("cp_fmt_nom_complet");
modelTypePersonnes.addField("cp_nom");
modelTypePersonnes.addField("cp_prenom");
modelTypePersonnes.addField("cp_id_personne");
modelTypePersonnes.addField("cp_code_postal");
modelTypePersonnes.addField("cp_ville");
modelTypePersonnes.addField("cp_truk_courriel");
String displayNamePersonnes = "cp_fmt_nom_complet";
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
personnesSaisiesComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
personnesSaisiesComboBox.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
if (personnesSaisiesComboBox.getValeur() instanceof ModelData) {
// N'ajouter l'auteur que s'il n'est pas déjà présent dans la grille et dans les valeurs initiales
Personne personneSaisieSelectionnee = new Personne(personnesSaisiesComboBox.getValeur());
Log.debug("Récupération info combo :"+personneSaisieSelectionnee.toString());
PublicationAPersonne pap = new PublicationAPersonne(aDonnee.GARDER_PREFIXE);
pap.setPersonne(personneSaisieSelectionnee, aDonnee.INTEGRER_PROPRIETES);
pap.setOrdreAuteurs(String.valueOf(grilleAuteurs.getStore().getCount()+1));
if (modeDeCreation != Formulaire.MODE_AJOUTER) {
pap.setPublicationLiee(publication);
pap.setIdPublication(publicationId);
}
pap.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
Log.debug("Récupération info combo pap id :"+pap.getId());
if (ajouterDansGrille(pap)) {
personnesSaisiesComboBox.getCombo().setValue(null);
}
}
}
});
}
private boolean ajouterDansGrille(PublicationAPersonne pap) {
return ajouterDansGrille(pap, grilleAuteurs.getStore().getCount());
}
private boolean ajouterDansGrille(PublicationAPersonne pap, int index) {
boolean ok = false;
if (pap != null) {
Log.debug("Début ajout dans grille :"+pap.toString());
if (grilleAuteurs.getStore().contains((ModelData) pap)) {
InfoLogger.display("Information", "La personne choisie existe déjà dans la liste d'auteurs.");
} else {
// 1) si elle ne fait pas partie des initiaux, ajouter à la liste à ajouter
if (!auteursInitialListe.containsValue(pap)) {
auteursAjoutes.put(pap.getId(), pap);
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été ajouté à la liste des ajoutés (il ne fait pas parti de la liste initiale).");
}
// L'enlever de la liste à supprimer
if (auteursSupprimes.containsValue(pap)) {
auteursSupprimes.remove(pap);
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été retiré de la liste des supprimés.");
}
// 2) Ajouter a la grille
grilleAuteurs.getStore().insert((ModelData) pap, index);
grilleAuteurs.getSelectionModel().select(index, false);
ok = true;
}
}
return ok;
}
private void supprimerDansGrille() {
List<ModelData> listeDonneesSelectionnees = grilleAuteurs.getSelectionModel().getSelectedItems();
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
supprimerAuteurDansGrille(donneeSelectionnee);
}
}
private void supprimerAuteurDansGrille(ModelData donneeSelectionnee) {
PublicationAPersonne personneSelectionnee = new PublicationAPersonne(donneeSelectionnee, aDonnee.GARDER_PREFIXE);
Log.debug("Début supprimer auteur dans grille : "+personneSelectionnee.toString());
if (personneSelectionnee.getId() == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerAuteur());
} else {
// 1) Ajouter a la liste des personne à supprimer uniquement si est présente dans la liste initiale
if (auteursInitialListe.containsKey(personneSelectionnee.getId())) {
auteursSupprimes.put(personneSelectionnee.getId(), personneSelectionnee);
Log.debug("Ajout Personne à supprimer : "+auteursSupprimes.toString());
}
if (auteursAjoutes.containsKey(personneSelectionnee.getId())) {
auteursAjoutes.remove(personneSelectionnee.getId());
}
if (auteursModifies.containsKey(personneSelectionnee.getId())) {
auteursModifies.remove(personneSelectionnee.getId());
}
// 2) Supprimer la personne de la liste
Log.debug("Personne trouvée : "+grilleAuteurs.getStore().findModel(donneeSelectionnee).toString());
grilleAuteurs.getStore().remove(donneeSelectionnee);
formaterOrdreAuteurs();
}
}
private GrillePaginable<ModelData> creerGrilleAuteurs() {
// ModelType
ModelType modelTypePersonnesAPublication = new ModelType();
modelTypePersonnesAPublication.setRoot("publicationsAPersonne");
modelTypePersonnesAPublication.setTotalName("nbElements");
modelTypePersonnesAPublication.addField("cpuap_id_personne");
modelTypePersonnesAPublication.addField("cpuap_id_publication");
modelTypePersonnesAPublication.addField("cpuap_id_role");
modelTypePersonnesAPublication.addField("cpuap_ordre");
modelTypePersonnesAPublication.addField("cp_id_personne");
modelTypePersonnesAPublication.addField("cp_fmt_nom_complet");
modelTypePersonnesAPublication.addField("cp_nom");
modelTypePersonnesAPublication.addField("cp_prenom");
modelTypePersonnesAPublication.addField("cp_id_personne");
modelTypePersonnesAPublication.addField("cp_code_postal");
modelTypePersonnesAPublication.addField("cp_ville");
modelTypePersonnesAPublication.addField("cp_truk_courriel");
// Proxy
ProxyPersonnesAPublication<ModelData> proxyPersonnesAPublication = new ProxyPersonnesAPublication<ModelData>(null, publicationId);
 
// Colonnes
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
ColumnConfig columnOrdre = new ColumnConfig("_ordre_", i18nC.ordre(), 15);
colonnes.add(columnOrdre);
colonnes.add(new ColumnConfig("cp_fmt_nom_complet", i18nC.personneNomComplet(), 150));
colonnes.add(new ColumnConfig("cp_code_postal", i18nC.personneCodePostal(), 150));
colonnes.add(new ColumnConfig("cp_ville", i18nC.personneVille(), 75));
colonnes.add(new ColumnConfig("cp_truk_courriel", i18nC.personneCourriel(), 75));
// Champs de traitement
HashMap<String, String> virtualFields = new HashMap<String, String>();
virtualFields.put("_ordre_", "cpuap_ordre");
// Modele de selection
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
modeleDeSelection.addListener(Events.SelectionChange, new SelectionChangedListener<ModelData>() {
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
activerBoutonsOrdreAuteur();
}
});
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
// Grille
// ATTENTION : le constructure de cette grille est à vérifier!
final GrillePaginable<ModelData> grilleAuteurs = new GrillePaginable<ModelData>(modelTypePersonnesAPublication, virtualFields, proxyPersonnesAPublication, colonnes, modeleDeColonnes);
grilleAuteurs.getGrille().setHeight("100%");
grilleAuteurs.getGrille().setBorders(true);
grilleAuteurs.getGrille().setSelectionModel(modeleDeSelection);
grilleAuteurs.getGrille().getView().setForceFit(true);
grilleAuteurs.getGrille().setAutoExpandColumn("fmt_nom_complet");
grilleAuteurs.getGrille().setStripeRows(true);
grilleAuteurs.getGrille().setTrackMouseOver(true);
grilleAuteurs.getStore().getLoader().addListener(Loader.Load, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
Iterator<ModelData> itAuteurs = auteurs.iterator();
while (itAuteurs.hasNext()) {
ModelData selection = itAuteurs.next();
PublicationAPersonne pap = new PublicationAPersonne(selection, aDonnee.GARDER_PREFIXE);
auteursInitialListe.put(pap.getId(), pap);
Log.debug("PublicationAPersonne ajoutée à la liste initiale avec l'id :"+pap.getId()+pap.toString()+selection.getProperties().toString());
}
controlerCoherenceAuteurs();
//zefgzf
Log.debug("Initialisation liste auteur :"+auteursInitialListe.size());
}
});
// Rajouter des écouteurs
grilleAuteurs.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
if (!changeOrderMarker) {
actualiserEtatBoutonsBarreOutils();
}
}
});
grilleAuteurs.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
if (!changeOrderMarker) {
actualiserEtatBoutonsBarreOutils();
Log.debug("Dans listener remove de grilleAuteur");
}
}
});
grilleAuteurs.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
public void handleEvent(StoreEvent<ModelData> ce) {
}
});
return grilleAuteurs;
}
private void genererTitreFormulaire() {
String titre = i18nC.publicationTitreFormAjout();
if (mode.equals(Formulaire.MODE_MODIFIER)) {
titre = i18nC.publicationTitreFormModif();
if (publication != null) {
titre += " - "+i18nC.id()+": "+publication.getId()+" - "+publication.getTitre();
}
}
panneauFormulaire.setHeadingHtml(titre);
}
 
private void creerZoneAuteurs() {
auteursFieldset = new ContentPanel();
auteursFieldset.setLayout(new FitLayout());
auteursFieldset.setHeadingHtml("Auteurs");
creerChampsAuteur();
}
private void creerChampsAuteur() {
auteursFieldset.removeAll();
barreOutils = creerBarreOutilsGrille();
auteursFieldset.setTopComponent(barreOutils);
grilleAuteurs = creerGrilleAuteurs();
auteursFieldset.add(grilleAuteurs);
auteursFieldset.layout();
}
private void creerZoneGeneralites() {
FormLayout layout = new FormLayout();
layout.setLabelWidth(200);
// Fieldset Infos Générales
generalitesFieldset = new FieldSet();
generalitesFieldset.setHeadingHtml("Informations générales");
generalitesFieldset.setCollapsible(true);
generalitesFieldset.setLayout(layout);
infosAuteursNonPresentsPanel = new ContentPanel();
Label LabelAuteurFmt = new Label("Auteurs de la publication : ");
LabelAuteurFmt.setId("label-auteurs-non-presents");
infosAuteurFmt = new Label(publication.getAuteur());
Label avertissementAuteurs = new Label("Attention, Certains auteurs apparaissent ci-dessous mais pas dans la grille des auteurs. "+
"Ceci signifie que la publication a été importée sans que tous les auteurs aient été créés auparavant.<br />"+
"Si vous souhaitez modifier cette publication, nous vous invitons à y associer correctement les auteurs grâce à la grille ci-dessus.<br />");
infosAuteursNonPresentsPanel.setHeaderVisible(false);
infosAuteursNonPresentsPanel.setId("infos-auteurs-non-presents");
infosAuteursNonPresentsPanel.add(avertissementAuteurs);
infosAuteursNonPresentsPanel.add(LabelAuteurFmt);
infosAuteursNonPresentsPanel.add(infosAuteurFmt);
infosAuteursNonPresentsPanel.setVisible(false);
generalitesFieldset.add(infosAuteursNonPresentsPanel);
titreChp = new TextField<String>();
titreChp.setName("cpu");
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
generalitesFieldset.add(titreChp, new FormData(450, 0));
collectionChp = new TextField<String>();
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
generalitesFieldset.add(collectionChp, new FormData(450, 0));
uriChp = new TextField<String>();
uriChp.setFieldLabel("URL de la publication");
generalitesFieldset.add(uriChp, new FormData(450, 0));
}
private void creerZoneEdition() {
FormLayout layout = new FormLayout();
layout.setLabelWidth(200);
 
// Fieldset Edition
editionFieldset = new FieldSet();
editionFieldset.setHeadingHtml("Édition");
editionFieldset.setCollapsible(true);
editionFieldset.setLayout(layout);
/*****************************************************/
/** Champ 'Editeur de la publication' **/
/*****************************************************/
ModelType modelTypeStructures = new ModelType();
modelTypeStructures.setRoot("structures");
modelTypeStructures.setTotalName("nbElements");
modelTypeStructures.addField("cs_nom");
modelTypeStructures.addField("cs_id_structure");
String displayNameStructures = "cs_nom";
ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(null);
editeurCombobox = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
editeurCombobox.setWidth(200, 600);
editeurCombobox.getCombo().setTabIndex(tabIndex++);
editeurCombobox.getCombo().setEmptyText("Sélectionner un éditeur...");
editeurCombobox.getCombo().setFieldLabel("Éditeur de la publication");
editeurCombobox.getCombo().setEditable(true);
editionFieldset.add(editeurCombobox, new FormData(600, 0));
/*********************************************/
/** Champ 'Date de publication' **/
/*********************************************/
datePublicationChp = new TextField<String>();
datePublicationChp.setMaxLength(9);
datePublicationChp.setMinLength(4);
datePublicationChp.setFieldLabel("Année de publication");
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
editionFieldset.add(datePublicationChp, new FormData(80, 0));
/*********************************/
/** Champ 'Tome' **/
/*********************************/
tomeChp = new TextField<String>();
tomeChp.setFieldLabel("Série de la revue ou tome");
editionFieldset.add(tomeChp, new FormData(75, 0));
 
/*************************************/
/** Champ 'Fascicule' **/
/*************************************/
fasciculeChp = new TextField<String>();
fasciculeChp.setFieldLabel("Fascicule de la revue");
editionFieldset.add(fasciculeChp, new FormData(75, 0));
 
/*********************************/
/** Champ 'Pages' **/
/*********************************/
pagesChp = new TextField<String>();
pagesChp.setFieldLabel("Pages");
pagesChp.setToolTip("Fomat : NBRE ou NBRE-NBRE. ('NBRE' correspond à une suite de chiffres arabes ou romains ou à un point d'interrogation '?' dans le cas d'une donnée inconnue)");
editionFieldset.add(pagesChp, new FormData(100, 0));
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes privées
private void miseAJourAuteursInitialListe() {
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
while (clesAjoutees.hasNext()) {
PublicationAPersonne auteurAjoute = auteursAjoutes.get(clesAjoutees.next());
auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
}
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
while (clesSupprimees.hasNext()) {
PublicationAPersonne auteurSupprime = auteursSupprimes.get(clesSupprimees.next());
auteursInitialListe.remove(auteurSupprime.getId());
}
}
public boolean soumettreFormulaire() {
boolean formulaireValideOk = verifierFormulaire();
if (formulaireValideOk) {
soumettrePublication();
}
if(clicBoutonvalidation) {
fermerFormulaire();
}
return formulaireValideOk;
}
 
private void soumettrePublication() {
Publication publicationCollectee = collecterPublication();
if (publicationCollectee != null) {
// Pour l'enregistrement des publications, on utilise le séquenceur
// Il doit attendre le retour de l'enregistrement pour poursuivre
sequenceur = new Sequenceur();
int seqId = sequenceur.lancerRequeteSynchrone(this);
if (mode.equals(Formulaire.MODE_AJOUTER)) {
mediateur.ajouterPublication(sequenceur, publicationCollectee, seqId);
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.modifierPublication(sequenceur, publicationCollectee, seqId);
}
// si l'on est en mode MODIFIER, on soumet les auteurs meme si les informations de la publication
// restent inchangées car il se peut que les auteurs aient été modifiés
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
soumettreAuteurs();
if(clicBoutonvalidation) {
fermerFormulaire();
}
}
}
private void soumettreAuteurs() {
//1) Auteurs ajoutés :
PublicationAPersonneListe listeAuteursAAjouter = new PublicationAPersonneListe();
Iterator<String> itAuteur = auteursAjoutes.keySet().iterator();
while (itAuteur.hasNext()) {
String cle = itAuteur.next();
PublicationAPersonne publiAPersonne = auteursAjoutes.get(cle);
Log.debug("Ajouter :"+publiAPersonne.toString());
publiAPersonne.setIdPublication(this.publicationId);
publiAPersonne.setOrdreAuteurs(publiAPersonne.getOrdreAuteurs());
listeAuteursAAjouter.put(cle, publiAPersonne);
}
// - envoyer au mediateur SSI personnes à ajouter
if (listeAuteursAAjouter.size() > 0) {
int seqId = sequenceur.lancerRequeteSynchrone(this);
mediateur.ajouterPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAAjouter, PublicationAPersonne.ROLE_AUTEUR, seqId);
}
//2) Auteurs supprimés :
PublicationAPersonneListe listeAuteursASupprimer = new PublicationAPersonneListe();
itAuteur = auteursSupprimes.keySet().iterator();
while (itAuteur.hasNext()) {
String cle = itAuteur.next();
PublicationAPersonne publiAPersonne = auteursSupprimes.get(cle);
Log.debug("Supprimer :"+publiAPersonne.toString());
listeAuteursASupprimer.put(cle, publiAPersonne);
}
// - Envoyer au médiateur SSI personnes à supprimer
if (listeAuteursASupprimer.size() > 0) {
// Pour une suppression des auteurs, on a pas besoin d'attendre le retour
Log.debug("Lancement suppression :"+listeAuteursASupprimer.size());
mediateur.supprimerPublicationAPersonne(this, listeAuteursASupprimer);
}
//3) Auteurs modifiés :
PublicationAPersonneListe listeAuteursAModifier = new PublicationAPersonneListe();
itAuteur = auteursModifies.keySet().iterator();
while (itAuteur.hasNext()) {
String cle = itAuteur.next();
PublicationAPersonne publiAPersonne = auteursModifies.get(cle);
Log.debug("Modifier :"+publiAPersonne.toString());
listeAuteursAModifier.put(cle, publiAPersonne);
}
// - Envoyer au médiateur SSI personnes à modifier
if (listeAuteursAModifier.size() > 0) {
int seqId = sequenceur.lancerRequeteSynchrone(this);
mediateur.modifierPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAModifier, PublicationAPersonne.ROLE_AUTEUR, seqId);
}
sequenceur.enfilerRafraichissement(this, new Information("auteurs_enregistres"));
}
private void peuplerFormulaire() {
titreChp.setValue(publication.getTitre());
collectionChp.setValue(publication.getCollection());
uriChp.setValue(publication.getURI());
datePublicationChp.setValue(publication.getAnneeParution());
tomeChp.setValue(publication.getIndicationNvt());
fasciculeChp.setValue(publication.getFascicule());
pagesChp.setValue(publication.getPages());
// Éditeur est soit une référence à une structure de la base soit une chaine
if (publication.getEditeur().matches("^[0-9]+$")) {
//editeurCombobox.getCombo().setValue(editeurCombobox.getStore().findModel("cs_id_structure", publication.getEditeur()));
editeurCombobox.chargerValeurInitiale(publication.getEditeur(), "cs_id_structure");
} else {
editeurCombobox.getCombo().setRawValue(publication.getEditeur());
}
}
private Publication collecterPublication() {
 
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
publicationCollectee.setAuteur(construireIntituleAuteur());
String titre = titreChp.getValue();
publicationCollectee.setTitre(titre);
String collection = collectionChp.getValue();
publicationCollectee.setCollection(collection);
publicationCollectee.setNomComplet(construireNomComplet());
String uri = uriChp.getValue();
publicationCollectee.setUri(uri);
String editeur = "";
if (editeurCombobox.getValeur() != null) {
Structure structure = new Structure(editeurCombobox.getValeur());
editeur = structure.getId();
publicationCollectee.setStructureEditeur(structure);
} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
editeur = editeurCombobox.getCombo().getRawValue();
}
Publication.editeurs.put(editeur, editeurCombobox.getCombo().getRawValue());
publicationCollectee.setEditeur(editeur);
String anneePublication = datePublicationChp.getRawValue();
publicationCollectee.setAnneeParution(anneePublication);
String tome = tomeChp.getValue();
publicationCollectee.setIndicationNvt(tome);
String fascicule = fasciculeChp.getValue();
publicationCollectee.setFascicule(fascicule);
String pages = pagesChp.getValue();
publicationCollectee.setPages(pages);
Publication publicationARetourner = null;
if (!publicationCollectee.comparer(publication)) {
publicationARetourner = publication = publicationCollectee;
}
Publication.publisSaisiesModifieesCache.put(publicationId, publicationARetourner);
return publicationARetourner;
}
private String construireDate(String valeurDate) {
String dateComplete = "";
if (!UtilString.isEmpty(valeurDate)){
String jour = "00";
String mois = "00";
String annee = "0000";
String messageErreur = null;
/** JJ/MM/AAAA **/
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
}
/** MM/AAAA **/
if (valeurDate.matches("\\d{2}/\\d{4}")) {
dateComplete = valeurDate+"-00";
}
/** AAAA **/
if (valeurDate.matches("\\d{4}")) {
dateComplete = valeurDate+"-00-00";
}
}
return dateComplete;
}
private String construireIntituleEditeur() {
String editeur = "";
if (editeurCombobox.getValeur() != null) {
Structure structure = new Structure(editeurCombobox.getValeur());
editeur = structure.getNom();
} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
editeur = editeurCombobox.getCombo().getRawValue();
}
return editeur;
}
private String construireIntituleAuteur() {
String intituleAuteur = "";
// rangé par ordre désigné par le champ 'cpuap_ordre' de la table PublicationAPersonne
grilleAuteurs.getStore().sort("_ordre_", SortDir.ASC);
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
Iterator<ModelData> itAuteurs = auteurs.iterator();
while (itAuteurs.hasNext()) {
Personne personneCourante = new PublicationAPersonne(itAuteurs.next(), false).getPersonne();
intituleAuteur += personneCourante.getNom().toUpperCase() + " " + personneCourante.getPrenom();
if (itAuteurs.hasNext()) {
intituleAuteur+=", ";
}
}
return intituleAuteur;
}
private String construireNomComplet() {
// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
String nomComplet = "";
String auteurs = construireIntituleAuteur();
String annee = datePublicationChp.getRawValue();
String titre = titreChp.getValue();
String editeur = construireIntituleEditeur();
nomComplet += auteurs+", "+annee+". "+titre+".";
if (!UtilString.isEmpty(editeur)) {
nomComplet += " Éditeur "+editeur+".";
}
if (collectionChp.getValue() != null) {
String revue = collectionChp.getValue();
nomComplet += ", "+revue;
}
if (fasciculeChp.getValue() != null) {
String fascicule = fasciculeChp.getValue();
nomComplet += ", "+fascicule;
}
if (tomeChp.getValue() != null) {
String tomaison = tomeChp.getValue();
nomComplet += ", "+tomaison;
}
if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
nomComplet += ".";
}
if (pagesChp.getValue() != null) {
String pages = pagesChp.getValue();
nomComplet += pages+".";
}
return nomComplet;
}
public void controlerCoherenceAuteurs() {
if(doitAfficherAvertissementAuteur()) {
infosAuteurFmt.setHtml(publication.getAuteur());
infosAuteursNonPresentsPanel.setVisible(true);
infosAuteursNonPresentsPanel.setHeight(50);
} else {
infosAuteursNonPresentsPanel.setVisible(false);
infosAuteursNonPresentsPanel.setHeight(0);
}
}
private boolean doitAfficherAvertissementAuteur() {
// La construction du fmt nom complet des auteurs étant mal fichue
// il est plus simple de comparer le nombre d'item une fois les chaines
// splittées par virgules, ainsi que le nombre d'espace
String auteurFmtreconstruit = construireIntituleAuteur();
String[] auteurFmtreconstruitParts = auteurFmtreconstruit.split(",");
String[] auteurParts = publication.getAuteur().split(",");
String[] auteurFmtreconstruitSpaces = auteurFmtreconstruit.split(" ");
String[] auteurPartsSpaces = publication.getAuteur().split(" ");
boolean unEstVideEtAutreNon = (auteurFmtreconstruit.trim().isEmpty() != publication.getAuteur().isEmpty());
return (modeDeCreation == MODE_MODIFIER &&
(unEstVideEtAutreNon ||
auteurFmtreconstruitParts.length != auteurParts.length ||
auteurFmtreconstruitSpaces.length != auteurPartsSpaces.length));
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes publiques
public boolean verifierFormulaire() {
boolean valide = true;
ArrayList<String> messages = new ArrayList<String>();
// Tester si au moins un auteur est présent
if (grilleAuteurs.getStore().getModels().size() == 0) {
messages.add("Veuillez saisir au moins un auteur.");
}
String titre = titreChp.getValue();
if (titre == null || titre.equals("")) {
messages.add("Veuillez saisir le titre de la publication !");
}
String uri = uriChp.getValue();
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
messages.add("L'URL saisie n'est pas valide !");
}
String datePublication = datePublicationChp.getRawValue();
if (datePublication == null || datePublication.equals("")) {
messages.add("Veuillez saisir une année de parution !");
} else {
if (!Publication.etreAnneeParutionValide(datePublication)) {
messages.add("Le format de l'année saisie est incorrect ! Formats acceptés : AAAA ou AAAA-AAAA");
}
}
String pages = pagesChp.getValue();
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
messages.add("Le format des pages est incorrect !");
}
if (messages.size() != 0) {
String[] tableauDeMessages = {};
tableauDeMessages = messages.toArray(tableauDeMessages);
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
valide = false;
}
return valide;
}
//+----------------------------------------------------------------------------------------------------------------+
// Accesseurs
//+----------------------------------------------------------------------------------------------------------------+
// Rafraichir
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Publication) {
publication = (Publication) nouvellesDonnees;
} else if (nouvellesDonnees instanceof Information) {
rafraichirInformation((Information) nouvellesDonnees);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
private void rafraichirInformation(Information info) {
String type = info.getType();
if (type.equals("auteurs_enregistres")) {
miseAJourAuteursInitialListe();
initialiserAuteurs();
repandreRafraichissement();
controlerFermeture();
} else if (type.equals("chargement_modifier_ok")) {
Debug.log("Chargement 1");
peuplerFormulaire();
genererTitreFormulaire();
}
 
if (type.equals("personne_ajoutee")) {
if (info.getDonnee(0) != null) {
Personne personne = (Personne) info.getDonnee(0);
personne = formaterChampPersonnePourGrille(personne);
PublicationAPersonne pap = new PublicationAPersonne(personne, false);
if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
ajouterDansGrille(pap);
}
} else if (type.equals("personne_modifiee")) {
if (info.getDonnee(0) != null) {
// créer la nouvelle entrée
Personne personne = (Personne) info.getDonnee(0);
PublicationAPersonne pap = new PublicationAPersonne();
pap.setPersonne(personne);
if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
// supprimer l'entrée précédente
PublicationAPersonne personneDansGrille = new PublicationAPersonne(grilleAuteurs.getStore().findModel("cp_id_personne", personne.getId()), false);
int index = grilleAuteurs.getStore().indexOf(personneDansGrille);
grilleAuteurs.getStore().remove(personneDansGrille);
if(index != -1) {
// ajouter la nouvelle entrée dans la grille
ajouterDansGrille(pap, index);
} else {
ajouterDansGrille(pap);
}
}
} else if (info.getType().equals("modif_publication")) {
InfoLogger.display("Modification d'une publication", info.toString());
soumettreAuteurs();
} else if (info.getType().equals("ajout_publication")) {
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String && ((String) info.getDonnee(0)).matches("[0-9]+")) {
String idPublication = (String) info.getDonnee(0);
this.publicationId = idPublication;
this.publication.setId(idPublication);
soumettreAuteurs();
InfoLogger.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
} else {
InfoLogger.display("Ajout d'une publication", info.toString());
}
} else if (info.getType().equals("suppression_publication_a_personne")) {
InfoLogger.display("Suppression d'auteur", info.getMessages().toString());
}
}
private Personne formaterChampPersonnePourGrille(Personne personne) {
personne.set("cp_id_personne", personne.getId());
personne.set("cp_fmt_nom_complet", personne.getNomComplet());
personne.set("cp_fmt_nom_complet", personne.getNomComplet());
personne.set("cpuap_id_personne", personne.getId());
personne.set("cp_code_postal", personne.get("code_postal"));
personne.set("cp_ville", personne.get("ville"));
personne.set("cp_truk_courriel", personne.getCourriel());
personne.set("cpuap_ordre", grilleAuteurs.getStore().getCount());
personne.set("cp_nom", personne.getNom());
personne.set("cp_prenom", personne.getPrenom());
return personne;
}
private void repandreRafraichissement() {
if (vueExterneARafraichirApresValidation != null) {
String type = "publication_modifiee";
if (mode.equals(Formulaire.MODE_AJOUTER)) {
type = "publication_ajoutee";
}
Information info = new Information(type);
info.setDonnee(0, publication);
vueExterneARafraichirApresValidation.rafraichir(info);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationForm.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/publication/PublicationForm.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/publication/PublicationForm.java:r1383-1511
Added: svn:executable
+*
\ No newline at end of property
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/publication/PublicationImportForm.java
New file
0,0 → 1,112
package org.tela_botanica.client.vues.publication;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAsyncDao;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.Callback;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.VerticalPanel;
 
public abstract class PublicationImportForm extends LayoutContainer {
 
private Mediateur mediateurCourant = null;
 
public PublicationImportForm(Mediateur mediateurCourant) {
this.mediateurCourant= mediateurCourant;
final FormPanel form = new FormPanel();
form.setAction(PublicationAsyncDao.getUrlImport());
 
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);
 
FileUpload upload = new FileUpload();
upload.setName("import_publication");
panel.add(upload);
Hidden typeUpload = new Hidden("type", "publication");
Hidden utilisateur = new Hidden("ce_utilisateur", ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId());
panel.add(typeUpload);
panel.add(utilisateur);
 
HorizontalPanel boutonsPanel = new HorizontalPanel();
boutonsPanel.add(new Button(Mediateur.i18nC.importer(), new ClickHandler() {
public void onClick(ClickEvent event) {
form.submit();
}
}));
boutonsPanel.add(new Button(Mediateur.i18nC.annuler(), new ClickHandler() {
public void onClick(ClickEvent event) {
surClicAnnuler();
}
}));
 
form.addSubmitHandler(new FormPanel.SubmitHandler() {
@Override
public void onSubmit(SubmitEvent event) {
surSoumissionFormulaire(event);
}
});
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
String resultat = event.getResults();
// Le formulaire est envoyé à travers un iframe caché, ce qui pose problème
// à certains navigateurs pour lire le retour
// si rien n'est renvoyé, on demande les stats d'upload au service par une autre requête
if(resultat == null || resultat.isEmpty()) {
PublicationAsyncDao.demanderStatistiquesDernierImport(new Callback<JSONValue, String>() {
@Override
public void onSuccess(JSONValue result) {
surFormulaireEnvoye(result);
}
@Override
public void onFailure(String reason) {
// TODO Auto-generated method stub
}
});
} else {
JSONValue responseValue = JSONParser.parseStrict(resultat);
surFormulaireEnvoye(responseValue);
}
}
});
Html indicationImportForm = new Html("<div id=\"indication_import_csv\"><a target=\"_blank\" href=\"documents/import_publications.csv\">"+Mediateur.i18nC.telechargerModeleImportPubli()+"</a><br />");
add(indicationImportForm);
add(form);
add(boutonsPanel);
}
public abstract void surSoumissionFormulaire(SubmitEvent event);
public abstract void surFormulaireEnvoye(JSONValue reponse);
public abstract void surClicAnnuler();
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/publication/PublicationVue.java
New file
0,0 → 1,55
package org.tela_botanica.client.vues.publication;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.modeles.publication.PublicationListe;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.core.client.GWT;
 
public class PublicationVue extends LayoutContainer implements Rafraichissable {
private Mediateur mediateur = null;
private PublicationListeVue panneauPublicationListe;
private PublicationDetailVue panneauPublicationDetail;
public PublicationVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
BorderLayout layout = new BorderLayout();
layout.setEnableState(false);
setLayout(layout);
 
panneauPublicationListe = new PublicationListeVue(mediateur);
add(panneauPublicationListe, new BorderLayoutData(LayoutRegion.CENTER));
 
panneauPublicationDetail = new PublicationDetailVue(mediateur);
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000);
southData.setSplit(true);
southData.setMargins(new Margins(5, 0, 0, 0));
add(panneauPublicationDetail, southData);
setId(ComposantId.PANNEAU_PUBLICATION_LISTE);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Publication) {
panneauPublicationDetail.rafraichir(nouvellesDonnees);
} else if (nouvellesDonnees instanceof PublicationListe) {
panneauPublicationListe.rafraichir(nouvellesDonnees);
mediateur.desactiverChargement(this);
} else if (nouvellesDonnees instanceof Information) {
panneauPublicationListe.rafraichir(nouvellesDonnees);
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/publication/PublicationVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/publication/PublicationVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/publication/PublicationListeVue.java
New file
0,0 → 1,277
package org.tela_botanica.client.vues.publication;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.ChampFiltreRecherche;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.modeles.publication.Publication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.modeles.publication.PublicationListe;
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;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
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.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.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 PublicationListeVue extends ContentPanel implements Rafraichissable {
 
private Mediateur mediateur = null;
private Constantes i18nC = null;
 
private Grid<Publication> grille = null;
private ListStore<Publication> store = null;
private ColumnModel modeleDesColonnes = null;
 
private Button ajouter;
private Button modifier;
private Button supprimer;
private Button importer;
private ChampFiltreRecherche champFiltreRecherche = null;
private BarrePaginationVue pagination = null;
private int indexElementSelectionne = 0;
private Publication publicationSelectionnee = null;
public PublicationListeVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
setLayout(new FitLayout());
setHeaderVisible(false);
// Gestion de la barre d'outil
ToolBar toolBar = new ToolBar();
ajouter = new Button(i18nC.ajouter());
ajouter.setIcon(Images.ICONES.ajouter());
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
mediateur.clicAjouterPublication();
}
});
ajouter.setToolTip(i18nC.indicationCreerUneFiche()+" "+i18nC.publicationSingulier());
toolBar.add(ajouter);
 
modifier = new Button(i18nC.modifier());
modifier.setIcon(Images.ICONES.formModifier());
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
mediateur.clicModifierPublication(grille.getSelectionModel().getSelectedItems());
}
});
modifier.setToolTip(i18nC.indicationModifierUneFiche());
toolBar.add(modifier);
supprimer = new Button(i18nC.supprimer());
supprimer.setIcon(Images.ICONES.supprimer());
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
mediateur.clicSupprimerPublication(grille.getSelectionModel().getSelectedItems());
}
});
supprimer.setToolTip(i18nC.indicationSupprimerUneFiche());
toolBar.add(supprimer);
setTopComponent(toolBar);
 
// Gestion de la grille
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
colonnes.add(new ColumnConfig("fmt_auteur", i18nC.publicationAuteurs(), 200));
colonnes.add(new ColumnConfig("titre", i18nC.publicationTitre(), 150));
colonnes.add(new ColumnConfig("collection", i18nC.publicationRevueCollection(), 110));
colonnes.add(creerColonneEditeur());
colonnes.add(creerColonneAnneePublication());
colonnes.add(new ColumnConfig("indication_nvt", i18nC.publicationNvt(), 35));
colonnes.add(new ColumnConfig("fascicule", i18nC.publicationFascicule(), 35));
colonnes.add(new ColumnConfig("truk_pages", i18nC.publicationPage(), 35));
modeleDesColonnes = new ColumnModel(colonnes);
 
GridSelectionModel<Publication> modeleDeSelection = new GridSelectionModel<Publication>();
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Publication>() {
public void selectionChanged(SelectionChangedEvent<Publication> event) {
publicationSelectionnee = (Publication) event.getSelectedItem();
indexElementSelectionne = store.indexOf(publicationSelectionnee);
clicListe(publicationSelectionnee);
}
});
store = new ListStore<Publication>();
store.sort("titre", SortDir.ASC);
grille = new Grid<Publication>(store, modeleDesColonnes);
grille.setWidth("100%");
grille.setAutoExpandColumn("titre");
grille.getView().setAutoFill(true);
grille.getView().setForceFit(true);
grille.setSelectionModel(modeleDeSelection);
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
grille.getSelectionModel().select(0, false);
}
});
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be) {
modifier.fireEvent(Events.Select);
}
});
add(grille);
PublicationListe publicationListe = new PublicationListe();
champFiltreRecherche = new ChampFiltreRecherche(mediateurCourant, toolBar, publicationListe);
importer = new Button(i18nC.importer());
importer.setIcon(Images.ICONES.importerCsv());
importer.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
if(mediateur.getUtilisateur().isIdentifie()) {
mediateur.clicImporterPublication(PublicationListeVue.this);
} else {
Window.alert(i18nC.identificationNecessaire());
}
}
});
importer.setToolTip(i18nC.indicationImporterUnePubli());
toolBar.add(importer);
// Définition de la barre de pagination
pagination = new BarrePaginationVue(publicationListe, mediateur, champFiltreRecherche);
setBottomComponent(pagination);
}
private ColumnConfig creerColonneEditeur() {
GridCellRenderer<Publication> editeurRendu = new GridCellRenderer<Publication>() {
public String render(Publication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Publication> store, Grid<Publication> grid) {
String editeur = model.getNomEditeur();
model.set("_editeur_", editeur);
return editeur;
}
};
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", i18nC.publicationEditeur(), 135);
editeurColonne.setRenderer(editeurRendu);
return editeurColonne;
}
private ColumnConfig creerColonneAnneePublication() {
GridCellRenderer<Publication> datePublicationRendu = new GridCellRenderer<Publication>() {
public String render(Publication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Publication> store, Grid<Publication> grid) {
String annee = model.getAnneeParution();
model.set("_annee_", annee);
return annee;
}
};
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", i18nC.publicationDateParution(), 75);
datePublicationColonne.setRenderer(datePublicationRendu);
return datePublicationColonne;
}
private void clicListe(Publication publication) {
if (publication != null && store.getCount() > 0) {
mediateur.clicListePublication(publication);
}
}
 
private void gererEtatActivationBouton() {
int nbreElementDuMagazin = store.getCount();
ajouter.enable();
if (nbreElementDuMagazin <= 0) {
supprimer.disable();
modifier.disable();
} else if (nbreElementDuMagazin > 0) {
modifier.enable();
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
supprimer.enable();
}
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof PublicationListe) {
PublicationListe publications = (PublicationListe) nouvellesDonnees;
champFiltreRecherche.setListePaginable(publications);
pagination.setlistePaginable(publications);
pagination.rafraichir(publications.getPageTable());
if (publications != null) {
List<Publication> liste = publications.toList();
store.removeAll();
store.add(liste);
mediateur.actualiserPanneauCentral();
}
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
gererEtatActivationBouton();
} else if (info.getType().equals("publication_modifiee")) {
if(publicationSelectionnee != null) {
store.remove(indexElementSelectionne);
publicationSelectionnee = null;
}
Publication publiModifee = (Publication)info.getDonnee(0);
// au cas ou le bouton appliquer aurait été cliqué avant de valider
store.remove(publiModifee);
store.insert(publiModifee, indexElementSelectionne);
publicationSelectionnee = publiModifee;
int indexElementSelectionne = store.indexOf(publicationSelectionnee);
grille.getSelectionModel().select(indexElementSelectionne, false);
grille.getView().focusRow(indexElementSelectionne);
clicListe(publicationSelectionnee);
} else if (info.getType().equals("suppression_publication")) {
InfoLogger.display(i18nC.publicationTitreSuppression(), info.getMessages().toString());
supprimerPublicationsSelectionnees();
gererEtatActivationBouton();
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
layout();
}
 
private void supprimerPublicationsSelectionnees() {
List<Publication> publicationsSelectionnees = grille.getSelectionModel().getSelectedItems();
Iterator<Publication> it = publicationsSelectionnees.iterator();
while (it.hasNext()) {
grille.getStore().remove(it.next());
}
layout(true);
}
public void afficherDernierePage() {
pagination.allerALaDernierePage();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationListeVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/publication/PublicationListeVue.java:r11-934,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/publication/PublicationListeVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/publication
New file
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/publication:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication:r1136-1291
Merged /trunk/src/org/tela_botanica/client/vues/publication:r11-934,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/ContenuVue.java
New file
0,0 → 1,70
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.collection.CollectionListe;
import org.tela_botanica.client.modeles.commentaire.CommentaireListe;
import org.tela_botanica.client.modeles.personne.PersonneListe;
import org.tela_botanica.client.modeles.publication.PublicationListe;
import org.tela_botanica.client.modeles.structure.StructureListe;
 
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
 
public class ContenuVue extends LayoutContainer implements Rafraichissable {
private Mediateur mediateur = null;
public ContenuVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
setLayout(new FitLayout());
setBorders(true);
}
public Rafraichissable getContenu() {
Rafraichissable contenuPanneauCentre = null;
if (getItems() != null && getItems().size() == 1) {
contenuPanneauCentre = (Rafraichissable) getItem(0);
}
return contenuPanneauCentre;
}
 
//+----------------------------------------------------------------------------------------------------------------+
// RAFRAICHISSEMENT
//+----------------------------------------------------------------------------------------------------------------+
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof StructureListe) {
mediateur.afficherListeStructures((StructureListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof CollectionListe) {
mediateur.afficherListeCollections((CollectionListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof PersonneListe) {
mediateur.afficherListePersonnes((PersonneListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof PublicationListe) {
mediateur.afficherListePublication((PublicationListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof CommentaireListe) {
mediateur.afficherListeCommentaire((CommentaireListe) nouvellesDonnees);
} else if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
if (getContenu() != null) {
getContenu().rafraichir(info);
}
} else {
// Affichage des éventuels messages de déboguage ou d'alerte
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
GWT.log(info.getMessages().toString(), null);
}
// Traitement en fonction des types d'information
if (info.getType().equals("liste_personne")) {
mediateur.afficherListePersonnes((PersonneListe) info.getDonnee(0));
InfoLogger.display("Chargement d'une liste de personnes", "");
}
}
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/ContenuVue.java:r11-443,923-935,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/ContenuVue.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/ContenuVue.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/FormulaireBarreValidation.java
New file
0,0 → 1,78
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.images.Images;
 
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
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.toolbar.FillToolItem;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
 
public class FormulaireBarreValidation extends ButtonBar {
private SelectionListener<ButtonEvent> ecouteur = null;
public static final String CODE_BOUTON_VALIDER = "VA";
public static final String CODE_BOUTON_APPLIQUER = "AP";
public static final String CODE_BOUTON_ANNULER = "AN";
public FormulaireBarreValidation(SelectionListener<ButtonEvent> ecouteurCourrant) {
ecouteur = ecouteurCourrant;
creerBarreOutilsValidation();
}
private void creerBarreOutilsValidation() {
this.setAlignment(HorizontalAlignment.LEFT);
this.add(new FillToolItem());
Button appliquer = creerBouton(CODE_BOUTON_APPLIQUER);
this.add(appliquer);
appliquer.setToolTip(Mediateur.i18nC.indicationAppliquer());
Button annuler = creerBouton(CODE_BOUTON_ANNULER);
annuler.setToolTip(Mediateur.i18nC.indicationAnnuler());
this.add(annuler);
Button valider = creerBouton(CODE_BOUTON_VALIDER);
valider.setToolTip(Mediateur.i18nC.indicationValider());
this.add(valider);
}
private Button creerBouton(final String code) {
String nom = getNom(code);
Button bouton = new Button(nom);
bouton.setData("code", code);
bouton.setIcon(getIcone(code));
bouton.addSelectionListener(ecouteur);
return bouton;
}
private AbstractImagePrototype getIcone(final String code) {
AbstractImagePrototype icone = null;
if (code.equals(CODE_BOUTON_VALIDER)) {
icone = Images.ICONES.valider();
} else if (code.equals(CODE_BOUTON_APPLIQUER)) {
icone = Images.ICONES.appliquer();
} else if (code.equals(CODE_BOUTON_ANNULER)) {
icone = Images.ICONES.annuler();
}
return icone;
}
private String getNom(final String code) {
String nom = null;
if (code.equals(CODE_BOUTON_VALIDER)) {
nom = Mediateur.i18nC.valider();
} else if (code.equals(CODE_BOUTON_APPLIQUER)) {
nom = Mediateur.i18nC.appliquer();
} else if (code.equals(CODE_BOUTON_ANNULER)) {
nom = Mediateur.i18nC.annuler();
}
return nom;
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/vues/FormulaireBarreValidation.java:r11-774,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/FormulaireBarreValidation.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/FormulaireBarreValidation.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/MenuHorizontalVue.java
New file
0,0 → 1,126
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.modeles.Menu;
import org.tela_botanica.client.modeles.MenuApplicationId;
 
import com.extjs.gxt.ui.client.Style.HideMode;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TabPanelEvent;
import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Document;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
 
 
public class MenuHorizontalVue extends ContentPanel {
private Mediateur mediateur = null;
private Constantes i18nC = null;
private TabPanel tbp = null;
public MenuHorizontalVue(Mediateur mediateurCourant) {
setId(ComposantId.PANNEAU_NAVIGATION);
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
setHeaderVisible(false);
// Ce tab Panel est un peu spécial car chaque onglet ne contient rien du tout
// ils ne servent qu'a être cliqués afin de déclencher une action de la part du médiateur
// ceci afin de pouvoir facilement changer d'avis si jamais on prend une autre forme de navigation
tbp = new TabPanel();
tbp.setId("ListeOngletsNavigation");
tbp.setWidth("100%");
TabItem tbAcc = new TabItem(i18nC.menuAccueil());
tbAcc.setBorders(false);
tbAcc.setId(MenuApplicationId.ACCUEIL);
tbAcc.setHeight(0);
TabItem tbIns = new TabItem(i18nC.menuStructure());
tbIns.setBorders(false);
tbIns.setId(MenuApplicationId.STRUCTURE);
tbIns.setHeight(0);
TabItem tbCol = new TabItem(i18nC.menuCollection());
tbCol.setBorders(false);
tbCol.setId(MenuApplicationId.COLLECTION);
tbCol.setHeight(0);
TabItem tbPer = new TabItem(i18nC.menuPersonne());
tbPer.setBorders(false);
tbPer.setId(MenuApplicationId.PERSONNE);
tbPer.setHeight(0);
TabItem tbPub = new TabItem(i18nC.menuPublication());
tbPub.setBorders(false);
tbPub.setId(MenuApplicationId.PUBLICATION);
tbPub.setHeight(0);
TabItem tbCom = new TabItem(i18nC.menuCommentaire());
tbCom.setBorders(false);
tbCom.setId(MenuApplicationId.COMMENTAIRE);
tbCom.setHeight(0);
TabItem tbStats = new TabItem(i18nC.menuStats());
tbStats.setBorders(false);
tbStats.setId(MenuApplicationId.STATS);
tbStats.setStyleAttribute("float", "right");
tbStats.setHeight(0);
tbp.add(tbAcc);
tbp.add(tbIns);
tbp.add(tbCol);
tbp.add(tbPer);
tbp.add(tbPub);
tbp.add(tbCom);
tbp.add(tbStats);
// Supression du conteneur vide de l'onglet (pour éviter un décalage de l'interface)
tbp.addListener(Events.BeforeSelect, new Listener<TabPanelEvent>() {
public void handleEvent(TabPanelEvent be) {
be.getItem().getElement().removeFromParent();
}
});
// interception de la selection afin de prévenir le médiateur pour qu'il charge
// le panneau central correspondant
tbp.addListener(Events.Select, new Listener<TabPanelEvent>() {
public void handleEvent(TabPanelEvent be) {
mediateur.clicMenu(be.getItem().getId());
}
});
// interception de la selection afin de prévenir le médiateur pour qu'il charge
// le panneau central correspondant
tbp.addListener(Events.Resize, new Listener<TabPanelEvent>() {
public void handleEvent(TabPanelEvent be) {
tbp.setWidth("100%");
}
});
this.add(tbp);
}
 
public void selectionMenu(String codeMenuClique) {
int nbTab = tbp.getItemCount();
for(int i = 0; i < nbTab; i++) {
if(tbp.getItem(i).getId().equals(codeMenuClique)) {
tbp.setSelection(tbp.getItem(i));
}
}
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/PopupChargement.java
New file
0,0 → 1,36
package org.tela_botanica.client.vues;
 
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
 
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PopupPanel;
 
public class PopupChargement extends PopupPanel{
private Mediateur mediateur = null;
private Constantes i18nC = null;
public PopupChargement(Mediateur mediateurCourrant) {
super();
mediateur = mediateurCourrant;
i18nC = mediateur.i18nC;
LayoutContainer cp = new LayoutContainer();
cp.setLayout(new TableLayout(2));
 
Image imageChargement = Images.ICONES.ajaxLoader().createImage();
cp.add(imageChargement);
Text texteChargement = new Text(i18nC.chargement());
cp.add(texteChargement);
add(cp);
center();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/PopupChargement.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/PopupChargement.java:r11-334,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/PopupChargement.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/EnteteVue.java
New file
0,0 → 1,241
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.i18n.ErrorMessages;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Utilisateur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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.button.SplitButton;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.google.gwt.user.client.Window;
 
public class EnteteVue extends LayoutContainer implements Rafraichissable {
 
private Mediateur mediateur = null;
private Constantes i18nC = null;
private ErrorMessages i18nM = null;
 
private String identificationInfoTpl = null;
private String titreTpl = null;
private HtmlContainer conteneurHtml = null;
private SelectionListener<ButtonEvent> boutonEcouteur = null;
private ButtonBar barreBoutons = null;
private Button identificationBouton = null;
//private SplitButton feedbackBouton = null;
private Button contactBouton = null;
private SplitButton aideBouton = null;
private SplitButton applisBouton = null;
 
public EnteteVue(Mediateur mediateurCourant) {
mediateur = mediateurCourant;
i18nC = Mediateur.i18nC;
i18nM = Mediateur.i18nM;
setId(ComposantId.PANNEAU_ENTETE);
setLayout(new RowLayout(Orientation.HORIZONTAL));
initialiserSquelettes();
boutonEcouteur = getEcouteurDesBoutons();
conteneurHtml = getIdentification();
identificationBouton = getBoutonIdentification();
//feedbackBouton = getBoutonAFeedback();
contactBouton = getBoutonContact();
aideBouton = getBoutonAide();
applisBouton = getBoutonApplications();
barreBoutons = new ButtonBar();
barreBoutons.setAlignment(Style.HorizontalAlignment.RIGHT);
barreBoutons.add(conteneurHtml);
barreBoutons.add(identificationBouton);
barreBoutons.add(aideBouton);
//barreBoutons.add(feedbackBouton);
barreBoutons.add(contactBouton);
barreBoutons.add(applisBouton);
add(getTitre(), new RowData(.20, 1));
add(barreBoutons, new RowData(.8, 1));
}
private void initialiserSquelettes() {
identificationInfoTpl = "<div id='"+ComposantId.DIV_IDENTIFICATION+"'>{0}</div>";
titreTpl = "<div id='"+ComposantId.DIV_TITRE+"'>{0}</div>";
}
private HtmlContainer getTitre() {
HtmlContainer titreConteneurHtml = new HtmlContainer();
titreConteneurHtml.setHtml(Format.substitute(titreTpl, Images.ICONES.logoCoel().getHTML()));//Registry.get(RegistreId.APPLI_NOM)));
return titreConteneurHtml;
}
private HtmlContainer getIdentification() {
HtmlContainer conteneurHtml = new HtmlContainer();
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
return conteneurHtml;
}
 
private SelectionListener<ButtonEvent> getEcouteurDesBoutons() {
SelectionListener<ButtonEvent> boutonEcouteur = new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
Button btn = (Button) be.getComponent();
String id = btn.getId();
String message = "";
if (id.equals(ComposantId.BTN_AIDE)
|| id.equals(ComposantId.BTN_FEEDBACK)
|| id.equals(ComposantId.BTN_APPLIS)) {
btn.showMenu();
} else if (id.equals(ComposantId.BTN_CONNEXION)) {
mediateur.ouvrirIdentification();
message = i18nM.chargementFenetre(btn.getHtml());
} else if (id.equals(ComposantId.BTN_DECONNEXION)) {
mediateur.deconnecterUtilisateur();
Utilisateur utilisateurCourant = mediateur.getUtilisateur();
message = i18nM.deconnexion(utilisateurCourant.getNomComplet());
} else if (id.equals(ComposantId.BTN_APPLIS)) {
btn.getMenu().show(btn);
}
if (!message.equals("")) {
InfoLogger.display(i18nC.chargement(), message);
}
}
};
return boutonEcouteur;
}
 
private Button getBoutonIdentification() {
Button bouton = new Button(i18nC.identification(), boutonEcouteur);
bouton.setId(ComposantId.BTN_CONNEXION);
return bouton;
}
 
private SplitButton getBoutonAide() {
MenuItem menuDoc = new MenuItem(i18nC.doc());
menuDoc.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent mEvent) {
mediateur.ouvrirAide();
}
});
menuDoc.setId(ComposantId.MENU_DOC);
 
MenuItem menuApropos = new MenuItem(i18nC.apropos());
menuApropos.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent mEvent) {
mediateur.ouvrirParametres();
}
});
menuApropos.setId(ComposantId.MENU_APROPOS);
 
MenuItem fenetreJournal = new MenuItem("Journal de l'application");
fenetreJournal.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent mEvent) {
//Menu me = (Menu) mEvent.getComponent();
//MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE);
//InfoLogger.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getHtml()));
mediateur.ouvrirFenetreJournal();
}
});
 
Menu menuAide = new Menu();
menuAide.add(menuDoc);
menuAide.add(menuApropos);
menuAide.add(fenetreJournal);
 
SplitButton boutonAvecMenus = new SplitButton(i18nC.aide());
boutonAvecMenus.setId(ComposantId.BTN_AIDE);
boutonAvecMenus.setIcon(Images.ICONES.aide());
boutonAvecMenus.addSelectionListener(boutonEcouteur);
boutonAvecMenus.setMenu(menuAide);
return boutonAvecMenus;
}
 
private Button getBoutonContact() {
Button menuContact = new Button(i18nC.contact());
menuContact.setId(ComposantId.MENU_CONTACT);
menuContact.addListener(Events.OnClick, new Listener<ButtonEvent>() {
@Override
public void handleEvent(ButtonEvent mEvent) {
mediateur.ouvrirUrlExterne(ComposantId.MENU_CONTACT);
}
});
menuContact.setId(ComposantId.MENU_CONTACT);
menuContact.setIcon(Images.ICONES.flecheDedansDehors());
 
return menuContact;
}
 
private SplitButton getBoutonApplications() {
MenuItem menuCel = new MenuItem(i18nC.cel());
menuCel.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent mEvent) {
Menu me = (Menu) mEvent.getComponent();
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL);
InfoLogger.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getHtml()));
mediateur.ouvrirUrlExterne(ComposantId.MENU_CEL);
}
});
menuCel.setId(ComposantId.MENU_CEL);
 
Menu menu = new Menu();
menu.add(menuCel);
 
SplitButton boutonAvecMenus = new SplitButton(i18nC.applicationExterne());
boutonAvecMenus.setId(ComposantId.BTN_APPLIS);
boutonAvecMenus.addSelectionListener(boutonEcouteur);
boutonAvecMenus.setMenu(menu);
boutonAvecMenus.setIcon(Images.ICONES.flecheBascule());
 
return boutonAvecMenus;
}
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
Utilisateur utilisateur = mediateur.getUtilisateur();
if (utilisateur.isIdentifie()) {
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.bienvenue()+utilisateur.getNomComplet())));
identificationBouton.setText(i18nC.deconnexion());
identificationBouton.setIcon(Images.ICONES.deconnexion());
identificationBouton.setId(ComposantId.BTN_DECONNEXION);
} else {
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme())));
identificationBouton.setText(i18nC.identification());
identificationBouton.setIcon(Images.ICONES.connexion());
identificationBouton.setId(ComposantId.BTN_CONNEXION);
}
}
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
layout();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/EnteteVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/EnteteVue.java:r11-443,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/EnteteVue.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/vues/StatutVue.java
New file
0,0 → 1,91
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.WidgetListener;
import com.extjs.gxt.ui.client.widget.InfoConfig;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Status;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
 
public class StatutVue extends LayoutContainer {
private Status barreStatut = null;
private Button messageErreur = null;
private Status messages = null;
private int nbErreursNonLues = 0;
public StatutVue() {
setLayout(new FitLayout());
setId(ComposantId.PANNEAU_STATUT);
 
ToolBar toolBar = new ToolBar();
barreStatut = new Status();
toolBar.add(barreStatut);
toolBar.add(new FillToolItem());
messages = new Status();
toolBar.add(messages);
messageErreur = new Button();
messageErreur.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
reinitialiserNonLue();
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).ouvrirFenetreJournal();
}
});
toolBar.add(messageErreur);
Status version = new Status();
String infoVersionAppli = Registry.get(RegistreId.APPLI_CODE)+" v"+Registry.get(RegistreId.APPLI_VERSION)+" - "+Registry.get(RegistreId.APPLI_VERSION_NOM);
version.setText(infoVersionAppli);
toolBar.add(version);
add(toolBar);
}
public void showBusy(String message) {
barreStatut.setBusy(message);
}
public void clear() {
barreStatut.clearStatus("");
}
public void afficherMessage(InfoConfig info) {
messages.setText(info.titleHtml +" - " + info.html);
}
 
public void afficherErreur() {
nbErreursNonLues++;
String labelErreur = " erreur";
if (nbErreursNonLues > 1) {
labelErreur+="s";
}
messageErreur.setText("<b style=\"color:red\">" + nbErreursNonLues + labelErreur + "</b>");
}
public void reinitialiserNonLue() {
nbErreursNonLues = 0;
messageErreur.setText("");
messageErreur.setVisible(false);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/StatutVue.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/vues/StatutVue.java:r11-442,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/StatutVue.java:r1383-1511