| 1287 | 
           cyprien | 
           1 | 
           package org.tela_botanica.client.composants;
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           import java.util.HashMap;
  | 
        
        
            | 
            | 
           4 | 
              | 
        
        
            | 
            | 
           5 | 
           import org.tela_botanica.client.Mediateur;
  | 
        
        
            | 
            | 
           6 | 
           import org.tela_botanica.client.RegistreId;
  | 
        
        
            | 
            | 
           7 | 
           import org.tela_botanica.client.composants.pagination.Proxy;
  | 
        
        
            | 
            | 
           8 | 
           import org.tela_botanica.client.composants.pagination.ProxyValeur;
  | 
        
        
            | 
            | 
           9 | 
           import org.tela_botanica.client.images.Images;
  | 
        
        
            | 
            | 
           10 | 
           import org.tela_botanica.client.interfaces.Rafraichissable;
  | 
        
        
            | 
            | 
           11 | 
           import org.tela_botanica.client.modeles.Valeur;
  | 
        
        
            | 
            | 
           12 | 
           import org.tela_botanica.client.modeles.aDonnee;
  | 
        
        
            | 
            | 
           13 | 
           import org.tela_botanica.client.util.Debug;
  | 
        
        
            | 
            | 
           14 | 
              | 
        
        
            | 
            | 
           15 | 
           import com.extjs.gxt.ui.client.Registry;
  | 
        
        
            | 
            | 
           16 | 
           import com.extjs.gxt.ui.client.data.ModelData;
  | 
        
        
            | 
            | 
           17 | 
           import com.extjs.gxt.ui.client.data.ModelType;
  | 
        
        
            | 
            | 
           18 | 
           import com.extjs.gxt.ui.client.event.ButtonEvent;
  | 
        
        
            | 
            | 
           19 | 
           import com.extjs.gxt.ui.client.event.Events;
  | 
        
        
            | 
            | 
           20 | 
           import com.extjs.gxt.ui.client.event.FieldEvent;
  | 
        
        
            | 
            | 
           21 | 
           import com.extjs.gxt.ui.client.event.Listener;
  | 
        
        
            | 
            | 
           22 | 
           import com.extjs.gxt.ui.client.event.SelectionListener;
  | 
        
        
            | 
            | 
           23 | 
           import com.extjs.gxt.ui.client.store.ListStore;
  | 
        
        
            | 
            | 
           24 | 
           import com.extjs.gxt.ui.client.widget.LayoutContainer;
  | 
        
        
            | 
            | 
           25 | 
           import com.extjs.gxt.ui.client.widget.MessageBox;
  | 
        
        
            | 
            | 
           26 | 
           import com.extjs.gxt.ui.client.widget.Text;
  | 
        
        
            | 
            | 
           27 | 
           import com.extjs.gxt.ui.client.widget.button.Button;
  | 
        
        
            | 
            | 
           28 | 
           import com.extjs.gxt.ui.client.widget.form.ComboBox;
  | 
        
        
            | 
            | 
           29 | 
           import com.extjs.gxt.ui.client.widget.form.Field;
  | 
        
        
            | 
            | 
           30 | 
           import com.extjs.gxt.ui.client.widget.form.HiddenField;
  | 
        
        
            | 
            | 
           31 | 
           import com.extjs.gxt.ui.client.widget.form.LabelField;
  | 
        
        
            | 
            | 
           32 | 
           import com.extjs.gxt.ui.client.widget.form.TextField;
  | 
        
        
            | 
            | 
           33 | 
           import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
  | 
        
        
            | 
            | 
           34 | 
           import com.extjs.gxt.ui.client.widget.layout.ColumnData;
  | 
        
        
            | 
            | 
           35 | 
           import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
  | 
        
        
            | 
            | 
           36 | 
           import com.extjs.gxt.ui.client.widget.layout.FormLayout;
  | 
        
        
            | 
            | 
           37 | 
           import com.extjs.gxt.ui.client.widget.layout.RowLayout;
  | 
        
        
            | 
            | 
           38 | 
              | 
        
        
            | 
            | 
           39 | 
           public class ChampMultiValeursPaginable extends LayoutContainer implements Rafraichissable {
  | 
        
        
            | 
            | 
           40 | 
           	//TODO : changer le champRecapitulatif par une hashMap
  | 
        
        
            | 
            | 
           41 | 
           	//TODO : autoriser la modification des champs saisis
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
           	  //-------------//
  | 
        
        
            | 
            | 
           44 | 
           	 //  ATTRIBUTS	//
  | 
        
        
            | 
            | 
           45 | 
           	//-------------//
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
            | 
            | 
           47 | 
           	Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
  | 
        
        
            | 
            | 
           48 | 
              | 
        
        
            | 
            | 
           49 | 
           	String idChampCache = null;
  | 
        
        
            | 
            | 
           50 | 
           	String titreErreur = null;
  | 
        
        
            | 
            | 
           51 | 
           	String valeurVideMsg = null;
  | 
        
        
            | 
            | 
           52 | 
           	String valeurIdentiqueMsg = null;
  | 
        
        
            | 
            | 
           53 | 
           	String valeurNonValideMsg = null;
  | 
        
        
            | 
            | 
           54 | 
           	String valeurParDefaut = "";
  | 
        
        
            | 
            | 
           55 | 
           	String validationMasque = null;
  | 
        
        
            | 
            | 
           56 | 
           	String exempleValidation = null;
  | 
        
        
            | 
            | 
           57 | 
           	boolean champValeurEstComboBox = false;
  | 
        
        
            | 
            | 
           58 | 
              | 
        
        
            | 
            | 
           59 | 
           	// Elements pour le champ 'valeurs'
  | 
        
        
            | 
            | 
           60 | 
           	Field<String> champValeurTxt = null;
  | 
        
        
            | 
            | 
           61 | 
           	ChampComboBoxRechercheTempsReelPaginable champValeurComboBox = null;
  | 
        
        
            | 
            | 
           62 | 
           	HiddenField<String> champRecapitulatif = null;
  | 
        
        
            | 
            | 
           63 | 
           	HashMap<String, LayoutContainer> valeurs = null;
  | 
        
        
            | 
            | 
           64 | 
              | 
        
        
            | 
            | 
           65 | 
           	// Elements pour gérer le type de valeurs que contient le champ
  | 
        
        
            | 
            | 
           66 | 
           	Proxy proxyChampValeur = null;
  | 
        
        
            | 
            | 
           67 | 
           	ModelType modeltypeChampValeur = null;
  | 
        
        
            | 
            | 
           68 | 
           	String displayNameChampValeur = "nom";
  | 
        
        
            | 
            | 
           69 | 
              | 
        
        
            | 
            | 
           70 | 
           	// Elements pour l'UI
  | 
        
        
            | 
            | 
           71 | 
           	LayoutContainer principalLayout = null;
  | 
        
        
            | 
            | 
           72 | 
           	LayoutContainer colonneConteneur = null;
  | 
        
        
            | 
            | 
           73 | 
           	ColumnData colonneChampValeur = null;
  | 
        
        
            | 
            | 
           74 | 
           	ColumnData colonneBoutonAjouter = null;
  | 
        
        
            | 
            | 
           75 | 
           	Button ajouterBouton = null;
  | 
        
        
            | 
            | 
           76 | 
           	int largeurTotale = 500;
  | 
        
        
            | 
            | 
           77 | 
           	int largeurBouton = 20;
  | 
        
        
            | 
            | 
           78 | 
           	int largeurChampValeur = 200;
  | 
        
        
            | 
            | 
           79 | 
           	String boutonSupprimerLabel = "";
  | 
        
        
            | 
            | 
           80 | 
           	String nomLabelChampTxt = "";
  | 
        
        
            | 
            | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
              | 
        
        
            | 
            | 
           83 | 
           	  //-------------//
  | 
        
        
            | 
            | 
           84 | 
           	 //   METHODES	//
  | 
        
        
            | 
            | 
           85 | 
           	//-------------//
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
            | 
            | 
           87 | 
           	/*--------------
  | 
        
        
            | 
            | 
           88 | 
           	  Constructeur
  | 
        
        
            | 
            | 
           89 | 
           	--------------*/
  | 
        
        
            | 
            | 
           90 | 
           	// Usage :	Si champValeurEstComboBox est FAUX alors modeltype, proxy et displayName doivent être à Null.
  | 
        
        
            | 
            | 
           91 | 
           	//			Sinon ils doivent impérativement être non nuls.
  | 
        
        
            | 
            | 
           92 | 
           	public ChampMultiValeursPaginable(String label, int largeurTotale, boolean champValeurEstComboBox, ModelType modeltype, Proxy proxy, String displayName) {
  | 
        
        
            | 
            | 
           93 | 
           		this.champValeurEstComboBox = champValeurEstComboBox;
  | 
        
        
            | 
            | 
           94 | 
              | 
        
        
            | 
            | 
           95 | 
           		if (champValeurEstComboBox) {
  | 
        
        
            | 
            | 
           96 | 
           			if ((proxy == null) || (modeltype == null) || (displayName == null)) {
  | 
        
        
            | 
            | 
           97 | 
           				MessageBox.alert("[ERREUR]","Constructeur de ChampMultiValeursPaginable - paramètre Null",null);
  | 
        
        
            | 
            | 
           98 | 
           			}
  | 
        
        
            | 
            | 
           99 | 
           			else {
  | 
        
        
            | 
            | 
           100 | 
           				this.proxyChampValeur = proxy;
  | 
        
        
            | 
            | 
           101 | 
           				this.modeltypeChampValeur = modeltype;
  | 
        
        
            | 
            | 
           102 | 
           				this.displayNameChampValeur = displayName;
  | 
        
        
            | 
            | 
           103 | 
           			}
  | 
        
        
            | 
            | 
           104 | 
           		}
  | 
        
        
            | 
            | 
           105 | 
              | 
        
        
            | 
            | 
           106 | 
           		initialiserChampMultiValeursPaginable(label, largeurTotale);
  | 
        
        
            | 
            | 
           107 | 
           	}
  | 
        
        
            | 
            | 
           108 | 
              | 
        
        
            | 
            | 
           109 | 
           	/*------------
  | 
        
        
            | 
            | 
           110 | 
           	  Accesseurs
  | 
        
        
            | 
            | 
           111 | 
           	------------*/
  | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
           	 //------------//
  | 
        
        
            | 
            | 
           114 | 
           	//    Get     //------------------------------------------------------------
  | 
        
        
            | 
            | 
           115 | 
              | 
        
        
            | 
            | 
           116 | 
           	public ChampComboBoxRechercheTempsReelPaginable getChampValeurComboBox() {
  | 
        
        
            | 
            | 
           117 | 
           		if (champValeurEstComboBox) return this.champValeurComboBox;
  | 
        
        
            | 
            | 
           118 | 
           		else return null;
  | 
        
        
            | 
            | 
           119 | 
           	}
  | 
        
        
            | 
            | 
           120 | 
              | 
        
        
            | 
            | 
           121 | 
           	public Field getChampValeurTxt() {
  | 
        
        
            | 
            | 
           122 | 
           		if (!champValeurEstComboBox) return this.champValeurTxt;
  | 
        
        
            | 
            | 
           123 | 
           		else return null;
  | 
        
        
            | 
            | 
           124 | 
           	}
  | 
        
        
            | 
            | 
           125 | 
              | 
        
        
            | 
            | 
           126 | 
           	public String getLabel() {
  | 
        
        
            | 
            | 
           127 | 
           		return this.nomLabelChampTxt;
  | 
        
        
            | 
            | 
           128 | 
           	}
  | 
        
        
            | 
            | 
           129 | 
              | 
        
        
            | 
            | 
           130 | 
           	public String getValeurs() {
  | 
        
        
            | 
            | 
           131 | 
           		String texteRecapitulatif = "";
  | 
        
        
            | 
            | 
           132 | 
           		if (champRecapitulatif.getValue() != null) {
  | 
        
        
            | 
            | 
           133 | 
           			texteRecapitulatif = champRecapitulatif.getValue();
  | 
        
        
            | 
            | 
           134 | 
           			texteRecapitulatif = texteRecapitulatif.replaceAll("(.*)"+aDonnee.SEPARATEUR_VALEURS+"$", "$1");
  | 
        
        
            | 
            | 
           135 | 
           		}
  | 
        
        
            | 
            | 
           136 | 
           		return texteRecapitulatif;
  | 
        
        
            | 
            | 
           137 | 
           	}
  | 
        
        
            | 
            | 
           138 | 
              | 
        
        
            | 
            | 
           139 | 
           	 //------------//
  | 
        
        
            | 
            | 
           140 | 
           	//    Set     //------------------------------------------------------------
  | 
        
        
            | 
            | 
           141 | 
              | 
        
        
            | 
            | 
           142 | 
           	public void setLabel(String label) {
  | 
        
        
            | 
            | 
           143 | 
           		if (label == null) {
  | 
        
        
            | 
            | 
           144 | 
           			label = "";
  | 
        
        
            | 
            | 
           145 | 
           		}
  | 
        
        
            | 
            | 
           146 | 
           		nomLabelChampTxt = label;
  | 
        
        
            | 
            | 
           147 | 
           	}
  | 
        
        
            | 
            | 
           148 | 
              | 
        
        
            | 
            | 
           149 | 
           	public void setLargeurTotale(int largeur) {
  | 
        
        
            | 
            | 
           150 | 
           		this.largeurTotale = largeur;
  | 
        
        
            | 
            | 
           151 | 
           		largeurChampValeur = largeurTotale - largeurBouton;
  | 
        
        
            | 
            | 
           152 | 
           	}
  | 
        
        
            | 
            | 
           153 | 
              | 
        
        
            | 
            | 
           154 | 
           	public void setValidation (String validation, String exempleValidation)	{
  | 
        
        
            | 
            | 
           155 | 
           		this.validationMasque = validation;
  | 
        
        
            | 
            | 
           156 | 
           		this.exempleValidation = exempleValidation;
  | 
        
        
            | 
            | 
           157 | 
              | 
        
        
            | 
            | 
           158 | 
           		this.valeurNonValideMsg = Mediateur.i18nM.valeurNonValideMsg(exempleValidation);
  | 
        
        
            | 
            | 
           159 | 
           	}
  | 
        
        
            | 
            | 
           160 | 
              | 
        
        
            | 
            | 
           161 | 
           	public void setValeurParDefaut(String valeur)	{
  | 
        
        
            | 
            | 
           162 | 
           		this.valeurParDefaut = valeur;
  | 
        
        
            | 
            | 
           163 | 
           		champValeurTxt.setValue(valeur);
  | 
        
        
            | 
            | 
           164 | 
           	}
  | 
        
        
            | 
            | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
           	public void setValeurBoutonSupprimer(String valeur)	{
  | 
        
        
            | 
            | 
           167 | 
           		this.boutonSupprimerLabel = valeur;
  | 
        
        
            | 
            | 
           168 | 
           	}
  | 
        
        
            | 
            | 
           169 | 
              | 
        
        
            | 
            | 
           170 | 
           	/*------------------
  | 
        
        
            | 
            | 
           171 | 
           	  Méthodes publiques
  | 
        
        
            | 
            | 
           172 | 
           	-------------------*/
  | 
        
        
            | 
            | 
           173 | 
           	public void peupler(String chaineExistante) {
  | 
        
        
            | 
            | 
           174 | 
           		if (valeurs.size()>0)	{
  | 
        
        
            | 
            | 
           175 | 
           			reinitialiser();
  | 
        
        
            | 
            | 
           176 | 
           		}
  | 
        
        
            | 
            | 
           177 | 
           		if (chaineExistante != null && !chaineExistante.trim().equals("")) {
  | 
        
        
            | 
            | 
           178 | 
           			String[] valeurs = chaineExistante.split(aDonnee.SEPARATEUR_VALEURS);
  | 
        
        
            | 
            | 
           179 | 
           			for (int i = 0; i < valeurs.length; i++) {
  | 
        
        
            | 
            | 
           180 | 
           				ajouterValeur(valeurs[i]);
  | 
        
        
            | 
            | 
           181 | 
           			}
  | 
        
        
            | 
            | 
           182 | 
           		}
  | 
        
        
            | 
            | 
           183 | 
           	}
  | 
        
        
            | 
            | 
           184 | 
              | 
        
        
            | 
            | 
           185 | 
           	public void rafraichir(Object nouvellesDonnees) {
  | 
        
        
            | 
            | 
           186 | 
              | 
        
        
            | 
            | 
           187 | 
           	}
  | 
        
        
            | 
            | 
           188 | 
              | 
        
        
            | 
            | 
           189 | 
           	/*-------------------
  | 
        
        
            | 
            | 
           190 | 
           	  Méthodes protégées
  | 
        
        
            | 
            | 
           191 | 
           	--------------------*/
  | 
        
        
            | 
            | 
           192 | 
           	protected void ajouterValeur(final String texte, final String strValeur, final String id)	{
  | 
        
        
            | 
            | 
           193 | 
           		//Implémenté dans classe inférieure
  | 
        
        
            | 
            | 
           194 | 
           	}
  | 
        
        
            | 
            | 
           195 | 
              | 
        
        
            | 
            | 
           196 | 
           	protected void ajouterValeur(final String texte) 	{
  | 
        
        
            | 
            | 
           197 | 
           		LayoutContainer colonneLayout = new LayoutContainer();
  | 
        
        
            | 
            | 
           198 | 
           		colonneLayout.setLayout(new ColumnLayout());
  | 
        
        
            | 
            | 
           199 | 
           		valeurs.put(texte, colonneLayout);
  | 
        
        
            | 
            | 
           200 | 
              | 
        
        
            | 
            | 
           201 | 
           		Text champTxt = new Text();
  | 
        
        
            | 
            | 
           202 | 
           		champTxt.setText(texte);
  | 
        
        
            | 
            | 
           203 | 
           		colonneLayout.add(champTxt, new ColumnData(largeurChampValeur));
  | 
        
        
            | 
            | 
           204 | 
              | 
        
        
            | 
            | 
           205 | 
           		Button supprimerBouton = new Button();
  | 
        
        
            | 
            | 
           206 | 
           		supprimerBouton.setIcon(Images.ICONES.supprimer());
  | 
        
        
            | 
            | 
           207 | 
           		supprimerBouton.setText(boutonSupprimerLabel);
  | 
        
        
            | 
            | 
           208 | 
           		supprimerBouton.setData("valeur", texte);
  | 
        
        
            | 
            | 
           209 | 
           		supprimerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           210 | 
           			public void componentSelected(ButtonEvent ce) {
  | 
        
        
            | 
            | 
           211 | 
           				String valeur = ce.getComponent().getData("valeur");
  | 
        
        
            | 
            | 
           212 | 
           				LayoutContainer valeurLayout = valeurs.get(valeur);
  | 
        
        
            | 
            | 
           213 | 
           				principalLayout.remove(valeurLayout);
  | 
        
        
            | 
            | 
           214 | 
           				valeurs.remove(valeur);
  | 
        
        
            | 
            | 
           215 | 
           				supprimerValeurDuRecapitulatif(valeur);
  | 
        
        
            | 
            | 
           216 | 
           				actualiserLayoutGlobal();
  | 
        
        
            | 
            | 
           217 | 
           			}
  | 
        
        
            | 
            | 
           218 | 
           		});
  | 
        
        
            | 
            | 
           219 | 
           		colonneLayout.add(supprimerBouton, new ColumnData(largeurBouton));
  | 
        
        
            | 
            | 
           220 | 
              | 
        
        
            | 
            | 
           221 | 
           		// Ajout du layout de la valeur au layout principal
  | 
        
        
            | 
            | 
           222 | 
           		principalLayout.add(colonneLayout);
  | 
        
        
            | 
            | 
           223 | 
              | 
        
        
            | 
            | 
           224 | 
           		// Ajout de la valeur au champ récapitulatif des valeurs ajoutées
  | 
        
        
            | 
            | 
           225 | 
           		ajouterValeurAuRecapitulatif(texte);
  | 
        
        
            | 
            | 
           226 | 
           		reinitialiserChamp();
  | 
        
        
            | 
            | 
           227 | 
           		actualiserLayoutGlobal();
  | 
        
        
            | 
            | 
           228 | 
           	}
  | 
        
        
            | 
            | 
           229 | 
              | 
        
        
            | 
            | 
           230 | 
           	protected void reinitialiserChamp()	{
  | 
        
        
            | 
            | 
           231 | 
           		if (champValeurEstComboBox) {
  | 
        
        
            | 
            | 
           232 | 
           			champValeurComboBox.getCombo().clear();
  | 
        
        
            | 
            | 
           233 | 
           		} else {
  | 
        
        
            | 
            | 
           234 | 
           			champValeurTxt.setValue(valeurParDefaut);
  | 
        
        
            | 
            | 
           235 | 
           		}
  | 
        
        
            | 
            | 
           236 | 
           	}
  | 
        
        
            | 
            | 
           237 | 
              | 
        
        
            | 
            | 
           238 | 
           	protected void actualiserLayoutGlobal() {
  | 
        
        
            | 
            | 
           239 | 
           		layout();
  | 
        
        
            | 
            | 
           240 | 
           	}
  | 
        
        
            | 
            | 
           241 | 
              | 
        
        
            | 
            | 
           242 | 
           	protected void ajouterValeurAuRecapitulatif(String texte) {
  | 
        
        
            | 
            | 
           243 | 
           		String texteRecapitulatif = "";
  | 
        
        
            | 
            | 
           244 | 
           		if (champRecapitulatif.getValue() != null)	{
  | 
        
        
            | 
            | 
           245 | 
           			texteRecapitulatif = champRecapitulatif.getValue();
  | 
        
        
            | 
            | 
           246 | 
           		}
  | 
        
        
            | 
            | 
           247 | 
           		texteRecapitulatif += texte + aDonnee.SEPARATEUR_VALEURS;
  | 
        
        
            | 
            | 
           248 | 
           		champRecapitulatif.setValue(texteRecapitulatif);
  | 
        
        
            | 
            | 
           249 | 
           	}
  | 
        
        
            | 
            | 
           250 | 
              | 
        
        
            | 
            | 
           251 | 
           	protected void supprimerValeurDuRecapitulatif(String texte) {
  | 
        
        
            | 
            | 
           252 | 
           		if (champRecapitulatif.getValue() != null)	{
  | 
        
        
            | 
            | 
           253 | 
           			String texteRecapitulatif = champRecapitulatif.getValue();
  | 
        
        
            | 
            | 
           254 | 
           			texteRecapitulatif = texteRecapitulatif.replace(texte + aDonnee.SEPARATEUR_VALEURS, "");
  | 
        
        
            | 
            | 
           255 | 
           			champRecapitulatif.setValue(texteRecapitulatif);
  | 
        
        
            | 
            | 
           256 | 
           		}
  | 
        
        
            | 
            | 
           257 | 
           	}
  | 
        
        
            | 
            | 
           258 | 
              | 
        
        
            | 
            | 
           259 | 
           	protected void reinitialiser() {
  | 
        
        
            | 
            | 
           260 | 
           		//TODO : pourrait etre mieux fait si les valeurs étaient enregistrées dans un
  | 
        
        
            | 
            | 
           261 | 
           		// layout particulier. Il suffirait alors d'enlever les valeurs de ce layout.
  | 
        
        
            | 
            | 
           262 | 
           		principalLayout.removeAll();
  | 
        
        
            | 
            | 
           263 | 
           		initialiserChampMultiValeursPaginable(nomLabelChampTxt, largeurTotale);
  | 
        
        
            | 
            | 
           264 | 
           	}
  | 
        
        
            | 
            | 
           265 | 
              | 
        
        
            | 
            | 
           266 | 
           	/*------------------
  | 
        
        
            | 
            | 
           267 | 
           	  Méthodes privées
  | 
        
        
            | 
            | 
           268 | 
           	-------------------*/
  | 
        
        
            | 
            | 
           269 | 
           	private void initialiserChampMultiValeursPaginable(String label, int largeurTotale) {
  | 
        
        
            | 
            | 
           270 | 
           		setLabel(label);
  | 
        
        
            | 
            | 
           271 | 
           		setLargeurTotale(largeurTotale);
  | 
        
        
            | 
            | 
           272 | 
              | 
        
        
            | 
            | 
           273 | 
           		titreErreur = Mediateur.i18nC.erreurSaisieTitre();
  | 
        
        
            | 
            | 
           274 | 
           		valeurVideMsg = Mediateur.i18nC.demanderValeur();
  | 
        
        
            | 
            | 
           275 | 
           		valeurIdentiqueMsg = Mediateur.i18nC.valeurDejaPresente();
  | 
        
        
            | 
            | 
           276 | 
              | 
        
        
            | 
            | 
           277 | 
           		valeurs = new HashMap<String, LayoutContainer>();
  | 
        
        
            | 
            | 
           278 | 
           		champRecapitulatif = new HiddenField<String>();
  | 
        
        
            | 
            | 
           279 | 
           		champRecapitulatif.setValue("");
  | 
        
        
            | 
            | 
           280 | 
              | 
        
        
            | 
            | 
           281 | 
           		setLayout(new FormLayout());
  | 
        
        
            | 
            | 
           282 | 
              | 
        
        
            | 
            | 
           283 | 
           		creerChampMultiValeurs();
  | 
        
        
            | 
            | 
           284 | 
           	}
  | 
        
        
            | 
            | 
           285 | 
              | 
        
        
            | 
            | 
           286 | 
           	private void creerChampMultiValeurs() {
  | 
        
        
            | 
            | 
           287 | 
           		principalLayout = new LayoutContainer();
  | 
        
        
            | 
            | 
           288 | 
           		principalLayout.setLayout(new RowLayout());
  | 
        
        
            | 
            | 
           289 | 
              | 
        
        
            | 
            | 
           290 | 
           		/* Creation du champ Valeur */
  | 
        
        
            | 
            | 
           291 | 
           		LabelField label = new LabelField(nomLabelChampTxt + ":");
  | 
        
        
            | 
            | 
           292 | 
           		label.setWidth("95%");
  | 
        
        
            | 
            | 
           293 | 
           		principalLayout.add(label);
  | 
        
        
            | 
            | 
           294 | 
              | 
        
        
            | 
            | 
           295 | 
           		colonneConteneur = new LayoutContainer();
  | 
        
        
            | 
            | 
           296 | 
           		colonneConteneur.setLayout(new ColumnLayout());
  | 
        
        
            | 
            | 
           297 | 
           		colonneChampValeur = new ColumnData(largeurChampValeur);
  | 
        
        
            | 
            | 
           298 | 
              | 
        
        
            | 
            | 
           299 | 
           		if (champValeurEstComboBox) {
  | 
        
        
            | 
            | 
           300 | 
           			champValeurComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyChampValeur, modeltypeChampValeur, displayNameChampValeur);
  | 
        
        
            | 
            | 
           301 | 
           			champValeurComboBox.setWidth(largeurChampValeur);
  | 
        
        
            | 
            | 
           302 | 
           			champValeurComboBox.getCombo().setEmptyText("Valeur...");
  | 
        
        
            | 
            | 
           303 | 
           			colonneConteneur.add(champValeurComboBox, colonneChampValeur);
  | 
        
        
            | 
            | 
           304 | 
           		} else {
  | 
        
        
            | 
            | 
           305 | 
           			champValeurTxt = new TextField<String>();
  | 
        
        
            | 
            | 
           306 | 
           			champValeurTxt.setWidth(largeurChampValeur);
  | 
        
        
            | 
            | 
           307 | 
           			champValeurTxt.setEmptyText("Valeur...");
  | 
        
        
            | 
            | 
           308 | 
           			colonneConteneur.add(champValeurTxt, colonneChampValeur);
  | 
        
        
            | 
            | 
           309 | 
           		}
  | 
        
        
           | 1369 | 
           cyprien | 
           310 | 
              | 
        
        
           | 1287 | 
           cyprien | 
           311 | 
           		/* Creation du bouton Ajouter */
  | 
        
        
            | 
            | 
           312 | 
           		ajouterBouton = new Button();
  | 
        
        
            | 
            | 
           313 | 
           		ajouterBouton.setWidth(largeurBouton);
  | 
        
        
            | 
            | 
           314 | 
           		ajouterBouton.setIcon(Images.ICONES.ajouter());
  | 
        
        
            | 
            | 
           315 | 
           		ajouterBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
  | 
        
        
            | 
            | 
           316 | 
           			public void componentSelected(ButtonEvent ce) {
  | 
        
        
            | 
            | 
           317 | 
           				// récupération de la valeur du champ "Valeur"
  | 
        
        
            | 
            | 
           318 | 
           				String valeurChamp = "";
  | 
        
        
            | 
            | 
           319 | 
           				if (champValeurEstComboBox) {
  | 
        
        
            | 
            | 
           320 | 
           					if (champValeurComboBox.getValeur() != null) {
  | 
        
        
           | 1329 | 
           cyprien | 
           321 | 
           						valeurChamp = (new Valeur(champValeurComboBox.getValeur())).getNom();
  | 
        
        
           | 1287 | 
           cyprien | 
           322 | 
           					}
  | 
        
        
            | 
            | 
           323 | 
           				} else {
  | 
        
        
            | 
            | 
           324 | 
           					valeurChamp = champValeurTxt.getValue();
  | 
        
        
            | 
            | 
           325 | 
           				}
  | 
        
        
            | 
            | 
           326 | 
           				// validation de la valeur avant ajout
  | 
        
        
            | 
            | 
           327 | 
           				if ((valeurChamp == null) || valeurChamp.trim().equals("") || valeurChamp.trim().equals(valeurParDefaut)) {
  | 
        
        
            | 
            | 
           328 | 
           					MessageBox.alert(titreErreur, valeurVideMsg, null);
  | 
        
        
           | 1329 | 
           cyprien | 
           329 | 
           				} else if (valeurs.get(valeurChamp) != null) {
  | 
        
        
           | 1287 | 
           cyprien | 
           330 | 
           					MessageBox.alert(titreErreur, valeurIdentiqueMsg, null);
  | 
        
        
            | 
            | 
           331 | 
           				} else {
  | 
        
        
            | 
            | 
           332 | 
           					if (validationMasque != null && !valeurChamp.matches(validationMasque)) {
  | 
        
        
            | 
            | 
           333 | 
           						MessageBox.alert(titreErreur, valeurNonValideMsg, null);
  | 
        
        
            | 
            | 
           334 | 
           					} else {
  | 
        
        
            | 
            | 
           335 | 
           						ajouterValeur(valeurChamp);
  | 
        
        
            | 
            | 
           336 | 
           					}
  | 
        
        
            | 
            | 
           337 | 
           				}
  | 
        
        
            | 
            | 
           338 | 
           			}
  | 
        
        
            | 
            | 
           339 | 
           		});
  | 
        
        
            | 
            | 
           340 | 
           		colonneBoutonAjouter = new ColumnData(largeurBouton);
  | 
        
        
            | 
            | 
           341 | 
           		colonneConteneur.add(ajouterBouton, colonneBoutonAjouter);
  | 
        
        
           | 1369 | 
           cyprien | 
           342 | 
              | 
        
        
           | 1287 | 
           cyprien | 
           343 | 
           		principalLayout.add(champRecapitulatif);
  | 
        
        
            | 
            | 
           344 | 
           		principalLayout.add(colonneConteneur);
  | 
        
        
            | 
            | 
           345 | 
           		add(principalLayout);
  | 
        
        
            | 
            | 
           346 | 
           	}
  | 
        
        
            | 
            | 
           347 | 
           }
  |