Rev 444 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.vues;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.i18n.Constantes;import org.tela_botanica.client.interfaces.Rafraichissable;import org.tela_botanica.client.modeles.Configuration;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.Personne;import org.tela_botanica.client.modeles.PersonneListe;import org.tela_botanica.client.modeles.Projet;import org.tela_botanica.client.modeles.ProjetListe;import org.tela_botanica.client.modeles.Structure;import org.tela_botanica.client.modeles.StructureAPersonne;import org.tela_botanica.client.modeles.StructureAPersonneListe;import org.tela_botanica.client.modeles.StructureConservation;import org.tela_botanica.client.modeles.StructureValorisation;import org.tela_botanica.client.modeles.Valeur;import org.tela_botanica.client.modeles.ValeurListe;import org.tela_botanica.client.util.UtilArray;import com.extjs.gxt.ui.client.Events;import com.extjs.gxt.ui.client.Registry;import com.extjs.gxt.ui.client.Style.HorizontalAlignment;import com.extjs.gxt.ui.client.Style.Scroll;import com.extjs.gxt.ui.client.event.BaseEvent;import com.extjs.gxt.ui.client.event.ComponentEvent;import com.extjs.gxt.ui.client.event.GridEvent;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.ToolBarEvent;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.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.FormPanel;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.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.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.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.tips.ToolTipConfig;import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem;import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;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;public class StructureForm extends LayoutContainer implements Rafraichissable {public static final String MODE_AJOUTER = "AJOUT";public static final String MODE_MODIFIER = "MODIF";private Constantes i18nC = null;private Mediateur mediateur = null;private String mode = null;private int tabIndex = 100;private FormPanel structureFormPanneau = null;private TabPanel onglets = null;private TabItem identificationOnglet = null;private TabItem personnelOnglet = null;private TabItem conservationOnglet = null;private TabItem valorisationOnglet = null;private HiddenField<String> idStructureChp = null;// Onglet IDENTIFICATIONprivate Structure identification;private ListStore<Valeur> magazinLstpr = null;private ComboBox<Valeur> comboLstpr = null;private ListStore<Valeur> magazinLstpu = null;private ComboBox<Valeur> comboLstpu = null;private ListStore<Valeur> magazinLiStatut = null;private ComboBox<Valeur> comboLiStatut = null;private ListStore<Valeur> fonctionsMagazin = null;private ComboBox<Valeur> fonctionsCombo = null;private ComboBox<InterneValeur> comboAcronyme = null;private TextField<String> ihChp = null;private TextField<String> mnhnChp = null;private ComboBox<InterneValeur> comboTypeStructure = null;private TextField<String> nomStructureChp;private DateField dateFondationChp;private TextArea adrChp;private TextField<String> cpChp;private TextField<String> villeChp;private TextField<String> regionChp;private TextField<String> telChp;private TextField<String> faxChp;private TextField<String> emailChp;private TextField<String> urlChp;private ListStore<Valeur> magazinPays;private ComboBox<Valeur> comboPays;// Onglet PERSONNELprivate StructureAPersonneListe personnel;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;// Onglet CONSERVATIONprivate StructureConservation conservation = null;private RadioGroup formationMarkRGrpChp;private RadioGroup interetFormationMarkRGrpChp;private RadioGroup collectionCommuneMarkRGrpChp;private RadioGroup accesControleMarkRGrpChp;private RadioGroup restaurationMarkRGrpChp;private RadioGroup traitementMarkRGrpChp;private RadioGroup collectionAcquisitionMarkRGrpChp;private RadioGroup echantillonAcquisitionMarkRGrpChp;private TextField<String> localStockageAutreChp;private TextField<String> meubleStockageAutreChp;private TextField<String> parametreStockageAutreChp;private TextField<String> collectionAutreAutreChp;private TextField<String> autreCollectionAutreChp;private TextField<String> opRestauAutreChp;private TextField<String> autreMaterielAutreChp;private TextField<String> poisonTraitementAutreChp;private TextField<String> traitementAutreChp;private TextField<String> insecteTraitementAutreChp;private TextField<String> actionAutreChp;private TextField<String> provenanceRechercheAutreChp;private TextField<String> typeRechercheAutreChp;private CheckBoxGroup localStockageTrukCacGrpChp = null;private ContentPanel localStockageTrukCp = null;private CheckBoxGroup meubleStockageTrukCacGrpChp = null;private ContentPanel meubleStockageTrukCp = null;private CheckBoxGroup parametreStockageTrukCacGrpChp = null;private ContentPanel parametreStockageTrukCp = null;private ContentPanel collectionAutreTrukCp = null;private CheckBoxGroup collectionAutreTrukCacGrpChp = null;private CheckBoxGroup opRestauTrukCacGrpChp = null;private ContentPanel opRestauTrukCp = null;private CheckBoxGroup autreMaterielTrukCacGrpChp = null;private ContentPanel autreMaterielTrukCp = null;private ContentPanel traitementTrukCp = null;private CheckBoxGroup traitementTrukCacGrpChp = null;private ContentPanel poisonTraitementTrukCp = null;private ContentPanel insecteTraitementTrukCp = null;private CheckBoxGroup insecteTraitementTrukCacGrpChp = null;private CheckBoxGroup poisonTraitementTrukCacGrpChp = null;private ContentPanel autreCollectionTrukCp = null;private CheckBoxGroup autreCollectionTrukCacGrpChp = null;private ContentPanel provenanceRechercheTrukCp = null;private CheckBoxGroup provenanceRechercheTrukCacGrpChp = null;private CheckBoxGroup typeRechercheTrukCacGrpChp = null;private ContentPanel typeRechercheTrukCp = null;private TextField<String> futureActionChp = null;private TextField<String> sansMotifAccesChp = null;private TextField<String> avecMotifAccesChp = null;private TextField<String> formationChp = null;private RadioGroup traitementAcquisitionMarkRGrpChp = null;private LabelField traitementAcquisitionMarkLabel = null;private RadioGroup materielConservationCeRGrpChp = null;// Onglet VALORISATIONprivate StructureValorisation valorisation = null;private RadioGroup actionMarkRGrpChp = null;private ContentPanel actionTrukCp = null;private CheckBoxGroup actionTrukCacGrpChp = null;private RadioGroup futureActionMarkRGrpChp;private RadioGroup rechercheMarkRGrpChp;private RadioGroup sansMotifAccesMarkRGrpChp;private RadioGroup avecMotifAccesMarkRGrpChp;private TextField<String> publicationChp;private ContentPanel materielConservationCp;private ListStore<Personne> personneExistanteMagazin;private ComboBox<Personne> personneExistanteCombo;private TextToolItem supprimerPersonnelBtn;private ListStore<Projet> projetsMagazin;private ComboBox<Projet> projetsCombo;private CellEditor fonctionEditor;private List<Valeur> fonctionsListe;public StructureForm(Mediateur mediateurCourrant, String modeDeCreation) {//+-----------------------------------------------------------------------------------------------------------+// Initialisation de variablesmode = modeDeCreation;mediateur = mediateurCourrant;i18nC = mediateur.i18nC;// Iniatilisation du layoutContainersetLayout(new FitLayout());setBorders(false);//+-----------------------------------------------------------------------------------------------------------+// Création du panneau du FORMULAIRE GÉNÉRALstructureFormPanneau = new FormPanel();structureFormPanneau.setBodyBorder(false);structureFormPanneau.setFrame(true);structureFormPanneau.setIconStyle("icone-form-ajouter");structureFormPanneau.setCollapsible(false);structureFormPanneau.setHeading(i18nC.titreAjoutFormStructurePanneau());structureFormPanneau.setButtonAlign(HorizontalAlignment.CENTER);structureFormPanneau.setLayout(new FlowLayout());//+-----------------------------------------------------------------------------------------------------------+// Création des ongletsonglets = 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 IDENTIFICATIONonglets.add(creerOngletIdentification());//+-----------------------------------------------------------------------------------------------------------+// Onlget formulaire PERSONNELonglets.add(creerOngletPersonnel());//+-----------------------------------------------------------------------------------------------------------+// Onlget formulaire CONSERVATIONonglets.add(creerOngletConservation());//+-----------------------------------------------------------------------------------------------------------+// Onlget formulaire VALORISATIONonglets.add(creerOngletValorisation());//+-----------------------------------------------------------------------------------------------------------+// Gestion du FORMULAIRE GÉNÉRAL// Sélection de l'onglet par défaut//onglets.setSelection(personnelOnglet);// Ajout des onglets au formulaire généralstructureFormPanneau.add(onglets);// Ajout des boutons au panneau formulaireButton annulerBtn = new Button("Annuler");annulerBtn.addSelectionListener(new SelectionListener<ComponentEvent>() {@Overridepublic void componentSelected(ComponentEvent ce) {mediateur.clicMenu(MenuApplicationId.STRUCTURE);}});structureFormPanneau.addButton(annulerBtn);Button validerBtn = new Button("Valider");validerBtn.addSelectionListener(new SelectionListener<ComponentEvent>() {@Overridepublic void componentSelected(ComponentEvent ce) {soumettreFormulaire();}});structureFormPanneau.addButton(validerBtn);// Ajout du panneau Formulaire à la disposition généraleadd(structureFormPanneau);}private void soumettreFormulaire() {// Vérification de la validité des champs du formulaireif (verifierFormulaire()) {GWT.log("Soumission du formulaire", null);// Collecte des données du formulaireStructure structure = collecterStructureIdentification();StructureConservation conservation = collecterStructureConservation();StructureValorisation valorisation = collecterStructureValorisation();collecterStructurePersonnel();if (mode.equals("AJOUT")) {// Ajout des informations sur la Structuremediateur.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("MODIF")) {// Modification des informations sur la Structureif (structure == null && conservation == null && valorisation == null) {Info.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");} else {mediateur.modifierStructure(this, identification.getId(), structure, conservation, valorisation);}if (personnelModifie.size() == 0 && personnelAjoute.size() == 0 && personnelSupprime.size() == 0) {Info.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");} else {if (personnelModifie.size() != 0) {mediateur.modifierStructureAPersonne(this, personnelModifie);}// Ajout des relations StructureAPersonneif (personnelAjoute.size() != 0) {mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute);}// Suppression des relations StructureAPersonneif (personnelSupprime.size() != 0) {mediateur.supprimerStructureAPersonne(this, personnelSupprime);}// Nous rechargeons la liste du PersonnelrafraichirPersonnel();}}}}private Boolean verifierFormulaire() {ArrayList<String> messages = new ArrayList<String>();// Vérification des infos sur le nom de la structureif ( (identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue() == null) ||(identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue().equals("")) ||(identificationOnglet.getData("acces").equals(false) && identification.getNom().equals(""))) {messages.add("Veuillez indiquez un nom à l'institution.");}// Vérification des infos sur le projet de la structureif ( (identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue() == null) ||(identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue().equals("")) ||(identificationOnglet.getData("acces").equals(false) && identification.getIdProjet().equals(""))) {messages.add("Veuillez sélectionner un projet pour l'institution.");}// Vérification du Personnelif (personnelOnglet.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);}}// Affichage des messages d'alerteif (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 StructureValorisation collecterStructureValorisation() {StructureValorisation valorisationARetourner = null;if (valorisationOnglet.getData("acces").equals(true)) {// Création de l'objetStructureValorisation valorisationCollectee = (StructureValorisation) valorisation.cloner(new StructureValorisation());// ACTIONif (actionMarkRGrpChp.getValue() != null) {valorisationCollectee.setAction(actionMarkRGrpChp.getValue().getValueAttribute());}// ACTION INFOvalorisationCollectee.setActionInfo(creerChaineDenormalisee(actionTrukCacGrpChp.getValues()));valorisationCollectee.setActionInfo("AUTRE", actionAutreChp.getValue());// PUBLICATIONvalorisationCollectee.setPublication(publicationChp.getValue());// COLLECTION AUTREvalorisationCollectee.setCollectionAutre(creerChaineDenormalisee(autreCollectionTrukCacGrpChp.getValues()));valorisationCollectee.setCollectionAutre("AUTRE", autreCollectionAutreChp.getValue());// ACTION FUTUREif (futureActionMarkRGrpChp.getValue() != null) {valorisationCollectee.setActionFuture(futureActionMarkRGrpChp.getValue().getValueAttribute());}// ACTION FUTURE INFOvalorisationCollectee.setActionFutureInfo(futureActionChp.getValue());// RECHERCHEif (rechercheMarkRGrpChp.getValue() != null) {valorisationCollectee.setRecherche(rechercheMarkRGrpChp.getValue().getValueAttribute());}// RECHERCHE PROVENANCEvalorisationCollectee.setRechercheProvenance(creerChaineDenormalisee(provenanceRechercheTrukCacGrpChp.getValues()));valorisationCollectee.setRechercheProvenance("AUTRE", provenanceRechercheAutreChp.getValue());// RECHERCHE TYPEvalorisationCollectee.setRechercheType(creerChaineDenormalisee(typeRechercheTrukCacGrpChp.getValues()));valorisationCollectee.setRechercheType("AUTRE", typeRechercheAutreChp.getValue());// ACCÈS SANS MOTIFif (sansMotifAccesMarkRGrpChp.getValue() != null) {valorisationCollectee.setAccesSansMotif(sansMotifAccesMarkRGrpChp.getValue().getValueAttribute());}// ACCÈS SANS MOTIF INFOvalorisationCollectee.setAccesSansMotifInfo(sansMotifAccesChp.getValue());// VISITE AVEC MOTIFif (avecMotifAccesMarkRGrpChp.getValue() != null) {valorisationCollectee.setVisiteAvecMotif(avecMotifAccesMarkRGrpChp.getValue().getValueAttribute());}// VISITE AVEC MOTIF INFOvalorisationCollectee.setVisiteAvecMotifInfo(avecMotifAccesChp.getValue());// Retour de l'objetif (!valorisationCollectee.comparer(valorisation)) {valorisationARetourner = valorisation = valorisationCollectee;}}return valorisationARetourner;}private void peuplerStructureValorisation() {if (valorisation != null && valorisationOnglet.getData("acces").equals(false)) {// ACTIONactionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1)).setValue(true);// ACTION INFOpeuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp);// PUBLICATIONpublicationChp.setValue(valorisation.getPublication());// COLLECTION AUTREpeuplerCasesACocher(valorisation.getCollectionAutre(), autreCollectionTrukCacGrpChp, autreCollectionAutreChp);// ACTION FUTUREfutureActionMarkRGrpChp.get((valorisation.getActionFuture().equals("1") ? 0 : 1)).setValue(true);// ACTION FUTURE INFOfutureActionChp.setValue(valorisation.getActionFutureInfo());// RECHERCHErechercheMarkRGrpChp.get((valorisation.getRecherche().equals("1") ? 0 : 1)).setValue(true);// RECHERCHE PROVENANCEpeuplerCasesACocher(valorisation.getRechercheProvenance(), provenanceRechercheTrukCacGrpChp, provenanceRechercheAutreChp);// RECHERCHE TYPEpeuplerCasesACocher(valorisation.getRechercheType(), typeRechercheTrukCacGrpChp, typeRechercheAutreChp);// ACCÈS SANS MOTIFsansMotifAccesMarkRGrpChp.get((valorisation.getAccesSansMotif().equals("1") ? 0 : 1)).setValue(true);// ACCÈS SANS MOTIF INFOsansMotifAccesChp.setValue(valorisation.getAccesSansMotifInfo());// VISITE AVEC MOTIFavecMotifAccesMarkRGrpChp.get((valorisation.getVisiteAvecMotif().equals("1") ? 0 : 1)).setValue(true);// VISITE AVEC MOTIF INFOavecMotifAccesChp.setValue(valorisation.getVisiteAvecMotifInfo());// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...valorisationOnglet.setData("acces", true);}}private StructureConservation collecterStructureConservation() {StructureConservation conservationARetourner = null;if (conservationOnglet.getData("acces").equals(true)) {// Création de l'objetStructureConservation conservationCollectee = (StructureConservation) conservation.cloner(new StructureConservation());// FORMATIONif (formationMarkRGrpChp.getValue() != null) {conservationCollectee.setFormation(formationMarkRGrpChp.getValue().getValueAttribute());}// FORMATION INFOconservationCollectee.setFormationInfo(formationChp.getValue());// FORMATION INTERETif (interetFormationMarkRGrpChp.getValue() != null) {conservationCollectee.setFormationInteret(interetFormationMarkRGrpChp.getValue().getValueAttribute());}// STOCKAGE LOCALconservationCollectee.setStockageLocal(creerChaineDenormalisee(localStockageTrukCacGrpChp.getValues()));conservationCollectee.setStockageLocal("AUTRE", localStockageAutreChp.getValue());// STOCKAGE MEUBLEconservationCollectee.setStockageMeuble(creerChaineDenormalisee(meubleStockageTrukCacGrpChp.getValues()));conservationCollectee.setStockageMeuble("AUTRE", meubleStockageAutreChp.getValue());// STOCKAGE PAREMETREconservationCollectee.setStockageParametre(creerChaineDenormalisee(parametreStockageTrukCacGrpChp.getValues()));conservationCollectee.setStockageParametre("AUTRE", parametreStockageAutreChp.getValue());// COLLECTION COMMUNEif (collectionCommuneMarkRGrpChp.getValue() != null) {conservationCollectee.setCollectionCommune(collectionCommuneMarkRGrpChp.getValue().getValueAttribute());}// COLLECTION AUTREconservationCollectee.setCollectionAutre(creerChaineDenormalisee(collectionAutreTrukCacGrpChp.getValues()));conservationCollectee.setCollectionAutre("AUTRE", collectionAutreAutreChp.getValue());// ACCÈS CONTROLÉif (accesControleMarkRGrpChp.getValue() != null) {conservationCollectee.setAccesControle(accesControleMarkRGrpChp.getValue().getValueAttribute());}// RESTAURATIONif (restaurationMarkRGrpChp.getValue() != null) {conservationCollectee.setRestauration(restaurationMarkRGrpChp.getValue().getValueAttribute());}// RESTAURATION OPÉRATIONconservationCollectee.setRestaurationOperation(creerChaineDenormalisee(opRestauTrukCacGrpChp.getValues()));conservationCollectee.setRestaurationOperation("AUTRE", opRestauAutreChp.getValue());// MATERIEL CONSERVATIONif (materielConservationCeRGrpChp.getValue() != null) {conservationCollectee.setMaterielConservation(materielConservationCeRGrpChp.getValue().getValueAttribute());// MATERIEL AUTREconservationCollectee.setMaterielAutre(creerChaineDenormalisee(autreMaterielTrukCacGrpChp.getValues()));conservationCollectee.setMaterielAutre("AUTRE", autreMaterielAutreChp.getValue());}// TRAITEMENTif (traitementMarkRGrpChp.getValue() != null) {conservationCollectee.setTraitement(traitementMarkRGrpChp.getValue().getValueAttribute());}// TRAIEMENTSconservationCollectee.setTraitements(creerChaineDenormalisee(traitementTrukCacGrpChp.getValues()));conservationCollectee.setTraitements("AUTRE", traitementAutreChp.getValue());// ACQUISITION COLLECTIONif (collectionAcquisitionMarkRGrpChp.getValue() != null) {conservationCollectee.setAcquisitionCollection(collectionAcquisitionMarkRGrpChp.getValue().getValueAttribute());}// ACQUISITION ECHANTILLONif (echantillonAcquisitionMarkRGrpChp.getValue() != null) {conservationCollectee.setAcquisitionEchantillon(echantillonAcquisitionMarkRGrpChp.getValue().getValueAttribute());}// ACQUISITION TRAITEMENTif (traitementAcquisitionMarkRGrpChp.getValue() != null) {conservationCollectee.setAcquisitionTraitement(traitementAcquisitionMarkRGrpChp.getValue().getValueAttribute());}// ACQUISITION TRAITEMENT POISONconservationCollectee.setAcquisitionTraitementPoison(creerChaineDenormalisee(poisonTraitementTrukCacGrpChp.getValues()));conservationCollectee.setAcquisitionTraitementPoison("AUTRE", poisonTraitementAutreChp.getValue());// ACQUISITION TRAITEMENT INSECTEconservationCollectee.setAcquisitionTraitementInsecte(creerChaineDenormalisee(insecteTraitementTrukCacGrpChp.getValues()));conservationCollectee.setAcquisitionTraitementInsecte("AUTRE", insecteTraitementAutreChp.getValue());// Retour de l'objetif (!conservationCollectee.comparer(conservation)) {conservationARetourner = conservation = conservationCollectee;}}return conservationARetourner;}private void peuplerStructureConservation() {if (conservation != null && conservationOnglet.getData("acces").equals(false)) {// FORMATION// Bouton oui, à toujours l'index 0 donc on teste en fonction...formationMarkRGrpChp.get((conservation.getFormation().equals("1") ? 0 : 1)).setValue(true);// FORMATION INFOformationChp.setValue(conservation.getFormationInfo());// FORMATION INTERETinteretFormationMarkRGrpChp.get((conservation.getFormationInteret().equals("1") ? 0 : 1)).setValue(true);// STOCKAGE LOCALpeuplerCasesACocher(conservation.getStockageLocal(), localStockageTrukCacGrpChp,localStockageAutreChp);// STOCKAGE MEUBLEpeuplerCasesACocher(conservation.getStockageMeuble(), meubleStockageTrukCacGrpChp, meubleStockageAutreChp);// STOCKAGE PAREMETREpeuplerCasesACocher(conservation.getStockageParametre(), parametreStockageTrukCacGrpChp, parametreStockageAutreChp);// COLLECTION COMMUNEcollectionCommuneMarkRGrpChp.get((conservation.getCollectionCommune().equals("1") ? 0 : 1)).setValue(true);// COLLECTION AUTREpeuplerCasesACocher(conservation.getCollectionAutre(), collectionAutreTrukCacGrpChp, collectionAutreAutreChp);// ACCÈS CONTROLÉaccesControleMarkRGrpChp.get((conservation.getAccesControle().equals("1") ? 0 : 1)).setValue(true);// RESTAURATIONrestaurationMarkRGrpChp.get((conservation.getRestauration().equals("1") ? 0 : 1)).setValue(true);// RESTAURATION OPÉRATIONpeuplerCasesACocher(conservation.getRestaurationOperation(), opRestauTrukCacGrpChp, opRestauAutreChp);// MATERIEL CONSERVATIONpeuplerBoutonsRadio(conservation.getMaterielConservation(), materielConservationCeRGrpChp);// MATERIEL AUTREpeuplerCasesACocher(conservation.getMaterielAutre(), autreMaterielTrukCacGrpChp, autreMaterielAutreChp);// TRAITEMENTtraitementMarkRGrpChp.get((conservation.getTraitement().equals("1") ? 0 : 1)).setValue(true);// TRAITEMENTSpeuplerCasesACocher(conservation.getTraitements(), traitementTrukCacGrpChp, traitementAutreChp);// ACQUISITION COLLECTIONcollectionAcquisitionMarkRGrpChp.get((conservation.getAcquisitionCollection().equals("1") ? 0 : 1)).setValue(true);// ACQUISITION ECHANTILLONechantillonAcquisitionMarkRGrpChp.get((conservation.getAcquisitionEchantillon().equals("1") ? 0 : 1)).setValue(true);// ACQUISITION TRAITEMENTtraitementAcquisitionMarkRGrpChp.get((conservation.getAcquisitionTraitement().equals("1") ? 0 : 1)).setValue(true);// ACQUISITION TRAITEMENT POISONpeuplerCasesACocher(conservation.getAcquisitionTraitementPoison(), poisonTraitementTrukCacGrpChp, poisonTraitementAutreChp);// ACQUISITION TRAITEMENT INSECTEpeuplerCasesACocher(conservation.getAcquisitionTraitementInsecte(), insecteTraitementTrukCacGrpChp, insecteTraitementAutreChp);// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...conservationOnglet.setData("acces", true);}}private Structure collecterStructureIdentification() {Structure structureARetourner = null;if (identificationOnglet.getData("acces").equals(true)) {Structure structureCollectee = (Structure) identification.cloner(new Structure());structureCollectee.setId(idStructureChp.getValue());structureCollectee.setNom(nomStructureChp.getValue());// Récupération de l'identifiant du projetif (projetsCombo.getValue() != null) {structureCollectee.setIdProjet(projetsCombo.getValue().getId());}// 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 structurestructureCollectee.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());}}structureCollectee.setDateFondation(dateFondationChp.getValue());structureCollectee.setAdresse(adrChp.getValue());structureCollectee.setCodePostal(cpChp.getValue());structureCollectee.setVille(villeChp.getValue());structureCollectee.setRegion(regionChp.getValue());structureCollectee.setPays(null);if (comboPays.getValue() != null) {structureCollectee.setPays(comboPays.getValue().getId());} else if (comboPays.getRawValue() != "") {structureCollectee.setPays(comboPays.getRawValue());}structureCollectee.setTelephone(telChp.getValue());structureCollectee.setFax(faxChp.getValue());structureCollectee.setCourriel(emailChp.getValue());structureCollectee.setUrl(Structure.URL_SITE, urlChp.getValue());if (nbreTotalPersonneStructureChp.getValue() != null) {structureCollectee.setNbrePersonne(nbreTotalPersonneStructureChp.getValue().intValue());}if (!structureCollectee.comparer(identification)) {structureARetourner = identification = structureCollectee;}}return structureARetourner;}private void peuplerStructureIdentification() {if (mode.equals(MODE_AJOUTER)) {// Indique que l'ongleta pu être modifié pour la méthode collecter...identificationOnglet.setData("acces", true);// Initialisation de l'objet Structureidentification = new Structure();// Indication du projet sélectionné par défautString projetCourantId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getProjetId();if (projetCourantId != null && !projetCourantId.equals("0")) {projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", projetCourantId));}}if (mode.equals(MODE_MODIFIER) && identification != null && identificationOnglet.getData("acces").equals(false)) {idStructureChp.setValue(identification.getId());nomStructureChp.setValue(identification.getNom());if (!identification.getIdProjet().equals("0")) {projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", identification.getIdProjet()));}if (!identification.getIdAlternatif().isEmpty()) {String[] acronyme = identification.getIdAlternatif().split("##");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()));}}dateFondationChp.setValue(identification.getDateFondation());adrChp.setValue(identification.getAdresse());cpChp.setValue(identification.getCodePostal());villeChp.setValue(identification.getVille());regionChp.setValue(identification.getRegion());if (identification.getPays().matches("^[0-9]+$")) {comboPays.setValue(comboPays.getStore().findModel("id_valeur", identification.getPays()));} else {comboPays.setRawValue(identification.getPays());}telChp.setValue(identification.getTelephone());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...identificationOnglet.setData("acces", true);}}private TabItem creerOngletValorisation() {valorisationOnglet = new TabItem();valorisationOnglet.setText("Valorisation");valorisationOnglet.setScrollMode(Scroll.AUTO);valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));valorisationOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateurvalorisationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {public void handleEvent(ComponentEvent be) {peuplerStructureValorisation();}});actionMarkRGrpChp = 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 ?");valorisationOnglet.add(actionMarkRGrpChp);actionTrukCp = creerChoixMultipleCp("actionValorisation");actionTrukCp.hide();actionTrukCacGrpChp = new CheckBoxGroup();actionTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");valorisationOnglet.add(actionTrukCp);publicationChp = new TextArea();publicationChp.setFieldLabel("Quelques titres des ouvrages, articles scientifiques, ...");valorisationOnglet.add(publicationChp, new FormData(550, 0));autreCollectionTrukCp = creerChoixMultipleCp("autreCollection");autreCollectionTrukCacGrpChp = new CheckBoxGroup();autreCollectionTrukCacGrpChp.setFieldLabel("L'organisme dispose-t-il d'autres collections (permettant une valorisation pluridisciplinaire) ?");valorisationOnglet.add(autreCollectionTrukCp);futureActionMarkRGrpChp = creerChoixUniqueRadioGroupe("future_action_mark", "ouiNon");futureActionMarkRGrpChp.setFieldLabel("Envisagez vous des actions de valorisation dans le cadre de votre politique culturelle ?");valorisationOnglet.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.source).setValue("");}});valorisationOnglet.add(futureActionChp, new FormData(550, 0));rechercheMarkRGrpChp = creerChoixUniqueRadioGroupe("recherche_mark", "ouiNon");rechercheMarkRGrpChp.setFieldLabel("Vos collections botaniques sont-elles utilisées pour des recherches scientifiques ?");valorisationOnglet.add(rechercheMarkRGrpChp);provenanceRechercheTrukCp = creerChoixMultipleCp("continentEtFr");provenanceRechercheTrukCp.hide();provenanceRechercheTrukCacGrpChp = new CheckBoxGroup();provenanceRechercheTrukCacGrpChp.setFieldLabel("Si oui, par des chercheurs (professionnels ou amateurs) de quelle provenance ?");valorisationOnglet.add(provenanceRechercheTrukCp);typeRechercheTrukCp = creerChoixMultipleCp("typeRecherche");typeRechercheTrukCp.hide();typeRechercheTrukCacGrpChp = new CheckBoxGroup();typeRechercheTrukCacGrpChp.setFieldLabel("Et pour quelles recherches ?");valorisationOnglet.add(typeRechercheTrukCp);sansMotifAccesMarkRGrpChp = creerChoixUniqueRadioGroupe("sans_motif_acces_mark", "ouiNon");sansMotifAccesMarkRGrpChp.setFieldLabel("Peut-on consulter vos collections botaniques sans motif de recherches scientifiques ?");valorisationOnglet.add(sansMotifAccesMarkRGrpChp);valorisationOnglet.add(sansMotifAccesChp = new TextArea(), new FormData(550, 0));sansMotifAccesChp.hide();sansMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() {public void handleEvent(BaseEvent be) {((TextArea) be.source).setValue("");}});sansMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les consulter ?");avecMotifAccesMarkRGrpChp = creerChoixUniqueRadioGroupe("avec_motif_acces_mark", "ouiNon");avecMotifAccesMarkRGrpChp.setFieldLabel("Peut-on visiter vos collections botaniques avec des objectifs de recherches scientifiques ?");valorisationOnglet.add(avecMotifAccesMarkRGrpChp);valorisationOnglet.add(avecMotifAccesChp = new TextArea(), new FormData(550, 0));avecMotifAccesChp.hide();avecMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() {public void handleEvent(BaseEvent be) {((TextArea) be.source).setValue("");}});avecMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les visiter ?");return valorisationOnglet;}private TabItem creerOngletConservation() {conservationOnglet = new TabItem();conservationOnglet.setText("Conservation");conservationOnglet.setScrollMode(Scroll.AUTO);conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP, null));conservationOnglet.setData("acces", false);conservationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {public void handleEvent(ComponentEvent be) {peuplerStructureConservation();conservationOnglet.layout();}});formationMarkRGrpChp = creerChoixUniqueRadioGroupe("formation_mark", "ouiNon");formationMarkRGrpChp.setFieldLabel("Le personnel s'occupant des collections a-t-il suivi des formations en conservations ?");conservationOnglet.add(formationMarkRGrpChp);formationChp = new TextArea();formationChp.hide();formationChp.addListener(Events.Hide, new Listener<BaseEvent>() {public void handleEvent(BaseEvent be) {((TextArea) be.source).setValue("");}});formationChp.setFieldLabel("Si oui, lesquelles ?");conservationOnglet.add(formationChp);interetFormationMarkRGrpChp = creerChoixUniqueRadioGroupe("interet_formation_mark", "ouiNon");interetFormationMarkRGrpChp.setFieldLabel("Seriez vous intéressé par une formation à la conservation et à la restauration d'herbier ?");conservationOnglet.add(interetFormationMarkRGrpChp);localStockageTrukCp = creerChoixMultipleCp("localStockage");localStockageTrukCacGrpChp = new CheckBoxGroup();localStockageTrukCacGrpChp.setFieldLabel("Avez vous des locaux spécifiques de stockage des collections botaniques ?");conservationOnglet.add(localStockageTrukCp);meubleStockageTrukCp = creerChoixMultipleCp("meubleStockage");meubleStockageTrukCacGrpChp = new CheckBoxGroup();meubleStockageTrukCacGrpChp.setFieldLabel("Avez vous des meubles spécifiques au stockage des collections botaniques ?");conservationOnglet.add(meubleStockageTrukCp);parametreStockageTrukCp = creerChoixMultipleCp("parametreStockage");parametreStockageTrukCacGrpChp = new CheckBoxGroup();parametreStockageTrukCacGrpChp.setFieldLabel("Quels paramètres maîtrisez vous ?");conservationOnglet.add(parametreStockageTrukCp);collectionCommuneMarkRGrpChp = 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) ?");conservationOnglet.add(collectionCommuneMarkRGrpChp);collectionAutreTrukCp = creerChoixMultipleCp("autreCollection");collectionAutreTrukCacGrpChp = new CheckBoxGroup();collectionAutreTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");collectionAutreTrukCp.hide();conservationOnglet.add(collectionAutreTrukCp);accesControleMarkRGrpChp = 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) ?");conservationOnglet.add(accesControleMarkRGrpChp);restaurationMarkRGrpChp = creerChoixUniqueRadioGroupe("restauration_mark", "ouiNon");restaurationMarkRGrpChp.setFieldLabel("Effectuez vous des opérations de restauration ou de remise en état de vos collections botaniques ?");conservationOnglet.add(restaurationMarkRGrpChp);opRestauTrukCp = creerChoixMultipleCp("opRestau");opRestauTrukCacGrpChp = new CheckBoxGroup();opRestauTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?");opRestauTrukCp.hide();conservationOnglet.add(opRestauTrukCp);// 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 ContenetPanelmaterielConservationCp = creerChoixMultipleCp("onep");conservationOnglet.add(materielConservationCp);materielConservationCeRGrpChp = 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..."));autreMaterielTrukCp = creerChoixMultipleCp("autreMateriel");autreMaterielTrukCacGrpChp = new CheckBoxGroup();autreMaterielTrukCacGrpChp.setFieldLabel("Si non, qu'utilisez vous comme matériel ?");autreMaterielTrukCp.hide();conservationOnglet.add(autreMaterielTrukCp);traitementMarkRGrpChp = creerChoixUniqueRadioGroupe("traitement_mark", "ouiNon");traitementMarkRGrpChp.setFieldLabel("Réalisez vous actuellement des traitements globaux contre les insectes ?");conservationOnglet.add(traitementMarkRGrpChp);traitementTrukCp = creerChoixMultipleCp("insecteTraitement");traitementTrukCp.hide();traitementTrukCacGrpChp = new CheckBoxGroup();traitementTrukCacGrpChp.setFieldLabel("Si oui, lesquels ?");conservationOnglet.add(traitementTrukCp);collectionAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("collection_acquisition_mark", "ouiNon");collectionAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, vos collections botaniques s'accroissent-elles de nouvelles acquisitions ?");conservationOnglet.add(collectionAcquisitionMarkRGrpChp);echantillonAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("echantillon_acquisition_mark", "ouiNon");echantillonAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, mettez vous en herbier de nouveaux échantillons ?");conservationOnglet.add(echantillonAcquisitionMarkRGrpChp);traitementAcquisitionMarkRGrpChp = 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 ?");conservationOnglet.add(traitementAcquisitionMarkRGrpChp);traitementAcquisitionMarkLabel = new LabelField();traitementAcquisitionMarkLabel.hide();traitementAcquisitionMarkLabel.setFieldLabel("Si oui, lesquels ?");conservationOnglet.add(traitementAcquisitionMarkLabel);poisonTraitementTrukCp = creerChoixMultipleCp("poisonTraitement");poisonTraitementTrukCp.hide();poisonTraitementTrukCacGrpChp = new CheckBoxGroup();poisonTraitementTrukCacGrpChp.setFieldLabel("Empoisonnement");poisonTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;");poisonTraitementTrukCacGrpChp.setLabelSeparator("");conservationOnglet.add(poisonTraitementTrukCp);insecteTraitementTrukCp = creerChoixMultipleCp("insecteTraitement");insecteTraitementTrukCp.hide();insecteTraitementTrukCacGrpChp = new CheckBoxGroup();insecteTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;");insecteTraitementTrukCacGrpChp.setLabelSeparator("");insecteTraitementTrukCacGrpChp.setFieldLabel("Désinsectisation");conservationOnglet.add(insecteTraitementTrukCp);return conservationOnglet;}private void collecterStructurePersonnel() {if (personnelOnglet.getData("acces").equals(true)) {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.if (personnelGrilleMagazin.getModifiedRecords().contains(personnelGrilleMagazin.getRecord(personne)) == true) {// Gestion de l'id de la structureif (mode.equals("MODIF")) {personne.setIdStructure(identification.getId());}// Gestion de la fonctionString 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);}}// Gestion de la notion de "contact"personne.setContact(false);if (personne.get("contact").equals(true)) {personne.setContact(true);}// Gestion du statutString 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);}}// Gestion du temps de travailif (personne.get("travail") != null && !personne.get("travail").equals(0)) {personne.setBotaTravailHebdoTps(personne.get("travail").toString());}// Gestion du téléphoneString telephone = personne.get("telephone");if (telephone != null && !telephone.equals("")) {personne.setTelephone(telephone);}// Gestion du faxString fax = personne.get("fax");if (fax != null && !fax.equals("")) {personne.setFax(fax);}// Gestion du courrielString courriel = personne.get("courriel");if (courriel != null && !courriel.equals("")) {personne.setCourriel(courriel);}// Gestion de la sépcialitéString specialite = personne.get("specialite");if (specialite != null && !specialite.equals("")) {personne.setSpecialite(specialite);}// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)if (personne.get("etat") != null && personne.get("etat").equals("A")) {// Une personne ajoutéepersonnelAjoute.put(""+i, personne);} else {// Une personne modifiéepersonnelModifie.put(personne.getId(), personne);}} else {GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null);}}}}private void peuplerStructurePersonnel() {if (mode.equals(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 fonctionif (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {GWT.log(personnel.get(index).getFonction(), null);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 statutif (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 du temps de travailString 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);// Nous vidons la variable personnel une fois qu'elle a remplie la grillepersonnel = null;}}private TabItem creerOngletPersonnel() {// Création des objets contenant les manipulations de la grillepersonnelModifie = new StructureAPersonneListe();personnelAjoute = new StructureAPersonneListe();personnelSupprime = new StructureAPersonneListe();personnelOnglet = new TabItem();personnelOnglet.setText("Personnel");personnelOnglet.setScrollMode(Scroll.AUTO);personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT, 0));personnelOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateurpersonnelOnglet.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...personnelOnglet.setData("acces", true);// Rafraichissement du contenu de la grille du personnel$rafraichirPersonnel();// Peuplement du formulairepeuplerStructurePersonnel();personnelOnglet.layout();}});ContentPanel cp = new ContentPanel();cp.setHeading("Personnes travaillant sur les collections");cp.setIconStyle("icone-table");//cp.setScrollMode(Scroll.AUTO);cp.setLayout(new FitLayout());cp.setWidth(1250);cp.setHeight("100%");cp.setFrame(true);personnelGrilleMagazin = new ListStore<StructureAPersonne>();personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() {public void handleEvent(StoreEvent<StructureAPersonne> ce) {// Activation du bouton supprimer si la grille contient un élémentif (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);mediateur.obtenirListeValeurEtRafraichir(this, "fonction");fonctionsMagazin = new ListStore<Valeur>();fonctionsCombo = new ComboBox<Valeur>();fonctionsCombo.setTriggerAction(TriggerAction.ALL);fonctionsCombo.setEditable(true);fonctionsCombo.setDisplayField("nom");fonctionsCombo.setStore(fonctionsMagazin);fonctionEditor = new CellEditor(fonctionsCombo) {@Overridepublic Object preProcessValue(Object valeur) {Valeur retour = null;if (valeur != null) {String chaineTransmise = (String) valeur;GWT.log("ici:"+fonctionsMagazin.getCount(), null);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;}@Overridepublic Object postProcessValue(Object valeur) {String retour = "";Valeur fonctionTrouvee = null;GWT.log("ICI ", null);if (valeur == null) {GWT.log(this.getField().getRawValue(), 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);TextField<String> prenomChp = new TextField<String>();prenomChp.setAllowBlank(false);prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");prenomChp.setAutoValidate(true);column.setEditor(new CellEditor(prenomChp));configs.add(column);column = new ColumnConfig("nom", "Nom", 100);TextField<String> nomChp = new TextField<String>();nomChp.setAllowBlank(false);nomChp.getMessages().setBlankText("Ce champ est obligatoire.");nomChp.setAutoValidate(true);column.setEditor(new CellEditor(nomChp));configs.add(column);column = new ColumnConfig("telephone", "Téléphone fixe", 100);TextField<String> telChp = new TextField<String>();column.setEditor(new CellEditor(telChp));configs.add(column);column = new ColumnConfig("fax", "Fax", 100);TextField<String> faxChp = new TextField<String>();column.setEditor(new CellEditor(faxChp));configs.add(column);column = new ColumnConfig("courriel", "Courriel principal", 200);TextField<String> emailChp = new TextField<String>();column.setEditor(new CellEditor(emailChp));configs.add(column);mediateur.obtenirListeValeurEtRafraichir(this, "statut");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);CellEditor statutEditor = new CellEditor(comboLiStatut) {@Overridepublic Object preProcessValue(Object value) {if (value == null) {return value;}//GWT.log("pre : "+value.toString(), null);return comboLiStatut.getStore().findModel("nom", (String) value);}@Overridepublic Object postProcessValue(Object value) {if (value == null) {return value;}//GWT.log("post : "+value.toString(), null);return ((Valeur) value).get("nom");}};column = new ColumnConfig("statut", "Statut", 100);column.setEditor(statutEditor);configs.add(column);column = new ColumnConfig("travail", "Temps travail", 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é principale", 150);TextField<String> speChp = new TextField<String>();column.setEditor(new CellEditor(speChp));configs.add(column);CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);configs.add(checkColumn);ToolBar toolBar = new ToolBar();TextToolItem ajouterPersonnelBtn = new TextToolItem("Ajouter", "icone-vcard-ajouter");ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {@Overridepublic void componentSelected(ToolBarEvent ce) {StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);ajouterMembreAGrillePersonnel(membreDuPersonnel);}});toolBar.add(ajouterPersonnelBtn);toolBar.add(new SeparatorToolItem());supprimerPersonnelBtn = new TextToolItem("Supprimer", "icone-vcard-supprimer");supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {@Overridepublic void componentSelected(ToolBarEvent ce) {StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();if (personne != null) {// Ajout de la personne supprimée à la listeif (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {personnelSupprime.put(personne.getId(), personne);}// Suppression de l'enregistrement de la grillegrillePersonnel.getStore().remove(personne);// Désactivation du bouton supprimer si la grille contient plus d'élémentif (grillePersonnel.getStore().getCount() == 0) {ce.item.disable();}}}});toolBar.add(supprimerPersonnelBtn);toolBar.add(new SeparatorToolItem());TextToolItem rafraichirPersonnelBtn = new TextToolItem("Rafraichir", "icone-rafraichir");rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {@Overridepublic void componentSelected(ToolBarEvent ce) {rafraichirPersonnel();}});toolBar.add(rafraichirPersonnelBtn);toolBar.add(new SeparatorToolItem());personneExistanteMagazin = new ListStore<Personne>();personneExistanteMagazin.add(new ArrayList<Personne>());personneExistanteCombo = new ComboBox<Personne>();personneExistanteCombo.setWidth(200);personneExistanteCombo.setEmptyText("Chercher une personne existante...");personneExistanteCombo.setTriggerAction(TriggerAction.ALL);personneExistanteCombo.setEditable(true);personneExistanteCombo.setDisplayField("fmt_nom_complet");personneExistanteCombo.setStore(personneExistanteMagazin);personneExistanteCombo.addKeyListener(new KeyListener() {public void componentKeyUp(ComponentEvent ce) {if (!ce.isNavKeyPress() && personneExistanteCombo.getRawValue() != null && personneExistanteCombo.getRawValue().length() > 0) {rafraichirPersonneExistante(personneExistanteCombo.getRawValue());}}});// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbartoolBar.add(new AdapterToolItem(personneExistanteCombo));TextToolItem ajouterPersonneExistanteBtn = new TextToolItem("Ajouter");ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {@Overridepublic void componentSelected(ToolBarEvent ce) {Personne personneExistante = personneExistanteCombo.getValue();if (personneExistante != null) {StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);membreDuPersonnel.setIdPersonne(personneExistante.getId());membreDuPersonnel.setNom(personneExistante.getNom());membreDuPersonnel.setPrenom(personneExistante.getPrenom());membreDuPersonnel.setTelephone(personneExistante.getTelephone());membreDuPersonnel.setFax(personneExistante.getFax());membreDuPersonnel.setCourriel(personneExistante.getCourriel());membreDuPersonnel.setSpecialite(personneExistante.getSpecialite());ajouterMembreAGrillePersonnel(membreDuPersonnel);}}});toolBar.add(ajouterPersonneExistanteBtn);cp.setTopComponent(toolBar);ColumnModel cm = new ColumnModel(configs);grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);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);grillePersonnel.addListener(Events.Change, new Listener<GridEvent>() {public void handleEvent(GridEvent ge) {// CommitChanges évite que la grille perde la valeur des combobox éditablespersonnelGrilleMagazin.commitChanges();}});cp.add(grillePersonnel);personnelOnglet.add(cp);return personnelOnglet;}private TabItem creerOngletIdentification() {//+-----------------------------------------------------------------------------------------------------------+// Onlget formulaire IDENTIFICATIONidentificationOnglet = new TabItem();identificationOnglet.setId("identification");identificationOnglet.setText("Identification");identificationOnglet.setLayout(new FormLayout());identificationOnglet.setScrollMode(Scroll.AUTO);identificationOnglet.setData("acces", false);identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {public void handleEvent(ComponentEvent be) {peuplerStructureIdentification();identificationOnglet.layout();}});//+-----------------------------------------------------------------------------------------------------------+// Champs cachésidStructureChp = new HiddenField<String>();//+-----------------------------------------------------------------------------------------------------------+// Fieldset IDENTITÉFieldSet fieldSetIdentite = new FieldSet();fieldSetIdentite.setHeading("Identité");fieldSetIdentite.setCollapsible(true);fieldSetIdentite.setLayout(creerFormLayout(200, LabelAlign.LEFT, 4));nomStructureChp = new TextField<String>();nomStructureChp.setTabIndex(tabIndex++);nomStructureChp.setFieldLabel("Nom de la structure");nomStructureChp.setAllowBlank(false);nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire.");fieldSetIdentite.add(nomStructureChp, new FormData(450, 0));mediateur.selectionnerProjets(this);projetsMagazin = new ListStore<Projet>();projetsCombo = new ComboBox<Projet>();projetsCombo.setTabIndex(tabIndex++);projetsCombo.setFieldLabel("Projet");projetsCombo.setLabelSeparator("");projetsCombo.setDisplayField("nom");projetsCombo.setEditable(false);projetsCombo.setTriggerAction(TriggerAction.ALL);projetsCombo.setStore(projetsMagazin);fieldSetIdentite.add(projetsCombo, new FormData(450, 0));// Création du sous-formulaire : AcronymeLayoutContainer ligne = new LayoutContainer();ligne.setLayout(new ColumnLayout());LayoutContainer gauche = new LayoutContainer();gauche.setLayout(creerFormLayout(200, LabelAlign.LEFT, 0));LayoutContainer droite = new LayoutContainer();droite.setLayout(creerFormLayout(0, null, 0));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("Acronymes");comboAcronyme.setDisplayField("nom");comboAcronyme.setStore(acronymes);comboAcronyme.setEditable(false);comboAcronyme.setTypeAhead(true);comboAcronyme.setTriggerAction(TriggerAction.ALL);comboAcronyme.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() {@Overridepublic 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);ihChp = new TextField<String>();//ihChp.setEmptyText("Index Herbariorum");ihChp.setTabIndex(tabIndex++);ihChp.setLabelSeparator("");ihChp.setToolTip("Index Herbariorum : herbier de plus de 5000 échantillons");ihChp.hide();droite.add(ihChp);mnhnChp = new TextField<String>();mnhnChp.setTabIndex(tabIndex++);//mnhnChp.setEmptyText("MNHN");mnhnChp.setLabelSeparator("");mnhnChp.setToolTip("Acronyme MNHN : herbier de moins de 5000 échantillons");mnhnChp.hide();droite.add(mnhnChp);ligne.add(gauche, new ColumnData(0.5));ligne.add(droite, new ColumnData(0.5));fieldSetIdentite.add(ligne);// Création du sous-formulaire : Type de StructureLayoutContainer ligneTs = new LayoutContainer();ligneTs.setLayout(new ColumnLayout());LayoutContainer gaucheTs = new LayoutContainer();gaucheTs.setLayout(creerFormLayout(200, LabelAlign.LEFT, 0));LayoutContainer droiteTs = new LayoutContainer();droiteTs.setLayout(creerFormLayout(0, null, 0));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>() {@Overridepublic 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);mediateur.obtenirListeValeurEtRafraichir(this, "stpu");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);mediateur.obtenirListeValeurEtRafraichir(this, "stpr");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);ligneTs.add(gaucheTs, new ColumnData(0.5));ligneTs.add(droiteTs, new ColumnData(0.5));fieldSetIdentite.add(ligneTs);dateFondationChp = new DateField();dateFondationChp.setTabIndex(tabIndex++);dateFondationChp.setFieldLabel("Date de fondation");dateFondationChp.getPropertyEditor().getFormat();dateFondationChp.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");fieldSetIdentite.add(dateFondationChp);nbreTotalPersonneStructureChp = new NumberField();nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution");nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#"));nbreTotalPersonneStructureChp.setToolTip("Ce champ doit contenir un nombre");fieldSetIdentite.add(nbreTotalPersonneStructureChp);identificationOnglet.add(fieldSetIdentite);//+-----------------------------------------------------------------------------------------------------------+// Fieldset ADRESSELayoutContainer principalFdAdresse = new LayoutContainer();principalFdAdresse.setLayout(new ColumnLayout());LayoutContainer gaucheFdAdresse = new LayoutContainer();gaucheFdAdresse.setLayout(creerFormLayout(100, LabelAlign.LEFT, 0));LayoutContainer droiteFdAdresse = new LayoutContainer();droiteFdAdresse.setLayout(creerFormLayout(100, LabelAlign.LEFT, 0));FieldSet fieldSetAdresse = new FieldSet();fieldSetAdresse.setHeading("Adresse");fieldSetAdresse.setCollapsible(true);fieldSetAdresse.setLayout(creerFormLayout(100, LabelAlign.LEFT, 4));adrChp = new TextArea();adrChp.setTabIndex(tabIndex++);adrChp.setFieldLabel("Adresse");fieldSetAdresse.add(adrChp, new FormData(550, 0));cpChp = new TextField<String>();cpChp.setTabIndex(tabIndex++);cpChp.setFieldLabel("Code postal");gaucheFdAdresse.add(cpChp);villeChp = new TextField<String>();villeChp.setTabIndex(tabIndex++);villeChp.setFieldLabel("Ville");droiteFdAdresse.add(villeChp);regionChp = new TextField<String>();regionChp.setTabIndex(tabIndex++);regionChp.setFieldLabel("Région");gaucheFdAdresse.add(regionChp);mediateur.obtenirListeValeurEtRafraichir(this, "pays");magazinPays = new ListStore<Valeur>();comboPays = new ComboBox<Valeur>();comboPays.setTabIndex(tabIndex++);comboPays.setFieldLabel("Pays");comboPays.setEmptyText("Sélectioner un pays...");comboPays.setEditable(true);comboPays.setLabelSeparator("");comboPays.setDisplayField("nom");comboPays.setTemplate(getTemplatePays());comboPays.setTypeAhead(true);comboPays.setTriggerAction(TriggerAction.ALL);comboPays.setStore(magazinPays);droiteFdAdresse.add(comboPays);principalFdAdresse.add(gaucheFdAdresse, new ColumnData(.5));principalFdAdresse.add(droiteFdAdresse, new ColumnData(.5));fieldSetAdresse.add(principalFdAdresse);identificationOnglet.add(fieldSetAdresse);//+-----------------------------------------------------------------------------------------------------------+// Fieldset TÉLÉPHONE et EMAILLayoutContainer principalFdTelMail = new LayoutContainer();principalFdTelMail.setLayout(new ColumnLayout());LayoutContainer gaucheFdTelMail = new LayoutContainer();gaucheFdTelMail.setLayout(creerFormLayout(100, LabelAlign.LEFT, 0));LayoutContainer droiteFdTelMail = new LayoutContainer();droiteFdTelMail.setLayout(creerFormLayout(100, LabelAlign.LEFT, 0));FieldSet fieldSetTelMail = new FieldSet();fieldSetTelMail.setHeading("Communication");fieldSetTelMail.setCollapsible(true);fieldSetTelMail.setLayout(creerFormLayout(200, LabelAlign.LEFT, 4));telChp = new TextField<String>();telChp.setTabIndex(tabIndex++);telChp.setFieldLabel("Téléphone");gaucheFdTelMail.add(telChp);faxChp = new TextField<String>();faxChp.setTabIndex(tabIndex++);faxChp.setFieldLabel("Fax");droiteFdTelMail.add(faxChp);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);urlChp = new TextField<String>();urlChp.setTabIndex(tabIndex++);urlChp.setFieldLabel("Site web");droiteFdTelMail.add(urlChp);principalFdTelMail.add(gaucheFdTelMail, new ColumnData(.5));principalFdTelMail.add(droiteFdTelMail, new ColumnData(.5));fieldSetTelMail.add(principalFdTelMail);identificationOnglet.add(fieldSetTelMail);return identificationOnglet;}private native String getTemplatePays() /*-{return ['<tpl for=".">','<div class="x-combo-list-item">{nom} ({abreviation})</div>','</tpl>'].join("");}-*/;private 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 {List<CheckBox> cases = groupeCac.getAll();for (int j = 0; j < cases.size(); j++) {if (cases.get(j).getId().equals("val-"+valeurs[i])) {cases.get(j).setValue(true);}}}}}private void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) {List<Radio> 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)) {boutons.get(i).setValue(true);}}}private 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;}/** 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* @param padding padding du layout* @return*/private FormLayout creerFormLayout(Integer labelWidth, LabelAlign labelAlign, Integer padding) {FormLayout formLayout = new FormLayout();if (labelWidth != null) {formLayout.setLabelWidth(labelWidth);}if (labelAlign != null) {formLayout.setLabelAlign(labelAlign);}if (padding != null) {formLayout.setPadding(padding);}return formLayout;}/** Méthode simplifiant la création de bouton radio oui/non** @param listeNom nom de la liste de valeur* @return*/private 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;}private 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.component));}});if (! val.getDescription().equals("NULL")) {radioBtn.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription()));}radioGroupe.add(radioBtn);}}private 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ésString valeurPourAfficher = "oui";// Construction de la liste des composants à afficher/cacherString 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);} else 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 listefinal 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 champsString 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'affichageif (composants.get(i) instanceof ContentPanel) {((ContentPanel) composants.get(i)).layout();}}}/** 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 listeNom nom de la liste de valeur* @return*/private ContentPanel creerChoixMultipleCp(String listeNom) {mediateur.obtenirListeValeurEtRafraichir(this, listeNom);ContentPanel cp = new ContentPanel();cp.setLayout(creerFormLayout(650, LabelAlign.TOP, 0));cp.setHeaderVisible(false);return cp;}/** 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*/private void creerChoixMultipleCac(ContentPanel 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.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) {ContentPanel autreCp = new ContentPanel();autreCp.setLayout(creerFormLayout(75, LabelAlign.TOP, 0));autreCp.setHeaderVisible(false);autreChp.setId("autre-"+listeValeurs.getId());autreChp.setFieldLabel("Autre");autreChp.setLabelStyle("font-weight:normal;");autreCp.add(autreChp);cp.add(autreCp);}cp.layout();}public void rafraichir(Object nouvelleDonnees) {try {if (nouvelleDonnees instanceof Information) {Information info = (Information) nouvelleDonnees;if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);}if (info.getType().equals("modif_structure")) {Info.display("Modification d'une institution", info.toString());} else if (info.getType().equals("ajout_structure")) {if (info.getMessage(0) != null && info.getMessage(0).matches("^[0-9]+$")) {Info.display("Ajout d'une Institution", "L'intitution a bien été ajoutée");// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnelmediateur.ajouterStructureAPersonne(this, info.toString(), personnelAjoute);} else {Info.display("Ajout d'une Institution", info.toString());}} else if (info.getType().equals("modif_structure_a_personne")) {Info.display("Modification du Personnel", info.toString());} else if (info.getType().equals("suppression_structure_a_personne")) {Info.display("Suppression du Personnel", info.toString());} else if (info.getType().equals("ajout_structure_a_personne")) {Info.display("Ajout du Personnel", info.toString());} else if (info.getType().equals("selection_structure")) {Info.display("Modification d'une institution", info.toString());GWT.log("Mode du formulaire : "+mode, null);String titre = i18nC.titreModifFormStructurePanneau();if (info.getDonnee(0) != null) {identification = (Structure) info.getDonnee(0);if (onglets.getSelectedItem().equals(identificationOnglet)) {peuplerStructureIdentification();}// Composition du titretitre += " - ID : "+identification.getId();}if (info.getDonnee(1) != null) {conservation = (StructureConservation) info.getDonnee(1);if (onglets.getSelectedItem().equals(conservationOnglet)) {peuplerStructureConservation();}}if (info.getDonnee(2) != null) {valorisation = (StructureValorisation) info.getDonnee(2);if (valorisation != null) {if (onglets.getSelectedItem().equals(valorisationOnglet)) {peuplerStructureValorisation();}}}structureFormPanneau.setHeading(titre);} else if (info.getType().equals("liste_structure_a_personne")) {if (info.getDonnee(0) != null) {personnel = (StructureAPersonneListe) info.getDonnee(0);//GWT.log(personnel.toString(), null);if (onglets.getSelectedItem().equals(personnelOnglet)) {peuplerStructurePersonnel();Info.display("Chargement du Personnel", "ok");}}if (info.getDonnee(1) != null) {Info.display("Debug", info.getDonnee(1).toString());}} else if (info.getType().equals("liste_personne")) {if (info.getDonnee(0) != null) {PersonneListe personnes = (PersonneListe) info.getDonnee(0);List<Personne> liste = new ArrayList<Personne>();for (Iterator<String> it = personnes.keySet().iterator(); it.hasNext();) {liste.add(personnes.get(it.next()));}GWT.log("Nbre de personnes trouvées :"+personnes.size(), null);personneExistanteMagazin.removeAll();personneExistanteMagazin.add(liste);personneExistanteCombo.setStore(personneExistanteMagazin);personneExistanteCombo.expand();}}} else if (nouvelleDonnees instanceof ValeurListe) {ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;List<Valeur> liste = listeValeurs.toList();// Test pour savoir si la liste contient des élémentsif (liste.size() > 0) {Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);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);}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);}if (listeValeurs.getId().equals(config.getListeId("pays"))) {magazinPays.removeAll();magazinPays.add(liste);comboPays.setStore(magazinPays);}if (listeValeurs.getId().equals(config.getListeId("localStockage"))) {localStockageAutreChp = new TextField<String>();creerChoixMultipleCac(localStockageTrukCp, localStockageTrukCacGrpChp, listeValeurs, localStockageAutreChp);}if (listeValeurs.getId().equals(config.getListeId("meubleStockage"))) {meubleStockageAutreChp = new TextField<String>();creerChoixMultipleCac(meubleStockageTrukCp, meubleStockageTrukCacGrpChp, listeValeurs, meubleStockageAutreChp);}if (listeValeurs.getId().equals(config.getListeId("parametreStockage"))) {parametreStockageAutreChp = new TextField<String>();creerChoixMultipleCac(parametreStockageTrukCp, parametreStockageTrukCacGrpChp, listeValeurs, parametreStockageAutreChp);}if (listeValeurs.getId().equals(config.getListeId("autreCollection"))) {if (collectionAutreTrukCp.getItemByItemId("collectionAutreTrukCacGrpChp") == null) {collectionAutreTrukCacGrpChp.setId("collectionAutreTrukCacGrpChp");collectionAutreAutreChp = new TextField<String>();creerChoixMultipleCac(collectionAutreTrukCp, collectionAutreTrukCacGrpChp, listeValeurs, collectionAutreAutreChp);}if (autreCollectionTrukCp.getItemByItemId("autreCollectionTrukCacGrpChp") == null) {autreCollectionTrukCacGrpChp.setId("autreCollectionTrukCacGrpChp");autreCollectionAutreChp = new TextField<String>();creerChoixMultipleCac(autreCollectionTrukCp, autreCollectionTrukCacGrpChp, listeValeurs, autreCollectionAutreChp);}}if (listeValeurs.getId().equals(config.getListeId("opRestau"))) {opRestauAutreChp = new TextField<String>();creerChoixMultipleCac(opRestauTrukCp, opRestauTrukCacGrpChp, listeValeurs, opRestauAutreChp);}if (listeValeurs.getId().equals(config.getListeId("onep"))) {creerChoixUniqueBoutonRadio(materielConservationCeRGrpChp, listeValeurs);materielConservationCp.add(materielConservationCeRGrpChp);materielConservationCp.layout();}if (listeValeurs.getId().equals(config.getListeId("autreMateriel"))) {autreMaterielAutreChp = new TextField<String>();creerChoixMultipleCac(autreMaterielTrukCp, autreMaterielTrukCacGrpChp, listeValeurs, autreMaterielAutreChp);}if (listeValeurs.getId().equals(config.getListeId("poisonTraitement"))) {poisonTraitementAutreChp = new TextField<String>();creerChoixMultipleCac(poisonTraitementTrukCp, poisonTraitementTrukCacGrpChp, listeValeurs, poisonTraitementAutreChp);}if (listeValeurs.getId().equals(config.getListeId("insecteTraitement"))) {if (traitementTrukCp.getItemByItemId("traitementTrukCacGrpChp") == null) {traitementTrukCacGrpChp.setId("traitementTrukCacGrpChp");traitementAutreChp = new TextField<String>();creerChoixMultipleCac(traitementTrukCp, traitementTrukCacGrpChp, listeValeurs, traitementAutreChp);}if (insecteTraitementTrukCp.getItemByItemId("insecteTraitementTrukCacGrpChp") == null) {insecteTraitementTrukCacGrpChp.setId("insecteTraitementTrukCacGrpChp");insecteTraitementAutreChp = new TextField<String>();creerChoixMultipleCac(insecteTraitementTrukCp, insecteTraitementTrukCacGrpChp, listeValeurs, insecteTraitementAutreChp);}}if (listeValeurs.getId().equals(config.getListeId("actionValorisation"))) {actionAutreChp = new TextField<String>();creerChoixMultipleCac(actionTrukCp, actionTrukCacGrpChp, listeValeurs, actionAutreChp);}if (listeValeurs.getId().equals(config.getListeId("continentEtFr"))) {provenanceRechercheAutreChp = new TextField<String>();creerChoixMultipleCac(provenanceRechercheTrukCp, provenanceRechercheTrukCacGrpChp, listeValeurs, provenanceRechercheAutreChp);}if (listeValeurs.getId().equals(config.getListeId("typeRecherche"))) {typeRechercheAutreChp = new TextField<String>();creerChoixMultipleCac(typeRechercheTrukCp, typeRechercheTrukCacGrpChp, listeValeurs, typeRechercheAutreChp);}//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);} else {GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);}} else if (nouvelleDonnees instanceof ProjetListe) {ProjetListe projets = (ProjetListe) nouvelleDonnees;List<Projet> liste = new ArrayList<Projet>();for (Iterator<String> it = projets.keySet().iterator(); it.hasNext();) {liste.add(projets.get(it.next()));}projetsMagazin.removeAll();projetsMagazin.add(liste);projetsCombo.setStore(projetsMagazin);} else {GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);}} catch (Exception e) {GWT.log("rafraichir()", e);}}private void rafraichirPersonnel() {if (mode.equals(MODE_MODIFIER)) {initialiserGrillePersonnelEnModifcation();} else if (mode.equals(MODE_AJOUTER)) {initialiserGrillePersonnelEnAjout();}}private void rafraichirPersonneExistante(String nom) {mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%");}private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) {grillePersonnel.stopEditing();personnelGrilleMagazin.insert(personnel, 0);// Nous modifions l'enregistrement pour que le modèle soit pris en compte lors de la collecte.Record record = personnelGrilleMagazin.getRecord(personnelGrilleMagazin.getAt(0));record.beginEdit();if (!personnel.getFonction().equals("")) {Object fonction = fonctionEditor.preProcessValue(personnel.getFonction());if (fonction != null && fonction instanceof Valeur) {record.set("fonction", ((Valeur)fonction).getNom());}}if (!personnel.getPrenom().equals("")) {record.set("prenom", personnel.getPrenom());}if (!personnel.getNom().equals("")) {record.set("nom", personnel.getNom());}if (!personnel.getTelephone().equals("")) {record.set("telephone", personnel.selectionnerTelephone(Personne.TELEPHONE_FIXE));}if (!personnel.getFax().equals("")) {record.set("fax", personnel.selectionnerFax(1));}if (!personnel.getCourriel().equals("")) {record.set("courriel", personnel.selectionnerCourriel(1));}if (!personnel.getStatut().equals("")) {record.set("statut", personnel.getStatut());}String tempsDeTravail = personnel.getBotaTravailHebdoTps();record.set("travail", (tempsDeTravail.matches("^[0-9]+$") ? Integer.parseInt(tempsDeTravail) : 0));if (!personnel.getSpecialite().equals("")) {record.set("specialite", personnel.afficherSpecialite());}record.set("contact", (personnel.getContact().equals("1") ? true : false));record.set("etat", personnel.get("etat"));record.endEdit();grillePersonnel.startEditing(0, 0);}private void initialiserGrillePersonnelEnAjout() {personnelGrilleMagazin.removeAll();StructureAPersonne conservateurDesCollections = new StructureAPersonne(StructureAPersonne.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);ajouterMembreAGrillePersonnel(conservateurDesCollections);StructureAPersonne directeurDuPersonnel = new StructureAPersonne(StructureAPersonne.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);ajouterMembreAGrillePersonnel(directeurDuPersonnel);}private void initialiserGrillePersonnelEnModifcation() {mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE);}}