| 935 | jpm | 1 | package org.tela_botanica.client.vues.projet;
 | 
        
           | 877 | aurelien | 2 |   | 
        
           |  |  | 3 | import java.util.ArrayList;
 | 
        
           |  |  | 4 |   | 
        
           | 980 | jpm | 5 | import org.tela_botanica.client.ComposantClass;
 | 
        
           | 877 | aurelien | 6 | import org.tela_botanica.client.Mediateur;
 | 
        
           | 1115 | jpm | 7 | import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
 | 
        
           | 1329 | cyprien | 8 | import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
 | 
        
           | 1239 | cyprien | 9 | import org.tela_botanica.client.composants.InfoLogger;
 | 
        
           | 1329 | cyprien | 10 | import org.tela_botanica.client.composants.pagination.ProxyValeur;
 | 
        
           | 877 | aurelien | 11 | import org.tela_botanica.client.interfaces.Rafraichissable;
 | 
        
           |  |  | 12 | import org.tela_botanica.client.modeles.Information;
 | 
        
           |  |  | 13 | import org.tela_botanica.client.modeles.MenuApplicationId;
 | 
        
           | 1329 | cyprien | 14 | import org.tela_botanica.client.modeles.Valeur;
 | 
        
           | 935 | jpm | 15 | import org.tela_botanica.client.modeles.projet.Projet;
 | 
        
           | 1367 | cyprien | 16 | import org.tela_botanica.client.synchronisation.Sequenceur;
 | 
        
           | 928 | jpm | 17 | import org.tela_botanica.client.util.Debug;
 | 
        
           | 877 | aurelien | 18 | import org.tela_botanica.client.util.Pattern;
 | 
        
           |  |  | 19 | import org.tela_botanica.client.util.UtilArray;
 | 
        
           | 928 | jpm | 20 | import org.tela_botanica.client.util.UtilString;
 | 
        
           | 935 | jpm | 21 | import org.tela_botanica.client.vues.Formulaire;
 | 
        
           | 877 | aurelien | 22 |   | 
        
           | 1322 | gduche | 23 | import com.extjs.gxt.ui.client.Style.Scroll;
 | 
        
           | 1329 | cyprien | 24 | import com.extjs.gxt.ui.client.data.ModelData;
 | 
        
           |  |  | 25 | import com.extjs.gxt.ui.client.data.ModelType;
 | 
        
           | 1118 | jpm | 26 | import com.extjs.gxt.ui.client.event.BaseEvent;
 | 
        
           | 980 | jpm | 27 | import com.extjs.gxt.ui.client.event.Events;
 | 
        
           | 1118 | jpm | 28 | import com.extjs.gxt.ui.client.event.Listener;
 | 
        
           | 928 | jpm | 29 | import com.extjs.gxt.ui.client.widget.Info;
 | 
        
           | 877 | aurelien | 30 | import com.extjs.gxt.ui.client.widget.MessageBox;
 | 
        
           |  |  | 31 | import com.extjs.gxt.ui.client.widget.form.CheckBox;
 | 
        
           |  |  | 32 | import com.extjs.gxt.ui.client.widget.form.FieldSet;
 | 
        
           |  |  | 33 | import com.extjs.gxt.ui.client.widget.form.TextArea;
 | 
        
           |  |  | 34 | import com.extjs.gxt.ui.client.widget.form.TextField;
 | 
        
           |  |  | 35 | import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
 | 
        
           |  |  | 36 | import com.extjs.gxt.ui.client.widget.layout.FormData;
 | 
        
           |  |  | 37 | import com.extjs.gxt.ui.client.widget.layout.FormLayout;
 | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 | public class ProjetForm extends Formulaire implements Rafraichissable {
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 | 	private Projet projet;
 | 
        
           | 878 | aurelien | 42 |   | 
        
           |  |  | 43 | 	private String listeValeurIndexationDureeId = "dureesIndexation";
 | 
        
           |  |  | 44 | 	private String listeValeurIndexationFrequenceId = "frequencesIndexation";
 | 
        
           | 887 | aurelien | 45 | 	private String listeLanguesId = "langues";
 | 
        
           | 878 | aurelien | 46 |   | 
        
           | 877 | aurelien | 47 | 	private FieldSet generalitesFieldset = null;
 | 
        
           |  |  | 48 | 	private TextField<String> nomChp = null;
 | 
        
           |  |  | 49 | 	private TextField<String> abreviationChp = null;
 | 
        
           | 886 | aurelien | 50 | 	private TextArea descriptionChp = null;
 | 
        
           | 877 | aurelien | 51 | 	private TextArea resumeChp = null;
 | 
        
           |  |  | 52 | 	private TextField<String> urlChp = null;
 | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 | 	private FieldSet complementFieldset = null;
 | 
        
           |  |  | 55 | 	private TextField<String> motsClesChp = null;
 | 
        
           |  |  | 56 | 	private TextField<String> citationChp = null;
 | 
        
           |  |  | 57 | 	private TextField<String> licenceChp = null;
 | 
        
           | 1329 | cyprien | 58 | 	private ChampComboBoxRechercheTempsReelPaginable langueChp = null;
 | 
        
           | 877 | aurelien | 59 | 	private CheckBox markPublicChp = null;
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 | 	private FieldSet indexationFieldset = null;
 | 
        
           |  |  | 62 | 	private TextField<String> indexationHeureChp = null;
 | 
        
           | 1115 | jpm | 63 | 	private ChampComboBoxListeValeurs indexationDureeChp = null;
 | 
        
           |  |  | 64 | 	private ChampComboBoxListeValeurs indexationFrequenceChp = null;
 | 
        
           | 877 | aurelien | 65 |   | 
        
           |  |  | 66 | 	private boolean formulaireValideOk = false;
 | 
        
           |  |  | 67 | 	private boolean projetValideOk = false;
 | 
        
           | 1367 | cyprien | 68 |   | 
        
           |  |  | 69 | 	private Sequenceur sequenceur = new Sequenceur();
 | 
        
           | 877 | aurelien | 70 |   | 
        
           |  |  | 71 | 	private Rafraichissable vueExterneARafraichirApresValidation = null;
 | 
        
           |  |  | 72 |   | 
        
           |  |  | 73 |   | 
        
           |  |  | 74 | 	public ProjetForm(Mediateur mediateurCourrant, String projetId) {
 | 
        
           |  |  | 75 | 		initialiserProjetForm(mediateurCourrant, projetId);
 | 
        
           |  |  | 76 | 	}
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 | 	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
 | 
        
           |  |  | 79 | 		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
 | 
        
           |  |  | 80 | 		initialiserProjetForm(mediateurCourrant, projetId);
 | 
        
           |  |  | 81 | 	}
 | 
        
           |  |  | 82 |   | 
        
           | 878 | aurelien | 83 | 	private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) {
 | 
        
           | 877 | aurelien | 84 | 		projet = new Projet();
 | 
        
           |  |  | 85 | 		projet.setId(projetId);
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 | 		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
 | 
        
           | 878 | aurelien | 88 | 		initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET);
 | 
        
           | 877 | aurelien | 89 |   | 
        
           |  |  | 90 | 		panneauFormulaire.setLayout(new FlowLayout());
 | 
        
           | 1322 | gduche | 91 | 		panneauFormulaire.setScrollMode(Scroll.AUTO);
 | 
        
           | 1094 | jpm | 92 | 		genererTitreFormulaire();
 | 
        
           | 877 | aurelien | 93 |   | 
        
           |  |  | 94 | 		creerZoneGeneralites();
 | 
        
           |  |  | 95 | 		panneauFormulaire.add(generalitesFieldset);
 | 
        
           |  |  | 96 |   | 
        
           |  |  | 97 | 		creerZoneComplement();
 | 
        
           |  |  | 98 | 		panneauFormulaire.add(complementFieldset);
 | 
        
           |  |  | 99 |   | 
        
           |  |  | 100 | 		creerZoneIndexation();
 | 
        
           |  |  | 101 | 		panneauFormulaire.add(indexationFieldset);
 | 
        
           |  |  | 102 |   | 
        
           | 886 | aurelien | 103 | 		creerTabIndex();
 | 
        
           |  |  | 104 |   | 
        
           | 877 | aurelien | 105 | 		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           | 1442 | cyprien | 106 | 			mediateur.selectionnerProjet(this, projetId, null, false, null);
 | 
        
           | 1118 | jpm | 107 | 		}
 | 
        
           | 877 | aurelien | 108 | 	}
 | 
        
           |  |  | 109 |   | 
        
           | 1094 | jpm | 110 | 	private void genererTitreFormulaire() {
 | 
        
           | 928 | jpm | 111 | 		String titre = i18nC.projetTitreFormAjout();
 | 
        
           | 877 | aurelien | 112 | 		if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           | 1094 | jpm | 113 | 			 titre = i18nC.projetTitreFormModif();
 | 
        
           |  |  | 114 | 			 if (projet != null) {
 | 
        
           |  |  | 115 | 				 titre += " - "+i18nC.id()+": "+projet.getId();
 | 
        
           |  |  | 116 | 			 }
 | 
        
           | 877 | aurelien | 117 | 		}
 | 
        
           | 928 | jpm | 118 | 		panneauFormulaire.setHeading(titre);
 | 
        
           | 877 | aurelien | 119 | 	}
 | 
        
           |  |  | 120 |   | 
        
           |  |  | 121 | 	private void creerZoneGeneralites() {
 | 
        
           |  |  | 122 | 		FormLayout layout = new FormLayout();
 | 
        
           |  |  | 123 | 		layout.setLabelWidth(100);
 | 
        
           |  |  | 124 |   | 
        
           |  |  | 125 | 		// Fieldset Infos Générales
 | 
        
           |  |  | 126 | 		generalitesFieldset = new FieldSet();
 | 
        
           | 928 | jpm | 127 | 		generalitesFieldset.setHeading(i18nC.projetTitreInfoGenerale());
 | 
        
           | 877 | aurelien | 128 | 		generalitesFieldset.setCollapsible(true);
 | 
        
           |  |  | 129 | 		generalitesFieldset.setLayout(layout);
 | 
        
           |  |  | 130 |   | 
        
           |  |  | 131 | 		nomChp = new TextField<String>();
 | 
        
           |  |  | 132 | 		nomChp.setName("cpu");
 | 
        
           | 1118 | jpm | 133 | 		nomChp.setFieldLabel(i18nC.projetNom());
 | 
        
           | 980 | jpm | 134 | 		nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           |  |  | 135 | 		nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
 | 
        
           | 877 | aurelien | 136 | 		generalitesFieldset.add(nomChp, new FormData(450, 0));
 | 
        
           |  |  | 137 |   | 
        
           |  |  | 138 | 		abreviationChp = new TextField<String>();
 | 
        
           | 1118 | jpm | 139 | 		abreviationChp.setFieldLabel(i18nC.projetAbreviation());
 | 
        
           | 981 | jpm | 140 | 		abreviationChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           | 980 | jpm | 141 | 		abreviationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
 | 
        
           | 877 | aurelien | 142 | 		generalitesFieldset.add(abreviationChp, new FormData(450, 0));
 | 
        
           |  |  | 143 |   | 
        
           | 886 | aurelien | 144 | 		descriptionChp = new TextArea();
 | 
        
           | 1118 | jpm | 145 | 		descriptionChp.setFieldLabel(i18nC.projetDescription());
 | 
        
           | 981 | jpm | 146 | 		descriptionChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           | 980 | jpm | 147 | 		descriptionChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
 | 
        
           | 877 | aurelien | 148 | 		generalitesFieldset.add(descriptionChp, new FormData(450, 0));
 | 
        
           |  |  | 149 |   | 
        
           |  |  | 150 | 		resumeChp = new TextArea();
 | 
        
           | 1118 | jpm | 151 | 		resumeChp.setFieldLabel(i18nC.projetResume());
 | 
        
           | 981 | jpm | 152 | 		resumeChp.addStyleName(ComposantClass.OBLIGATOIRE);
 | 
        
           | 980 | jpm | 153 | 		resumeChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
 | 
        
           | 877 | aurelien | 154 | 		generalitesFieldset.add(resumeChp, new FormData(450, 0));
 | 
        
           |  |  | 155 |   | 
        
           |  |  | 156 | 		urlChp = new TextField<String>();
 | 
        
           | 1118 | jpm | 157 | 		urlChp.setFieldLabel(i18nC.projetUrl());
 | 
        
           | 877 | aurelien | 158 | 		generalitesFieldset.add(urlChp, new FormData(450, 0));
 | 
        
           |  |  | 159 | 	}
 | 
        
           |  |  | 160 |   | 
        
           |  |  | 161 | 	private void creerZoneComplement() {
 | 
        
           |  |  | 162 | 		FormLayout layout = new FormLayout();
 | 
        
           |  |  | 163 | 		layout.setLabelWidth(100);
 | 
        
           |  |  | 164 |   | 
        
           | 928 | jpm | 165 | 		// Fieldset Complément
 | 
        
           | 877 | aurelien | 166 | 		complementFieldset = new FieldSet();
 | 
        
           | 928 | jpm | 167 | 		complementFieldset.setHeading(i18nC.projetTitreComplement());
 | 
        
           | 877 | aurelien | 168 | 		complementFieldset.setCollapsible(true);
 | 
        
           |  |  | 169 | 		complementFieldset.setLayout(layout);
 | 
        
           |  |  | 170 |   | 
        
           |  |  | 171 | 		motsClesChp = new TextField<String>();
 | 
        
           | 1115 | jpm | 172 | 		motsClesChp.setFieldLabel(i18nC.projetMotsCles());
 | 
        
           |  |  | 173 | 		complementFieldset.add(motsClesChp, new FormData(450, 0));
 | 
        
           | 877 | aurelien | 174 |   | 
        
           |  |  | 175 | 		citationChp = new TextField<String>();
 | 
        
           | 1115 | jpm | 176 | 		citationChp.setFieldLabel(i18nC.projetCitation());
 | 
        
           |  |  | 177 | 		complementFieldset.add(citationChp, new FormData(450, 0));
 | 
        
           | 877 | aurelien | 178 |   | 
        
           |  |  | 179 | 		licenceChp = new TextField<String>();
 | 
        
           | 1115 | jpm | 180 | 		licenceChp.setFieldLabel(i18nC.projetLicence());
 | 
        
           |  |  | 181 | 		complementFieldset.add(licenceChp, new FormData(450, 0));
 | 
        
           | 877 | aurelien | 182 |   | 
        
           | 1329 | cyprien | 183 | 		ModelType modelTypesLangues = new ModelType();
 | 
        
           |  |  | 184 | 		modelTypesLangues.setRoot("valeurs");
 | 
        
           |  |  | 185 | 		modelTypesLangues.setTotalName("nbElements");
 | 
        
           |  |  | 186 | 		modelTypesLangues.addField("cmlv_nom");
 | 
        
           |  |  | 187 | 		modelTypesLangues.addField("cmlv_id_valeur");
 | 
        
           |  |  | 188 | 		modelTypesLangues.addField("cmlv_abreviation");
 | 
        
           |  |  | 189 | 		modelTypesLangues.addField("cmlv_description");
 | 
        
           | 887 | aurelien | 190 |   | 
        
           | 1329 | cyprien | 191 | 		String displayNameLangues = "cmlv_nom";
 | 
        
           |  |  | 192 | 		String nomListeTypes = "langues";
 | 
        
           | 1442 | cyprien | 193 | 		ProxyValeur<ModelData> proxyLangues = new ProxyValeur<ModelData>(nomListeTypes, null);
 | 
        
           | 1329 | cyprien | 194 |   | 
        
           |  |  | 195 | 		langueChp = new ChampComboBoxRechercheTempsReelPaginable(proxyLangues, modelTypesLangues, displayNameLangues);
 | 
        
           |  |  | 196 | 		langueChp.setWidth(100,300);
 | 
        
           |  |  | 197 | 		langueChp.getCombo().setTabIndex(tabIndex++);
 | 
        
           |  |  | 198 | 		langueChp.getCombo().setFieldLabel(i18nC.projetLangue());
 | 
        
           |  |  | 199 | 		langueChp.getCombo().setForceSelection(true);
 | 
        
           |  |  | 200 |   | 
        
           |  |  | 201 | 		complementFieldset.add(langueChp, new FormData(300, 0));
 | 
        
           |  |  | 202 |   | 
        
           | 877 | aurelien | 203 | 		markPublicChp = new CheckBox();
 | 
        
           | 1118 | jpm | 204 | 		markPublicChp.setFieldLabel(i18nC.projetMarkPublic());
 | 
        
           |  |  | 205 | 		markPublicChp.addListener(Events.Change, new Listener<BaseEvent>() {
 | 
        
           |  |  | 206 | 			public void handleEvent(BaseEvent be) {
 | 
        
           |  |  | 207 | 				if (markPublicChp.getValue()) {
 | 
        
           |  |  | 208 | 					indexationFieldset.show();
 | 
        
           |  |  | 209 | 				} else {
 | 
        
           |  |  | 210 | 					indexationFieldset.hide();
 | 
        
           |  |  | 211 | 				}
 | 
        
           |  |  | 212 | 			}
 | 
        
           |  |  | 213 | 		});
 | 
        
           | 877 | aurelien | 214 | 		complementFieldset.add(markPublicChp);
 | 
        
           |  |  | 215 | 	}
 | 
        
           |  |  | 216 |   | 
        
           |  |  | 217 | 	private void creerZoneIndexation() {
 | 
        
           |  |  | 218 | 		FormLayout layout = new FormLayout();
 | 
        
           |  |  | 219 | 		layout.setLabelWidth(100);
 | 
        
           |  |  | 220 |   | 
        
           | 928 | jpm | 221 | 		// Fieldset Indexation
 | 
        
           | 877 | aurelien | 222 | 		indexationFieldset = new FieldSet();
 | 
        
           | 928 | jpm | 223 | 		indexationFieldset.setHeading(i18nC.projetTitreIndexation());
 | 
        
           | 877 | aurelien | 224 | 		indexationFieldset.setCollapsible(true);
 | 
        
           |  |  | 225 | 		indexationFieldset.setLayout(layout);
 | 
        
           | 1118 | jpm | 226 | 		indexationFieldset.hide();
 | 
        
           |  |  | 227 | 		indexationFieldset.addListener(Events.Hide, new Listener<BaseEvent>() {
 | 
        
           |  |  | 228 | 			public void handleEvent(BaseEvent be) {
 | 
        
           |  |  | 229 | 				indexationHeureChp.clear();
 | 
        
           |  |  | 230 | 				indexationFrequenceChp.clear();
 | 
        
           |  |  | 231 | 				indexationDureeChp.clear();
 | 
        
           |  |  | 232 | 			}
 | 
        
           |  |  | 233 | 		});
 | 
        
           | 877 | aurelien | 234 |   | 
        
           |  |  | 235 | 		indexationHeureChp = new TextField<String>();
 | 
        
           | 878 | aurelien | 236 | 		indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure());
 | 
        
           | 1115 | jpm | 237 | 		indexationHeureChp.setToolTip(i18nC.projetMessageHeureMinute());
 | 
        
           | 877 | aurelien | 238 | 		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
 | 
        
           |  |  | 239 |   | 
        
           | 1115 | jpm | 240 | 		indexationFrequenceChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationFrequence(), listeValeurIndexationFrequenceId);
 | 
        
           | 878 | aurelien | 241 | 		indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0));
 | 
        
           |  |  | 242 |   | 
        
           | 1115 | jpm | 243 | 		indexationDureeChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationDuree(), listeValeurIndexationDureeId);
 | 
        
           | 877 | aurelien | 244 | 		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
 | 
        
           |  |  | 245 |   | 
        
           |  |  | 246 | 	}
 | 
        
           | 886 | aurelien | 247 |   | 
        
           |  |  | 248 | 	private void creerTabIndex() {
 | 
        
           | 887 | aurelien | 249 | 		nomChp.setTabIndex(1);
 | 
        
           |  |  | 250 | 		abreviationChp.setTabIndex(2);
 | 
        
           |  |  | 251 | 		descriptionChp.setTabIndex(3);
 | 
        
           |  |  | 252 | 		resumeChp.setTabIndex(4);
 | 
        
           |  |  | 253 | 		urlChp.setTabIndex(5);
 | 
        
           | 886 | aurelien | 254 |   | 
        
           |  |  | 255 | 		motsClesChp.setTabIndex(6);
 | 
        
           |  |  | 256 | 		citationChp.setTabIndex(7);
 | 
        
           |  |  | 257 | 		licenceChp.setTabIndex(8);
 | 
        
           | 887 | aurelien | 258 | 		langueChp.setTabIndex(9);
 | 
        
           |  |  | 259 | 		markPublicChp.setTabIndex(10);
 | 
        
           | 886 | aurelien | 260 |   | 
        
           | 887 | aurelien | 261 | 		indexationHeureChp.setTabIndex(11);
 | 
        
           |  |  | 262 | 		indexationFrequenceChp.setTabIndex(12);
 | 
        
           |  |  | 263 | 		indexationDureeChp.setTabIndex(13);
 | 
        
           | 886 | aurelien | 264 |   | 
        
           |  |  | 265 | 		nomChp.focus();
 | 
        
           |  |  | 266 | 	}
 | 
        
           | 877 | aurelien | 267 |   | 
        
           |  |  | 268 | 	public void rafraichir(Object nouvellesDonnees) {
 | 
        
           | 928 | jpm | 269 | 		if (nouvellesDonnees instanceof Information) {
 | 
        
           |  |  | 270 | 			Information info = (Information) nouvellesDonnees;
 | 
        
           |  |  | 271 | 			rafraichirInformation(info);
 | 
        
           | 1115 | jpm | 272 | 		} else {
 | 
        
           |  |  | 273 | 			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
 | 
        
           | 878 | aurelien | 274 | 		}
 | 
        
           |  |  | 275 |   | 
        
           | 877 | aurelien | 276 | 		if (etreValide()) {
 | 
        
           |  |  | 277 | 			initialiserValidation();
 | 
        
           |  |  | 278 | 			repandreRafraichissement();
 | 
        
           | 1239 | cyprien | 279 | 			controlerFermeture();
 | 
        
           | 877 | aurelien | 280 | 		}
 | 
        
           |  |  | 281 | 	}
 | 
        
           |  |  | 282 |   | 
        
           | 928 | jpm | 283 | 	private void rafraichirInformation(Information info) {
 | 
        
           |  |  | 284 | 		final String type = info.getType();
 | 
        
           |  |  | 285 |   | 
        
           |  |  | 286 | 		// Gestion des problèmes
 | 
        
           |  |  | 287 | 		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
 | 
        
           |  |  | 288 | 			Debug.log("MESSAGES:\n"+info.getMessages().toString());
 | 
        
           |  |  | 289 | 		}
 | 
        
           |  |  | 290 |   | 
        
           |  |  | 291 | 		// Gestion des actions
 | 
        
           |  |  | 292 | 		if (type.equals("selection_projet")) {
 | 
        
           |  |  | 293 | 			if (info.getDonnee(0) != null) {
 | 
        
           |  |  | 294 | 				projet = (Projet) info.getDonnee(0);
 | 
        
           |  |  | 295 | 			}
 | 
        
           |  |  | 296 | 			peuplerFormulaire();
 | 
        
           | 1094 | jpm | 297 | 			genererTitreFormulaire();
 | 
        
           | 1102 | jpm | 298 | 		}
 | 
        
           |  |  | 299 | 		if (type.equals("ajout_projet") || type.equals("modif_projet")) {
 | 
        
           | 928 | jpm | 300 | 			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
 | 
        
           | 1094 | jpm | 301 | 				projetValideOk = true;
 | 
        
           | 928 | jpm | 302 | 				String projetId = (String) info.getDonnee(0);
 | 
        
           | 1094 | jpm | 303 | 				if (vueExterneARafraichirApresValidation != null) {
 | 
        
           |  |  | 304 | 					projet.setId(projetId);
 | 
        
           |  |  | 305 | 				}
 | 
        
           | 928 | jpm | 306 | 			}
 | 
        
           |  |  | 307 | 		}
 | 
        
           |  |  | 308 |   | 
        
           |  |  | 309 | 		// Gestion des messages
 | 
        
           |  |  | 310 | 		if (type.equals("selection_projet")) {
 | 
        
           | 1239 | cyprien | 311 | 			InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
 | 
        
           | 928 | jpm | 312 | 		} else if (type.equals("modif_projet")) {
 | 
        
           | 1239 | cyprien | 313 | 			InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
 | 
        
           | 928 | jpm | 314 | 		} else if (type.equals("ajout_projet")) {
 | 
        
           | 1094 | jpm | 315 | 			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
 | 
        
           |  |  | 316 | 				String projetId = (String) info.getDonnee(0);
 | 
        
           | 1239 | cyprien | 317 | 				InfoLogger.display(i18nC.projetTitreFormAjout(), "Le projet '"+projetId+"' a bien été ajouté");
 | 
        
           | 1094 | jpm | 318 | 			} else {
 | 
        
           | 1239 | cyprien | 319 | 				InfoLogger.display(i18nC.projetTitreFormAjout(), info.toString(), true);
 | 
        
           | 928 | jpm | 320 | 			}
 | 
        
           |  |  | 321 | 		}
 | 
        
           | 877 | aurelien | 322 | 	}
 | 
        
           | 928 | jpm | 323 |   | 
        
           | 877 | aurelien | 324 | 	private Boolean etreValide() {
 | 
        
           |  |  | 325 | 		Boolean valide = false;
 | 
        
           |  |  | 326 | 		if (formulaireValideOk && projetValideOk) {
 | 
        
           |  |  | 327 | 			valide = true;
 | 
        
           |  |  | 328 | 		}
 | 
        
           |  |  | 329 | 		return valide;
 | 
        
           |  |  | 330 | 	}
 | 
        
           |  |  | 331 |   | 
        
           |  |  | 332 | 	private void initialiserValidation() {
 | 
        
           |  |  | 333 | 		formulaireValideOk = false;
 | 
        
           |  |  | 334 | 		projetValideOk = false;
 | 
        
           |  |  | 335 | 	}
 | 
        
           |  |  | 336 |   | 
        
           |  |  | 337 | 	private void repandreRafraichissement() {
 | 
        
           |  |  | 338 | 		if (vueExterneARafraichirApresValidation != null) {
 | 
        
           | 878 | aurelien | 339 | 			String type = "projet_modifie";
 | 
        
           | 877 | aurelien | 340 | 			if (mode.equals(Formulaire.MODE_AJOUTER)) {
 | 
        
           | 878 | aurelien | 341 | 				type = "projet_ajoute";
 | 
        
           | 877 | aurelien | 342 | 			}
 | 
        
           |  |  | 343 | 			Information info = new Information(type);
 | 
        
           |  |  | 344 | 			info.setDonnee(0, projet);
 | 
        
           |  |  | 345 | 			vueExterneARafraichirApresValidation.rafraichir(info);
 | 
        
           |  |  | 346 | 		}
 | 
        
           |  |  | 347 | 	}
 | 
        
           |  |  | 348 |   | 
        
           |  |  | 349 | 	public boolean soumettreFormulaire() {
 | 
        
           |  |  | 350 | 		formulaireValideOk = verifierFormulaire();
 | 
        
           |  |  | 351 | 		if (formulaireValideOk) {
 | 
        
           |  |  | 352 | 			Projet projetCollecte = collecterProjet();
 | 
        
           |  |  | 353 | 			if (projetCollecte != null) {
 | 
        
           |  |  | 354 | 				if (mode.equals(Formulaire.MODE_AJOUTER)) {
 | 
        
           |  |  | 355 | 					mediateur.ajouterProjet(this, projetCollecte);
 | 
        
           |  |  | 356 | 				} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           |  |  | 357 | 					mediateur.modifierProjet(this, projetCollecte);
 | 
        
           |  |  | 358 | 				}
 | 
        
           |  |  | 359 | 			}
 | 
        
           |  |  | 360 | 		}
 | 
        
           |  |  | 361 | 		return formulaireValideOk;
 | 
        
           |  |  | 362 | 	}
 | 
        
           |  |  | 363 |   | 
        
           | 934 | jpm | 364 | 	public boolean verifierFormulaire() {
 | 
        
           | 877 | aurelien | 365 | 		boolean valide = true;
 | 
        
           |  |  | 366 | 		ArrayList<String> messages = new ArrayList<String>();
 | 
        
           |  |  | 367 |   | 
        
           |  |  | 368 | 		String titre = nomChp.getValue();
 | 
        
           |  |  | 369 | 		if (titre == null || titre.equals("")) {
 | 
        
           | 1115 | jpm | 370 | 			messages.add(i18nC.projetMessageNom());
 | 
        
           | 877 | aurelien | 371 | 		}
 | 
        
           |  |  | 372 |   | 
        
           | 886 | aurelien | 373 | 		String abr = abreviationChp.getValue();
 | 
        
           | 1115 | jpm | 374 | 		if (abr == null || abr.equals(i18nC.projetMessageAbreviation())) {
 | 
        
           |  |  | 375 | 			messages.add(i18nC.projetMessageAbreviation());
 | 
        
           | 886 | aurelien | 376 | 		}
 | 
        
           |  |  | 377 |   | 
        
           |  |  | 378 | 		String desc = descriptionChp.getValue();
 | 
        
           | 1115 | jpm | 379 | 		if (desc == null || desc.equals(i18nC.projetMessageDescription())) {
 | 
        
           |  |  | 380 | 			messages.add(i18nC.projetDescription());
 | 
        
           | 886 | aurelien | 381 | 		}
 | 
        
           |  |  | 382 |   | 
        
           |  |  | 383 | 		String resume = resumeChp.getValue();
 | 
        
           | 1115 | jpm | 384 | 		if (resume == null || resume.equals(i18nC.projetMessageResume())) {
 | 
        
           |  |  | 385 | 			messages.add(i18nC.projetMessageResume());
 | 
        
           | 886 | aurelien | 386 | 		}
 | 
        
           |  |  | 387 |   | 
        
           | 877 | aurelien | 388 | 		String uri = urlChp.getValue();
 | 
        
           | 886 | aurelien | 389 | 		if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) {
 | 
        
           | 1115 | jpm | 390 | 			messages.add(i18nC.messageUrlNonValide());
 | 
        
           | 877 | aurelien | 391 | 		}
 | 
        
           |  |  | 392 |   | 
        
           | 1118 | jpm | 393 | 		if (markPublicChp.getValue()) {
 | 
        
           |  |  | 394 | 			String heure = indexationHeureChp.getValue();
 | 
        
           |  |  | 395 | 			if (!UtilString.isEmpty(heure) && !heure.matches(Pattern.heureMinute)) {
 | 
        
           | 1115 | jpm | 396 | 				messages.add(i18nC.projetMessageHeureMinute());
 | 
        
           | 887 | aurelien | 397 | 			}
 | 
        
           | 886 | aurelien | 398 | 		}
 | 
        
           |  |  | 399 |   | 
        
           | 877 | aurelien | 400 | 		if (messages.size() != 0) {
 | 
        
           |  |  | 401 | 			String[] tableauDeMessages = {};
 | 
        
           |  |  | 402 | 			tableauDeMessages = messages.toArray(tableauDeMessages);
 | 
        
           | 1115 | jpm | 403 | 			MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
 | 
        
           | 877 | aurelien | 404 | 			valide = false;
 | 
        
           |  |  | 405 | 		}
 | 
        
           |  |  | 406 | 		return valide;
 | 
        
           |  |  | 407 | 	}
 | 
        
           |  |  | 408 |   | 
        
           |  |  | 409 | 	private void peuplerFormulaire() {
 | 
        
           | 878 | aurelien | 410 | 		nomChp.setValue(projet.getNom());
 | 
        
           |  |  | 411 | 		abreviationChp.setValue(projet.getAbreviation());
 | 
        
           |  |  | 412 | 		descriptionChp.setValue(projet.getDescription());
 | 
        
           |  |  | 413 | 		resumeChp.setValue(projet.getResume());
 | 
        
           |  |  | 414 | 		urlChp.setValue(projet.getUrl());
 | 
        
           |  |  | 415 |   | 
        
           |  |  | 416 | 		motsClesChp.setValue(projet.getMotsCles());
 | 
        
           |  |  | 417 | 		citationChp.setValue(projet.getCitation());
 | 
        
           |  |  | 418 | 		licenceChp.setValue(projet.getLicence());
 | 
        
           | 1464 | cyprien | 419 | 		if (projet.getLangueId().matches("[0-9]+")) {
 | 
        
           |  |  | 420 | 			langueChp.getCombo().setValue(langueChp.getStore().findModel("cmlv_id_valeur", projet.getLangueId()));
 | 
        
           | 1329 | cyprien | 421 | 		} else {
 | 
        
           | 1464 | cyprien | 422 | 			langueChp.getCombo().setRawValue(projet.getLangueId());
 | 
        
           | 1329 | cyprien | 423 | 		}
 | 
        
           | 924 | jpm | 424 | 		if (projet.getMarkPublic().equals("1")) {
 | 
        
           | 887 | aurelien | 425 | 			markPublicChp.setValue(true);
 | 
        
           | 1118 | jpm | 426 | 			String[] heureTab = projet.getIndexationHeure().split(":");
 | 
        
           |  |  | 427 | 			if (heureTab.length > 1) {
 | 
        
           |  |  | 428 | 				String heure = heureTab[0]+":"+heureTab[1];
 | 
        
           |  |  | 429 | 				if (heure.matches(Pattern.heureMinute)) {
 | 
        
           |  |  | 430 | 					indexationHeureChp.setValue(heure);
 | 
        
           |  |  | 431 | 				}
 | 
        
           |  |  | 432 | 			}
 | 
        
           |  |  | 433 | 			indexationFrequenceChp.peupler(projet.getIndexationFreq());
 | 
        
           |  |  | 434 | 			indexationDureeChp.peupler(projet.getIndexationDuree());
 | 
        
           | 887 | aurelien | 435 | 		} else {
 | 
        
           |  |  | 436 | 			markPublicChp.setValue(false);
 | 
        
           |  |  | 437 | 		}
 | 
        
           | 878 | aurelien | 438 |   | 
        
           |  |  | 439 | 		doLayout(true);
 | 
        
           | 877 | aurelien | 440 | 	}
 | 
        
           |  |  | 441 |   | 
        
           |  |  | 442 | 	private Projet collecterProjet() {
 | 
        
           | 887 | aurelien | 443 | 		Projet projetCollecte = (Projet) projet.cloner(new Projet());
 | 
        
           | 877 | aurelien | 444 |   | 
        
           | 928 | jpm | 445 | 		projetCollecte.setNom(nomChp.getValue());
 | 
        
           |  |  | 446 | 		projetCollecte.setAbreviation(abreviationChp.getValue());
 | 
        
           |  |  | 447 | 		projetCollecte.setDescription(descriptionChp.getValue());
 | 
        
           |  |  | 448 | 		projetCollecte.setResume(resumeChp.getValue());
 | 
        
           |  |  | 449 | 		projetCollecte.setUrl(urlChp.getValue());
 | 
        
           | 877 | aurelien | 450 |   | 
        
           | 928 | jpm | 451 | 		projetCollecte.setMotsCles(motsClesChp.getValue());
 | 
        
           |  |  | 452 | 		projetCollecte.setCitation(citationChp.getValue());
 | 
        
           |  |  | 453 | 		projetCollecte.setLicence(licenceChp.getValue());
 | 
        
           | 1329 | cyprien | 454 | 		if (langueChp.getValeur() != null) {
 | 
        
           |  |  | 455 | 			Valeur valeur = new Valeur(langueChp.getValeur());
 | 
        
           |  |  | 456 | 			projetCollecte.setLangue(valeur.getId());
 | 
        
           |  |  | 457 | 		} else {
 | 
        
           |  |  | 458 | 			projetCollecte.setLangue("");
 | 
        
           |  |  | 459 | 		}
 | 
        
           | 928 | jpm | 460 | 		String markPublic = (markPublicChp.getValue()) ? "1" : "0";
 | 
        
           |  |  | 461 | 		projetCollecte.setMarkPublic(markPublic);
 | 
        
           | 887 | aurelien | 462 |   | 
        
           | 928 | jpm | 463 | 		projetCollecte.setIndexationHeure(indexationHeureChp.getValue());
 | 
        
           | 1115 | jpm | 464 | 		projetCollecte.setIndexationFreq(indexationFrequenceChp.getValeur());
 | 
        
           |  |  | 465 | 		projetCollecte.setIndexationDuree(indexationDureeChp.getValeur());
 | 
        
           | 928 | jpm | 466 |   | 
        
           |  |  | 467 | 		Projet projetARetourner = null;
 | 
        
           | 887 | aurelien | 468 | 		if (!projetCollecte.comparer(projet)) {
 | 
        
           |  |  | 469 | 			projetARetourner = projet = projetCollecte;
 | 
        
           |  |  | 470 | 		}
 | 
        
           | 877 | aurelien | 471 | 		return projetARetourner;
 | 
        
           |  |  | 472 | 	}
 | 
        
           |  |  | 473 |   | 
        
           | 934 | jpm | 474 | 	public void reinitialiserFormulaire() {
 | 
        
           | 877 | aurelien | 475 | 		if (mode.equals(Formulaire.MODE_MODIFIER)) {
 | 
        
           |  |  | 476 | 			mediateur.afficherFormProjet(projet.getId());
 | 
        
           |  |  | 477 | 		} else {
 | 
        
           |  |  | 478 | 			mediateur.afficherFormProjet(null);
 | 
        
           |  |  | 479 | 		}
 | 
        
           |  |  | 480 | 	}
 | 
        
           | 908 | aurelien | 481 |   | 
        
           | 877 | aurelien | 482 | }
 |