| 935 | jpm | 1 | package org.tela_botanica.client.vues.publication;
 | 
        
           | 219 | aurelien | 2 |   | 
        
           | 227 | aurelien | 3 | import java.util.ArrayList;
 | 
        
           | 1513 | jpm | 4 | import java.util.HashMap;
 | 
        
           | 227 | aurelien | 5 | import java.util.Iterator;
 | 
        
           | 365 | jp_milcent | 6 | import java.util.List;
 | 
        
           | 227 | aurelien | 7 |   | 
        
           | 981 | jpm | 8 | import org.tela_botanica.client.ComposantClass;
 | 
        
           | 219 | aurelien | 9 | import org.tela_botanica.client.Mediateur;
 | 
        
           | 1329 | cyprien | 10 | import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
 | 
        
           | 1513 | jpm | 11 | import org.tela_botanica.client.composants.GrillePaginable;
 | 
        
           | 1284 | gduche | 12 | import org.tela_botanica.client.composants.InfoLogger;
 | 
        
           | 1369 | cyprien | 13 | import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
 | 
        
           | 1513 | jpm | 14 | import org.tela_botanica.client.composants.pagination.ProxyPersonnesAPublication;
 | 
        
           | 1329 | cyprien | 15 | import org.tela_botanica.client.composants.pagination.ProxyStructures;
 | 
        
           | 822 | jpm | 16 | import org.tela_botanica.client.images.Images;
 | 
        
           | 219 | aurelien | 17 | import org.tela_botanica.client.interfaces.Rafraichissable;
 | 
        
           | 705 | aurelien | 18 | import org.tela_botanica.client.modeles.Information;
 | 
        
           | 775 | jpm | 19 | import org.tela_botanica.client.modeles.MenuApplicationId;
 | 
        
           | 1284 | gduche | 20 | import org.tela_botanica.client.modeles.aDonnee;
 | 
        
           | 935 | jpm | 21 | import org.tela_botanica.client.modeles.personne.Personne;
 | 
        
           |  |  | 22 | import org.tela_botanica.client.modeles.publication.Publication;
 | 
        
           |  |  | 23 | import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
 | 
        
           |  |  | 24 | import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
 | 
        
           |  |  | 25 | import org.tela_botanica.client.modeles.structure.Structure;
 | 
        
           | 1322 | gduche | 26 | import org.tela_botanica.client.synchronisation.Sequenceur;
 | 
        
           | 1329 | cyprien | 27 | import org.tela_botanica.client.util.Debug;
 | 
        
           | 1561 | jpm | 28 | import org.tela_botanica.client.util.Log;
 | 
        
           | 792 | jpm | 29 | import org.tela_botanica.client.util.Pattern;
 | 
        
           | 782 | jpm | 30 | import org.tela_botanica.client.util.UtilArray;
 | 
        
           | 884 | jpm | 31 | import org.tela_botanica.client.util.UtilString;
 | 
        
           | 1284 | gduche | 32 | import org.tela_botanica.client.vues.FenetreForm;
 | 
        
           | 935 | jpm | 33 | import org.tela_botanica.client.vues.Formulaire;
 | 
        
           | 1284 | gduche | 34 | import org.tela_botanica.client.vues.FormulaireBarreValidation;
 | 
        
           |  |  | 35 | import org.tela_botanica.client.vues.personne.PersonneForm;
 | 
        
           | 219 | aurelien | 36 |   | 
        
           | 1284 | gduche | 37 | import com.extjs.gxt.ui.client.Style.Scroll;
 | 
        
           |  |  | 38 | import com.extjs.gxt.ui.client.Style.SortDir;
 | 
        
           | 1561 | jpm | 39 | import com.extjs.gxt.ui.client.data.BaseModelData;
 | 
        
           |  |  | 40 | import com.extjs.gxt.ui.client.data.LoadEvent;
 | 
        
           |  |  | 41 | import com.extjs.gxt.ui.client.data.Loader;
 | 
        
           | 1329 | cyprien | 42 | import com.extjs.gxt.ui.client.data.ModelData;
 | 
        
           |  |  | 43 | import com.extjs.gxt.ui.client.data.ModelType;
 | 
        
           | 1284 | gduche | 44 | import com.extjs.gxt.ui.client.event.BaseEvent;
 | 
        
           | 505 | jp_milcent | 45 | import com.extjs.gxt.ui.client.event.ButtonEvent;
 | 
        
           | 980 | jpm | 46 | import com.extjs.gxt.ui.client.event.Events;
 | 
        
           | 1284 | gduche | 47 | import com.extjs.gxt.ui.client.event.Listener;
 | 
        
           | 1428 | cyprien | 48 | import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
 | 
        
           |  |  | 49 | import com.extjs.gxt.ui.client.event.SelectionChangedListener;
 | 
        
           | 219 | aurelien | 50 | import com.extjs.gxt.ui.client.event.SelectionListener;
 | 
        
           |  |  | 51 | import com.extjs.gxt.ui.client.store.ListStore;
 | 
        
           | 1284 | gduche | 52 | import com.extjs.gxt.ui.client.store.Store;
 | 
        
           |  |  | 53 | import com.extjs.gxt.ui.client.store.StoreEvent;
 | 
        
           | 1329 | cyprien | 54 | import com.extjs.gxt.ui.client.widget.ContentPanel;
 | 
        
           | 1878 | aurelien | 55 | import com.extjs.gxt.ui.client.widget.Html;
 | 
        
           | 1095 | jpm | 56 | import com.extjs.gxt.ui.client.widget.Info;
 | 
        
           | 1878 | aurelien | 57 | import com.extjs.gxt.ui.client.widget.Label;
 | 
        
           | 219 | aurelien | 58 | import com.extjs.gxt.ui.client.widget.LayoutContainer;
 | 
        
           | 705 | aurelien | 59 | import com.extjs.gxt.ui.client.widget.MessageBox;
 | 
        
           | 1284 | gduche | 60 | import com.extjs.gxt.ui.client.widget.Text;
 | 
        
           | 219 | aurelien | 61 | import com.extjs.gxt.ui.client.widget.button.Button;
 | 
        
           | 1284 | gduche | 62 | import com.extjs.gxt.ui.client.widget.button.ButtonBar;
 | 
        
           | 1032 | jpm | 63 | import com.extjs.gxt.ui.client.widget.form.Field;
 | 
        
           | 219 | aurelien | 64 | import com.extjs.gxt.ui.client.widget.form.FieldSet;
 | 
        
           | 1284 | gduche | 65 | import com.extjs.gxt.ui.client.widget.form.FormPanel;
 | 
        
           | 219 | aurelien | 66 | import com.extjs.gxt.ui.client.widget.form.TextField;
 | 
        
           | 1032 | jpm | 67 | import com.extjs.gxt.ui.client.widget.form.Validator;
 | 
        
           | 1284 | gduche | 68 | import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
 | 
        
           |  |  | 69 | import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
 | 
        
           |  |  | 70 | import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
 | 
        
           |  |  | 71 | import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 | 
        
           | 219 | aurelien | 72 | import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
 | 
        
           |  |  | 73 | import com.extjs.gxt.ui.client.widget.layout.FormData;
 | 
        
           |  |  | 74 | import com.extjs.gxt.ui.client.widget.layout.FormLayout;
 | 
        
           | 1284 | gduche | 75 | import com.extjs.gxt.ui.client.widget.layout.RowData;
 | 
        
           |  |  | 76 | import com.extjs.gxt.ui.client.widget.layout.RowLayout;
 | 
        
           |  |  | 77 | import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
 | 
        
           |  |  | 78 | import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
 | 
        
           | 705 | aurelien | 79 | import com.google.gwt.core.client.GWT;
 | 
        
           | 1878 | aurelien | 80 | import com.google.gwt.user.client.Window;
 | 
        
           | 219 | aurelien | 81 |   | 
        
           | 877 | aurelien | 82 |   | 
        
           | 775 | jpm | 83 | public class PublicationForm extends Formulaire implements Rafraichissable {
 | 
        
           | 219 | aurelien | 84 |   | 
        
           | 1428 | cyprien | 85 | 	  //-------------//
 | 
        
           |  |  | 86 | 	 //  ATTRIBUTS	//
 | 
        
           |  |  | 87 | 	//-------------//
 | 
        
           |  |  | 88 |   | 
        
           |  |  | 89 | 	/** Publication **/
 | 
        
           |  |  | 90 | 	// on se sert d'un objet Publication lorsque l'on est en mode MODIFIER
 | 
        
           | 786 | jpm | 91 | 	private Publication publication;
 | 
        
           | 1428 | cyprien | 92 | 	// on se sert de l'identifiant d'une publication lorsque l'on est en mode AJOUTER
 | 
        
           |  |  | 93 | 	private String publicationId = null;
 | 
        
           | 1322 | gduche | 94 |   | 
        
           | 1428 | cyprien | 95 | 	/** Auteurs **/
 | 
        
           |  |  | 96 | 	private PublicationAPersonneListe auteursInitialListe = null;
 | 
        
           |  |  | 97 | 	private PublicationAPersonneListe auteursAjoutes = null;
 | 
        
           |  |  | 98 | 	private PublicationAPersonneListe auteursSupprimes = null;
 | 
        
           |  |  | 99 | 	private PublicationAPersonneListe auteursModifies = null;
 | 
        
           | 219 | aurelien | 100 |   | 
        
           | 1329 | cyprien | 101 | 	private ContentPanel auteursFieldset = null;
 | 
        
           | 227 | aurelien | 102 |   | 
        
           | 775 | jpm | 103 | 	private FieldSet generalitesFieldset = null;
 | 
        
           | 786 | jpm | 104 | 	private TextField<String> titreChp = null;
 | 
        
           |  |  | 105 | 	private TextField<String> collectionChp = null;
 | 
        
           |  |  | 106 | 	private TextField<String> uriChp = null;
 | 
        
           | 219 | aurelien | 107 |   | 
        
           | 775 | jpm | 108 | 	private FieldSet editionFieldset = null;
 | 
        
           | 1329 | cyprien | 109 | 	private ChampComboBoxRechercheTempsReelPaginable editeurCombobox = null;
 | 
        
           | 786 | jpm | 110 | 	private TextField<String> datePublicationChp = null;
 | 
        
           |  |  | 111 | 	private TextField<String> tomeChp = null;
 | 
        
           |  |  | 112 | 	private TextField<String> fasciculeChp = null;
 | 
        
           |  |  | 113 | 	private TextField<String> pagesChp = null;
 | 
        
           | 219 | aurelien | 114 |   | 
        
           | 1284 | gduche | 115 | 	private LayoutContainer zoneHaut, zoneBas;
 | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 | 	private ToolBar barreOutils = null;
 | 
        
           | 1513 | jpm | 118 | 	private GrillePaginable<ModelData> grilleAuteurs;
 | 
        
           | 1375 | cyprien | 119 | 	private ChampComboBoxRechercheTempsReelPaginable personnesSaisiesComboBox = null;
 | 
        
           | 1284 | gduche | 120 | 	private Button personnesBoutonSupprimer = null;
 | 
        
           |  |  | 121 | 	private Button personnesBoutonModifier = null;
 | 
        
           | 1428 | cyprien | 122 | 	private Button boutonAuteurUp = null;
 | 
        
           |  |  | 123 | 	private Button boutonAuteurDown = null;
 | 
        
           | 1284 | gduche | 124 |   | 
        
           |  |  | 125 | 	private FenetreForm fenetreFormulaire = null;
 | 
        
           | 1322 | gduche | 126 | 	private Sequenceur sequenceur;
 | 
        
           | 1284 | gduche | 127 |   | 
        
           | 1428 | cyprien | 128 | 	private String modeDeCreation = null;
 | 
        
           |  |  | 129 | 	boolean changeOrderMarker = false;
 | 
        
           |  |  | 130 |   | 
        
           | 1878 | aurelien | 131 | 	private Label infosAuteurFmt = null;
 | 
        
           |  |  | 132 | 	private ContentPanel infosAuteursNonPresentsPanel = null;
 | 
        
           | 1428 | cyprien | 133 |   | 
        
           | 1878 | aurelien | 134 |   | 
        
           | 1526 | jpm | 135 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 136 | 	//    Constructeurs
 | 
        
           | 1428 | cyprien | 137 |   | 
        
           | 781 | jpm | 138 | 	public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
 | 
        
           | 782 | jpm | 139 | 		initialiserPublicationForm(mediateurCourrant, publicationId);
 | 
        
           |  |  | 140 | 	}
 | 
        
           |  |  | 141 |   | 
        
           |  |  | 142 | 	public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
 | 
        
           | 822 | jpm | 143 | 		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
 | 
        
           | 782 | jpm | 144 | 		initialiserPublicationForm(mediateurCourrant, publicationId);
 | 
        
           |  |  | 145 | 	}
 | 
        
           | 1428 | cyprien | 146 |   | 
        
           | 782 | jpm | 147 |   | 
        
           | 1526 | jpm | 148 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 149 | 	//    Initialisation
 | 
        
           | 1428 | cyprien | 150 |   | 
        
           | 782 | jpm | 151 | 	private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
 | 
        
           | 1322 | gduche | 152 | 		sequenceur = new Sequenceur();
 | 
        
           | 799 | jpm | 153 | 		publication = new Publication();
 | 
        
           | 822 | jpm | 154 | 		publication.setId(publicationId);
 | 
        
           | 1428 | cyprien | 155 | 		this.publicationId = publicationId;
 | 
        
           |  |  | 156 | 		auteursInitialListe = new PublicationAPersonneListe();
 | 
        
           | 1322 | gduche | 157 | 		initialiserAuteurs();	// Crée les listes d'auteurs ajoutés et supprimés
 | 
        
           | 1428 | cyprien | 158 | 		// Si 'publicationId' est vide alors on est en mode "AJOUTER", sinon on est en mode "MODIFIER"
 | 
        
           |  |  | 159 | 		modeDeCreation = (UtilString.isEmpty(publicationId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
 | 
        
           | 775 | jpm | 160 | 		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
 | 
        
           | 1284 | gduche | 161 | 		panneauFormulaire.setLayout(new RowLayout());
 | 
        
           |  |  | 162 | 		panneauFormulaire.setStyleAttribute("padding", "0");
 | 
        
           | 1561 | jpm | 163 | 		panneauFormulaire.setHeight(600);
 | 
        
           | 1322 | gduche | 164 |   | 
        
           | 1284 | gduche | 165 | 		zoneHaut = new LayoutContainer(new FitLayout());
 | 
        
           |  |  | 166 | 		zoneBas = new LayoutContainer(new FlowLayout());
 | 
        
           | 1561 | jpm | 167 | 		panneauFormulaire.add(zoneHaut, new RowData(0.99, 0.45));
 | 
        
           |  |  | 168 | 		panneauFormulaire.add(zoneBas, new RowData(0.99, 0.55));
 | 
        
           | 1284 | gduche | 169 | 		panneauFormulaire.setScrollMode(Scroll.AUTO);
 | 
        
           | 1095 | jpm | 170 | 		genererTitreFormulaire();
 | 
        
           |  |  | 171 |   | 
        
           | 775 | jpm | 172 | 		creerZoneAuteurs();
 | 
        
           | 1284 | gduche | 173 | 		zoneHaut.add(auteursFieldset);
 | 
        
           | 219 | aurelien | 174 |   | 
        
           | 775 | jpm | 175 | 		creerZoneGeneralites();
 | 
        
           | 1284 | gduche | 176 | 		zoneBas.add(generalitesFieldset);
 | 
        
           | 239 | aurelien | 177 |   | 
        
           | 775 | jpm | 178 | 		creerZoneEdition();
 | 
        
           | 1284 | gduche | 179 | 		zoneBas.add(editionFieldset);
 | 
        
           | 822 | jpm | 180 |   | 
        
           |  |  | 181 | 		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           | 1322 | gduche | 182 | 			mediateurCourrant.selectionnerPublication(this, publicationId, sequenceur);
 | 
        
           | 1373 | cyprien | 183 | 			sequenceur.enfilerRafraichissement(this, new Information("chargement_modifier_ok"));
 | 
        
           | 822 | jpm | 184 | 		}
 | 
        
           | 781 | jpm | 185 | 	}
 | 
        
           | 1428 | cyprien | 186 |   | 
        
           |  |  | 187 | 	private void initialiserAuteurs() {
 | 
        
           |  |  | 188 | 		auteursAjoutes = new PublicationAPersonneListe();
 | 
        
           |  |  | 189 | 		auteursSupprimes = new PublicationAPersonneListe();
 | 
        
           |  |  | 190 | 		auteursModifies = new PublicationAPersonneListe();
 | 
        
           |  |  | 191 | 	}
 | 
        
           | 782 | jpm | 192 |   | 
        
           | 1526 | jpm | 193 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 194 | 	//    User Interface
 | 
        
           | 1284 | gduche | 195 |   | 
        
           |  |  | 196 | 	private ToolBar creerBarreOutilsGrille() {
 | 
        
           |  |  | 197 | 		ToolBar barreOutils = new ToolBar();
 | 
        
           |  |  | 198 |   | 
        
           | 1779 | aurelien | 199 | 		creerComboBoxPersonnesSaisies();
 | 
        
           |  |  | 200 | 		barreOutils.add(personnesSaisiesComboBox);
 | 
        
           |  |  | 201 |   | 
        
           |  |  | 202 | 		personnesSaisiesComboBox.getCombo().setEmptyText("Rechercher et sélectionner une personne existante dans la base");
 | 
        
           |  |  | 203 |   | 
        
           |  |  | 204 | 		barreOutils.add(new Text(" ou "));
 | 
        
           |  |  | 205 |   | 
        
           | 1284 | gduche | 206 | 		Button ajouterBouton = creerBoutonAjouter();
 | 
        
           |  |  | 207 | 		barreOutils.add(ajouterBouton);
 | 
        
           |  |  | 208 |   | 
        
           |  |  | 209 | 		barreOutils.add(new SeparatorToolItem());
 | 
        
           |  |  | 210 |   | 
        
           |  |  | 211 | 		personnesBoutonModifier = creerBoutonModifier();
 | 
        
           |  |  | 212 | 		barreOutils.add(personnesBoutonModifier);
 | 
        
           |  |  | 213 |   | 
        
           |  |  | 214 | 		barreOutils.add(new SeparatorToolItem());
 | 
        
           |  |  | 215 |   | 
        
           |  |  | 216 | 		personnesBoutonSupprimer = creerBoutonSupprimer();
 | 
        
           |  |  | 217 | 		barreOutils.add(personnesBoutonSupprimer);
 | 
        
           |  |  | 218 |   | 
        
           |  |  | 219 | 		barreOutils.add(new SeparatorToolItem());
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 | 		Button rafraichirBouton = creerBoutonRafraichir();
 | 
        
           |  |  | 222 | 		barreOutils.add(rafraichirBouton);
 | 
        
           |  |  | 223 |   | 
        
           | 1428 | cyprien | 224 | 		barreOutils.add(new SeparatorToolItem());
 | 
        
           |  |  | 225 |   | 
        
           |  |  | 226 | 		barreOutils.add(new Text(i18nC.deplacerAuteur()));
 | 
        
           |  |  | 227 | 		boutonAuteurUp = creerBoutonAuteurUp();
 | 
        
           |  |  | 228 | 		barreOutils.add(boutonAuteurUp);
 | 
        
           |  |  | 229 | 		boutonAuteurDown = creerBoutonAuteurDown();
 | 
        
           |  |  | 230 | 		barreOutils.add(boutonAuteurDown);
 | 
        
           |  |  | 231 |   | 
        
           | 1284 | gduche | 232 | 		return barreOutils;
 | 
        
           |  |  | 233 | 	}
 | 
        
           | 1428 | cyprien | 234 |   | 
        
           |  |  | 235 | 	public void actualiserEtatBoutonsBarreOutils() {
 | 
        
           |  |  | 236 | 		// Activation des boutons si la grille contient un élément
 | 
        
           |  |  | 237 | 		if (grilleAuteurs.getStore().getCount() > 0) {
 | 
        
           |  |  | 238 | 			personnesBoutonSupprimer.enable();
 | 
        
           |  |  | 239 | 			personnesBoutonModifier.enable();
 | 
        
           |  |  | 240 | 		}
 | 
        
           |  |  | 241 | 		// Désactivation des boutons si la grille ne contient plus d'élément
 | 
        
           |  |  | 242 | 		if (grilleAuteurs.getStore().getCount() == 0) {
 | 
        
           |  |  | 243 | 			personnesBoutonSupprimer.disable();
 | 
        
           |  |  | 244 | 			personnesBoutonModifier.disable();
 | 
        
           |  |  | 245 | 		}
 | 
        
           |  |  | 246 | 	}
 | 
        
           |  |  | 247 |   | 
        
           |  |  | 248 | 	private Button creerBoutonAuteurUp() {
 | 
        
           |  |  | 249 | 		Button bouton = new Button();
 | 
        
           |  |  | 250 | 		bouton.setIcon(Images.ICONES.arrowUp());
 | 
        
           |  |  | 251 | 		bouton.setEnabled(false);
 | 
        
           | 1513 | jpm | 252 | 		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           | 1428 | cyprien | 253 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           | 1513 | jpm | 254 | 				if (grilleAuteurs.getGrille().getSelectionModel().getSelectedItem() != null) {
 | 
        
           | 1561 | jpm | 255 | 					mettreAJourOrdreAuteur(-1);
 | 
        
           | 1428 | cyprien | 256 | 				}
 | 
        
           |  |  | 257 | 			}
 | 
        
           |  |  | 258 | 		});
 | 
        
           |  |  | 259 | 		return bouton;
 | 
        
           |  |  | 260 | 	}
 | 
        
           |  |  | 261 |   | 
        
           |  |  | 262 | 	private Button creerBoutonAuteurDown() {
 | 
        
           |  |  | 263 | 		Button bouton = new Button();
 | 
        
           |  |  | 264 | 		bouton.setIcon(Images.ICONES.arrowDown());
 | 
        
           |  |  | 265 | 		bouton.setEnabled(false);
 | 
        
           |  |  | 266 | 		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 267 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 268 | 				if (grilleAuteurs.getSelectionModel().getSelectedItem() != null) {
 | 
        
           | 1561 | jpm | 269 | 					mettreAJourOrdreAuteur(+1);
 | 
        
           | 1428 | cyprien | 270 | 				}
 | 
        
           |  |  | 271 | 			}
 | 
        
           |  |  | 272 | 		});
 | 
        
           |  |  | 273 | 		return bouton;
 | 
        
           |  |  | 274 | 	}
 | 
        
           | 1561 | jpm | 275 |   | 
        
           |  |  | 276 | 	private void formaterOrdreAuteurs() {
 | 
        
           |  |  | 277 | 		List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
 | 
        
           |  |  | 278 | 		Iterator<ModelData> itAuteurs = auteurs.iterator();
 | 
        
           |  |  | 279 | 		while (itAuteurs.hasNext())	{
 | 
        
           |  |  | 280 | 			ModelData selection = itAuteurs.next();
 | 
        
           |  |  | 281 | 			PublicationAPersonne pap = new PublicationAPersonne(selection, false);
 | 
        
           |  |  | 282 |   | 
        
           |  |  | 283 | 			String ordre = String.valueOf(grilleAuteurs.getStore().indexOf(selection) + 1);
 | 
        
           |  |  | 284 | 			if (pap.getOrdreAuteurs() != ordre) {
 | 
        
           |  |  | 285 | 				selection.set("_ordre_", ordre);
 | 
        
           |  |  | 286 | 				grilleAuteurs.getStore().update(selection);
 | 
        
           |  |  | 287 | 				pap.setOrdreAuteurs(ordre);
 | 
        
           |  |  | 288 | 				auteursModifies.put(pap.getId(), pap);
 | 
        
           |  |  | 289 | 			}
 | 
        
           |  |  | 290 | 		}
 | 
        
           |  |  | 291 | 	}
 | 
        
           |  |  | 292 |   | 
        
           |  |  | 293 | 	private void mettreAJourOrdreAuteur(int monterOuDescendre) {
 | 
        
           |  |  | 294 | 		ModelData publiAPersonneSelectionnee = grilleAuteurs.getSelectionModel().getSelectedItem();
 | 
        
           |  |  | 295 | 		int index = grilleAuteurs.getStore().indexOf(publiAPersonneSelectionnee);
 | 
        
           |  |  | 296 | 		int nouvelIndex = index + monterOuDescendre;
 | 
        
           |  |  | 297 |   | 
        
           |  |  | 298 | 		if (verifierOrdreAuteur(nouvelIndex)) {
 | 
        
           |  |  | 299 | 			// le marqueur suivant est obligatoire sinon les évènements liés au magasin se
 | 
        
           |  |  | 300 | 			// déclenchent et posent problème
 | 
        
           |  |  | 301 | 			changeOrderMarker = true;
 | 
        
           |  |  | 302 |   | 
        
           |  |  | 303 | 			int indexAPermuter = index + monterOuDescendre;
 | 
        
           |  |  | 304 | 			ModelData publiAPersonneSwitch = grilleAuteurs.getStore().getAt(indexAPermuter);
 | 
        
           |  |  | 305 | 			String ordreAPermuter = String.valueOf((indexAPermuter + 1) - monterOuDescendre);
 | 
        
           |  |  | 306 | 			publiAPersonneSwitch.set("_ordre_", ordreAPermuter);
 | 
        
           |  |  | 307 | 			grilleAuteurs.getStore().update(publiAPersonneSwitch);
 | 
        
           |  |  | 308 | 			PublicationAPersonne papSwitch = new PublicationAPersonne(publiAPersonneSwitch, false);
 | 
        
           |  |  | 309 | 			papSwitch.setOrdreAuteurs(ordreAPermuter);
 | 
        
           |  |  | 310 | 			auteursModifies.put(papSwitch.getId(), papSwitch);
 | 
        
           | 1284 | gduche | 311 |   | 
        
           | 1561 | jpm | 312 | 			grilleAuteurs.getStore().remove(publiAPersonneSelectionnee);
 | 
        
           |  |  | 313 | 			String nouvelOrdre = String.valueOf((index + 1) + monterOuDescendre);
 | 
        
           |  |  | 314 | 			publiAPersonneSelectionnee.set("_ordre_", nouvelOrdre);
 | 
        
           |  |  | 315 | 			grilleAuteurs.getStore().insert(publiAPersonneSelectionnee, nouvelIndex);
 | 
        
           |  |  | 316 | 			PublicationAPersonne papSelectionnee = new PublicationAPersonne(publiAPersonneSelectionnee, false);
 | 
        
           |  |  | 317 | 			papSelectionnee.setOrdreAuteurs(nouvelOrdre);
 | 
        
           |  |  | 318 | 			auteursModifies.put(papSelectionnee.getId(), papSelectionnee);
 | 
        
           |  |  | 319 | 			changeOrderMarker = false;
 | 
        
           |  |  | 320 |   | 
        
           |  |  | 321 | 			grilleAuteurs.getSelectionModel().select(nouvelIndex, false);
 | 
        
           |  |  | 322 | 		}
 | 
        
           |  |  | 323 | 	}
 | 
        
           |  |  | 324 |   | 
        
           |  |  | 325 | 	private boolean verifierOrdreAuteur(int nouvelIndex) {
 | 
        
           |  |  | 326 | 		int nbrElement = grilleAuteurs.getStore().getCount();
 | 
        
           |  |  | 327 | 		boolean ok = true;
 | 
        
           |  |  | 328 | 		if (nouvelIndex < 0 || nouvelIndex >= nbrElement) {
 | 
        
           |  |  | 329 | 			ok = false;
 | 
        
           |  |  | 330 | 		}
 | 
        
           |  |  | 331 | 		return ok;
 | 
        
           |  |  | 332 | 	}
 | 
        
           |  |  | 333 |   | 
        
           |  |  | 334 | 	private void activerBoutonsOrdreAuteur() {
 | 
        
           |  |  | 335 | 		ModelData papSelectionnee = grilleAuteurs.getGrille().getSelectionModel().getSelectedItem();
 | 
        
           |  |  | 336 | 		int index = grilleAuteurs.getStore().indexOf(papSelectionnee);
 | 
        
           |  |  | 337 |   | 
        
           |  |  | 338 | 		if (index >= 1) {
 | 
        
           |  |  | 339 | 			boutonAuteurUp.setEnabled(true);
 | 
        
           |  |  | 340 | 		} else {
 | 
        
           |  |  | 341 | 			boutonAuteurUp.setEnabled(false);
 | 
        
           |  |  | 342 | 		}
 | 
        
           |  |  | 343 |   | 
        
           |  |  | 344 | 		if ((index+1) < grilleAuteurs.getStore().getCount()) {
 | 
        
           |  |  | 345 | 			boutonAuteurDown.setEnabled(true);
 | 
        
           |  |  | 346 | 		} else {
 | 
        
           |  |  | 347 | 			boutonAuteurDown.setEnabled(false);
 | 
        
           |  |  | 348 | 		}
 | 
        
           |  |  | 349 | 	}
 | 
        
           |  |  | 350 |   | 
        
           | 1284 | gduche | 351 | 	private Button creerBoutonAjouter() {
 | 
        
           |  |  | 352 | 		Button bouton = new Button(i18nC.ajouter());
 | 
        
           |  |  | 353 | 		bouton.setIcon(Images.ICONES.vcardAjouter());
 | 
        
           |  |  | 354 | 		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 355 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 356 | 				fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
 | 
        
           |  |  | 357 | 				fenetreFormulaire.show();
 | 
        
           |  |  | 358 | 			}
 | 
        
           |  |  | 359 | 		});
 | 
        
           |  |  | 360 | 		return bouton;
 | 
        
           |  |  | 361 | 	}
 | 
        
           |  |  | 362 |   | 
        
           |  |  | 363 | 	private Button creerBoutonModifier() {
 | 
        
           |  |  | 364 | 		Button bouton = new Button(i18nC.modifier());
 | 
        
           |  |  | 365 | 		bouton.setIcon(Images.ICONES.vcardModifier());
 | 
        
           |  |  | 366 | 		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 367 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           | 1513 | jpm | 368 | 				Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
 | 
        
           | 1284 | gduche | 369 |   | 
        
           |  |  | 370 | 				if (personneSaisieSelectionnee == null) {
 | 
        
           |  |  | 371 | 					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
 | 
        
           |  |  | 372 | 				} else {
 | 
        
           |  |  | 373 | 					fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
 | 
        
           |  |  | 374 | 					fenetreFormulaire.show();
 | 
        
           |  |  | 375 | 				}
 | 
        
           |  |  | 376 | 			}
 | 
        
           |  |  | 377 | 		});
 | 
        
           |  |  | 378 | 		return bouton;
 | 
        
           |  |  | 379 | 	}
 | 
        
           |  |  | 380 |   | 
        
           |  |  | 381 | 	private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
 | 
        
           |  |  | 382 | 		String personneId = null;
 | 
        
           |  |  | 383 | 		if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           | 1513 | jpm | 384 | 			Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
 | 
        
           | 1284 | gduche | 385 | 			personneId = personneSaisieSelectionnee.getId();
 | 
        
           |  |  | 386 | 		}
 | 
        
           |  |  | 387 |   | 
        
           |  |  | 388 | 		final FenetreForm fenetre = new FenetreForm("");
 | 
        
           |  |  | 389 | 		final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
 | 
        
           |  |  | 390 | 		fenetre.add(formulaire);
 | 
        
           |  |  | 391 | 		return fenetre;
 | 
        
           |  |  | 392 | 	}
 | 
        
           |  |  | 393 |   | 
        
           |  |  | 394 | 	private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
 | 
        
           |  |  | 395 | 		PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
 | 
        
           |  |  | 396 | 		FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
 | 
        
           | 1680 | raphael | 397 | 		fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
 | 
        
           | 1284 | gduche | 398 | 		panneauFormulaire.setHeaderVisible(false);
 | 
        
           |  |  | 399 | 		panneauFormulaire.setTopComponent(null);
 | 
        
           |  |  | 400 |   | 
        
           |  |  | 401 | 		// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
 | 
        
           |  |  | 402 | 		panneauFormulaire.getBottomComponent().hide();
 | 
        
           |  |  | 403 | 		SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
 | 
        
           |  |  | 404 | 		final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
 | 
        
           |  |  | 405 | 		fenetre.setBottomComponent(barreValidation);
 | 
        
           |  |  | 406 |   | 
        
           |  |  | 407 | 		return formulairePersonne;
 | 
        
           |  |  | 408 | 	}
 | 
        
           |  |  | 409 |   | 
        
           |  |  | 410 | 	private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
 | 
        
           |  |  | 411 | 		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 412 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 413 | 				String code = ((Button) ce.getComponent()).getData("code");
 | 
        
           |  |  | 414 | 				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
 | 
        
           |  |  | 415 | 					if (formulaire.soumettreFormulaire()) {
 | 
        
           |  |  | 416 | 						fenetre.hide();
 | 
        
           |  |  | 417 | 					}
 | 
        
           |  |  | 418 | 				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
 | 
        
           |  |  | 419 | 					formulaire.soumettreFormulaire();
 | 
        
           |  |  | 420 | 				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
 | 
        
           |  |  | 421 | 					fenetre.hide();
 | 
        
           |  |  | 422 | 				}
 | 
        
           |  |  | 423 | 			}
 | 
        
           |  |  | 424 | 		};
 | 
        
           |  |  | 425 |   | 
        
           |  |  | 426 | 		return ecouteur;
 | 
        
           |  |  | 427 | 	}
 | 
        
           |  |  | 428 |   | 
        
           |  |  | 429 | 	private Button creerBoutonSupprimer() {
 | 
        
           |  |  | 430 | 		Button bouton = new Button(i18nC.supprimer());
 | 
        
           |  |  | 431 | 		bouton.setIcon(Images.ICONES.vcardSupprimer());
 | 
        
           |  |  | 432 | 		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 433 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           | 1561 | jpm | 434 | 				supprimerDansGrille();
 | 
        
           | 1284 | gduche | 435 | 			}
 | 
        
           |  |  | 436 | 		});
 | 
        
           |  |  | 437 | 		return bouton;
 | 
        
           |  |  | 438 | 	}
 | 
        
           |  |  | 439 |   | 
        
           |  |  | 440 | 	private Button creerBoutonRafraichir() {
 | 
        
           |  |  | 441 | 		Button bouton = new Button(i18nC.rafraichir());
 | 
        
           |  |  | 442 | 		bouton.setIcon(Images.ICONES.rafraichir());
 | 
        
           |  |  | 443 | 		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
 | 
        
           |  |  | 444 | 			public void componentSelected(ButtonEvent ce) {
 | 
        
           |  |  | 445 | 				actualiserGrille();
 | 
        
           |  |  | 446 | 			}
 | 
        
           |  |  | 447 | 		});
 | 
        
           |  |  | 448 | 		return bouton;
 | 
        
           |  |  | 449 | 	}
 | 
        
           |  |  | 450 |   | 
        
           |  |  | 451 | 	private void actualiserGrille() {
 | 
        
           |  |  | 452 | 		if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           |  |  | 453 | 			// FIXME : c'est la merde
 | 
        
           | 1561 | jpm | 454 | 			grilleAuteurs.reload();
 | 
        
           | 1284 | gduche | 455 | 		} else {
 | 
        
           | 1428 | cyprien | 456 | 			grilleAuteurs.getStore().removeAll();
 | 
        
           | 1284 | gduche | 457 | 			layout();
 | 
        
           |  |  | 458 | 		}
 | 
        
           |  |  | 459 | 	}
 | 
        
           |  |  | 460 |   | 
        
           | 1375 | cyprien | 461 | 	private void creerComboBoxPersonnesSaisies() {
 | 
        
           |  |  | 462 | 		ModelType modelTypePersonnes = new ModelType();
 | 
        
           |  |  | 463 | 		modelTypePersonnes.setRoot("personnes");
 | 
        
           |  |  | 464 | 		modelTypePersonnes.setTotalName("nbElements");
 | 
        
           |  |  | 465 | 		modelTypePersonnes.addField("cp_fmt_nom_complet");
 | 
        
           | 1428 | cyprien | 466 | 		modelTypePersonnes.addField("cp_nom");
 | 
        
           |  |  | 467 | 		modelTypePersonnes.addField("cp_prenom");
 | 
        
           | 1375 | cyprien | 468 | 		modelTypePersonnes.addField("cp_id_personne");
 | 
        
           |  |  | 469 | 		modelTypePersonnes.addField("cp_code_postal");
 | 
        
           |  |  | 470 | 		modelTypePersonnes.addField("cp_ville");
 | 
        
           |  |  | 471 | 		modelTypePersonnes.addField("cp_truk_courriel");
 | 
        
           | 1284 | gduche | 472 |   | 
        
           | 1375 | cyprien | 473 | 		String displayNamePersonnes = "cp_fmt_nom_complet";
 | 
        
           | 1468 | jpm | 474 | 		ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
 | 
        
           | 1375 | cyprien | 475 |   | 
        
           |  |  | 476 | 		personnesSaisiesComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
 | 
        
           |  |  | 477 |   | 
        
           |  |  | 478 | 		personnesSaisiesComboBox.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
 | 
        
           | 1428 | cyprien | 479 | 			public void handleEvent(BaseEvent be) {
 | 
        
           | 1375 | cyprien | 480 | 				if (personnesSaisiesComboBox.getValeur() instanceof ModelData) {
 | 
        
           | 1284 | gduche | 481 | 					// N'ajouter l'auteur que s'il n'est pas déjà présent dans la grille et dans les valeurs initiales
 | 
        
           | 1375 | cyprien | 482 | 					Personne personneSaisieSelectionnee = new Personne(personnesSaisiesComboBox.getValeur());
 | 
        
           | 1573 | jpm | 483 | 					Log.debug("Récupération info combo :"+personneSaisieSelectionnee.toString());
 | 
        
           |  |  | 484 | 					PublicationAPersonne pap = new PublicationAPersonne(aDonnee.GARDER_PREFIXE);
 | 
        
           |  |  | 485 | 					pap.setPersonne(personneSaisieSelectionnee, aDonnee.INTEGRER_PROPRIETES);
 | 
        
           | 1468 | jpm | 486 | 					pap.setOrdreAuteurs(String.valueOf(grilleAuteurs.getStore().getCount()+1));
 | 
        
           |  |  | 487 | 					if (modeDeCreation != Formulaire.MODE_AJOUTER) {
 | 
        
           |  |  | 488 | 						pap.setPublicationLiee(publication);
 | 
        
           |  |  | 489 | 						pap.setIdPublication(publicationId);
 | 
        
           |  |  | 490 | 					}
 | 
        
           | 1573 | jpm | 491 | 					pap.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
 | 
        
           |  |  | 492 | 					Log.debug("Récupération info combo pap id :"+pap.getId());
 | 
        
           |  |  | 493 |   | 
        
           |  |  | 494 | 					if (ajouterDansGrille(pap)) {
 | 
        
           | 1375 | cyprien | 495 | 						personnesSaisiesComboBox.getCombo().setValue(null);
 | 
        
           | 1284 | gduche | 496 | 					}
 | 
        
           |  |  | 497 | 				}
 | 
        
           |  |  | 498 | 			}
 | 
        
           |  |  | 499 | 		});
 | 
        
           |  |  | 500 | 	}
 | 
        
           |  |  | 501 |   | 
        
           | 1573 | jpm | 502 | 	private boolean ajouterDansGrille(PublicationAPersonne pap) {
 | 
        
           |  |  | 503 | 		return ajouterDansGrille(pap, grilleAuteurs.getStore().getCount());
 | 
        
           | 1284 | gduche | 504 | 	}
 | 
        
           |  |  | 505 |   | 
        
           | 1573 | jpm | 506 | 	private boolean ajouterDansGrille(PublicationAPersonne pap, int index) {
 | 
        
           |  |  | 507 | 		boolean ok = false;
 | 
        
           | 1428 | cyprien | 508 | 		if (pap != null) {
 | 
        
           | 1573 | jpm | 509 | 			Log.debug("Début ajout dans grille :"+pap.toString());
 | 
        
           |  |  | 510 | 			if (grilleAuteurs.getStore().contains((ModelData) pap))	{
 | 
        
           |  |  | 511 | 				InfoLogger.display("Information", "La personne choisie existe déjà dans la liste d'auteurs.");
 | 
        
           | 1561 | jpm | 512 | 			} else {
 | 
        
           |  |  | 513 | 				// 1) si elle ne fait pas partie des initiaux, ajouter à la liste à ajouter
 | 
        
           | 1428 | cyprien | 514 | 				if (!auteursInitialListe.containsValue(pap))	{
 | 
        
           |  |  | 515 | 					auteursAjoutes.put(pap.getId(), pap);
 | 
        
           | 1573 | jpm | 516 | 					Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été ajouté à la liste des ajoutés (il ne fait pas parti de la liste initiale).");
 | 
        
           | 1284 | gduche | 517 | 				}
 | 
        
           |  |  | 518 |   | 
        
           |  |  | 519 | 				// L'enlever de la liste à supprimer
 | 
        
           | 1428 | cyprien | 520 | 				if (auteursSupprimes.containsValue(pap))	{
 | 
        
           |  |  | 521 | 					auteursSupprimes.remove(pap);
 | 
        
           | 1573 | jpm | 522 | 					Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été retiré de la liste des supprimés.");
 | 
        
           | 1284 | gduche | 523 | 				}
 | 
        
           | 1561 | jpm | 524 |   | 
        
           |  |  | 525 | 				// 2) Ajouter a la grille
 | 
        
           | 1573 | jpm | 526 | 				grilleAuteurs.getStore().insert((ModelData) pap, index);
 | 
        
           | 1428 | cyprien | 527 | 				grilleAuteurs.getSelectionModel().select(index, false);
 | 
        
           | 1573 | jpm | 528 | 				ok = true;
 | 
        
           | 1284 | gduche | 529 | 			}
 | 
        
           |  |  | 530 | 		}
 | 
        
           | 1573 | jpm | 531 | 		return ok;
 | 
        
           | 1284 | gduche | 532 | 	}
 | 
        
           |  |  | 533 |   | 
        
           | 1561 | jpm | 534 | 	private void supprimerDansGrille() {
 | 
        
           | 1613 | aurelien | 535 | 		List<ModelData> listeDonneesSelectionnees = grilleAuteurs.getSelectionModel().getSelectedItems();
 | 
        
           |  |  | 536 | 		for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
 | 
        
           |  |  | 537 | 			supprimerAuteurDansGrille(donneeSelectionnee);
 | 
        
           |  |  | 538 | 		}
 | 
        
           |  |  | 539 | 	}
 | 
        
           |  |  | 540 |   | 
        
           |  |  | 541 | 	private void supprimerAuteurDansGrille(ModelData donneeSelectionnee) {
 | 
        
           | 1573 | jpm | 542 | 		PublicationAPersonne personneSelectionnee = new PublicationAPersonne(donneeSelectionnee, aDonnee.GARDER_PREFIXE);
 | 
        
           |  |  | 543 | 		Log.debug("Début supprimer auteur dans grille : "+personneSelectionnee.toString());
 | 
        
           | 1561 | jpm | 544 | 		if (personneSelectionnee.getId() == null) {
 | 
        
           |  |  | 545 | 			InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerAuteur());
 | 
        
           |  |  | 546 | 		} else {
 | 
        
           | 1428 | cyprien | 547 | 			// 1) Ajouter a la liste des personne à supprimer uniquement si est présente dans la liste initiale
 | 
        
           | 1561 | jpm | 548 | 			if (auteursInitialListe.containsKey(personneSelectionnee.getId())) {
 | 
        
           |  |  | 549 | 				auteursSupprimes.put(personneSelectionnee.getId(), personneSelectionnee);
 | 
        
           |  |  | 550 | 				Log.debug("Ajout Personne à supprimer : "+auteursSupprimes.toString());
 | 
        
           | 1284 | gduche | 551 | 			}
 | 
        
           |  |  | 552 |   | 
        
           | 1573 | jpm | 553 | 			if (auteursAjoutes.containsKey(personneSelectionnee.getId()))	{
 | 
        
           |  |  | 554 | 				auteursAjoutes.remove(personneSelectionnee.getId());
 | 
        
           | 1284 | gduche | 555 | 			}
 | 
        
           |  |  | 556 |   | 
        
           | 1573 | jpm | 557 | 			if (auteursModifies.containsKey(personneSelectionnee.getId()))	{
 | 
        
           |  |  | 558 | 				auteursModifies.remove(personneSelectionnee.getId());
 | 
        
           | 1428 | cyprien | 559 | 			}
 | 
        
           |  |  | 560 |   | 
        
           |  |  | 561 | 			// 2) Supprimer la personne de la liste
 | 
        
           | 1561 | jpm | 562 | 			Log.debug("Personne trouvée : "+grilleAuteurs.getStore().findModel(donneeSelectionnee).toString());
 | 
        
           |  |  | 563 | 			grilleAuteurs.getStore().remove(donneeSelectionnee);
 | 
        
           |  |  | 564 | 			formaterOrdreAuteurs();
 | 
        
           | 1284 | gduche | 565 | 		}
 | 
        
           |  |  | 566 | 	}
 | 
        
           |  |  | 567 |   | 
        
           | 1513 | jpm | 568 | 	private GrillePaginable<ModelData> creerGrilleAuteurs() {
 | 
        
           |  |  | 569 | 		// ModelType
 | 
        
           |  |  | 570 | 		ModelType modelTypePersonnesAPublication = new ModelType();
 | 
        
           |  |  | 571 | 		modelTypePersonnesAPublication.setRoot("publicationsAPersonne");
 | 
        
           |  |  | 572 | 		modelTypePersonnesAPublication.setTotalName("nbElements");
 | 
        
           |  |  | 573 | 		modelTypePersonnesAPublication.addField("cpuap_id_personne");
 | 
        
           |  |  | 574 | 		modelTypePersonnesAPublication.addField("cpuap_id_publication");
 | 
        
           |  |  | 575 | 		modelTypePersonnesAPublication.addField("cpuap_id_role");
 | 
        
           |  |  | 576 | 		modelTypePersonnesAPublication.addField("cpuap_ordre");
 | 
        
           |  |  | 577 | 		modelTypePersonnesAPublication.addField("cp_id_personne");
 | 
        
           |  |  | 578 | 		modelTypePersonnesAPublication.addField("cp_fmt_nom_complet");
 | 
        
           |  |  | 579 | 		modelTypePersonnesAPublication.addField("cp_nom");
 | 
        
           |  |  | 580 | 		modelTypePersonnesAPublication.addField("cp_prenom");
 | 
        
           |  |  | 581 | 		modelTypePersonnesAPublication.addField("cp_id_personne");
 | 
        
           |  |  | 582 | 		modelTypePersonnesAPublication.addField("cp_code_postal");
 | 
        
           |  |  | 583 | 		modelTypePersonnesAPublication.addField("cp_ville");
 | 
        
           |  |  | 584 | 		modelTypePersonnesAPublication.addField("cp_truk_courriel");
 | 
        
           | 1428 | cyprien | 585 |   | 
        
           | 1513 | jpm | 586 | 		// Proxy
 | 
        
           |  |  | 587 | 		ProxyPersonnesAPublication<ModelData> proxyPersonnesAPublication = new ProxyPersonnesAPublication<ModelData>(null, publicationId);
 | 
        
           |  |  | 588 |   | 
        
           |  |  | 589 | 		// Colonnes
 | 
        
           |  |  | 590 | 		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
 | 
        
           |  |  | 591 | 		ColumnConfig columnOrdre = new ColumnConfig("_ordre_", i18nC.ordre(), 15);
 | 
        
           |  |  | 592 | 		colonnes.add(columnOrdre);
 | 
        
           |  |  | 593 | 		colonnes.add(new ColumnConfig("cp_fmt_nom_complet", i18nC.personneNomComplet(), 150));
 | 
        
           |  |  | 594 | 		colonnes.add(new ColumnConfig("cp_code_postal", i18nC.personneCodePostal(), 150));
 | 
        
           |  |  | 595 | 		colonnes.add(new ColumnConfig("cp_ville", i18nC.personneVille(), 75));
 | 
        
           |  |  | 596 | 		colonnes.add(new ColumnConfig("cp_truk_courriel", i18nC.personneCourriel(), 75));
 | 
        
           |  |  | 597 |   | 
        
           |  |  | 598 | 		// Champs de traitement
 | 
        
           |  |  | 599 | 		HashMap<String, String> virtualFields = new HashMap<String, String>();
 | 
        
           |  |  | 600 | 		virtualFields.put("_ordre_", "cpuap_ordre");
 | 
        
           |  |  | 601 |   | 
        
           |  |  | 602 | 		// Modele de selection
 | 
        
           |  |  | 603 | 		GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
 | 
        
           |  |  | 604 | 		modeleDeSelection.addListener(Events.SelectionChange, new SelectionChangedListener<ModelData>() {
 | 
        
           |  |  | 605 | 			public void selectionChanged(SelectionChangedEvent<ModelData> se) {
 | 
        
           | 1561 | jpm | 606 | 				activerBoutonsOrdreAuteur();
 | 
        
           | 1513 | jpm | 607 | 			}
 | 
        
           |  |  | 608 | 		});
 | 
        
           |  |  | 609 |   | 
        
           |  |  | 610 | 		ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
 | 
        
           |  |  | 611 |   | 
        
           |  |  | 612 | 		// Grille
 | 
        
           |  |  | 613 | 		// ATTENTION : le constructure de cette grille est à vérifier!
 | 
        
           |  |  | 614 | 		final GrillePaginable<ModelData> grilleAuteurs = new GrillePaginable<ModelData>(modelTypePersonnesAPublication, virtualFields, proxyPersonnesAPublication, colonnes, modeleDeColonnes);
 | 
        
           |  |  | 615 | 		grilleAuteurs.getGrille().setHeight("100%");
 | 
        
           |  |  | 616 | 		grilleAuteurs.getGrille().setBorders(true);
 | 
        
           |  |  | 617 | 		grilleAuteurs.getGrille().setSelectionModel(modeleDeSelection);
 | 
        
           |  |  | 618 | 		grilleAuteurs.getGrille().getView().setForceFit(true);
 | 
        
           |  |  | 619 | 		grilleAuteurs.getGrille().setAutoExpandColumn("fmt_nom_complet");
 | 
        
           |  |  | 620 | 		grilleAuteurs.getGrille().setStripeRows(true);
 | 
        
           |  |  | 621 | 		grilleAuteurs.getGrille().setTrackMouseOver(true);
 | 
        
           |  |  | 622 |   | 
        
           | 1561 | jpm | 623 | 		grilleAuteurs.getStore().getLoader().addListener(Loader.Load, new Listener<LoadEvent>() {
 | 
        
           |  |  | 624 | 			public void handleEvent(LoadEvent be) {
 | 
        
           |  |  | 625 | 				List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
 | 
        
           |  |  | 626 | 				Iterator<ModelData> itAuteurs = auteurs.iterator();
 | 
        
           |  |  | 627 | 				while (itAuteurs.hasNext())	{
 | 
        
           |  |  | 628 | 					ModelData selection = itAuteurs.next();
 | 
        
           | 1573 | jpm | 629 | 					PublicationAPersonne pap = new PublicationAPersonne(selection, aDonnee.GARDER_PREFIXE);
 | 
        
           |  |  | 630 | 					auteursInitialListe.put(pap.getId(), pap);
 | 
        
           |  |  | 631 | 					Log.debug("PublicationAPersonne ajoutée à la liste initiale avec l'id :"+pap.getId()+pap.toString()+selection.getProperties().toString());
 | 
        
           | 1561 | jpm | 632 | 				}
 | 
        
           | 1878 | aurelien | 633 | 				controlerCoherenceAuteurs();
 | 
        
           |  |  | 634 | 				//zefgzf
 | 
        
           | 1561 | jpm | 635 | 				Log.debug("Initialisation liste auteur :"+auteursInitialListe.size());
 | 
        
           |  |  | 636 | 			}
 | 
        
           |  |  | 637 | 		});
 | 
        
           |  |  | 638 |   | 
        
           | 1513 | jpm | 639 | 		// Rajouter des écouteurs
 | 
        
           |  |  | 640 | 		grilleAuteurs.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
 | 
        
           |  |  | 641 | 			public void handleEvent(StoreEvent<ModelData> ce) {
 | 
        
           |  |  | 642 | 				if (!changeOrderMarker) {
 | 
        
           | 1428 | cyprien | 643 | 					actualiserEtatBoutonsBarreOutils();
 | 
        
           |  |  | 644 | 				}
 | 
        
           | 1284 | gduche | 645 | 			}
 | 
        
           |  |  | 646 | 		});
 | 
        
           | 1513 | jpm | 647 | 		grilleAuteurs.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
 | 
        
           |  |  | 648 | 			public void handleEvent(StoreEvent<ModelData> ce) {
 | 
        
           | 1428 | cyprien | 649 | 				if (!changeOrderMarker) {
 | 
        
           |  |  | 650 | 					actualiserEtatBoutonsBarreOutils();
 | 
        
           | 1561 | jpm | 651 | 					Log.debug("Dans listener remove de grilleAuteur");
 | 
        
           | 1428 | cyprien | 652 | 				}
 | 
        
           | 1284 | gduche | 653 | 			}
 | 
        
           |  |  | 654 | 		});
 | 
        
           | 1513 | jpm | 655 | 		grilleAuteurs.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
 | 
        
           |  |  | 656 | 			public void handleEvent(StoreEvent<ModelData> ce) {
 | 
        
           | 1561 | jpm | 657 |   | 
        
           | 1284 | gduche | 658 | 			}
 | 
        
           | 1513 | jpm | 659 | 		});
 | 
        
           | 1284 | gduche | 660 |   | 
        
           | 1513 | jpm | 661 | 		return grilleAuteurs;
 | 
        
           | 1284 | gduche | 662 | 	}
 | 
        
           |  |  | 663 |   | 
        
           | 1095 | jpm | 664 | 	private void genererTitreFormulaire() {
 | 
        
           | 989 | jpm | 665 | 		String titre = i18nC.publicationTitreFormAjout();
 | 
        
           | 822 | jpm | 666 | 		if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           | 1095 | jpm | 667 | 			 titre = i18nC.publicationTitreFormModif();
 | 
        
           |  |  | 668 | 			 if (publication != null) {
 | 
        
           | 1322 | gduche | 669 | 				 titre += " - "+i18nC.id()+": "+publication.getId()+" - "+publication.getTitre();
 | 
        
           | 1095 | jpm | 670 | 			 }
 | 
        
           | 822 | jpm | 671 | 		}
 | 
        
           | 1680 | raphael | 672 | 		panneauFormulaire.setHeadingHtml(titre);
 | 
        
           | 822 | jpm | 673 | 	}
 | 
        
           | 1284 | gduche | 674 |   | 
        
           | 822 | jpm | 675 |   | 
        
           | 775 | jpm | 676 | 	private void creerZoneAuteurs() {
 | 
        
           | 1329 | cyprien | 677 | 		auteursFieldset = new ContentPanel();
 | 
        
           |  |  | 678 | 		auteursFieldset.setLayout(new FitLayout());
 | 
        
           | 1680 | raphael | 679 | 		auteursFieldset.setHeadingHtml("Auteurs");
 | 
        
           | 1329 | cyprien | 680 |   | 
        
           | 822 | jpm | 681 | 		creerChampsAuteur();
 | 
        
           | 775 | jpm | 682 | 	}
 | 
        
           |  |  | 683 |   | 
        
           | 822 | jpm | 684 | 	private void creerChampsAuteur() {
 | 
        
           | 775 | jpm | 685 | 		auteursFieldset.removeAll();
 | 
        
           | 1284 | gduche | 686 | 		barreOutils = creerBarreOutilsGrille();
 | 
        
           | 1329 | cyprien | 687 | 		auteursFieldset.setTopComponent(barreOutils);
 | 
        
           | 1428 | cyprien | 688 | 		grilleAuteurs = creerGrilleAuteurs();
 | 
        
           | 1878 | aurelien | 689 | 		auteursFieldset.add(grilleAuteurs);
 | 
        
           |  |  | 690 |   | 
        
           | 1131 | jpm | 691 | 		auteursFieldset.layout();
 | 
        
           | 775 | jpm | 692 | 	}
 | 
        
           |  |  | 693 |   | 
        
           |  |  | 694 | 	private void creerZoneGeneralites() {
 | 
        
           |  |  | 695 | 		FormLayout layout = new FormLayout();
 | 
        
           |  |  | 696 | 		layout.setLabelWidth(200);
 | 
        
           | 219 | aurelien | 697 |   | 
        
           |  |  | 698 | 		// Fieldset Infos Générales
 | 
        
           | 775 | jpm | 699 | 		generalitesFieldset = new FieldSet();
 | 
        
           | 1680 | raphael | 700 | 		generalitesFieldset.setHeadingHtml("Informations générales");
 | 
        
           | 775 | jpm | 701 | 		generalitesFieldset.setCollapsible(true);
 | 
        
           |  |  | 702 | 		generalitesFieldset.setLayout(layout);
 | 
        
           | 219 | aurelien | 703 |   | 
        
           | 1878 | aurelien | 704 | 		infosAuteursNonPresentsPanel = new ContentPanel();
 | 
        
           |  |  | 705 | 		Label LabelAuteurFmt = new Label("Auteurs de la publication : ");
 | 
        
           |  |  | 706 | 		LabelAuteurFmt.setId("label-auteurs-non-presents");
 | 
        
           |  |  | 707 | 		infosAuteurFmt = new Label(publication.getAuteur());
 | 
        
           |  |  | 708 | 		Label avertissementAuteurs = new Label("Attention, Certains auteurs apparaissent ci-dessous mais pas dans la grille des auteurs. "+
 | 
        
           |  |  | 709 | 												"Ceci signifie que la publication a été importée sans que tous les auteurs aient été créés auparavant.<br />"+
 | 
        
           |  |  | 710 | 												"Si vous souhaitez modifier cette publication, nous vous invitons à y associer correctement les auteurs grâce à la grille ci-dessus.<br />");
 | 
        
           |  |  | 711 |   | 
        
           |  |  | 712 | 		infosAuteursNonPresentsPanel.setHeaderVisible(false);
 | 
        
           |  |  | 713 | 		infosAuteursNonPresentsPanel.setId("infos-auteurs-non-presents");
 | 
        
           |  |  | 714 |   | 
        
           |  |  | 715 | 		infosAuteursNonPresentsPanel.add(avertissementAuteurs);
 | 
        
           |  |  | 716 | 		infosAuteursNonPresentsPanel.add(LabelAuteurFmt);
 | 
        
           |  |  | 717 | 		infosAuteursNonPresentsPanel.add(infosAuteurFmt);
 | 
        
           |  |  | 718 | 		infosAuteursNonPresentsPanel.setVisible(false);
 | 
        
           |  |  | 719 |   | 
        
           |  |  | 720 | 		generalitesFieldset.add(infosAuteursNonPresentsPanel);
 | 
        
           |  |  | 721 |   | 
        
           |  |  | 722 |   | 
        
           | 786 | jpm | 723 | 		titreChp = new TextField<String>();
 | 
        
           |  |  | 724 | 		titreChp.setName("cpu");
 | 
        
           |  |  | 725 | 		titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
 | 
        
           | 981 | jpm | 726 | 		titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           | 980 | jpm | 727 | 		titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
 | 
        
           | 792 | jpm | 728 | 		generalitesFieldset.add(titreChp, new FormData(450, 0));
 | 
        
           | 219 | aurelien | 729 |   | 
        
           | 786 | jpm | 730 | 		collectionChp = new TextField<String>();
 | 
        
           | 792 | jpm | 731 | 		collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
 | 
        
           |  |  | 732 | 		generalitesFieldset.add(collectionChp, new FormData(450, 0));
 | 
        
           | 219 | aurelien | 733 |   | 
        
           | 786 | jpm | 734 | 		uriChp = new TextField<String>();
 | 
        
           | 792 | jpm | 735 | 		uriChp.setFieldLabel("URL de la publication");
 | 
        
           |  |  | 736 | 		generalitesFieldset.add(uriChp, new FormData(450, 0));
 | 
        
           | 775 | jpm | 737 | 	}
 | 
        
           |  |  | 738 |   | 
        
           |  |  | 739 | 	private void creerZoneEdition() {
 | 
        
           |  |  | 740 | 		FormLayout layout = new FormLayout();
 | 
        
           |  |  | 741 | 		layout.setLabelWidth(200);
 | 
        
           |  |  | 742 |   | 
        
           | 219 | aurelien | 743 | 		// Fieldset Edition
 | 
        
           | 775 | jpm | 744 | 		editionFieldset = new FieldSet();
 | 
        
           | 1680 | raphael | 745 | 		editionFieldset.setHeadingHtml("Édition");
 | 
        
           | 775 | jpm | 746 | 		editionFieldset.setCollapsible(true);
 | 
        
           |  |  | 747 | 		editionFieldset.setLayout(layout);
 | 
        
           | 219 | aurelien | 748 |   | 
        
           | 1329 | cyprien | 749 | 		/*****************************************************/
 | 
        
           |  |  | 750 | 		/**			Champ 'Editeur de la publication'		**/
 | 
        
           |  |  | 751 | 		/*****************************************************/
 | 
        
           |  |  | 752 | 		ModelType modelTypeStructures = new ModelType();
 | 
        
           |  |  | 753 | 		modelTypeStructures.setRoot("structures");
 | 
        
           |  |  | 754 | 		modelTypeStructures.setTotalName("nbElements");
 | 
        
           |  |  | 755 | 		modelTypeStructures.addField("cs_nom");
 | 
        
           |  |  | 756 | 		modelTypeStructures.addField("cs_id_structure");
 | 
        
           | 219 | aurelien | 757 |   | 
        
           | 1329 | cyprien | 758 | 		String displayNameStructures = "cs_nom";
 | 
        
           | 1468 | jpm | 759 | 		ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(null);
 | 
        
           | 1329 | cyprien | 760 |   | 
        
           |  |  | 761 | 		editeurCombobox = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
 | 
        
           |  |  | 762 | 		editeurCombobox.setWidth(200, 600);
 | 
        
           |  |  | 763 | 		editeurCombobox.getCombo().setTabIndex(tabIndex++);
 | 
        
           |  |  | 764 | 		editeurCombobox.getCombo().setEmptyText("Sélectionner un éditeur...");
 | 
        
           |  |  | 765 | 		editeurCombobox.getCombo().setFieldLabel("Éditeur de la publication");
 | 
        
           |  |  | 766 | 		editeurCombobox.getCombo().setEditable(true);
 | 
        
           |  |  | 767 | 		editionFieldset.add(editeurCombobox, new FormData(600, 0));
 | 
        
           |  |  | 768 |   | 
        
           |  |  | 769 | 		/*********************************************/
 | 
        
           |  |  | 770 | 		/**			Champ 'Date de publication'		**/
 | 
        
           |  |  | 771 | 		/*********************************************/
 | 
        
           | 786 | jpm | 772 | 		datePublicationChp = new TextField<String>();
 | 
        
           | 1516 | jpm | 773 | 		datePublicationChp.setMaxLength(9);
 | 
        
           | 786 | jpm | 774 | 		datePublicationChp.setMinLength(4);
 | 
        
           |  |  | 775 | 		datePublicationChp.setFieldLabel("Année de publication");
 | 
        
           | 981 | jpm | 776 | 		datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           | 980 | jpm | 777 | 		datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
 | 
        
           | 1516 | jpm | 778 | 		editionFieldset.add(datePublicationChp, new FormData(80, 0));
 | 
        
           | 219 | aurelien | 779 |   | 
        
           | 1513 | jpm | 780 | 		/*********************************/
 | 
        
           |  |  | 781 | 		/**			Champ 'Tome'		**/
 | 
        
           |  |  | 782 | 		/*********************************/
 | 
        
           | 786 | jpm | 783 | 		tomeChp = new TextField<String>();
 | 
        
           | 792 | jpm | 784 | 		tomeChp.setFieldLabel("Série de la revue ou tome");
 | 
        
           |  |  | 785 | 		editionFieldset.add(tomeChp, new FormData(75, 0));
 | 
        
           | 1329 | cyprien | 786 |   | 
        
           | 1513 | jpm | 787 | 		/*************************************/
 | 
        
           |  |  | 788 | 		/**			Champ 'Fascicule'		**/
 | 
        
           |  |  | 789 | 		/*************************************/
 | 
        
           | 786 | jpm | 790 | 		fasciculeChp = new TextField<String>();
 | 
        
           | 792 | jpm | 791 | 		fasciculeChp.setFieldLabel("Fascicule de la revue");
 | 
        
           |  |  | 792 | 		editionFieldset.add(fasciculeChp, new FormData(75, 0));
 | 
        
           | 1329 | cyprien | 793 |   | 
        
           | 1513 | jpm | 794 | 		/*********************************/
 | 
        
           |  |  | 795 | 		/**			Champ 'Pages'		**/
 | 
        
           |  |  | 796 | 		/*********************************/
 | 
        
           | 786 | jpm | 797 | 		pagesChp = new TextField<String>();
 | 
        
           |  |  | 798 | 		pagesChp.setFieldLabel("Pages");
 | 
        
           | 887 | aurelien | 799 | 		pagesChp.setToolTip("Fomat : NBRE ou NBRE-NBRE. ('NBRE' correspond à une suite de chiffres arabes ou romains ou à un point d'interrogation '?' dans le cas d'une donnée inconnue)");
 | 
        
           | 792 | jpm | 800 | 		editionFieldset.add(pagesChp, new FormData(100, 0));
 | 
        
           | 219 | aurelien | 801 | 	}
 | 
        
           | 1180 | jpm | 802 |   | 
        
           | 901 | jpm | 803 |   | 
        
           | 1526 | jpm | 804 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 805 | 	//    Méthodes privées
 | 
        
           | 1428 | cyprien | 806 |   | 
        
           | 1133 | jpm | 807 | 	private void miseAJourAuteursInitialListe() {
 | 
        
           | 901 | jpm | 808 | 		Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
 | 
        
           |  |  | 809 | 		while (clesAjoutees.hasNext()) {
 | 
        
           | 1428 | cyprien | 810 | 			PublicationAPersonne auteurAjoute = auteursAjoutes.get(clesAjoutees.next());
 | 
        
           | 1133 | jpm | 811 | 			auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
 | 
        
           | 901 | jpm | 812 | 		}
 | 
        
           |  |  | 813 |   | 
        
           |  |  | 814 | 		Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
 | 
        
           |  |  | 815 | 		while (clesSupprimees.hasNext()) {
 | 
        
           | 1428 | cyprien | 816 | 			PublicationAPersonne auteurSupprime = auteursSupprimes.get(clesSupprimees.next());
 | 
        
           | 1133 | jpm | 817 | 			auteursInitialListe.remove(auteurSupprime.getId());
 | 
        
           | 901 | jpm | 818 | 		}
 | 
        
           |  |  | 819 | 	}
 | 
        
           |  |  | 820 |   | 
        
           | 786 | jpm | 821 | 	public boolean soumettreFormulaire() {
 | 
        
           | 1322 | gduche | 822 | 		boolean formulaireValideOk = verifierFormulaire();
 | 
        
           | 822 | jpm | 823 | 		if (formulaireValideOk) {
 | 
        
           | 901 | jpm | 824 | 			soumettrePublication();
 | 
        
           |  |  | 825 | 		}
 | 
        
           | 1617 | aurelien | 826 |   | 
        
           |  |  | 827 | 		if(clicBoutonvalidation) {
 | 
        
           |  |  | 828 | 			fermerFormulaire();
 | 
        
           |  |  | 829 | 		}
 | 
        
           |  |  | 830 |   | 
        
           | 901 | jpm | 831 | 		return formulaireValideOk;
 | 
        
           |  |  | 832 | 	}
 | 
        
           | 1322 | gduche | 833 |   | 
        
           | 901 | jpm | 834 | 	private void soumettrePublication() {
 | 
        
           |  |  | 835 | 		Publication publicationCollectee = collecterPublication();
 | 
        
           |  |  | 836 | 		if (publicationCollectee != null) {
 | 
        
           | 1428 | cyprien | 837 | 			// Pour l'enregistrement des publications, on utilise le séquenceur
 | 
        
           | 1322 | gduche | 838 | 			// Il doit attendre le retour de l'enregistrement pour poursuivre
 | 
        
           |  |  | 839 | 			sequenceur = new Sequenceur();
 | 
        
           |  |  | 840 | 			int seqId = sequenceur.lancerRequeteSynchrone(this);
 | 
        
           | 901 | jpm | 841 | 			if (mode.equals(Formulaire.MODE_AJOUTER)) {
 | 
        
           | 1322 | gduche | 842 | 				mediateur.ajouterPublication(sequenceur, publicationCollectee, seqId);
 | 
        
           | 901 | jpm | 843 | 			} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           | 1322 | gduche | 844 | 				mediateur.modifierPublication(sequenceur, publicationCollectee, seqId);
 | 
        
           | 901 | jpm | 845 | 			}
 | 
        
           | 1428 | cyprien | 846 |   | 
        
           |  |  | 847 | 		// si l'on est en mode MODIFIER, on soumet les auteurs meme si les informations de la publication
 | 
        
           |  |  | 848 | 		// restent inchangées car il se peut que les auteurs aient été modifiés
 | 
        
           |  |  | 849 | 		} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           |  |  | 850 | 			soumettreAuteurs();
 | 
        
           | 1617 | aurelien | 851 | 			if(clicBoutonvalidation) {
 | 
        
           |  |  | 852 | 				fermerFormulaire();
 | 
        
           |  |  | 853 | 			}
 | 
        
           | 901 | jpm | 854 | 		}
 | 
        
           |  |  | 855 | 	}
 | 
        
           |  |  | 856 |   | 
        
           |  |  | 857 | 	private void soumettreAuteurs() {
 | 
        
           | 1284 | gduche | 858 | 		//1) Auteurs ajoutés :
 | 
        
           | 1428 | cyprien | 859 | 		PublicationAPersonneListe listeAuteursAAjouter = new PublicationAPersonneListe();
 | 
        
           | 1284 | gduche | 860 | 		Iterator<String> itAuteur = auteursAjoutes.keySet().iterator();
 | 
        
           | 1428 | cyprien | 861 | 		while (itAuteur.hasNext())	{
 | 
        
           | 1284 | gduche | 862 | 			String cle = itAuteur.next();
 | 
        
           | 1561 | jpm | 863 | 			PublicationAPersonne publiAPersonne = auteursAjoutes.get(cle);
 | 
        
           |  |  | 864 | 			Log.debug("Ajouter :"+publiAPersonne.toString());
 | 
        
           | 1428 | cyprien | 865 | 			publiAPersonne.setIdPublication(this.publicationId);
 | 
        
           |  |  | 866 | 			publiAPersonne.setOrdreAuteurs(publiAPersonne.getOrdreAuteurs());
 | 
        
           |  |  | 867 | 			listeAuteursAAjouter.put(cle, publiAPersonne);
 | 
        
           | 1284 | gduche | 868 | 		}
 | 
        
           |  |  | 869 |   | 
        
           |  |  | 870 | 		// - envoyer au mediateur SSI personnes à ajouter
 | 
        
           | 1428 | cyprien | 871 | 		if (listeAuteursAAjouter.size() > 0)	{
 | 
        
           | 1322 | gduche | 872 | 			int seqId = sequenceur.lancerRequeteSynchrone(this);
 | 
        
           | 1428 | cyprien | 873 | 			mediateur.ajouterPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAAjouter, PublicationAPersonne.ROLE_AUTEUR, seqId);
 | 
        
           | 1284 | gduche | 874 | 		}
 | 
        
           |  |  | 875 |   | 
        
           |  |  | 876 | 		//2) Auteurs supprimés :
 | 
        
           | 1428 | cyprien | 877 | 		PublicationAPersonneListe listeAuteursASupprimer = new PublicationAPersonneListe();
 | 
        
           | 1284 | gduche | 878 | 		itAuteur = auteursSupprimes.keySet().iterator();
 | 
        
           |  |  | 879 | 		while (itAuteur.hasNext())	{
 | 
        
           |  |  | 880 | 			String cle = itAuteur.next();
 | 
        
           | 1428 | cyprien | 881 | 			PublicationAPersonne publiAPersonne = auteursSupprimes.get(cle);
 | 
        
           | 1561 | jpm | 882 | 			Log.debug("Supprimer :"+publiAPersonne.toString());
 | 
        
           | 1428 | cyprien | 883 | 			listeAuteursASupprimer.put(cle, publiAPersonne);
 | 
        
           | 1284 | gduche | 884 | 		}
 | 
        
           |  |  | 885 |   | 
        
           |  |  | 886 | 		// - Envoyer au médiateur SSI personnes à supprimer
 | 
        
           | 1428 | cyprien | 887 | 		if (listeAuteursASupprimer.size() > 0) {
 | 
        
           | 1322 | gduche | 888 | 			// Pour une suppression des auteurs, on a pas besoin d'attendre le retour
 | 
        
           | 1561 | jpm | 889 | 			Log.debug("Lancement suppression :"+listeAuteursASupprimer.size());
 | 
        
           | 1428 | cyprien | 890 | 			mediateur.supprimerPublicationAPersonne(this, listeAuteursASupprimer);
 | 
        
           | 1284 | gduche | 891 | 		}
 | 
        
           |  |  | 892 |   | 
        
           | 1428 | cyprien | 893 | 		//3) Auteurs modifiés :
 | 
        
           |  |  | 894 | 		PublicationAPersonneListe listeAuteursAModifier = new PublicationAPersonneListe();
 | 
        
           |  |  | 895 | 		itAuteur = auteursModifies.keySet().iterator();
 | 
        
           |  |  | 896 | 		while (itAuteur.hasNext())	{
 | 
        
           |  |  | 897 | 			String cle = itAuteur.next();
 | 
        
           |  |  | 898 | 			PublicationAPersonne publiAPersonne = auteursModifies.get(cle);
 | 
        
           | 1561 | jpm | 899 | 			Log.debug("Modifier :"+publiAPersonne.toString());
 | 
        
           | 1428 | cyprien | 900 | 			listeAuteursAModifier.put(cle, publiAPersonne);
 | 
        
           | 227 | aurelien | 901 | 		}
 | 
        
           | 705 | aurelien | 902 |   | 
        
           | 1428 | cyprien | 903 | 		// - Envoyer au médiateur SSI personnes à modifier
 | 
        
           |  |  | 904 | 		if (listeAuteursAModifier.size() > 0) {
 | 
        
           |  |  | 905 | 			int seqId = sequenceur.lancerRequeteSynchrone(this);
 | 
        
           | 1468 | jpm | 906 | 			mediateur.modifierPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAModifier, PublicationAPersonne.ROLE_AUTEUR, seqId);
 | 
        
           | 705 | aurelien | 907 | 		}
 | 
        
           |  |  | 908 |   | 
        
           | 1428 | cyprien | 909 | 		sequenceur.enfilerRafraichissement(this, new Information("auteurs_enregistres"));
 | 
        
           |  |  | 910 | 	}
 | 
        
           |  |  | 911 |   | 
        
           | 822 | jpm | 912 | 	private void peuplerFormulaire() {
 | 
        
           |  |  | 913 | 		titreChp.setValue(publication.getTitre());
 | 
        
           |  |  | 914 | 		collectionChp.setValue(publication.getCollection());
 | 
        
           |  |  | 915 | 		uriChp.setValue(publication.getURI());
 | 
        
           | 1516 | jpm | 916 | 		datePublicationChp.setValue(publication.getAnneeParution());
 | 
        
           | 822 | jpm | 917 | 		tomeChp.setValue(publication.getIndicationNvt());
 | 
        
           |  |  | 918 | 		fasciculeChp.setValue(publication.getFascicule());
 | 
        
           |  |  | 919 | 		pagesChp.setValue(publication.getPages());
 | 
        
           |  |  | 920 |   | 
        
           | 1526 | jpm | 921 | 		// Éditeur est soit une référence à une structure de la base soit une chaine
 | 
        
           | 822 | jpm | 922 | 		if (publication.getEditeur().matches("^[0-9]+$")) {
 | 
        
           | 1526 | jpm | 923 | 			//editeurCombobox.getCombo().setValue(editeurCombobox.getStore().findModel("cs_id_structure", publication.getEditeur()));
 | 
        
           |  |  | 924 | 			editeurCombobox.chargerValeurInitiale(publication.getEditeur(), "cs_id_structure");
 | 
        
           | 822 | jpm | 925 | 		} else {
 | 
        
           | 1329 | cyprien | 926 | 			editeurCombobox.getCombo().setRawValue(publication.getEditeur());
 | 
        
           | 822 | jpm | 927 | 		}
 | 
        
           |  |  | 928 | 	}
 | 
        
           |  |  | 929 |   | 
        
           | 786 | jpm | 930 | 	private Publication collecterPublication() {
 | 
        
           | 1428 | cyprien | 931 |   | 
        
           | 786 | jpm | 932 | 		Publication publicationCollectee = (Publication) publication.cloner(new Publication());
 | 
        
           | 1124 | jpm | 933 | 		publicationCollectee.setAuteur(construireIntituleAuteur());
 | 
        
           | 786 | jpm | 934 |   | 
        
           |  |  | 935 | 		String titre = titreChp.getValue();
 | 
        
           |  |  | 936 | 		publicationCollectee.setTitre(titre);
 | 
        
           |  |  | 937 |   | 
        
           |  |  | 938 | 		String collection = collectionChp.getValue();
 | 
        
           |  |  | 939 | 		publicationCollectee.setCollection(collection);
 | 
        
           |  |  | 940 |   | 
        
           | 1124 | jpm | 941 | 		publicationCollectee.setNomComplet(construireNomComplet());
 | 
        
           | 786 | jpm | 942 |   | 
        
           |  |  | 943 | 		String uri = uriChp.getValue();
 | 
        
           |  |  | 944 | 		publicationCollectee.setUri(uri);
 | 
        
           |  |  | 945 |   | 
        
           |  |  | 946 | 		String editeur = "";
 | 
        
           | 1329 | cyprien | 947 | 		if (editeurCombobox.getValeur() != null) {
 | 
        
           |  |  | 948 | 			Structure structure = new Structure(editeurCombobox.getValeur());
 | 
        
           |  |  | 949 | 			editeur = structure.getId();
 | 
        
           |  |  | 950 | 			publicationCollectee.setStructureEditeur(structure);
 | 
        
           |  |  | 951 | 		} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
 | 
        
           |  |  | 952 | 			editeur = editeurCombobox.getCombo().getRawValue();
 | 
        
           | 786 | jpm | 953 | 		}
 | 
        
           | 1896 | aurelien | 954 |   | 
        
           |  |  | 955 | 		Publication.editeurs.put(editeur, editeurCombobox.getCombo().getRawValue());
 | 
        
           |  |  | 956 |   | 
        
           | 786 | jpm | 957 | 		publicationCollectee.setEditeur(editeur);
 | 
        
           |  |  | 958 |   | 
        
           | 792 | jpm | 959 | 		String anneePublication = datePublicationChp.getRawValue();
 | 
        
           | 1516 | jpm | 960 | 		publicationCollectee.setAnneeParution(anneePublication);
 | 
        
           | 786 | jpm | 961 |   | 
        
           |  |  | 962 | 		String tome = tomeChp.getValue();
 | 
        
           |  |  | 963 | 		publicationCollectee.setIndicationNvt(tome);
 | 
        
           |  |  | 964 |   | 
        
           |  |  | 965 | 		String fascicule = fasciculeChp.getValue();
 | 
        
           |  |  | 966 | 		publicationCollectee.setFascicule(fascicule);
 | 
        
           |  |  | 967 |   | 
        
           |  |  | 968 | 		String pages = pagesChp.getValue();
 | 
        
           |  |  | 969 | 		publicationCollectee.setPages(pages);
 | 
        
           |  |  | 970 |   | 
        
           | 927 | jpm | 971 | 		Publication publicationARetourner = null;
 | 
        
           | 786 | jpm | 972 | 		if (!publicationCollectee.comparer(publication)) {
 | 
        
           |  |  | 973 | 			publicationARetourner = publication = publicationCollectee;
 | 
        
           |  |  | 974 | 		}
 | 
        
           | 1896 | aurelien | 975 |   | 
        
           |  |  | 976 | 		Publication.publisSaisiesModifieesCache.put(publicationId, publicationARetourner);
 | 
        
           | 786 | jpm | 977 | 		return publicationARetourner;
 | 
        
           |  |  | 978 | 	}
 | 
        
           |  |  | 979 |   | 
        
           | 1607 | aurelien | 980 | 	private String construireDate(String valeurDate) {
 | 
        
           |  |  | 981 |   | 
        
           |  |  | 982 | 		String dateComplete = "";
 | 
        
           |  |  | 983 | 		if (!UtilString.isEmpty(valeurDate)){
 | 
        
           |  |  | 984 | 			String jour = "00";
 | 
        
           |  |  | 985 | 			String mois = "00";
 | 
        
           |  |  | 986 | 			String annee = "0000";
 | 
        
           |  |  | 987 | 			String messageErreur = null;
 | 
        
           |  |  | 988 |   | 
        
           |  |  | 989 | 			/**  JJ/MM/AAAA  **/
 | 
        
           |  |  | 990 | 			if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
 | 
        
           |  |  | 991 |   | 
        
           |  |  | 992 | 			}
 | 
        
           |  |  | 993 |   | 
        
           |  |  | 994 | 			/**  MM/AAAA  **/
 | 
        
           |  |  | 995 | 			if (valeurDate.matches("\\d{2}/\\d{4}")) {
 | 
        
           |  |  | 996 | 				dateComplete = valeurDate+"-00";
 | 
        
           |  |  | 997 | 			}
 | 
        
           |  |  | 998 |   | 
        
           |  |  | 999 | 			/**  AAAA  **/
 | 
        
           |  |  | 1000 | 			if (valeurDate.matches("\\d{4}")) {
 | 
        
           |  |  | 1001 | 				dateComplete = valeurDate+"-00-00";
 | 
        
           |  |  | 1002 | 			}
 | 
        
           |  |  | 1003 | 		}
 | 
        
           |  |  | 1004 |   | 
        
           |  |  | 1005 | 		return dateComplete;
 | 
        
           |  |  | 1006 | 	}
 | 
        
           |  |  | 1007 |   | 
        
           | 1124 | jpm | 1008 | 	private String construireIntituleEditeur() {
 | 
        
           |  |  | 1009 | 		String editeur = "";
 | 
        
           | 1329 | cyprien | 1010 | 		if (editeurCombobox.getValeur() != null) {
 | 
        
           |  |  | 1011 | 			Structure structure = new Structure(editeurCombobox.getValeur());
 | 
        
           | 1526 | jpm | 1012 | 			editeur = structure.getNom();
 | 
        
           | 1329 | cyprien | 1013 | 		} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
 | 
        
           |  |  | 1014 | 			editeur = editeurCombobox.getCombo().getRawValue();
 | 
        
           | 1124 | jpm | 1015 | 		}
 | 
        
           |  |  | 1016 | 		return editeur;
 | 
        
           |  |  | 1017 | 	}
 | 
        
           |  |  | 1018 |   | 
        
           |  |  | 1019 | 	private String construireIntituleAuteur() {
 | 
        
           | 1284 | gduche | 1020 | 		String intituleAuteur = "";
 | 
        
           |  |  | 1021 |   | 
        
           | 1513 | jpm | 1022 | 		// rangé par ordre désigné par le champ 'cpuap_ordre' de la table PublicationAPersonne
 | 
        
           |  |  | 1023 | 		grilleAuteurs.getStore().sort("_ordre_", SortDir.ASC);
 | 
        
           |  |  | 1024 | 		List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
 | 
        
           |  |  | 1025 | 		Iterator<ModelData> itAuteurs = auteurs.iterator();
 | 
        
           |  |  | 1026 |   | 
        
           | 1284 | gduche | 1027 | 		while (itAuteurs.hasNext())	{
 | 
        
           | 1513 | jpm | 1028 | 			Personne personneCourante = new PublicationAPersonne(itAuteurs.next(), false).getPersonne();
 | 
        
           | 1284 | gduche | 1029 | 			intituleAuteur += personneCourante.getNom().toUpperCase() + " " + personneCourante.getPrenom();
 | 
        
           |  |  | 1030 | 			if (itAuteurs.hasNext())	{
 | 
        
           |  |  | 1031 | 				intituleAuteur+=", ";
 | 
        
           |  |  | 1032 | 			}
 | 
        
           |  |  | 1033 | 		}
 | 
        
           |  |  | 1034 | 		return intituleAuteur;
 | 
        
           | 1124 | jpm | 1035 | 	}
 | 
        
           |  |  | 1036 |   | 
        
           |  |  | 1037 | 	private String construireNomComplet() {
 | 
        
           |  |  | 1038 | 		// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
 | 
        
           |  |  | 1039 | 		String nomComplet = "";
 | 
        
           |  |  | 1040 | 		String auteurs = construireIntituleAuteur();
 | 
        
           |  |  | 1041 | 		String annee = datePublicationChp.getRawValue();
 | 
        
           |  |  | 1042 | 		String titre = titreChp.getValue();
 | 
        
           |  |  | 1043 | 		String editeur = construireIntituleEditeur();
 | 
        
           |  |  | 1044 |   | 
        
           |  |  | 1045 | 		nomComplet += auteurs+", "+annee+". "+titre+".";
 | 
        
           |  |  | 1046 |   | 
        
           |  |  | 1047 | 		if (!UtilString.isEmpty(editeur)) {
 | 
        
           |  |  | 1048 | 			nomComplet += " Éditeur "+editeur+".";
 | 
        
           |  |  | 1049 | 		}
 | 
        
           |  |  | 1050 |   | 
        
           |  |  | 1051 | 		if (collectionChp.getValue() != null) {
 | 
        
           |  |  | 1052 | 			String revue = collectionChp.getValue();
 | 
        
           |  |  | 1053 | 			nomComplet += ", "+revue;
 | 
        
           |  |  | 1054 | 		}
 | 
        
           |  |  | 1055 |   | 
        
           |  |  | 1056 | 		if (fasciculeChp.getValue() != null) {
 | 
        
           |  |  | 1057 | 			String fascicule = fasciculeChp.getValue();
 | 
        
           |  |  | 1058 | 			nomComplet += ", "+fascicule;
 | 
        
           |  |  | 1059 | 		}
 | 
        
           |  |  | 1060 |   | 
        
           |  |  | 1061 | 		if (tomeChp.getValue() != null) {
 | 
        
           |  |  | 1062 | 			String tomaison = tomeChp.getValue();
 | 
        
           |  |  | 1063 | 			nomComplet += ", "+tomaison;
 | 
        
           |  |  | 1064 | 		}
 | 
        
           |  |  | 1065 |   | 
        
           |  |  | 1066 | 		if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
 | 
        
           |  |  | 1067 | 			nomComplet += ".";
 | 
        
           |  |  | 1068 | 		}
 | 
        
           |  |  | 1069 |   | 
        
           |  |  | 1070 | 		if (pagesChp.getValue() != null) {
 | 
        
           |  |  | 1071 | 			String pages = pagesChp.getValue();
 | 
        
           |  |  | 1072 | 			nomComplet += pages+".";
 | 
        
           |  |  | 1073 | 		}
 | 
        
           |  |  | 1074 |   | 
        
           |  |  | 1075 | 		return nomComplet;
 | 
        
           |  |  | 1076 | 	}
 | 
        
           |  |  | 1077 |   | 
        
           | 1878 | aurelien | 1078 | 	public void controlerCoherenceAuteurs() {
 | 
        
           |  |  | 1079 | 		if(doitAfficherAvertissementAuteur()) {
 | 
        
           |  |  | 1080 | 			infosAuteurFmt.setHtml(publication.getAuteur());
 | 
        
           |  |  | 1081 | 			infosAuteursNonPresentsPanel.setVisible(true);
 | 
        
           |  |  | 1082 | 			infosAuteursNonPresentsPanel.setHeight(50);
 | 
        
           |  |  | 1083 | 		} else {
 | 
        
           |  |  | 1084 | 			infosAuteursNonPresentsPanel.setVisible(false);
 | 
        
           |  |  | 1085 | 			infosAuteursNonPresentsPanel.setHeight(0);
 | 
        
           |  |  | 1086 | 		}
 | 
        
           |  |  | 1087 | 	}
 | 
        
           |  |  | 1088 |   | 
        
           |  |  | 1089 | 	private boolean doitAfficherAvertissementAuteur() {
 | 
        
           | 1880 | aurelien | 1090 | 		// La construction du fmt nom complet des auteurs étant mal fichue
 | 
        
           |  |  | 1091 | 		// il est plus simple de comparer le nombre d'item une fois les chaines
 | 
        
           |  |  | 1092 | 		// splittées par virgules, ainsi que le nombre d'espace
 | 
        
           | 1878 | aurelien | 1093 | 		String auteurFmtreconstruit = construireIntituleAuteur();
 | 
        
           |  |  | 1094 | 		String[] auteurFmtreconstruitParts = auteurFmtreconstruit.split(",");
 | 
        
           |  |  | 1095 | 		String[] auteurParts = publication.getAuteur().split(",");
 | 
        
           |  |  | 1096 |   | 
        
           |  |  | 1097 | 		String[] auteurFmtreconstruitSpaces = auteurFmtreconstruit.split(" ");
 | 
        
           |  |  | 1098 | 		String[] auteurPartsSpaces = publication.getAuteur().split(" ");
 | 
        
           |  |  | 1099 |   | 
        
           | 1880 | aurelien | 1100 | 		boolean unEstVideEtAutreNon = (auteurFmtreconstruit.trim().isEmpty() != publication.getAuteur().isEmpty());
 | 
        
           |  |  | 1101 |   | 
        
           | 1878 | aurelien | 1102 | 		return (modeDeCreation == MODE_MODIFIER &&
 | 
        
           | 1880 | aurelien | 1103 | 				(unEstVideEtAutreNon ||
 | 
        
           |  |  | 1104 | 				auteurFmtreconstruitParts.length != auteurParts.length ||
 | 
        
           | 1878 | aurelien | 1105 | 				auteurFmtreconstruitSpaces.length != auteurPartsSpaces.length));
 | 
        
           |  |  | 1106 | 	}
 | 
        
           |  |  | 1107 |   | 
        
           | 1526 | jpm | 1108 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 1109 | 	//    Méthodes publiques
 | 
        
           | 1428 | cyprien | 1110 |   | 
        
           |  |  | 1111 | 	public boolean verifierFormulaire() {
 | 
        
           |  |  | 1112 | 		boolean valide = true;
 | 
        
           |  |  | 1113 | 		ArrayList<String> messages = new ArrayList<String>();
 | 
        
           |  |  | 1114 |   | 
        
           |  |  | 1115 | 		// Tester si au moins un auteur est présent
 | 
        
           |  |  | 1116 | 		if (grilleAuteurs.getStore().getModels().size() == 0) {
 | 
        
           |  |  | 1117 | 			messages.add("Veuillez saisir au moins un auteur.");
 | 
        
           |  |  | 1118 | 		}
 | 
        
           |  |  | 1119 |   | 
        
           |  |  | 1120 | 		String titre = titreChp.getValue();
 | 
        
           |  |  | 1121 | 		if (titre == null || titre.equals("")) {
 | 
        
           |  |  | 1122 | 			messages.add("Veuillez saisir le titre de la publication !");
 | 
        
           |  |  | 1123 | 		}
 | 
        
           |  |  | 1124 |   | 
        
           |  |  | 1125 | 		String uri = uriChp.getValue();
 | 
        
           |  |  | 1126 | 		if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
 | 
        
           |  |  | 1127 | 			messages.add("L'URL saisie n'est pas valide !");
 | 
        
           |  |  | 1128 | 		}
 | 
        
           |  |  | 1129 |   | 
        
           |  |  | 1130 | 		String datePublication = datePublicationChp.getRawValue();
 | 
        
           |  |  | 1131 | 		if (datePublication == null || datePublication.equals("")) {
 | 
        
           |  |  | 1132 | 			messages.add("Veuillez saisir une année de parution !");
 | 
        
           |  |  | 1133 | 		} else {
 | 
        
           | 1516 | jpm | 1134 | 			if (!Publication.etreAnneeParutionValide(datePublication)) {
 | 
        
           |  |  | 1135 | 				messages.add("Le format de l'année saisie est incorrect ! Formats acceptés : AAAA ou AAAA-AAAA");
 | 
        
           | 1428 | cyprien | 1136 | 			}
 | 
        
           |  |  | 1137 | 		}
 | 
        
           |  |  | 1138 |   | 
        
           |  |  | 1139 | 		String pages = pagesChp.getValue();
 | 
        
           |  |  | 1140 | 		String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
 | 
        
           |  |  | 1141 | 		if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
 | 
        
           |  |  | 1142 | 			messages.add("Le format des pages est incorrect !");
 | 
        
           |  |  | 1143 | 		}
 | 
        
           |  |  | 1144 |   | 
        
           |  |  | 1145 | 		if (messages.size() != 0) {
 | 
        
           |  |  | 1146 | 			String[] tableauDeMessages = {};
 | 
        
           |  |  | 1147 | 			tableauDeMessages = messages.toArray(tableauDeMessages);
 | 
        
           |  |  | 1148 | 			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
 | 
        
           |  |  | 1149 | 			valide = false;
 | 
        
           |  |  | 1150 | 		}
 | 
        
           |  |  | 1151 | 		return valide;
 | 
        
           |  |  | 1152 | 	}
 | 
        
           |  |  | 1153 |   | 
        
           |  |  | 1154 |   | 
        
           | 1526 | jpm | 1155 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 1156 | 	//    Accesseurs
 | 
        
           | 1428 | cyprien | 1157 |   | 
        
           | 1526 | jpm | 1158 | 	//+----------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 1159 | 	//    Rafraichir
 | 
        
           | 1428 | cyprien | 1160 |   | 
        
           |  |  | 1161 | 	public void rafraichir(Object nouvellesDonnees) {
 | 
        
           |  |  | 1162 | 		if (nouvellesDonnees instanceof Publication) {
 | 
        
           |  |  | 1163 | 			publication = (Publication) nouvellesDonnees;
 | 
        
           |  |  | 1164 | 		} else if (nouvellesDonnees instanceof Information) {
 | 
        
           |  |  | 1165 | 			rafraichirInformation((Information) nouvellesDonnees);
 | 
        
           |  |  | 1166 | 		} else {
 | 
        
           |  |  | 1167 | 			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
 | 
        
           |  |  | 1168 | 		}
 | 
        
           |  |  | 1169 | 	}
 | 
        
           |  |  | 1170 |   | 
        
           | 1513 | jpm | 1171 | 	private void rafraichirInformation(Information info) {
 | 
        
           | 1428 | cyprien | 1172 |   | 
        
           |  |  | 1173 | 		String type = info.getType();
 | 
        
           |  |  | 1174 | 		if (type.equals("auteurs_enregistres")) {
 | 
        
           |  |  | 1175 | 			miseAJourAuteursInitialListe();
 | 
        
           |  |  | 1176 | 			initialiserAuteurs();
 | 
        
           |  |  | 1177 | 			repandreRafraichissement();
 | 
        
           |  |  | 1178 | 			controlerFermeture();
 | 
        
           |  |  | 1179 | 		} else if (type.equals("chargement_modifier_ok"))	{
 | 
        
           | 1526 | jpm | 1180 | 			Debug.log("Chargement 1");
 | 
        
           | 1428 | cyprien | 1181 | 			peuplerFormulaire();
 | 
        
           |  |  | 1182 | 			genererTitreFormulaire();
 | 
        
           |  |  | 1183 | 		}
 | 
        
           |  |  | 1184 |   | 
        
           |  |  | 1185 | 		if (type.equals("personne_ajoutee")) {
 | 
        
           |  |  | 1186 | 			if (info.getDonnee(0) != null) {
 | 
        
           |  |  | 1187 | 				Personne personne = (Personne) info.getDonnee(0);
 | 
        
           | 1617 | aurelien | 1188 | 				personne = formaterChampPersonnePourGrille(personne);
 | 
        
           |  |  | 1189 | 				PublicationAPersonne pap = new PublicationAPersonne(personne, false);
 | 
        
           | 1428 | cyprien | 1190 | 				if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
 | 
        
           |  |  | 1191 | 				ajouterDansGrille(pap);
 | 
        
           |  |  | 1192 | 			}
 | 
        
           |  |  | 1193 | 		} else if (type.equals("personne_modifiee")) {
 | 
        
           |  |  | 1194 | 			if (info.getDonnee(0) != null) {
 | 
        
           |  |  | 1195 |   | 
        
           |  |  | 1196 | 				// créer la nouvelle entrée
 | 
        
           |  |  | 1197 | 				Personne personne = (Personne) info.getDonnee(0);
 | 
        
           |  |  | 1198 | 				PublicationAPersonne pap = new PublicationAPersonne();
 | 
        
           |  |  | 1199 | 				pap.setPersonne(personne);
 | 
        
           |  |  | 1200 | 				if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
 | 
        
           |  |  | 1201 |   | 
        
           |  |  | 1202 | 				// supprimer l'entrée précédente
 | 
        
           | 1513 | jpm | 1203 | 				PublicationAPersonne personneDansGrille = new PublicationAPersonne(grilleAuteurs.getStore().findModel("cp_id_personne", personne.getId()), false);
 | 
        
           | 1428 | cyprien | 1204 | 				int index = grilleAuteurs.getStore().indexOf(personneDansGrille);
 | 
        
           |  |  | 1205 | 				grilleAuteurs.getStore().remove(personneDansGrille);
 | 
        
           | 1617 | aurelien | 1206 | 				if(index != -1) {
 | 
        
           |  |  | 1207 | 					// ajouter la nouvelle entrée dans la grille
 | 
        
           |  |  | 1208 | 					ajouterDansGrille(pap, index);
 | 
        
           |  |  | 1209 | 				} else {
 | 
        
           |  |  | 1210 | 					ajouterDansGrille(pap);
 | 
        
           |  |  | 1211 | 				}
 | 
        
           | 1428 | cyprien | 1212 | 			}
 | 
        
           |  |  | 1213 | 		} else if (info.getType().equals("modif_publication")) {
 | 
        
           |  |  | 1214 | 			InfoLogger.display("Modification d'une publication", info.toString());
 | 
        
           |  |  | 1215 | 			soumettreAuteurs();
 | 
        
           |  |  | 1216 | 		} else if (info.getType().equals("ajout_publication")) {
 | 
        
           |  |  | 1217 | 			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String && ((String) info.getDonnee(0)).matches("[0-9]+")) {
 | 
        
           |  |  | 1218 | 				String idPublication = (String) info.getDonnee(0);
 | 
        
           |  |  | 1219 | 				this.publicationId = idPublication;
 | 
        
           | 1468 | jpm | 1220 | 				this.publication.setId(idPublication);
 | 
        
           | 1428 | cyprien | 1221 | 				soumettreAuteurs();
 | 
        
           |  |  | 1222 | 				InfoLogger.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
 | 
        
           |  |  | 1223 | 			} else {
 | 
        
           |  |  | 1224 | 				InfoLogger.display("Ajout d'une publication", info.toString());
 | 
        
           |  |  | 1225 | 			}
 | 
        
           | 1561 | jpm | 1226 | 		} else if (info.getType().equals("suppression_publication_a_personne")) {
 | 
        
           |  |  | 1227 | 			InfoLogger.display("Suppression d'auteur", info.getMessages().toString());
 | 
        
           |  |  | 1228 | 		}
 | 
        
           | 1428 | cyprien | 1229 | 	}
 | 
        
           |  |  | 1230 |   | 
        
           | 1617 | aurelien | 1231 | 	private Personne formaterChampPersonnePourGrille(Personne personne) {
 | 
        
           |  |  | 1232 | 		personne.set("cp_id_personne", personne.getId());
 | 
        
           |  |  | 1233 | 		personne.set("cp_fmt_nom_complet", personne.getNomComplet());
 | 
        
           |  |  | 1234 | 		personne.set("cp_fmt_nom_complet", personne.getNomComplet());
 | 
        
           |  |  | 1235 | 		personne.set("cpuap_id_personne", personne.getId());
 | 
        
           |  |  | 1236 | 		personne.set("cp_code_postal", personne.get("code_postal"));
 | 
        
           |  |  | 1237 | 		personne.set("cp_ville", personne.get("ville"));
 | 
        
           |  |  | 1238 | 		personne.set("cp_truk_courriel", personne.getCourriel());
 | 
        
           |  |  | 1239 |   | 
        
           |  |  | 1240 | 		personne.set("cpuap_ordre", grilleAuteurs.getStore().getCount());
 | 
        
           |  |  | 1241 | 		personne.set("cp_nom", personne.getNom());
 | 
        
           |  |  | 1242 | 		personne.set("cp_prenom", personne.getPrenom());
 | 
        
           |  |  | 1243 | 		return personne;
 | 
        
           |  |  | 1244 | 	}
 | 
        
           |  |  | 1245 |   | 
        
           | 1428 | cyprien | 1246 | 	private void repandreRafraichissement() {
 | 
        
           |  |  | 1247 | 		if (vueExterneARafraichirApresValidation != null) {
 | 
        
           |  |  | 1248 | 			String type = "publication_modifiee";
 | 
        
           |  |  | 1249 | 			if (mode.equals(Formulaire.MODE_AJOUTER)) {
 | 
        
           |  |  | 1250 | 				type = "publication_ajoutee";
 | 
        
           |  |  | 1251 | 			}
 | 
        
           |  |  | 1252 | 			Information info = new Information(type);
 | 
        
           |  |  | 1253 | 			info.setDonnee(0, publication);
 | 
        
           |  |  | 1254 | 			vueExterneARafraichirApresValidation.rafraichir(info);
 | 
        
           |  |  | 1255 | 		}
 | 
        
           |  |  | 1256 | 	}
 | 
        
           | 1661 | raphael | 1257 | }
 |