| 1637 | aurelien | 1 | package org.tela_botanica.client.vues.structure;
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | import java.util.ArrayList;
 | 
        
           |  |  | 4 | import java.util.Collection;
 | 
        
           |  |  | 5 | import java.util.Iterator;
 | 
        
           |  |  | 6 | import java.util.List;
 | 
        
           |  |  | 7 |   | 
        
           |  |  | 8 | import org.tela_botanica.client.ComposantClass;
 | 
        
           |  |  | 9 | import org.tela_botanica.client.Mediateur;
 | 
        
           |  |  | 10 | import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
 | 
        
           |  |  | 11 | import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
 | 
        
           |  |  | 12 | import org.tela_botanica.client.composants.InfoLogger;
 | 
        
           |  |  | 13 | import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
 | 
        
           |  |  | 14 | import org.tela_botanica.client.images.Images;
 | 
        
           |  |  | 15 | import org.tela_botanica.client.interfaces.Rafraichissable;
 | 
        
           |  |  | 16 | import org.tela_botanica.client.modeles.Information;
 | 
        
           |  |  | 17 | import org.tela_botanica.client.modeles.Valeur;
 | 
        
           |  |  | 18 | import org.tela_botanica.client.modeles.ValeurListe;
 | 
        
           |  |  | 19 | import org.tela_botanica.client.modeles.aDonnee;
 | 
        
           |  |  | 20 | import org.tela_botanica.client.modeles.personne.Personne;
 | 
        
           |  |  | 21 | import org.tela_botanica.client.modeles.structure.StructureAPersonne;
 | 
        
           |  |  | 22 | import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
 | 
        
           |  |  | 23 | import org.tela_botanica.client.synchronisation.Sequenceur;
 | 
        
           |  |  | 24 | import org.tela_botanica.client.util.Debug;
 | 
        
           |  |  | 25 | import org.tela_botanica.client.util.UtilString;
 | 
        
           |  |  | 26 | import org.tela_botanica.client.vues.Formulaire;
 | 
        
           |  |  | 27 | import org.tela_botanica.client.vues.FormulaireOnglet;
 | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 | import com.extjs.gxt.ui.client.Style.Scroll;
 | 
        
           |  |  | 30 | import com.extjs.gxt.ui.client.data.ModelData;
 | 
        
           |  |  | 31 | import com.extjs.gxt.ui.client.data.ModelType;
 | 
        
           |  |  | 32 | import com.extjs.gxt.ui.client.event.BaseEvent;
 | 
        
           |  |  | 33 | import com.extjs.gxt.ui.client.event.ButtonEvent;
 | 
        
           |  |  | 34 | import com.extjs.gxt.ui.client.event.ComponentEvent;
 | 
        
           |  |  | 35 | import com.extjs.gxt.ui.client.event.Events;
 | 
        
           |  |  | 36 | import com.extjs.gxt.ui.client.event.Listener;
 | 
        
           |  |  | 37 | import com.extjs.gxt.ui.client.event.SelectionListener;
 | 
        
           |  |  | 38 | import com.extjs.gxt.ui.client.store.ListStore;
 | 
        
           |  |  | 39 | import com.extjs.gxt.ui.client.store.Record;
 | 
        
           |  |  | 40 | import com.extjs.gxt.ui.client.store.Store;
 | 
        
           |  |  | 41 | import com.extjs.gxt.ui.client.store.StoreEvent;
 | 
        
           |  |  | 42 | import com.extjs.gxt.ui.client.widget.ContentPanel;
 | 
        
           |  |  | 43 | import com.extjs.gxt.ui.client.widget.TabItem;
 | 
        
           |  |  | 44 | import com.extjs.gxt.ui.client.widget.button.Button;
 | 
        
           |  |  | 45 | import com.extjs.gxt.ui.client.widget.form.ComboBox;
 | 
        
           |  |  | 46 | import com.extjs.gxt.ui.client.widget.form.Field;
 | 
        
           |  |  | 47 | import com.extjs.gxt.ui.client.widget.form.NumberField;
 | 
        
           |  |  | 48 | import com.extjs.gxt.ui.client.widget.form.TextArea;
 | 
        
           |  |  | 49 | import com.extjs.gxt.ui.client.widget.form.TextField;
 | 
        
           |  |  | 50 | import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
 | 
        
           |  |  | 51 | import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
 | 
        
           |  |  | 52 | import com.extjs.gxt.ui.client.widget.grid.CellEditor;
 | 
        
           |  |  | 53 | import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
 | 
        
           |  |  | 54 | import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
 | 
        
           |  |  | 55 | import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
 | 
        
           |  |  | 56 | import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
 | 
        
           |  |  | 57 | import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
 | 
        
           |  |  | 58 | import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
 | 
        
           |  |  | 59 | import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 | 
        
           |  |  | 60 | import com.extjs.gxt.ui.client.widget.layout.FormLayout;
 | 
        
           |  |  | 61 | import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
 | 
        
           |  |  | 62 | import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
 | 
        
           |  |  | 63 | import com.google.gwt.core.client.GWT;
 | 
        
           |  |  | 64 | import com.google.gwt.i18n.client.NumberFormat;
 | 
        
           |  |  | 65 |   | 
        
           |  |  | 66 | public class StructureFormPersonne extends FormulaireOnglet implements Rafraichissable {
 | 
        
           |  |  | 67 |   | 
        
           |  |  | 68 | 	private StructureAPersonneListe personnel = null;
 | 
        
           |  |  | 69 | 	private StructureAPersonneListe personnelAjoute = null;
 | 
        
           |  |  | 70 | 	private StructureAPersonneListe personnelModifie = null;
 | 
        
           |  |  | 71 | 	private StructureAPersonneListe personnelSupprime = null;
 | 
        
           |  |  | 72 | 	private NumberField nbreTotalPersonneStructureChp = null;
 | 
        
           |  |  | 73 | 	private EditorGrid<StructureAPersonne> grillePersonnel = null;
 | 
        
           |  |  | 74 | 	private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 | 	public ListStore<Valeur> fonctionsMagazin;
 | 
        
           |  |  | 77 | 	public ComboBox<Valeur> fonctionsCombo;
 | 
        
           |  |  | 78 | 	public ListStore<Valeur> magazinLiStatut;
 | 
        
           |  |  | 79 | 	public ComboBox<Valeur> comboLiStatut;
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 | 	private ListStore<Personne> personneExistanteMagazin = null;
 | 
        
           |  |  | 82 | 	private ChampComboBoxRechercheTempsReelPaginable personneExistanteCombo = null;
 | 
        
           |  |  | 83 | 	private Button supprimerPersonnelBtn = null;
 | 
        
           |  |  | 84 | 	private CellEditor fonctionEditor = null;
 | 
        
           |  |  | 85 | 	private List<Valeur> fonctionsListe = null;
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 | 	private String ID = "personnel";
 | 
        
           |  |  | 88 | 	private Formulaire formulaireCourant = null;
 | 
        
           |  |  | 89 | 	private int decompteRafraichissementPersonnel;
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 | 	private Sequenceur sequenceur = null;
 | 
        
           |  |  | 92 |   | 
        
           |  |  | 93 | 	final class EtatPersonnelStructure {
 | 
        
           |  |  | 94 | 		public StructureAPersonneListe personnelModifie;
 | 
        
           |  |  | 95 | 		public StructureAPersonneListe personnelAjoute;
 | 
        
           |  |  | 96 | 		public StructureAPersonneListe personnelSupprime;
 | 
        
           |  |  | 97 | 		public StructureAPersonneListe personnel;
 | 
        
           |  |  | 98 | 	}
 | 
        
           |  |  | 99 |   | 
        
           |  |  | 100 | 	public StructureFormPersonne(Formulaire formulaireCourant, Mediateur mediateur) {
 | 
        
           |  |  | 101 |   | 
        
           |  |  | 102 | 		initialiserOnglet(formulaireCourant);
 | 
        
           |  |  | 103 | 		this.formulaireCourant = formulaireCourant;
 | 
        
           |  |  | 104 |   | 
        
           |  |  | 105 | 		// Création des objets contenant les manipulations de la grille
 | 
        
           |  |  | 106 | 		personnelModifie = new StructureAPersonneListe();
 | 
        
           |  |  | 107 | 		personnelAjoute = new StructureAPersonneListe();
 | 
        
           |  |  | 108 | 		personnelSupprime = new StructureAPersonneListe();
 | 
        
           |  |  | 109 |   | 
        
           |  |  | 110 | 		setId(ID);
 | 
        
           |  |  | 111 | 		setText(Mediateur.i18nC.personneSingulier());
 | 
        
           |  |  | 112 | 		FormulaireOnglet.parametrer(this);
 | 
        
           |  |  | 113 |   | 
        
           |  |  | 114 | 		this.setLayout(Formulaire.creerFormLayout(400, LabelAlign.LEFT));
 | 
        
           |  |  | 115 | 		this.setStyleAttribute("padding", "0");
 | 
        
           |  |  | 116 | 		this.addListener(Events.Select, new Listener<ComponentEvent>() {
 | 
        
           |  |  | 117 | 			public void handleEvent(ComponentEvent be) {
 | 
        
           |  |  | 118 | 				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
 | 
        
           |  |  | 119 | 				setData("acces", true);
 | 
        
           |  |  | 120 |   | 
        
           |  |  | 121 | 				// Rafraichissement du contenu de la grille du personnel
 | 
        
           |  |  | 122 | 				if (StructureFormPersonne.this.formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
 | 
        
           |  |  | 123 | 					rafraichirPersonnel();
 | 
        
           |  |  | 124 | 				}
 | 
        
           |  |  | 125 | 			}
 | 
        
           |  |  | 126 | 		});
 | 
        
           |  |  | 127 |   | 
        
           |  |  | 128 | 		ContentPanel cp = new ContentPanel();
 | 
        
           | 1680 | raphael | 129 | 		cp.setHeadingHtml("Personnes travaillant sur les collections");
 | 
        
           | 1637 | aurelien | 130 | 		cp.setIcon(Images.ICONES.table());
 | 
        
           |  |  | 131 | 		cp.setScrollMode(Scroll.AUTO);
 | 
        
           |  |  | 132 | 		cp.setLayout(new FitLayout());
 | 
        
           |  |  | 133 | 		//cp.setWidth(1250);
 | 
        
           |  |  | 134 | 		//cp.setHeight("100%");
 | 
        
           |  |  | 135 | 		cp.setFrame(true);
 | 
        
           |  |  | 136 |   | 
        
           |  |  | 137 | 		personnelGrilleMagazin = new ListStore<StructureAPersonne>();
 | 
        
           |  |  | 138 | 		personnelGrilleMagazin.setMonitorChanges(true);
 | 
        
           |  |  | 139 |   | 
        
           |  |  | 140 | 		personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() {
 | 
        
           |  |  | 141 | 			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
 | 
        
           |  |  | 142 | 				// Activation du bouton supprimer si la grille contient un élément
 | 
        
           |  |  | 143 | 				if (grillePersonnel.getStore().getCount() > 0) {
 | 
        
           |  |  | 144 | 					supprimerPersonnelBtn.enable();
 | 
        
           |  |  | 145 | 				}
 | 
        
           |  |  | 146 |   | 
        
           |  |  | 147 | 			}
 | 
        
           |  |  | 148 | 		});
 | 
        
           |  |  | 149 |   | 
        
           |  |  | 150 |   | 
        
           |  |  | 151 | 		RowNumberer r = new RowNumberer();
 | 
        
           |  |  | 152 |   | 
        
           |  |  | 153 | 		List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
 | 
        
           |  |  | 154 |   | 
        
           |  |  | 155 | 		GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>();
 | 
        
           |  |  | 156 | 		configs.add(r);
 | 
        
           |  |  | 157 |   | 
        
           |  |  | 158 | 		ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150);
 | 
        
           |  |  | 159 | 		fonctionsMagazin = new ListStore<Valeur>();
 | 
        
           |  |  | 160 |   | 
        
           |  |  | 161 | 		fonctionsCombo = new ComboBox<Valeur>();
 | 
        
           |  |  | 162 | 		fonctionsCombo.setTriggerAction(TriggerAction.ALL);
 | 
        
           |  |  | 163 | 		fonctionsCombo.setEditable(true);
 | 
        
           |  |  | 164 | 		fonctionsCombo.setDisplayField("nom");
 | 
        
           |  |  | 165 | 		fonctionsCombo.setStore(fonctionsMagazin);
 | 
        
           |  |  | 166 | 		mediateur.obtenirListeValeurEtRafraichir(this, "fonction", sequenceur);
 | 
        
           |  |  | 167 |   | 
        
           |  |  | 168 | 		fonctionEditor = new CellEditor(fonctionsCombo) {
 | 
        
           |  |  | 169 | 			@Override
 | 
        
           |  |  | 170 | 			public Object preProcessValue(Object valeur) {
 | 
        
           |  |  | 171 | 				Valeur retour = null;
 | 
        
           |  |  | 172 |   | 
        
           |  |  | 173 | 				if (valeur != null) {
 | 
        
           |  |  | 174 | 					String chaineTransmise = (String) valeur;
 | 
        
           |  |  | 175 | 					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
 | 
        
           |  |  | 176 | 						fonctionsMagazin.add(fonctionsListe);
 | 
        
           |  |  | 177 | 					}
 | 
        
           |  |  | 178 | 					if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) {
 | 
        
           |  |  | 179 | 						retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise);
 | 
        
           |  |  | 180 | 					} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) {
 | 
        
           |  |  | 181 | 						retour = fonctionsMagazin.findModel("nom", chaineTransmise);
 | 
        
           |  |  | 182 | 					} else {
 | 
        
           |  |  | 183 | 						retour = new Valeur("", chaineTransmise, "", "");
 | 
        
           |  |  | 184 | 					}
 | 
        
           |  |  | 185 | 				}
 | 
        
           |  |  | 186 |   | 
        
           |  |  | 187 | 				return retour;
 | 
        
           |  |  | 188 | 			}
 | 
        
           |  |  | 189 |   | 
        
           |  |  | 190 | 			@Override
 | 
        
           |  |  | 191 | 			public Object postProcessValue(Object valeur) {
 | 
        
           |  |  | 192 | 				String retour = "";
 | 
        
           |  |  | 193 | 				Valeur fonctionTrouvee = null;
 | 
        
           |  |  | 194 | 				if (valeur == null) {
 | 
        
           |  |  | 195 | 					String valeurBrute = this.getField().getRawValue();
 | 
        
           |  |  | 196 | 					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
 | 
        
           |  |  | 197 | 						fonctionsMagazin.add(fonctionsListe);
 | 
        
           |  |  | 198 | 					}
 | 
        
           |  |  | 199 | 					if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) {
 | 
        
           |  |  | 200 | 						fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute);
 | 
        
           |  |  | 201 | 					} else {
 | 
        
           |  |  | 202 | 						retour = valeurBrute;
 | 
        
           |  |  | 203 | 					}
 | 
        
           |  |  | 204 | 				} else if (valeur instanceof Valeur) {
 | 
        
           |  |  | 205 | 					fonctionTrouvee = (Valeur) valeur;
 | 
        
           |  |  | 206 | 				}
 | 
        
           |  |  | 207 |   | 
        
           |  |  | 208 | 				if (fonctionTrouvee != null) {
 | 
        
           |  |  | 209 | 					retour = fonctionTrouvee.getNom();
 | 
        
           |  |  | 210 | 				}
 | 
        
           |  |  | 211 |   | 
        
           |  |  | 212 | 				return retour;
 | 
        
           |  |  | 213 | 			}
 | 
        
           |  |  | 214 | 		};
 | 
        
           |  |  | 215 | 		column.setEditor(fonctionEditor);
 | 
        
           |  |  | 216 | 		configs.add(column);
 | 
        
           |  |  | 217 |   | 
        
           |  |  | 218 | 		column = new ColumnConfig("prenom", "Prénom", 100);
 | 
        
           |  |  | 219 | 		TextField<String> prenomChp = new TextField<String>();
 | 
        
           |  |  | 220 | 		prenomChp.setAllowBlank(false);
 | 
        
           |  |  | 221 | 		prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");
 | 
        
           |  |  | 222 | 		prenomChp.setAutoValidate(true);
 | 
        
           |  |  | 223 | 		prenomChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           |  |  | 224 | 		prenomChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
 | 
        
           |  |  | 225 | 		column.setEditor(new CellEditor(prenomChp));
 | 
        
           |  |  | 226 | 		configs.add(column);
 | 
        
           |  |  | 227 |   | 
        
           |  |  | 228 | 		column = new ColumnConfig("nom", "Nom", 100);
 | 
        
           |  |  | 229 | 		TextField<String> nomChp = new TextField<String>();
 | 
        
           |  |  | 230 | 		nomChp.setAllowBlank(false);
 | 
        
           |  |  | 231 | 		nomChp.getMessages().setBlankText("Ce champ est obligatoire.");
 | 
        
           |  |  | 232 | 		nomChp.setAutoValidate(true);
 | 
        
           |  |  | 233 | 		nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           |  |  | 234 | 		nomChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
 | 
        
           |  |  | 235 | 		column.setEditor(new CellEditor(nomChp));
 | 
        
           |  |  | 236 | 		configs.add(column);
 | 
        
           |  |  | 237 |   | 
        
           |  |  | 238 | 		column = new ColumnConfig("tel_fix", "Téléphone fixe", 100);
 | 
        
           |  |  | 239 | 		TextField<String> telChp = new TextField<String>();
 | 
        
           |  |  | 240 | 		column.setEditor(new CellEditor(telChp));
 | 
        
           |  |  | 241 | 		configs.add(column);
 | 
        
           |  |  | 242 |   | 
        
           |  |  | 243 | 		column = new ColumnConfig("tel_fax", "Fax", 100);
 | 
        
           |  |  | 244 | 		TextField<String> faxChp = new TextField<String>();
 | 
        
           |  |  | 245 | 		column.setEditor(new CellEditor(faxChp));
 | 
        
           |  |  | 246 | 		configs.add(column);
 | 
        
           |  |  | 247 |   | 
        
           |  |  | 248 | 		column = new ColumnConfig("courriel", "Courriel principal", 200);
 | 
        
           |  |  | 249 | 		TextField<String> emailChp = new TextField<String>();
 | 
        
           |  |  | 250 | 		column.setEditor(new CellEditor(emailChp));
 | 
        
           |  |  | 251 | 		configs.add(column);
 | 
        
           |  |  | 252 |   | 
        
           |  |  | 253 | 		magazinLiStatut = new ListStore<Valeur>();
 | 
        
           |  |  | 254 | 		magazinLiStatut.add(new ArrayList<Valeur>());
 | 
        
           |  |  | 255 |   | 
        
           |  |  | 256 | 		comboLiStatut = new ComboBox<Valeur>();
 | 
        
           |  |  | 257 | 		comboLiStatut.setTriggerAction(TriggerAction.ALL);
 | 
        
           |  |  | 258 | 		comboLiStatut.setEditable(false);
 | 
        
           |  |  | 259 | 		comboLiStatut.disableTextSelection(true);
 | 
        
           |  |  | 260 | 		comboLiStatut.setDisplayField("nom");
 | 
        
           |  |  | 261 | 		comboLiStatut.setStore(magazinLiStatut);
 | 
        
           |  |  | 262 | 		mediateur.obtenirListeValeurEtRafraichir(this, "statut", sequenceur);
 | 
        
           |  |  | 263 |   | 
        
           |  |  | 264 | 		CellEditor statutEditor = new CellEditor(comboLiStatut) {
 | 
        
           |  |  | 265 | 			@Override
 | 
        
           |  |  | 266 | 			public Object preProcessValue(Object value) {
 | 
        
           |  |  | 267 | 				if (value == null) {
 | 
        
           |  |  | 268 | 					return value;
 | 
        
           |  |  | 269 | 				}
 | 
        
           |  |  | 270 | 				return comboLiStatut.getStore().findModel("nom", (String) value);
 | 
        
           |  |  | 271 | 			}
 | 
        
           |  |  | 272 |   | 
        
           |  |  | 273 | 			@Override
 | 
        
           |  |  | 274 | 			public Object postProcessValue(Object value) {
 | 
        
           |  |  | 275 | 				if (value == null) {
 | 
        
           |  |  | 276 | 					return value;
 | 
        
           |  |  | 277 | 				}
 | 
        
           |  |  | 278 | 				return ((Valeur) value).get("nom");
 | 
        
           |  |  | 279 | 			}
 | 
        
           |  |  | 280 | 		};
 | 
        
           |  |  | 281 | 		column = new ColumnConfig("statut", "Statut", 100);
 | 
        
           |  |  | 282 | 		column.setEditor(statutEditor);
 | 
        
           |  |  | 283 | 		configs.add(column);
 | 
        
           |  |  | 284 |   | 
        
           |  |  | 285 | 		column = new ColumnConfig("travail", "Travail hebdo (%)", 100);
 | 
        
           |  |  | 286 | 		column.setNumberFormat(NumberFormat.getFormat("##"));
 | 
        
           |  |  | 287 | 		NumberField tpsWChp = new NumberField();
 | 
        
           |  |  | 288 | 		tpsWChp.setFormat(NumberFormat.getFormat("##"));
 | 
        
           |  |  | 289 | 		tpsWChp.setToolTip("Ce champ doit contenir un nombre");
 | 
        
           |  |  | 290 | 		column.setEditor(new CellEditor(tpsWChp));
 | 
        
           |  |  | 291 | 		configs.add(column);
 | 
        
           |  |  | 292 |   | 
        
           |  |  | 293 | 		column = new ColumnConfig("specialite", "Spécialité principale", 150);
 | 
        
           |  |  | 294 | 		TextField<String> speChp = new TextField<String>();
 | 
        
           |  |  | 295 | 		column.setEditor(new CellEditor(speChp));
 | 
        
           |  |  | 296 | 		configs.add(column);
 | 
        
           |  |  | 297 |   | 
        
           |  |  | 298 | 		CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
 | 
        
           |  |  | 299 | 		configs.add(checkColumn);
 | 
        
           |  |  | 300 |   | 
        
           |  |  | 301 | 		ToolBar toolBar = new ToolBar();
 | 
        
           |  |  | 302 |   | 
        
           |  |  | 303 | 		Button ajouterPersonnelBtn = new Button("Ajouter");
 | 
        
           |  |  | 304 | 		ajouterPersonnelBtn.setIcon(Images.ICONES.vcardAjouter());
 | 
        
           |  |  | 305 | 		ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 306 | 			@Override
 | 
        
           |  |  | 307 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 308 | 				StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
 | 
        
           |  |  | 309 | 				ajouterMembreAGrillePersonnel(membreDuPersonnel);
 | 
        
           |  |  | 310 | 			}
 | 
        
           |  |  | 311 | 		});
 | 
        
           |  |  | 312 | 		toolBar.add(ajouterPersonnelBtn);
 | 
        
           |  |  | 313 |   | 
        
           |  |  | 314 | 		toolBar.add(new SeparatorToolItem());
 | 
        
           |  |  | 315 |   | 
        
           |  |  | 316 | 		supprimerPersonnelBtn = new Button("Supprimer");
 | 
        
           |  |  | 317 | 		supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer());
 | 
        
           |  |  | 318 | 		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 319 | 			@Override
 | 
        
           |  |  | 320 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 321 | 				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
 | 
        
           |  |  | 322 | 				if (personne != null) {
 | 
        
           |  |  | 323 | 					// Ajout de la personne supprimée à la liste
 | 
        
           |  |  | 324 | 					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
 | 
        
           |  |  | 325 | 						personnelSupprime.put(personne.getId(), personne);
 | 
        
           |  |  | 326 | 					}
 | 
        
           |  |  | 327 |   | 
        
           |  |  | 328 | 					// Suppression de l'enregistrement de la grille
 | 
        
           |  |  | 329 | 					grillePersonnel.getStore().remove(personne);
 | 
        
           |  |  | 330 |   | 
        
           |  |  | 331 | 					// Désactivation du bouton supprimer si la grille contient plus d'élément
 | 
        
           |  |  | 332 | 					if (grillePersonnel.getStore().getCount() == 0) {
 | 
        
           |  |  | 333 | 						//TODO : check : Item -> component
 | 
        
           |  |  | 334 | 						ce.getComponent().disable();
 | 
        
           |  |  | 335 | 					}
 | 
        
           |  |  | 336 | 				}
 | 
        
           |  |  | 337 | 			}
 | 
        
           |  |  | 338 | 		});
 | 
        
           |  |  | 339 | 		toolBar.add(supprimerPersonnelBtn);
 | 
        
           |  |  | 340 |   | 
        
           |  |  | 341 | 		toolBar.add(new SeparatorToolItem());
 | 
        
           |  |  | 342 |   | 
        
           |  |  | 343 | 		Button rafraichirPersonnelBtn = new Button("Rafraichir");
 | 
        
           |  |  | 344 | 		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
 | 
        
           |  |  | 345 | 		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 346 | 			@Override
 | 
        
           |  |  | 347 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 348 | 				rafraichirPersonnel();
 | 
        
           |  |  | 349 | 			}
 | 
        
           |  |  | 350 | 		});
 | 
        
           |  |  | 351 | 		toolBar.add(rafraichirPersonnelBtn);
 | 
        
           |  |  | 352 |   | 
        
           |  |  | 353 | 		toolBar.add(new SeparatorToolItem());
 | 
        
           |  |  | 354 |   | 
        
           |  |  | 355 | 		personneExistanteMagazin = new ListStore<Personne>();
 | 
        
           |  |  | 356 | 		personneExistanteMagazin.add(new ArrayList<Personne>());
 | 
        
           |  |  | 357 |   | 
        
           |  |  | 358 | 		ModelType modelTypePersonnes = new ModelType();
 | 
        
           |  |  | 359 | 		modelTypePersonnes.setRoot("personnes");
 | 
        
           |  |  | 360 | 		modelTypePersonnes.setTotalName("nbElements");
 | 
        
           |  |  | 361 | 		modelTypePersonnes.addField("cp_fmt_nom_complet");
 | 
        
           |  |  | 362 | 		modelTypePersonnes.addField("cp_nom");
 | 
        
           |  |  | 363 | 		modelTypePersonnes.addField("cp_prenom");
 | 
        
           |  |  | 364 | 		modelTypePersonnes.addField("cp_truk_courriel");
 | 
        
           |  |  | 365 | 		modelTypePersonnes.addField("cp_truk_telephone");
 | 
        
           |  |  | 366 | 		modelTypePersonnes.addField("cp_ce_truk_specialite");
 | 
        
           |  |  | 367 | 		modelTypePersonnes.addField("cp_id_personne");
 | 
        
           |  |  | 368 |   | 
        
           |  |  | 369 | 		String displayNamePersonnes = "cp_fmt_nom_complet";
 | 
        
           |  |  | 370 | 		ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
 | 
        
           |  |  | 371 |   | 
        
           |  |  | 372 | 		personneExistanteCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
 | 
        
           |  |  | 373 |   | 
        
           |  |  | 374 | 		// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar
 | 
        
           |  |  | 375 | 			//> CHECK
 | 
        
           |  |  | 376 | 		toolBar.add(personneExistanteCombo);
 | 
        
           |  |  | 377 |   | 
        
           |  |  | 378 | 		Button ajouterPersonneExistanteBtn = new Button("Ajouter à la grille");
 | 
        
           |  |  | 379 | 		ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 380 | 			@Override
 | 
        
           |  |  | 381 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 382 |   | 
        
           |  |  | 383 | 				Personne personneExistante = new Personne(personneExistanteCombo.getValeur());
 | 
        
           |  |  | 384 |   | 
        
           |  |  | 385 | 				if (personneExistante != null) {
 | 
        
           |  |  | 386 | 					StructureAPersonne membreDuPersonnel = new StructureAPersonne(personneExistante, "", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
 | 
        
           |  |  | 387 | 					ajouterMembreAGrillePersonnel(membreDuPersonnel);
 | 
        
           |  |  | 388 | 				}
 | 
        
           |  |  | 389 | 			}
 | 
        
           |  |  | 390 | 		});
 | 
        
           |  |  | 391 | 		toolBar.add(ajouterPersonneExistanteBtn);
 | 
        
           |  |  | 392 |   | 
        
           |  |  | 393 | 		cp.setTopComponent(toolBar);
 | 
        
           |  |  | 394 |   | 
        
           |  |  | 395 | 		ColumnModel cm = new ColumnModel(configs);
 | 
        
           |  |  | 396 |   | 
        
           |  |  | 397 | 		grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);
 | 
        
           |  |  | 398 | 		grillePersonnel.setHeight("100%");
 | 
        
           |  |  | 399 | 		grillePersonnel.setBorders(true);
 | 
        
           |  |  | 400 | 		grillePersonnel.setSelectionModel(sm);
 | 
        
           |  |  | 401 | 		grillePersonnel.addPlugin(checkColumn);
 | 
        
           |  |  | 402 | 		grillePersonnel.addPlugin(r);
 | 
        
           |  |  | 403 | 		grillePersonnel.getView().setForceFit(true);
 | 
        
           |  |  | 404 |   		grillePersonnel.setAutoExpandColumn("specialite");
 | 
        
           |  |  | 405 |   		grillePersonnel.setStripeRows(true);
 | 
        
           |  |  | 406 |   		grillePersonnel.setTrackMouseOver(true);
 | 
        
           |  |  | 407 |   | 
        
           |  |  | 408 |   | 
        
           |  |  | 409 | 		personnelGrilleMagazin.addListener(Store.Update, new Listener<StoreEvent<StructureAPersonne>>() {
 | 
        
           |  |  | 410 | 			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
 | 
        
           |  |  | 411 | 				StructureAPersonne structureAPersonne = ce.getModel();
 | 
        
           |  |  | 412 | 				String etat = structureAPersonne.get("etat");
 | 
        
           |  |  | 413 | 				if ((etat==null || !etat.equals(aDonnee.ETAT_AJOUTE)) && structureAPersonne!=null && !UtilString.isEmpty(structureAPersonne.getId()))	{
 | 
        
           |  |  | 414 | 					ce.getModel().set("etat", aDonnee.ETAT_MODIFIE);
 | 
        
           |  |  | 415 | 				}
 | 
        
           |  |  | 416 | 			}
 | 
        
           |  |  | 417 | 		});
 | 
        
           |  |  | 418 |   | 
        
           |  |  | 419 |   | 
        
           |  |  | 420 |   		cp.add(grillePersonnel);
 | 
        
           |  |  | 421 | 		this.add(cp);
 | 
        
           |  |  | 422 | 	}
 | 
        
           |  |  | 423 |   | 
        
           |  |  | 424 | 	public Collection<? extends String> verifier() {
 | 
        
           |  |  | 425 | 		ArrayList<String> messages = new ArrayList<String>();
 | 
        
           |  |  | 426 | 		// Vérification du Personnel
 | 
        
           |  |  | 427 | 		if (getData("acces").equals(true)) {
 | 
        
           |  |  | 428 | 			String personnelNumero = "";
 | 
        
           |  |  | 429 | 			int nbrePersonne = personnelGrilleMagazin.getCount();
 | 
        
           |  |  | 430 | 			for (int i = 0; i < nbrePersonne; i++) {
 | 
        
           |  |  | 431 | 				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
 | 
        
           |  |  | 432 | 				if (personne.getNom().equals("") || personne.getPrenom().equals("")) {
 | 
        
           |  |  | 433 | 					personnelNumero += (i != 0 ? ", " : "")+(i+1);
 | 
        
           |  |  | 434 | 				}
 | 
        
           |  |  | 435 | 			}
 | 
        
           |  |  | 436 | 			if (!personnelNumero.equals("")) {
 | 
        
           |  |  | 437 | 				messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero);
 | 
        
           |  |  | 438 | 			}
 | 
        
           |  |  | 439 | 		}
 | 
        
           |  |  | 440 | 		return messages;
 | 
        
           |  |  | 441 | 	}
 | 
        
           |  |  | 442 |   | 
        
           |  |  | 443 | 	@Override
 | 
        
           |  |  | 444 | 	public void rafraichir(Object nouvellesDonnees) {
 | 
        
           |  |  | 445 | 		if (nouvellesDonnees instanceof ValeurListe) {
 | 
        
           |  |  | 446 | 			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
 | 
        
           |  |  | 447 | 			rafraichirValeurListe(listeValeurs);
 | 
        
           |  |  | 448 | 		} else if (nouvellesDonnees instanceof Information) {
 | 
        
           |  |  | 449 | 			Information info = (Information) nouvellesDonnees;
 | 
        
           |  |  | 450 | 			rafraichirInformation(info);
 | 
        
           |  |  | 451 | 		} else {
 | 
        
           |  |  | 452 | 			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
 | 
        
           |  |  | 453 | 		}
 | 
        
           |  |  | 454 | 	}
 | 
        
           |  |  | 455 |   | 
        
           |  |  | 456 | 	public void rafraichirInformation(Information info) {
 | 
        
           |  |  | 457 | 		if (info.getType().equals("ajout_structure")) {
 | 
        
           |  |  | 458 | 			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
 | 
        
           |  |  | 459 | 				String structureId = (String) info.getDonnee(0);
 | 
        
           |  |  | 460 | 				// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel
 | 
        
           |  |  | 461 | 				mediateur.ajouterStructureAPersonne(this, structureId, getPersonnelAjoute());
 | 
        
           |  |  | 462 | 			}
 | 
        
           |  |  | 463 | 		} else if (info.getType().equals("modif_structure_a_personne")) {
 | 
        
           |  |  | 464 | 			InfoLogger.display("Modification du Personnel", info.toString());
 | 
        
           |  |  | 465 | 			testerLancementRafraichirPersonnel();
 | 
        
           |  |  | 466 | 		} else if (info.getType().equals("suppression_structure_a_personne")) {
 | 
        
           |  |  | 467 | 			InfoLogger.display("Suppression du Personnel", info.toString());
 | 
        
           |  |  | 468 | 			testerLancementRafraichirPersonnel();
 | 
        
           |  |  | 469 | 		} else if (info.getType().equals("ajout_structure_a_personne")) {
 | 
        
           |  |  | 470 | 			InfoLogger.display("Ajout du Personnel", info.toString());
 | 
        
           |  |  | 471 | 			testerLancementRafraichirPersonnel();
 | 
        
           |  |  | 472 | 		} else if (info.getType().equals("liste_structure_a_personne")) {
 | 
        
           |  |  | 473 | 			if (info.getDonnee(0) != null) {
 | 
        
           |  |  | 474 | 				StructureAPersonneListe personnel = (StructureAPersonneListe) info.getDonnee(0);
 | 
        
           |  |  | 475 | 				peupler(personnel);
 | 
        
           |  |  | 476 | 				layout();
 | 
        
           |  |  | 477 | 				InfoLogger.display("Chargement du Personnel", "ok");
 | 
        
           |  |  | 478 | 			}
 | 
        
           |  |  | 479 | 		}
 | 
        
           |  |  | 480 | 	}
 | 
        
           |  |  | 481 |   | 
        
           |  |  | 482 | 	public void rafraichirValeurListe(ValeurListe listeValeurs) {
 | 
        
           |  |  | 483 | 		List<Valeur> liste = listeValeurs.toList();
 | 
        
           |  |  | 484 | 		if (listeValeurs.getId().equals(config.getListeId("statut"))) {
 | 
        
           |  |  | 485 | 			magazinLiStatut.removeAll();
 | 
        
           |  |  | 486 | 			magazinLiStatut.add(liste);
 | 
        
           |  |  | 487 | 			comboLiStatut.setStore(magazinLiStatut);
 | 
        
           |  |  | 488 | 		}
 | 
        
           |  |  | 489 | 		if (listeValeurs.getId().equals(config.getListeId("fonction"))) {
 | 
        
           |  |  | 490 | 			// FIXME : le store ne contient pas tout le temps les données, chose étrange.
 | 
        
           |  |  | 491 | 			// On stocke donc les données dans une variables de la classe pour recharger le store si besoin.
 | 
        
           |  |  | 492 | 			fonctionsListe = liste;
 | 
        
           |  |  | 493 | 			fonctionsMagazin.removeAll();
 | 
        
           |  |  | 494 | 			fonctionsMagazin.add(liste);
 | 
        
           |  |  | 495 | 			fonctionsCombo.setStore(fonctionsMagazin);
 | 
        
           |  |  | 496 | 		}
 | 
        
           |  |  | 497 | 	}
 | 
        
           |  |  | 498 |   | 
        
           |  |  | 499 | 	public EtatPersonnelStructure collecter() {
 | 
        
           |  |  | 500 | 		StructureForm formulaire = (StructureForm)formulaireCourant;
 | 
        
           |  |  | 501 |   | 
        
           |  |  | 502 | 		if (getData("acces").equals(true)) {
 | 
        
           |  |  | 503 | 			personnelGrilleMagazin.commitChanges();
 | 
        
           |  |  | 504 | 			int nbrePersonne = personnelGrilleMagazin.getCount();
 | 
        
           |  |  | 505 | 			for (int i = 0; i < nbrePersonne; i++) {
 | 
        
           |  |  | 506 | 				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
 | 
        
           |  |  | 507 |   | 
        
           |  |  | 508 | 				// Seules les lignes ajoutées ou modifiées sont prises en compte.
 | 
        
           |  |  | 509 | 				Record record = personnelGrilleMagazin.getRecord(personne);
 | 
        
           |  |  | 510 | 				if (personnelGrilleMagazin.getModifiedRecords().contains(record) == true
 | 
        
           |  |  | 511 | 						|| (personne.get("etat") != null && (personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE) || personne.get("etat").equals(StructureAPersonne.ETAT_MODIFIE)) )) {
 | 
        
           |  |  | 512 |   | 
        
           |  |  | 513 | 					// Gestion de l'id de la structure
 | 
        
           |  |  | 514 | 					if (mode.equals("MODIF")) {
 | 
        
           |  |  | 515 | 						personne.setIdStructure(getIdIdentification());
 | 
        
           |  |  | 516 | 					}
 | 
        
           |  |  | 517 |   | 
        
           |  |  | 518 | 					// Gestion de la fonction
 | 
        
           |  |  | 519 | 					String fonction = personne.get("fonction");
 | 
        
           |  |  | 520 | 					if (fonction != null && !fonction.equals("")) {
 | 
        
           |  |  | 521 | 						Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction);
 | 
        
           |  |  | 522 | 						if (valeurRecherche != null) {
 | 
        
           |  |  | 523 | 							personne.setFonction(valeurRecherche.getId());
 | 
        
           |  |  | 524 | 						} else {
 | 
        
           |  |  | 525 | 							personne.setFonction("AUTRE", fonction);
 | 
        
           |  |  | 526 | 						}
 | 
        
           |  |  | 527 | 					} else {
 | 
        
           |  |  | 528 | 						personne.setFonction("");
 | 
        
           |  |  | 529 | 					}
 | 
        
           |  |  | 530 |   | 
        
           |  |  | 531 | 					// Gestion du nom complet
 | 
        
           |  |  | 532 | 					String nomComplet = personne.getPrenom()+" "+personne.getNom();
 | 
        
           |  |  | 533 | 					personne.setNomComplet(nomComplet);
 | 
        
           |  |  | 534 |   | 
        
           |  |  | 535 | 					// Gestion de la notion de "contact"
 | 
        
           |  |  | 536 | 					personne.setContact(false);
 | 
        
           |  |  | 537 | 					if (personne.get("contact").equals(true)) {
 | 
        
           |  |  | 538 | 						personne.setContact(true);
 | 
        
           |  |  | 539 | 					}
 | 
        
           |  |  | 540 |   | 
        
           |  |  | 541 | 					// Gestion du statut
 | 
        
           |  |  | 542 | 					String statut = personne.get("statut");
 | 
        
           |  |  | 543 | 					if (statut != null && !statut.equals("")) {
 | 
        
           |  |  | 544 | 						Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut);
 | 
        
           |  |  | 545 | 						if (valeurRecherche != null) {
 | 
        
           |  |  | 546 | 							personne.setStatut(valeurRecherche.getId());
 | 
        
           |  |  | 547 | 						} else {
 | 
        
           |  |  | 548 | 							personne.setStatut("AUTRE", statut);
 | 
        
           |  |  | 549 | 						}
 | 
        
           |  |  | 550 | 					} else {
 | 
        
           |  |  | 551 | 						personne.setStatut("");
 | 
        
           |  |  | 552 | 					}
 | 
        
           |  |  | 553 |   | 
        
           |  |  | 554 | 					// Gestion du temps de travail
 | 
        
           |  |  | 555 | 					String personneTravail = "";
 | 
        
           |  |  | 556 | 					if(personne.get("travail") != null) {
 | 
        
           |  |  | 557 | 						personneTravail = personne.get("travail").toString();
 | 
        
           |  |  | 558 | 					}
 | 
        
           |  |  | 559 | 					personne.setBotaTravailHebdoTps(personneTravail);
 | 
        
           |  |  | 560 |   | 
        
           |  |  | 561 | 					// Gestion du téléphone
 | 
        
           |  |  | 562 | 					String telephoneFixe = personne.get("tel_fix");
 | 
        
           |  |  | 563 | 					personne.setTelephoneFixe(telephoneFixe);
 | 
        
           |  |  | 564 |   | 
        
           |  |  | 565 | 					// Gestion du fax
 | 
        
           |  |  | 566 | 					String fax = personne.get("tel_fax");
 | 
        
           |  |  | 567 | 					personne.setFax(fax);
 | 
        
           |  |  | 568 |   | 
        
           |  |  | 569 | 					// Gestion du courriel
 | 
        
           |  |  | 570 | 					String courriel = personne.get("courriel");
 | 
        
           |  |  | 571 | 					personne.setCourriel(courriel);
 | 
        
           |  |  | 572 |   | 
        
           |  |  | 573 | 					// Gestion de la spécialité
 | 
        
           |  |  | 574 | 					String specialite = personne.get("specialite");
 | 
        
           |  |  | 575 | 					personne.setSpecialite(specialite);
 | 
        
           |  |  | 576 |   | 
        
           |  |  | 577 | 					// On met à faux le décès
 | 
        
           |  |  | 578 | 					personne.setDeces(Personne.ETRE_VIVANT);
 | 
        
           |  |  | 579 |   | 
        
           |  |  | 580 | 					// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)
 | 
        
           |  |  | 581 | 					if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) { // Une personne ajoutée
 | 
        
           |  |  | 582 | 						personnelAjoute.put(""+i, personne);
 | 
        
           |  |  | 583 | 					} else {// Une personne modifiée
 | 
        
           |  |  | 584 | 						personnelModifie.put(personne.getId(), personne);
 | 
        
           |  |  | 585 | 					}
 | 
        
           |  |  | 586 | 				} else {
 | 
        
           |  |  | 587 | 					GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null);
 | 
        
           |  |  | 588 | 				}
 | 
        
           |  |  | 589 | 			}
 | 
        
           |  |  | 590 | 		}
 | 
        
           |  |  | 591 |   | 
        
           |  |  | 592 | 		EtatPersonnelStructure etatPersonnel = new EtatPersonnelStructure();
 | 
        
           |  |  | 593 | 		etatPersonnel.personnelAjoute = personnelAjoute;
 | 
        
           |  |  | 594 | 		etatPersonnel.personnelModifie = personnelModifie;
 | 
        
           |  |  | 595 | 		etatPersonnel.personnelSupprime = personnelSupprime;
 | 
        
           |  |  | 596 |   | 
        
           |  |  | 597 | 		// Remise à zéro des modification dans la liste du personnel
 | 
        
           |  |  | 598 | 		personnelModifie = new StructureAPersonneListe();
 | 
        
           |  |  | 599 | 		personnelAjoute = new StructureAPersonneListe();
 | 
        
           |  |  | 600 | 		personnelSupprime = new StructureAPersonneListe();
 | 
        
           |  |  | 601 |   | 
        
           |  |  | 602 | 		return etatPersonnel;
 | 
        
           |  |  | 603 | 	}
 | 
        
           |  |  | 604 |   | 
        
           |  |  | 605 | 	public void peupler(StructureAPersonneListe personnel) {
 | 
        
           |  |  | 606 | 		//this.personnel = personnel;
 | 
        
           |  |  | 607 | 		if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && personnel != null) {
 | 
        
           |  |  | 608 | 			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
 | 
        
           |  |  | 609 | 			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
 | 
        
           |  |  | 610 | 				String index = it.next();
 | 
        
           |  |  | 611 |   | 
        
           |  |  | 612 | 				// Gestion de la fonction
 | 
        
           |  |  | 613 | 				if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {
 | 
        
           |  |  | 614 | 					if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) {
 | 
        
           |  |  | 615 | 						personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
 | 
        
           |  |  | 616 | 					}
 | 
        
           |  |  | 617 | 				} else {
 | 
        
           |  |  | 618 | 					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
 | 
        
           |  |  | 619 | 				}
 | 
        
           |  |  | 620 |   | 
        
           |  |  | 621 | 				// Gestion de la notion de "contact"
 | 
        
           |  |  | 622 | 				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
 | 
        
           |  |  | 623 |   | 
        
           |  |  | 624 | 				// Gestion du statut
 | 
        
           |  |  | 625 | 				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
 | 
        
           |  |  | 626 | 					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
 | 
        
           |  |  | 627 | 				} else {
 | 
        
           |  |  | 628 | 					personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", ""));
 | 
        
           |  |  | 629 | 				}
 | 
        
           |  |  | 630 | 				// Gestion de la specialite
 | 
        
           |  |  | 631 | 				if (((String) personnel.get(index).getSpecialite()).matches("^[0-9]+$")) {
 | 
        
           |  |  | 632 | 					// Author : Cyprien
 | 
        
           |  |  | 633 | 					// TODO
 | 
        
           |  |  | 634 | 					// Ici faire un combobox ?
 | 
        
           |  |  | 635 | 					// ...
 | 
        
           |  |  | 636 | 				} else {
 | 
        
           |  |  | 637 | 					personnel.get(index).set("specialite", personnel.get(index).getSpecialite().replaceFirst("AUTRE##", ""));
 | 
        
           |  |  | 638 | 				}
 | 
        
           |  |  | 639 |   | 
        
           |  |  | 640 | 				// Gestion du temps de travail
 | 
        
           |  |  | 641 | 				String tps = personnel.get(index).getBotaTravailHebdoTps();
 | 
        
           |  |  | 642 | 				personnel.get(index).set("travail", (tps.matches("^[0-9]+$")  ? Integer.parseInt(tps) : 0));
 | 
        
           |  |  | 643 |   | 
        
           |  |  | 644 | 				personnes.add(personnel.get(index));
 | 
        
           |  |  | 645 | 			}
 | 
        
           |  |  | 646 | 			personnelGrilleMagazin.removeAll();
 | 
        
           |  |  | 647 | 			personnelGrilleMagazin.add(personnes);
 | 
        
           |  |  | 648 |   | 
        
           |  |  | 649 | 			// Remise à zéro des modification dans la liste du personnel
 | 
        
           |  |  | 650 | 			personnelModifie = new StructureAPersonneListe();
 | 
        
           |  |  | 651 | 			personnelAjoute = new StructureAPersonneListe();
 | 
        
           |  |  | 652 | 			personnelSupprime = new StructureAPersonneListe();
 | 
        
           |  |  | 653 |   | 
        
           |  |  | 654 | 			// Nous vidons la variable personnel une fois qu'elle a remplie la grille
 | 
        
           |  |  | 655 | 			personnel = null;
 | 
        
           |  |  | 656 | 		}
 | 
        
           |  |  | 657 | 	}
 | 
        
           |  |  | 658 |   | 
        
           |  |  | 659 | 	public StructureAPersonneListe getPersonnelAjoute() {
 | 
        
           |  |  | 660 | 		return personnelAjoute;
 | 
        
           |  |  | 661 | 	}
 | 
        
           |  |  | 662 |   | 
        
           |  |  | 663 | 	private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) {
 | 
        
           |  |  | 664 | 		grillePersonnel.stopEditing();
 | 
        
           |  |  | 665 | 		personnelGrilleMagazin.insert(personnel, 0);
 | 
        
           |  |  | 666 | 		grillePersonnel.startEditing(0, 0);
 | 
        
           |  |  | 667 | 	}
 | 
        
           |  |  | 668 |   | 
        
           |  |  | 669 | 	public void testerLancementRafraichirPersonnel() {
 | 
        
           |  |  | 670 | 		decompteRafraichissementPersonnel--;
 | 
        
           |  |  | 671 | 		if (decompteRafraichissementPersonnel <= 0) {
 | 
        
           |  |  | 672 | 			// Nous rechargeons la liste du Personnel
 | 
        
           |  |  | 673 | 			rafraichirPersonnel();
 | 
        
           |  |  | 674 | 		}
 | 
        
           |  |  | 675 | 	}
 | 
        
           |  |  | 676 |   | 
        
           |  |  | 677 | 	private void rafraichirPersonnel() {
 | 
        
           |  |  | 678 | 		decompteRafraichissementPersonnel = 0;
 | 
        
           |  |  | 679 | 		if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           |  |  | 680 | 			initialiserGrillePersonnelEnModification();
 | 
        
           |  |  | 681 | 		} else if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
 | 
        
           |  |  | 682 | 			initialiserGrillePersonnelEnAjout();
 | 
        
           |  |  | 683 | 		}
 | 
        
           |  |  | 684 | 	}
 | 
        
           |  |  | 685 |   | 
        
           |  |  | 686 | 	private void rafraichirPersonneExistante(String nom) {
 | 
        
           | 1764 | aurelien | 687 | 		mediateur.selectionnerPersonneParNomComplet(this, nom+"%", null);
 | 
        
           | 1637 | aurelien | 688 | 	}
 | 
        
           |  |  | 689 |   | 
        
           |  |  | 690 | 	public void incrementerDecompteRafraichissementPersonnel() {
 | 
        
           |  |  | 691 | 		decompteRafraichissementPersonnel++;
 | 
        
           |  |  | 692 | 	}
 | 
        
           |  |  | 693 |   | 
        
           |  |  | 694 | 	private void initialiserGrillePersonnelEnAjout() {
 | 
        
           |  |  | 695 | 		personnelGrilleMagazin.removeAll();
 | 
        
           |  |  | 696 | 		layout();
 | 
        
           |  |  | 697 | 	}
 | 
        
           |  |  | 698 |   | 
        
           |  |  | 699 | 	private String getIdIdentification() {
 | 
        
           |  |  | 700 | 		return ((StructureForm)formulaireCourant).getIdIdentification();
 | 
        
           |  |  | 701 | 	}
 | 
        
           |  |  | 702 |   | 
        
           |  |  | 703 | 	private void initialiserGrillePersonnelEnModification() {
 | 
        
           |  |  | 704 | 		mediateur.selectionnerStructureAPersonne(this, getIdIdentification(), StructureAPersonne.ROLE_EQUIPE, null);
 | 
        
           |  |  | 705 | 	}
 | 
        
           |  |  | 706 | }
 |